3
0
Fork 0

simple split to multi module project

This commit is contained in:
willem.cazander 2010-09-25 18:34:44 +02:00
parent 5c13908f8e
commit 2906c482d1
182 changed files with 396 additions and 589 deletions

10
foei-ee-jca/.classpath Normal file
View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

23
foei-ee-jca/.project Normal file
View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>foei-ee-jca</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,6 @@
#Sat Sep 25 01:04:18 CEST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5

View file

@ -0,0 +1,9 @@
#Sat Sep 25 01:04:17 CEST 2010
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
includeModules=false
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
skipCompilerPlugin=true
version=1

36
foei-ee-jca/pom.xml Normal file
View file

@ -0,0 +1,36 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.idcanet.foei</groupId>
<artifactId>foei-base</artifactId>
<version>0.8-SNAPSHOT</version>
</parent>
<groupId>com.idcanet.foei</groupId>
<artifactId>foei-ee-jca</artifactId>
<version>0.8-SNAPSHOT</version>
<name>foei-ee-jca</name>
<description>foei-ee-jca</description>
<dependencies>
<dependency>
<groupId>com.idcanet.foei</groupId>
<artifactId>foei-core</artifactId>
<version>0.8-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-tomcat</artifactId>
<version>5.1.0.GA</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>jboss</groupId>
<artifactId>jboss-serialization</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-ext-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,91 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import javax.resource.spi.endpoint.MessageEndpointFactory;
import com.idcanet.foei.core.FoeiBindingException;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessListener;
import com.idcanet.foei.ee.jca.spi.FoeiActivationSpec;
import com.idcanet.foei.ee.jca.spi.FoeiEventWrapper;
import com.idcanet.foei.ee.jca.spi.FoeiResourceAdapter;
/**
* Injects the ejb3 beans in the process.<br/>
*
*
* @author Willem Cazander
* @version 1.0 Apr 26, 2008
*/
public class EJBFoeiProcessListener implements FoeiProcessListener {
private FoeiResourceAdapter foeiResourceAdapter = null;
public EJBFoeiProcessListener(FoeiResourceAdapter foeiResourceAdapter) {
this.foeiResourceAdapter=foeiResourceAdapter;
}
/**
* @see com.idcanet.foei.core.FoeiProcessListener#foeiProcessCreated(com.idcanet.foei.core.FoeiProcess)
*/
public void foeiProcessCreated(FoeiProcess process) {
// list all beans.
for (String name:foeiResourceAdapter.getEJBFoeiBeanNames()) {
FoeiActivationSpec foeiActivationSpec = foeiResourceAdapter.getFoeiActivationSpec(name);
MessageEndpointFactory endpointFactory = foeiResourceAdapter.getMessageEndpointFactory(name);
// check context name
if (process.getFoeiContext().getName().matches(foeiActivationSpec.getFoeiContextName())) {
// check process name
if (process.getName().matches(foeiActivationSpec.getFoeiProcessName())) {
// create wrapper for in foei, which can get an instance of the EJB bean.
FoeiEventWrapper wrapper = new FoeiEventWrapper(endpointFactory,process);
// inject bean
try {
process.addEventObject(wrapper, foeiActivationSpec.getFoeiBeanName());
} catch (FoeiBindingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
/**
* @see com.idcanet.foei.core.FoeiProcessListener#foeiProcessDestroyed(com.idcanet.foei.core.FoeiProcess)
*/
public void foeiProcessDestroyed(FoeiProcess process) {
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import javax.resource.ResourceException;
import com.idcanet.foei.core.FoeiContext;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public interface FoeiConnection {
/**
* Retrieves instance of the Foei Context
* @return File Retriever connection instance
* @throws ResourceException in case of any problem
*/
public FoeiContext getFoeiContext() throws ResourceException;
public void close() throws ResourceException;
}

View file

@ -0,0 +1,45 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import javax.resource.ResourceException;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public interface FoeiConnectionFactory {
/**
* Retrieves instance of the Foei Context Connection
* @return File Retriever connection instance
* @throws ResourceException in case of any problem
*/
public FoeiConnection getFoeiConnection() throws ResourceException;
}

View file

@ -0,0 +1,88 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import java.io.Serializable;
import javax.naming.NamingException;
import javax.naming.Reference;
import javax.resource.Referenceable;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ManagedConnectionFactory;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
@SuppressWarnings("serial")
public class FoeiConnectionFactoryImpl implements FoeiConnectionFactory, Serializable, Referenceable {
/** Managed connection factory */
private ManagedConnectionFactory mcf;
/** Connection manager */
private ConnectionManager cm;
/** JNDI reference */
private Reference reference;
/**
* The constructor
* @param factory managed connection factory
* @param cm connection manager
*/
public FoeiConnectionFactoryImpl(ManagedConnectionFactory factory,ConnectionManager cm) {
this.mcf = factory;
this.cm = cm;
}
/**
* @see javax.resource.Referenceable#setReference(javax.naming.Reference)
*/
public void setReference(Reference reference) {
this.reference=reference;
}
/**
* @see javax.naming.Referenceable#getReference()
*/
public Reference getReference() throws NamingException {
return reference;
}
/**
* @see com.idcanet.foei.jca.cci.FoeiConnectionFactory#getFoeiConnection()
*/
public FoeiConnection getFoeiConnection() throws ResourceException {
return (FoeiConnection) cm.allocateConnection(mcf, null);
}
}

View file

@ -0,0 +1,84 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import javax.resource.ResourceException;
import com.idcanet.foei.core.FoeiContext;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public class FoeiConnectionImpl implements FoeiConnection {
/** Underlying physical connection instance */
private FoeiManagedConnection mc;
/**
* The constructor
* @param mc underlying physical connection instance
*/
public FoeiConnectionImpl(FoeiManagedConnection mc) {
this.mc = mc;
}
/**
* Associates this handle with given underlying physical
* connection instance
* @param newMc underlying physical connection instance
*/
public void associateConnection(FoeiManagedConnection newMc) {
this.mc.removeConnection(this);
newMc.addConnection(this);
this.mc = newMc;
}
/**
* Invalidates the connection
*/
public void invalidate() {
mc = null;
}
/**
* @see com.idcanet.foei.jca.cci.FoeiContextConnection#getFoeiContext()
*/
public FoeiContext getFoeiContext() throws ResourceException {
return mc.getFoeiContext();
}
/**oeiContextConnection#close()
*/
public void close() throws ResourceException {
mc.close(this);
}
}

View file

@ -0,0 +1,237 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.resource.NotSupportedException;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionEvent;
import javax.resource.spi.ConnectionEventListener;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.LocalTransaction;
import javax.resource.spi.ManagedConnection;
import javax.resource.spi.ManagedConnectionMetaData;
import javax.security.auth.Subject;
import javax.transaction.xa.XAResource;
import com.idcanet.foei.core.FoeiContext;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public class FoeiManagedConnection implements ManagedConnection {
/** Log writer */
private PrintWriter writer;
/** List of listeners */
private List<ConnectionEventListener> listeners;
/** Set of application-level handlers */
private Set<FoeiConnectionImpl> connectionSet;
private FoeiContext foeiContext = null;
/**
* The constructor
* @param conReqInfo {@link ConnectionRequestInfo}
* @param writer log writer of the factory that calls this constructor
* @param repositoryPath path to the repository containing files to retireve
*/
public FoeiManagedConnection(ConnectionRequestInfo conReqInfo,PrintWriter writer, FoeiContext foeiContext) {
this.writer = writer;
this.listeners = new ArrayList<ConnectionEventListener>(10);
this.connectionSet = new HashSet<FoeiConnectionImpl>(10);
this.foeiContext = foeiContext;
}
/**
* @see javax.resource.spi.ManagedConnection#getConnection(javax.security.auth.Subject,
* javax.resource.spi.ConnectionRequestInfo)
*/
public Object getConnection(Subject subj, ConnectionRequestInfo conReqInfo) throws ResourceException {
if (this.foeiContext == null) {
throw new ResourceException("foeiContext is null");
}
FoeiConnectionImpl conn = new FoeiConnectionImpl(this);
addConnection(conn);
return conn;
}
/**
* @see javax.resource.spi.ManagedConnection#destroy()
*/
public void destroy() throws ResourceException {
invalidateAllConnections();
synchronized (this.listeners) {
listeners = null;
}
foeiContext.destroy();
foeiContext = null;
}
/**
* @see javax.resource.spi.ManagedConnection#cleanup()
*/
public void cleanup() throws ResourceException {
invalidateAllConnections();
}
/**
* @see javax.resource.spi.ManagedConnection#associateConnection(java.lang.Object)
*/
public void associateConnection(Object conn) throws ResourceException {
if (!(conn instanceof FoeiConnectionImpl)) {
throw new ResourceException("Connection has an incorrect type");
}
((FoeiConnectionImpl)conn).associateConnection(this);
}
/**
* @see javax.resource.spi.ManagedConnection#addConnectionEventListener(javax.resource.spi.ConnectionEventListener)
*/
public void addConnectionEventListener(ConnectionEventListener listener) {
synchronized (this.listeners) {
listeners.add(listener);
}
}
/**
* @see javax.resource.spi.ManagedConnection#removeConnectionEventListener(javax.resource.spi.ConnectionEventListener)
*/
public void removeConnectionEventListener(ConnectionEventListener listener) {
synchronized (this.listeners) {
listeners.remove(listener);
}
}
/**
* @see javax.resource.spi.ManagedConnection#getXAResource()
*/
public XAResource getXAResource() throws ResourceException {
throw new NotSupportedException("XA transactions are not supported");
}
/**
* @see javax.resource.spi.ManagedConnection#getLocalTransaction()
*/
public LocalTransaction getLocalTransaction() throws ResourceException {
throw new NotSupportedException("Transactions are not supported");
}
/**
* @see javax.resource.spi.ManagedConnection#getMetaData()
*/
public ManagedConnectionMetaData getMetaData() throws ResourceException {
return new FoeiManagedConnectionMetaData();
}
/**
* @see javax.resource.spi.ManagedConnection#setLogWriter(java.io.PrintWriter)
*/
public void setLogWriter(PrintWriter out) throws ResourceException {
this.writer = out;
}
/**
* @see javax.resource.spi.ManagedConnection#getLogWriter()
*/
public PrintWriter getLogWriter() throws ResourceException {
return writer;
}
/**
* Removes application-level handler from handlers set
* @param con handler to remove
* @see FileRetrieverConnectionImpl#associateConnection(FileRetrieverManagedConnection)
*/
void removeConnection(FoeiConnectionImpl con) {
synchronized (this.connectionSet) {
connectionSet.remove(con);
}
}
/**
* Adds application-level handler to handlers set
* @param con handler to add
* @see FileRetrieverConnectionImpl#associateConnection(FileRetrieverManagedConnection)
*/
void addConnection(FoeiConnectionImpl con) {
synchronized (this.connectionSet) {
connectionSet.add(con);
}
}
/**
* Invalidate all application-level handlers and clears handlers set
*/
void invalidateAllConnections() {
synchronized (this.connectionSet) {
Iterator<FoeiConnectionImpl> itr = connectionSet.iterator();
while (itr.hasNext()) {
FoeiConnectionImpl con = itr.next();
con.invalidate();
}
connectionSet.clear();
}
}
public FoeiContext getFoeiContext() {
return foeiContext;
}
/**
* Closes connection
* @param con connection to close
*/
public void close(FoeiConnectionImpl con) {
ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
event.setConnectionHandle(con);
synchronized (this.listeners) {
Iterator<ConnectionEventListener> itr = listeners.iterator();
while (itr.hasNext()) {
try {
itr.next().connectionClosed(event);
} catch (Throwable e) {
}
}
}
con.invalidate();
removeConnection(con);
}
}

View file

@ -0,0 +1,204 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.ManagedConnection;
import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.ResourceAdapter;
import javax.resource.spi.ResourceAdapterAssociation;
import javax.security.auth.Subject;
import com.idcanet.foei.core.EventExecutorManager;
import com.idcanet.foei.core.FoeiContext;
import com.idcanet.foei.core.FoeiProcessManager;
import com.idcanet.foei.core.impl.FoeiConfiguratorImpl;
import com.idcanet.foei.core.impl.FoeiContextImpl;
import com.idcanet.foei.ee.jca.spi.FoeiResourceAdapter;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
@SuppressWarnings("serial")
public class FoeiManagedConnectionFactory implements ManagedConnectionFactory,ResourceAdapterAssociation {
private Logger logger = Logger.getLogger(FoeiManagedConnectionFactory.class.getName());
/** Log writer */
private transient PrintWriter writer;
/** Path to file system repository */
private String foeiContextName = null;
private FoeiContext foeiContext = null;
private ResourceAdapter resourceAdapter = null;
/**
* @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory(javax.resource.spi.ConnectionManager)
*/
public Object createConnectionFactory(ConnectionManager cm) throws ResourceException {
if (foeiContext==null) {
logger.info("Starting foeiContext: "+foeiContextName);
Context objectContext = null;
EventExecutorManager eventExecutorManager = null;
FoeiProcessManager foeiProcessManager = null;
Map<String,String> properties = new HashMap<String,String>(0);
try {
objectContext = FoeiConfiguratorImpl.newContext(properties);
//eventExecutorManager = new JCAEventExecutorManager((FoeiResourceAdapter)getResourceAdapter());
eventExecutorManager = FoeiConfiguratorImpl.newEventExecutorManager(properties);
foeiProcessManager = FoeiConfiguratorImpl.newFoeiProcessManager(properties);
// inject ejb beans per process
foeiProcessManager.addFoeiProcessListener(new EJBFoeiProcessListener((FoeiResourceAdapter)getResourceAdapter()));
FoeiConfiguratorImpl.loadEventThreadListeners(properties,eventExecutorManager);
} catch (Exception e) {
throw new ResourceException("Error while building childs objects:",e);
}
foeiContext = new FoeiContextImpl(foeiContextName,objectContext,eventExecutorManager,properties,foeiProcessManager);
}
return new FoeiConnectionFactoryImpl(this, cm);
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory()
*/
public Object createConnectionFactory() throws ResourceException {
return createConnectionFactory(null);
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#createManagedConnection(javax.security.auth.Subject, javax.resource.spi.ConnectionRequestInfo)
*/
public ManagedConnection createManagedConnection(Subject subj,ConnectionRequestInfo conReqInfo) throws ResourceException {
return new FoeiManagedConnection(conReqInfo, writer, foeiContext);
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#matchManagedConnections(java.util.Set, javax.security.auth.Subject, javax.resource.spi.ConnectionRequestInfo)
*/
@SuppressWarnings("unchecked")
public ManagedConnection matchManagedConnections(Set set, Subject subj, ConnectionRequestInfo conReqInfo) throws ResourceException {
Iterator itr = set.iterator();
if (itr.hasNext()) {
Object obj = itr.next();
if (obj instanceof FoeiManagedConnection) {
return (FoeiManagedConnection)obj;
}
}
return null;
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#setLogWriter(java.io.PrintWriter)
*/
public void setLogWriter(PrintWriter out) throws ResourceException {
this.writer = out;
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#getLogWriter()
*/
public PrintWriter getLogWriter() throws ResourceException {
return writer;
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#hashCode()
*/
public int hashCode() {
if (foeiContextName == null) {
return super.hashCode();
} else {
return foeiContextName.hashCode();
}
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof FoeiManagedConnectionFactory)) {
return false;
}
if (foeiContextName == null) {
return false;
}
return foeiContextName.equals(((FoeiManagedConnectionFactory)obj).getFoeiContextName());
}
/**
* @return the foeiContextName
*/
public String getFoeiContextName() {
return foeiContextName;
}
/**
* @param foeiContextName the foeiContextName to set
*/
public void setFoeiContextName(String foeiContextName) {
this.foeiContextName = foeiContextName;
}
/**
* @see javax.resource.spi.ResourceAdapterAssociation#getResourceAdapter()
*/
public ResourceAdapter getResourceAdapter() {
return resourceAdapter;
}
/**
* @see javax.resource.spi.ResourceAdapterAssociation#setResourceAdapter(javax.resource.spi.ResourceAdapter)
*/
public void setResourceAdapter(ResourceAdapter resourceAdapter) throws ResourceException {
this.resourceAdapter=resourceAdapter;
}
}

View file

@ -0,0 +1,70 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import javax.resource.ResourceException;
import javax.resource.spi.ManagedConnectionMetaData;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public class FoeiManagedConnectionMetaData implements ManagedConnectionMetaData {
/** Default instance of the class */
public final static FoeiManagedConnectionMetaData INSTANCE = new FoeiManagedConnectionMetaData();
/**
* @see javax.resource.spi.ManagedConnectionMetaData#getEISProductName()
*/
public String getEISProductName() throws ResourceException {
return "Foei EE EIS";
}
/**
* @see javax.resource.spi.ManagedConnectionMetaData#getEISProductVersion()
*/
public String getEISProductVersion() throws ResourceException {
return "1.0";
}
/**
* @see javax.resource.spi.ManagedConnectionMetaData#getMaxConnections()
*/
public int getMaxConnections() throws ResourceException {
return 0;
}
/**
* @see javax.resource.spi.ManagedConnectionMetaData#getUserName()
*/
public String getUserName() throws ResourceException {
return "IDCANET";
}
}

View file

@ -0,0 +1,45 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.spi;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.event.EventInput;
import com.idcanet.foei.event.EventOutput;
import com.idcanet.foei.event.EventPort;
import com.idcanet.foei.event.IllegalEventPortNameException;
/**
* Gets called when process is created or destroyed.<br/>
*
*
* @author Willem Cazander
* @version 1.0 Apr 26, 2008
*/
public interface EJBFoeiBean extends EventInput,EventOutput {
public void doEvent(FoeiProcess process,FoeiEventWrapper wrapper,EventPort eventPort,Object object) throws IllegalEventPortNameException;
}

View file

@ -0,0 +1,144 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.spi;
import java.io.Serializable;
import javax.resource.ResourceException;
import javax.resource.spi.ActivationSpec;
import javax.resource.spi.InvalidPropertyException;
import javax.resource.spi.ResourceAdapter;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
@SuppressWarnings("serial")
public class FoeiActivationSpec implements ActivationSpec, Serializable {
/** The resource adapter */
private transient ResourceAdapter resourceAdapter = null;
private String foeiBeanName = null;
private String foeiProcessName = null;
private String foeiContextName = null;
/**
* @see javax.resource.spi.ActivationSpec#validate()
*/
public void validate() throws InvalidPropertyException {
if (foeiBeanName==null) {
throw new InvalidPropertyException("foeiBeanName is null,please set foeiBeanName property.");
}
if (foeiBeanName.isEmpty()) {
throw new InvalidPropertyException("foeiBeanName is empty,please set foeiBeanName property.");
}
if (foeiProcessName==null) {
foeiProcessName=".*";
}
if (foeiProcessName.isEmpty()) {
foeiProcessName=".*";
}
if ("*".equals(foeiProcessName)) {
foeiProcessName=".*";
}
if (foeiContextName==null) {
foeiContextName=".*";
}
if (foeiContextName.isEmpty()) {
foeiContextName=".*";
}
if ("*".equals(foeiContextName)) {
foeiContextName=".*";
}
// TODO: check if is regex
}
/**
* @see javax.resource.spi.ResourceAdapterAssociation#getResourceAdapter()
*/
public ResourceAdapter getResourceAdapter() {
return resourceAdapter;
}
/**
* @see javax.resource.spi.ResourceAdapterAssociation#setResourceAdapter(javax.resource.spi.ResourceAdapter)
*/
public void setResourceAdapter(ResourceAdapter resourceAdapter) throws ResourceException {
if (resourceAdapter==null) {
throw new ResourceException("ResourceAdapter may not be null.");
}
this.resourceAdapter=resourceAdapter;
}
/**
* @return the foeiBeanName
*/
public String getFoeiBeanName() {
return foeiBeanName;
}
/**
* @param foeiBeanName the foeiBeanName to set
*/
public void setFoeiBeanName(String foeiBeanName) {
this.foeiBeanName = foeiBeanName;
}
/**
* @return the foeiProcessName
*/
public String getFoeiProcessName() {
return foeiProcessName;
}
/**
* @param foeiProcessName the foeiProcessName to set
*/
public void setFoeiProcessName(String foeiProcessName) {
this.foeiProcessName = foeiProcessName;
}
/**
* @return the foeiContextName
*/
public String getFoeiContextName() {
return foeiContextName;
}
/**
* @param foeiContextName the foeiContextName to set
*/
public void setFoeiContextName(String foeiContextName) {
this.foeiContextName = foeiContextName;
}
}

View file

@ -0,0 +1,113 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.spi;
import java.util.logging.Logger;
import javax.resource.spi.endpoint.MessageEndpoint;
import javax.resource.spi.endpoint.MessageEndpointFactory;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.event.AbstractEventObject;
import com.idcanet.foei.event.EventPort;
import com.idcanet.foei.event.IllegalEventPortNameException;
/**
* Wrappers the ejb bean into the foei executing context.
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
@SuppressWarnings("serial")
public class FoeiEventWrapper extends AbstractEventObject {
private Logger logger = Logger.getLogger(FoeiEventWrapper.class.getName());
private MessageEndpointFactory endpointFactory = null;
private FoeiProcess foeiProcess = null;
public FoeiEventWrapper(MessageEndpointFactory endpointFactory,FoeiProcess foeiProcess) {
this.endpointFactory=endpointFactory;
this.foeiProcess=foeiProcess;
MessageEndpoint endpoint = null;
try {
endpoint = endpointFactory.createEndpoint(null); // creates new EJB3 bean instance !!
if (endpoint != null) {
EJBFoeiBean bean = (EJBFoeiBean) endpoint;
// copy ports, todo: go to annotations
// TODO: check if has input port at all...
for (EventPort p:bean.getInputPorts()) {
this.addInputPort(p.getName(), p.getObjectClass());
}
for (EventPort p:bean.getOutputPorts()) {
this.addOutputPort(p.getName(), p.getObjectClass());
}
} else {
logger.warning("MessageEndPoint is null.");
}
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (endpoint != null) {
endpoint.release();
}
}
}
/**
* @see com.idcanet.foei.event.AbstractEventInput#doEvent(com.idcanet.foei.event.EventPort, java.lang.Object)
*/
@Override
public void doEvent(EventPort eventPort, Object object) throws IllegalEventPortNameException {
MessageEndpoint endpoint = null;
try {
endpoint = endpointFactory.createEndpoint(null); // creates new EJB3 bean instance !!
if (endpoint != null) {
EJBFoeiBean input = (EJBFoeiBean) endpoint;
// mmm needed ?
// yes for normaly equals ..
EventPort port = input.getInputPort(eventPort.getName());
input.doEvent(foeiProcess,this,port, object);
} else {
logger.warning("MessageEndPoint is null.");
}
} catch (Exception e) {
throw new IllegalEventPortNameException(e);
} finally {
if (endpoint != null) {
endpoint.release(); // release ejb bean
}
}
}
}

View file

@ -0,0 +1,135 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.spi;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import javax.resource.ResourceException;
import javax.resource.spi.ActivationSpec;
import javax.resource.spi.BootstrapContext;
import javax.resource.spi.ResourceAdapter;
import javax.resource.spi.ResourceAdapterInternalException;
import javax.resource.spi.endpoint.MessageEndpointFactory;
import javax.transaction.xa.XAResource;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public class FoeiResourceAdapter implements ResourceAdapter {
private Logger logger = Logger.getLogger(FoeiResourceAdapter.class.getName());
private BootstrapContext bootstrapContext = null;
private Map<String,SpecBean> ejbs = null;
/**
* @see javax.resource.spi.ResourceAdapter#start(javax.resource.spi.BootstrapContext)
*/
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
logger.info("Starting FoeiResourceAdapter");
ejbs = new HashMap<String,SpecBean>(5);
this.bootstrapContext=bootstrapContext;
}
/**
* @see javax.resource.spi.ResourceAdapter#stop()
*/
public void stop() {
logger.info("Stopping FoeiResourceAdapter");
ejbs.clear();
bootstrapContext=null;
}
/**
* @see javax.resource.spi.ResourceAdapter#getXAResources(javax.resource.spi.ActivationSpec[])
*/
public XAResource[] getXAResources(ActivationSpec[] specs) throws ResourceException {
return null;
}
/**
* @see javax.resource.spi.ResourceAdapter#endpointActivation(javax.resource.spi.endpoint.MessageEndpointFactory, javax.resource.spi.ActivationSpec)
*/
public void endpointActivation(MessageEndpointFactory endPointFactory,ActivationSpec spec) throws ResourceException {
FoeiActivationSpec fac = (FoeiActivationSpec)spec;
logger.info("Activation of: "+fac.getFoeiBeanName());
SpecBean s = new SpecBean();
s.messageEndpointFactory=endPointFactory;
s.foeiActivationSpec=fac;
ejbs.put(fac.getFoeiBeanName(),s);
}
/**
* @see javax.resource.spi.ResourceAdapter#endpointDeactivation(javax.resource.spi.endpoint.MessageEndpointFactory, javax.resource.spi.ActivationSpec)
*/
public void endpointDeactivation(MessageEndpointFactory endPointFactory,ActivationSpec spec) {
FoeiActivationSpec fac = (FoeiActivationSpec)spec;
logger.info("Deactivation of "+fac.getFoeiBeanName());
ejbs.remove(fac.getFoeiBeanName());
}
/**
* @return the bootstrapContext
*/
public BootstrapContext getBootstrapContext() {
return bootstrapContext;
}
/**
* @param bootstrapContext the bootstrapContext to set
*/
public void setBootstrapContext(BootstrapContext bootstrapContext) {
this.bootstrapContext = bootstrapContext;
}
public List<String> getEJBFoeiBeanNames() {
return new ArrayList<String>(ejbs.keySet());
}
public FoeiActivationSpec getFoeiActivationSpec(String name) {
SpecBean s = ejbs.get(name);
return s.foeiActivationSpec;
}
public MessageEndpointFactory getMessageEndpointFactory(String name) {
SpecBean s = ejbs.get(name);
return s.messageEndpointFactory;
}
private class SpecBean {
FoeiActivationSpec foeiActivationSpec;
MessageEndpointFactory messageEndpointFactory;
}
}

View file

@ -0,0 +1,200 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. 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 IDCA 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 IDCA 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.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.spi;
import com.idcanet.foei.core.EventExecutor;
import com.idcanet.foei.core.EventExecutorManager;
import com.idcanet.foei.core.EventThreadListener;
import com.idcanet.foei.core.FoeiContext;
import com.idcanet.foei.core.FoeiPortMessage;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessFactory;
import com.idcanet.foei.core.impl.FoeiConfiguratorImpl;
import com.idcanet.foei.core.impl.FoeiProcessRunnableWrapper;
import com.idcanet.foei.event.EventPort;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.resource.spi.work.Work;
import javax.resource.spi.work.WorkException;
/**
* Defines the EventExecutorManager implementation
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public class JCAEventExecutorManager implements EventExecutorManager {
/** The logger to log to. */
private Logger logger = null;
/** The EventThreadListeners */
private List<EventThreadListener> eventThreadListeners = null;
/** The class for the EventExecutor */
private Class<?> eventExecutorClass = null;
private FoeiResourceAdapter foeiResourceAdapter = null;
/**
* Creates an EventExecutorManagerImpl ans inits the logger.
*/
public JCAEventExecutorManager(FoeiResourceAdapter foeiResourceAdapter) {
logger = Logger.getLogger(JCAEventExecutorManager.class.getName());
eventThreadListeners = new ArrayList<EventThreadListener>(1);
this.foeiResourceAdapter=foeiResourceAdapter;
}
// ============= EventExecutorManager
/**
* Executes an Event mostly send from an EventObject.
* @see EventExecutorManager#executeEvent(Object, EventPort)
*/
public void executeEvent(EventPort eventPort,Object eventObject) {
executeEvent(eventPort,eventObject,FoeiProcessFactory.getFoeiProcess());
}
/**
* Executes an EventPort with object in an FoeiProcess.
* @param eventPort
* @param eventObject
* @param foeiProcess
*/
public void executeEvent(EventPort eventPort,Object eventObject,FoeiProcess foeiProcess) {
FoeiPortMessage msg = new FoeiPortMessage();
msg.setEventObject(eventObject);
msg.setEventPort(eventPort);
foeiProcess.getWorkQueue().add(msg);
if (foeiProcess.getExecutors().size()>3) {
return;
}
EventExecutor e = null;
try {
e = (EventExecutor)eventExecutorClass.newInstance();
} catch (Exception ee) {
logger.log(Level.WARNING,"Error Creating EventExecutor: "+ee.getMessage(),ee);
return;
}
e.setFoeiProcess(foeiProcess);
foeiProcess.getExecutors().add(e);
try {
logger.info("Setting work to EE workmanager");
foeiResourceAdapter.getBootstrapContext().getWorkManager().scheduleWork(new WorkWrapper(e));
} catch (WorkException ee) {
ee.printStackTrace();
}
}
/**
* Executes an event.
* @see EventExecutorManager#execute(Runnable)
*/
public void execute(Runnable runnable,FoeiProcess foeiProcess) {
try {
foeiResourceAdapter.getBootstrapContext().getWorkManager().scheduleWork(new WorkWrapper(new FoeiProcessRunnableWrapper(runnable,foeiProcess)));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Starts the ThreadPool
* @see EventExecutorManager#start()
*/
public void start(FoeiContext foeiContext) {
if(foeiContext==null) {
throw new NullPointerException("FoeiContext may not be null.");
}
logger.info("Starting EventExecutorManagerImpl");
try {
eventExecutorClass = FoeiConfiguratorImpl.newEventExecutorClass(foeiContext.getStartProperties());
} catch (ClassNotFoundException cce) {
logger.log(Level.WARNING,"Error getting eventExecutor class: "+cce.getMessage(),cce);
throw new RuntimeException("Could not get EventExecutor class: "+cce.getMessage(),cce);
}
}
/**
* Stops the ThreadPool
* @see EventExecutorManager#stop()
*/
public void stop(FoeiContext foeiContext) {
}
/**
* @see EventExecutorManager#getEventThreadListeners()
*/
public List<EventThreadListener> getEventThreadListeners() {
return eventThreadListeners;
}
/**
* @see EventExecutorManager#addEventThreadListener(EventThreadListener)
*/
public void addEventThreadListener(EventThreadListener eventThreadListener) throws IllegalStateException {
if(eventThreadListener==null) {
throw new NullPointerException("eventThreadListener may not be null.");
}
eventThreadListeners.add(eventThreadListener);
}
}
class WorkWrapper implements Work {
private Runnable run = null;
private Logger logger = Logger.getLogger(WorkWrapper.class.getName());
public WorkWrapper(Runnable run) {
this.run=run;
}
/**
* @see javax.resource.spi.work.Work#release()
*/
public void release() {
logger.info("Releasing jca foei adapter.");
}
/**
* @see java.lang.Runnable#run()
*/
public void run() {
try {
logger.info("Executing job: "+run);
run.run();
} catch (Throwable e) {
logger.log(Level.WARNING,"Error in jca foei work unit: "+e.getMessage(),e);
} finally {
logger.info("Done running jobs");
}
}
}

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE connection-factories PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN" "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
<!--
This is JBoss-specific descriptor.
It should be placed in the "deploy" directory of desired server configuration.
-->
<connection-factories>
<no-tx-connection-factory>
<jndi-name>foei/datafeeds</jndi-name>
<rar-name>foei-ra.rar</rar-name>
<connection-definition>com.idcanet.foei.ee.jca.cci.FoeiConnectionFactory</connection-definition>
<config-property name="foeiContextName" type="java.lang.String">datafeeds</config-property>
<min-pool-size>2</min-pool-size>
<max-pool-size>200</max-pool-size>
<blocking-timeout-millis>32123</blocking-timeout-millis>
<idle-timeout-minutes>1</idle-timeout-minutes>
</no-tx-connection-factory>
<no-tx-connection-factory>
<jndi-name>foei/m4n</jndi-name>
<rar-name>foei-ra.rar</rar-name>
<connection-definition>com.idcanet.foei.ee.jca.cci.FoeiConnectionFactory</connection-definition>
<config-property name="foeiContextName" type="java.lang.String">m4n</config-property>
<min-pool-size>2</min-pool-size>
<max-pool-size>200</max-pool-size>
<blocking-timeout-millis>32888</blocking-timeout-millis>
<idle-timeout-minutes>1</idle-timeout-minutes>
</no-tx-connection-factory>
</connection-factories>

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is Geronimo-specific descriptor -->
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector" version="1.5"
configId="com/ibm/j2g/jca.rar"
parentId="org/apache/geronimo/Server">
<resourceadapter>
<outbound-resourceadapter>
<connection-definition>
<connectionfactory-interface>com.idcanet.foei.ee.jca.cci.FoeiConnectionFactory</connectionfactory-interface>
<connectiondefinition-instance>
<name>foei/datafeeds</name>
<config-property-setting name="foeiContextName">datafeeds</config-property-setting>
<connectionmanager>
<no-transaction/>
<no-pool/>
</connectionmanager>
</connectiondefinition-instance>
</connection-definition>
</outbound-resourceadapter>
</resourceadapter>
</connector>

View file

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
version="1.5">
<display-name>FoeiJCA</display-name>
<vendor-name>IDCA</vendor-name>
<eis-type>Foei Adapter</eis-type>
<resourceadapter-version>1.0</resourceadapter-version>
<license>
<description>
Copyright 2004-2006 IDCA. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and
the following disclaimer.
2. 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 IDCA 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 IDCA 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.
The views and conclusions contained in the software and documentation are those of the authors and
should not be interpreted as representing official policies, either expressed or implied, of IDCA.
</description>
<license-required>true</license-required>
</license>
<resourceadapter>
<resourceadapter-class>com.idcanet.foei.ee.jca.spi.FoeiResourceAdapter</resourceadapter-class>
<outbound-resourceadapter>
<connection-definition>
<managedconnectionfactory-class>com.idcanet.foei.ee.jca.cci.FoeiManagedConnectionFactory</managedconnectionfactory-class>
<config-property>
<description>The foei context name.</description>
<config-property-name>foeiContextName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
<connectionfactory-interface>com.idcanet.foei.ee.jca.cci.FoeiConnectionFactory</connectionfactory-interface>
<connectionfactory-impl-class>com.idcanet.foei.ee.jca.cci.FoeiConnectionFactoryImpl</connectionfactory-impl-class>
<connection-interface>com.idcanet.foei.ee.jca.cci.FoeiConnection</connection-interface>
<connection-impl-class>com.idcanet.foei.ee.jca.cci.FoeiConnectionImpl</connection-impl-class>
</connection-definition>
<transaction-support>NoTransaction</transaction-support>
<reauthentication-support>false</reauthentication-support>
</outbound-resourceadapter>
<inbound-resourceadapter>
<messageadapter>
<messagelistener>
<messagelistener-type>com.idcanet.foei.ee.jca.spi.EJBFoeiBean</messagelistener-type>
<activationspec>
<activationspec-class>com.idcanet.foei.ee.jca.spi.FoeiActivationSpec</activationspec-class>
<required-config-property>
<config-property-name>foeiBeanName</config-property-name>
</required-config-property>
</activationspec>
</messagelistener>
</messageadapter>
</inbound-resourceadapter>
</resourceadapter>
</connector>

View file

View file