Small refactor for comming converters
This commit is contained in:
parent
75b3d5e0a0
commit
1c308a684a
178 changed files with 5865 additions and 1531 deletions
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright 2007-2012 forwardfire.net All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.xpql.ejb3;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.ejb.Remote;
|
||||
|
||||
import net.forwardfire.vasc.xpql.query.Query;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 17 Sep 2010
|
||||
*/
|
||||
public interface XpqlQueryManager {
|
||||
|
||||
public Query getQuery(String name);
|
||||
|
||||
public List<Object> execute(Query query);
|
||||
|
||||
public Object executeObject(Query query);
|
||||
|
||||
public Integer executeUpdate(Query query);
|
||||
|
||||
public List<Object> execute(String query,Map<String,Object> parameters);
|
||||
|
||||
public Object executeObject(String query,Map<String,Object> parameters);
|
||||
|
||||
public Integer executeUpdate(String query,Map<String,Object> parameters);
|
||||
|
||||
@Local
|
||||
public interface ILocal extends XpqlQueryManager {
|
||||
}
|
||||
|
||||
@Remote
|
||||
public interface IRemote extends XpqlQueryManager {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
package net.forwardfire.vasc.xpql.ejb3.x4o;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
|
||||
import net.forwardfire.vasc.xpql.ejb3.XpqlQueryManager;
|
||||
import net.forwardfire.vasc.xpql.query.Query;
|
||||
|
||||
import org.x4o.xml.element.AbstractElement;
|
||||
import org.x4o.xml.element.ElementException;
|
||||
|
||||
public class XpqlEjb3QueriesElement extends AbstractElement {
|
||||
|
||||
|
||||
@Override
|
||||
public void doElementEnd() throws ElementException {
|
||||
|
||||
// set queries map to element object
|
||||
Map<String,Query> queries = new HashMap<String,Query>(100);
|
||||
setElementObject(queries);
|
||||
|
||||
String jndiName = getAttributes().get("jndi");
|
||||
if (jndiName==null) {
|
||||
throw new ElementException("No 'jndi' attributes defined.");
|
||||
}
|
||||
if (jndiName.isEmpty()) {
|
||||
throw new ElementException("Empty 'jndi' attributes can't load.");
|
||||
}
|
||||
|
||||
// load queries from ejb3 bean reference
|
||||
XpqlQueryManager xpqlManager = null;
|
||||
try {
|
||||
Context context = new InitialContext();
|
||||
xpqlManager = (XpqlQueryManager)context.lookup( jndiName );
|
||||
} catch (Exception e) {
|
||||
throw new ElementException("Could not get the ejb resource bundle: "+e.getMessage(),e);
|
||||
}
|
||||
if (xpqlManager==null) {
|
||||
throw new ElementException("XpqlQueryManager ejb resource is null.");
|
||||
}
|
||||
XpqlController refBean = new XpqlController(xpqlManager);
|
||||
setElementObject(refBean);
|
||||
}
|
||||
|
||||
class XpqlController implements Map<String,Query> {
|
||||
private XpqlQueryManager xpqlManager = null;
|
||||
|
||||
public XpqlController(XpqlQueryManager xpqlManager) {
|
||||
this.xpqlManager=xpqlManager;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
}
|
||||
|
||||
public boolean containsKey(Object key) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean containsValue(Object value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Set<Map.Entry<String, Query>> entrySet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Query get(Object key) {
|
||||
return xpqlManager.getQuery((String)key);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Set<String> keySet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Query put(String key, Query value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void putAll(Map m) {
|
||||
}
|
||||
|
||||
public Query remove(Object key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Collection<Query> values() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
|
||||
<properties>
|
||||
<comment>
|
||||
Vasc namespace for the xpql ejb3 backend
|
||||
</comment>
|
||||
<entry key="eld.http://vasc.forwardfire.net/eld/vasc-xpql-ejb3.eld">vasc-xpql-ejb3.eld</entry>
|
||||
</properties>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<eld:root xmlns:eld="http://eld.x4o.org/eld/eld-lang.eld">
|
||||
<eld:elementClass tag="xpqlEjb3Queries" elementClassName="net.forwardfire.vasc.backends.jpa.x4o.XpqlEjb3QueriesElement"/>
|
||||
</eld:root>
|
||||
Loading…
Add table
Add a link
Reference in a new issue