3
0
Fork 0

[svn r329] WIP commit, added EE JCA support and updated for x4o and made speed improvement and job que per process.

This commit is contained in:
willemc 2008-04-21 01:48:21 +02:00
parent 520ba683db
commit 46f1863f05
35 changed files with 1734 additions and 105 deletions

View file

@ -9,5 +9,8 @@
<classpathentry kind="lib" path="lib/jms-api.jar"/>
<classpathentry kind="lib" path="lib/servlet-api.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_5_CONTAINER"/>
<classpathentry kind="var" path="jboss4/jboss-jca.jar"/>
<classpathentry kind="var" path="jboss4/jboss-j2ee.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

121
build/build-jca.xml Normal file
View file

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="foei-jca" default="deploy" basedir=".././">
<property file="build/build.properties"/>
<path id="classpath">
<fileset dir="${jboss.home}/server/${jboss.server}/lib" includes="*.jar"/>
</path>
<!-- Builds JCA application -->
<target name="build">
<mkdir dir="bin"/>
<javac srcdir="src" destdir="bin" classpathref="classpath"/>
<antcall target="build.${server.name}"/>
<!--
<jar destfile="dd.war">
<zipfileset dir="bin" prefix="WEB-INF/classes" includes="**/web/*.class"/>
<zipfileset dir="web" excludes="WEB-INF/*-web.xml"/>
<zipfileset dir="web" includes="WEB-INF/${server.name}-web.xml"/>
</jar>
-->
</target>
<target name="doBuildBinJar">
<jar destfile="idcanet-foei-bin.jar" basedir="bin" includes="**">
</jar>
</target>
<!-- Packs JBoss version of the resource adapter module -->
<target name="build.jboss">
<jar destfile="foei-ra.rar">
<zipfileset dir="bin" includes="com/idcanet/foei/ee/jca/**/*.class"/>
<zipfileset dir="meta/jboss" prefix="META-INF" includes="ra.xml"/>
</jar>
<jar destfile="bin/foei-ra.jar">
<zipfileset dir="bin" includes="com/idcanet/foei/ee/jca/**/*.class"/>
</jar>
</target>
<!-- Packs Geronimo version of the resource adapter module -->
<target name="build.geronimo">
<jar destfile="bin/foei-ra.jar">
<zipfileset dir="bin" includes="com/idcanet/foei/ee/jca/**/*.class"/>
</jar>
<jar destfile="foei-ra.rar">
<zipfileset dir="bin" includes="foei-ra.jar"/>
<zipfileset dir="meta/geronimo" prefix="META-INF" includes="ra.xml"/>
</jar>
</target>
<!--
Deploys (or redeploys) the application on the currently selected
server
-->
<target name="deploy" depends="build,doBuildBinJar">
<antcall target="deploy.${server.name}"/>
</target>
<!--
Deploys (or redeploys) the application on JBoss. If the server is
started the application will be installed and started on the fly.
The JBoss version of the application must be previously built
and located in the current folder.
-->
<target name="deploy.jboss">
<copy todir="${jboss.home}/server/${jboss.server}/deploy" file="meta/jboss/foei-ds.xml"/>
<copy todir="${jboss.home}/server/${jboss.server}/deploy" file="foei-ra.rar"/>
<copy todir="${jboss.home}/server/${jboss.server}/lib" file="idcanet-foei-bin.jar"/>
<!-- <copy todir="${jboss.home}/server/${jboss.server}/deploy" file="jca.war"/> -->
</target>
<!--
Deploys (or redeploys) the application on Geronimo. The server
should be started.
The Geronimo version of the application must be previously built
and located in the current folder.
-->
<target name="deploy.geronimo">
<java jar="${geronimo.home}/bin/deployer.jar" fork="true">
<arg value="--user"/>
<arg value="${geronimo.user}"/>
<arg value="--password"/>
<arg value="${geronimo.password}"/>
<arg value="undeploy"/>
<arg value="com/ibm/j2g/jca.war"/>
</java>
<java jar="${geronimo.home}/bin/deployer.jar" fork="true">
<arg value="--user"/>
<arg value="${geronimo.user}"/>
<arg value="--password"/>
<arg value="${geronimo.password}"/>
<arg value="undeploy"/>
<arg value="com/ibm/j2g/jca.rar"/>
</java>
<java jar="${geronimo.home}/bin/deployer.jar" fork="true">
<arg value="--user"/>
<arg value="${geronimo.user}"/>
<arg value="--password"/>
<arg value="${geronimo.password}"/>
<arg value="deploy"/>
<arg value="meta/geronimo/jca-plan.xml"/>
<arg value="jca.rar"/>
</java>
<java jar="${geronimo.home}/bin/deployer.jar" fork="true">
<arg value="--user"/>
<arg value="${geronimo.user}"/>
<arg value="--password"/>
<arg value="${geronimo.password}"/>
<arg value="deploy"/>
<arg value="jca.war"/>
</java>
</target>
</project>

16
build/build.properties Normal file
View file

@ -0,0 +1,16 @@
# Name of the server to build the application for:
server.name = jboss
# Home directory of JBoss 4.0.2 J2ee Application Server and name of the server
# instance on which the application should be deployed (this instance should be
# either a copy of the default JBoss server or the default server itself because
# its libs are also used for building the source code):
jboss.home = /home/willemc/devv/jboss-4.2.1.GA
jboss.server = default
# Home directory of Geronimo 1.0M5 J2ee Application Server and its administrator
# credentials:
geronimo.home = /home/willemc/devv/apache-geronimo
geronimo.user = system
geronimo.password = manager

View file

@ -1,7 +1,7 @@
-- IDCANET X4O TODO list --
-- IDCANET FOEI TODO list --
- make J2EE compaitle
- (80% DONE) make J2EE compaitle
- Add annotations for ports
- Make asysc piping faster
- Start implementing JMS interfaces

Binary file not shown.

38
meta/jboss/foei-ds.xml Normal file
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>

78
meta/jboss/ra.xml Normal file
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.event.EventInput</messagelistener-type>
<activationspec>
<activationspec-class>com.idcanet.foei.ee.jca.spi.FoeiActivationSpec</activationspec-class>
<required-config-property>
<config-property-name>beanName</config-property-name>
</required-config-property>
</activationspec>
</messagelistener>
</messageadapter>
</inbound-resourceadapter>
</resourceadapter>
</connector>

View file

@ -80,6 +80,11 @@ public class DestroyFoeiProcess extends AbstractEventInput {
throw new IllegalEventPortNameException("Not excisting input EventPort: "+eventPort.getName());
}
FoeiProcess process = FoeiProcessFactory.getFoeiProcess();
if (process.getWorkQueue().isEmpty()==false) {
//return;
}
if(delayTime!=null) {
try {
logger.info("Sleeping "+delayTime+" ms before destoying process: "+process.getName());

View file

@ -26,8 +26,6 @@
package com.idcanet.foei.core;
import com.idcanet.foei.event.EventPort;
/**
* Reuables EventExecutor wich are executed
* in the EcentExecutorManager
@ -38,16 +36,11 @@ import com.idcanet.foei.event.EventPort;
public interface EventExecutor extends Runnable {
/**
* Sets the object to process.
* Sets the foei process
* @param object
*/
public void setEventObject(Object object);
public void setFoeiProcess(FoeiProcess foeiProcess);
/**
* Sets the eventPort to/from the object needs to go.
* @param eventPort
*/
public void setEventPort(EventPort eventPort);
/**
* Returns true when this EventExecutor is ready

View file

@ -41,9 +41,6 @@ public interface FoeiConfigurator {
/** The key of the foei fontext name */
static public final String CONTEXT_NAME = "foei.context_name";
/** The key of the root path */
static public final String ROOT_PATH = "foei.root_path";
/** The key of the className of the ObjectBindingsManager */
static public final String OBJECT_BINDINGS_MANAGER = "foei.object_bindings_manager";

View file

@ -44,12 +44,6 @@ public interface FoeiContext {
*/
public String getName();
/**
* Gets the root path.
* @return returns the root path.
*/
public String getRootPath();
/**
* Gets the EventObjectContext.
* @return Returns the Context

View file

@ -0,0 +1,85 @@
/*
* 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.
*/
package com.idcanet.foei.core;
import com.idcanet.foei.event.EventPort;
/**
* Message block used in work queue to store non-immatiate port events.
*
* @author Willem Cazander
* @version 1.0 Apr 9, 2008
*/
public class FoeiPortMessage {
/** The event obect. */
private Object eventObject = null;
/** The eventport */
private EventPort eventPort = null;
public FoeiPortMessage() {
}
public FoeiPortMessage(Object eventObject,EventPort eventPort) {
setEventObject(eventObject);
setEventPort(eventPort);
}
/**
* @return the eventObject
*/
public Object getEventObject() {
return eventObject;
}
/**
* @param eventObject the eventObject to set
*/
public void setEventObject(Object eventObject) {
if (eventObject==null) {
throw new NullPointerException("May not set null eventObject");
}
this.eventObject = eventObject;
}
/**
* @return the eventPort
*/
public EventPort getEventPort() {
return eventPort;
}
/**
* @param eventPort the eventPort to set
*/
public void setEventPort(EventPort eventPort) {
if (eventPort==null) {
throw new NullPointerException("May not set null eventPort");
}
this.eventPort = eventPort;
}
}

View file

@ -26,6 +26,9 @@
package com.idcanet.foei.core;
import java.util.Queue;
import java.util.Set;
import javax.naming.Context;
/**
@ -66,4 +69,12 @@ public interface FoeiProcess extends ObjectBindingsManager,ObjectContextManager,
* Stops all stuff in this process
*/
public void destroy();
/**
* Returns the work queue for this foei process
* @return
*/
public Queue<FoeiPortMessage> getWorkQueue();
public Set<EventExecutor> getExecutors();
}

View file

@ -27,11 +27,13 @@
package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.EventExecutor;
import com.idcanet.foei.core.FoeiPortMessage;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessFactory;
import com.idcanet.foei.event.EventInput;
import com.idcanet.foei.event.EventPort;
import com.idcanet.foei.event.EventPortType;
import com.idcanet.foei.event.IllegalEventPortNameException;
import java.util.List;
import java.util.logging.Level;
@ -48,11 +50,12 @@ public class EventExecutorImpl implements EventExecutor {
/** The logger to log to. */
private Logger logger = null;
/** The event obect. */
private Object eventObject = null;
//private Object eventObject = null;
/** The eventport */
private EventPort eventPort = null;
//private EventPort eventPort = null;
private FoeiProcess foeiProcess = null;
/** True when ready */
private boolean ready = false;
private volatile boolean ready = false;
/**
* Creates an EventExecutor
@ -64,14 +67,16 @@ public class EventExecutorImpl implements EventExecutor {
/**
* @see EventExecutor#setEventObject(Object)
*/
public void setEventObject(Object eventObject) {
this.eventObject=eventObject;
ready = false;
public void setFoeiProcess(FoeiProcess foeiProcess) {
this.foeiProcess=foeiProcess;
//this.eventObject=eventObject;
//ready = false;
}
/**
* @see EventExecutor#setEventPort(EventPort)
*/
/*
public void setEventPort(EventPort eventPort) {
if(eventPort==null) {
throw new NullPointerException("EventPort may not be null.");
@ -79,6 +84,7 @@ public class EventExecutorImpl implements EventExecutor {
this.eventPort=eventPort;
ready = false;
}
*/
/**
* @see EventExecutor#isReady()
@ -91,13 +97,45 @@ public class EventExecutorImpl implements EventExecutor {
* @see Runnable#run()
*/
public void run() {
if(eventPort==null) {
logger.warning("Can't execute event on null eventPort.");
if(foeiProcess==null) {
logger.warning("Can't execute event on null foeiProcess.");
return;
}
ready = false;
int processed = 0;
try {
FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess();
//FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess();
FoeiProcessFactory.bindFoeiProcess(foeiProcess);
FoeiPortMessage msg = foeiProcess.getWorkQueue().poll();
while (msg!=null) {
process(msg);
processed++;
msg = foeiProcess.getWorkQueue().poll();
}
Thread.sleep(200);
msg = foeiProcess.getWorkQueue().poll();
while (msg!=null) {
process(msg);
processed++;
msg = foeiProcess.getWorkQueue().poll();
}
} catch (Exception e) {
logger.log(Level.WARNING,"Error while Executing Event",e);
} finally {
ready = true;
FoeiProcessFactory.unbindFoeiProcess();
foeiProcess.getExecutors().remove(this);
logger.info(Thread.currentThread().getName()+"--"+this.toString()+" executed: "+processed);
}
}
private void process(FoeiPortMessage msg) throws IllegalEventPortNameException {
EventPort eventPort = msg.getEventPort();
Object eventObject = msg.getEventObject();
if(eventPort.getEventPortType()==EventPortType.input) {
EventInput eventInput = (EventInput)eventPort.getEventObject();
eventPort.addEventsPassed(); // inc input port
@ -119,15 +157,14 @@ public class EventExecutorImpl implements EventExecutor {
port.addEventsPassed(); // inc Immediate import port
eventInput.doEvent(port,eventObject);
} else {
foeiProcess.executeEvent(port,eventObject);
//foeiProcess.executeEvent(port,eventObject);
msg = new FoeiPortMessage();
msg.setEventObject(port);
msg.setEventPort(eventPort);
foeiProcess.getWorkQueue().add(msg);
}
}
return;
}
} catch (Exception e) {
logger.log(Level.WARNING,"Error while Executing Event",e);
} finally {
ready = true;
}
}
}

View file

@ -30,6 +30,7 @@ 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.event.EventPort;
@ -83,6 +84,16 @@ public class EventExecutorManagerImpl implements EventExecutorManager {
* @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();
@ -90,14 +101,17 @@ public class EventExecutorManagerImpl implements EventExecutorManager {
logger.log(Level.WARNING,"Error Creating EventExecutor: "+ee.getMessage(),ee);
return;
}
e.setEventObject(eventObject);
e.setEventPort(eventPort);
if(eventPort.isImmediate()) {
e.run();
} else {
e.setFoeiProcess(foeiProcess);
foeiProcess.getExecutors().add(e);
//e.setEventObject(eventObject);
//e.setEventPort(eventPort);
//if(eventPort.isImmediate()) {
// e.run();
//} else {
// mmmm
execute(e,foeiProcess);
}
//execute(e,foeiProcess);
threadPoolExecutor.execute(e);
//}
}
/**

View file

@ -64,13 +64,11 @@ public class FoeiConfiguratorImpl implements FoeiConfigurator {
throw new NullPointerException("properties may not be null.");
}
String name = getContextName(properties);
String rootPath = null;
Context objectContext = null;
EventExecutorManager eventExecutorManager = null;
FoeiProcessManager foeiProcessManager = null;
try {
rootPath = getRootPath(properties);
objectContext = newContext(properties);
eventExecutorManager = newEventExecutorManager(properties);
foeiProcessManager = newFoeiProcessManager(properties);
@ -78,7 +76,7 @@ public class FoeiConfiguratorImpl implements FoeiConfigurator {
} catch (Exception e) {
throw new FoeiContextBuildingException("Error while building childs objects:",e);
}
return new FoeiContextImpl(name,rootPath,objectContext,eventExecutorManager,properties,foeiProcessManager);
return new FoeiContextImpl(name,objectContext,eventExecutorManager,properties,foeiProcessManager);
}
/**
@ -94,20 +92,6 @@ public class FoeiConfiguratorImpl implements FoeiConfigurator {
return contextName;
}
/**
* Gets the root path from the properties Map.
* @param properties The properties map.
* @return Returns the rootpath from the properties map.
*/
static public String getRootPath(Map<String,String> properties) {
String rootPath = properties.get(FoeiConfigurator.ROOT_PATH);
if(rootPath==null) {
throw new NullPointerException("rootPath needs to be set in properties as: "+FoeiConfigurator.ROOT_PATH);
}
return rootPath;
}
/**
*
* @param properties

View file

@ -40,14 +40,11 @@ import javax.naming.Context;
* @author Willem Cazander
* @version 1.0 Jan 19, 2006
*/
public class FoeiContextImpl implements FoeiContext
{
public class FoeiContextImpl implements FoeiContext {
/** The name of this Instance **/
private String name = null;
/** The root path of this instance **/
private String rootPath = null;
/** The FoeiContext where all objects are stored. **/
private Context objectContext = null;
@ -70,14 +67,11 @@ public class FoeiContextImpl implements FoeiContext
* @param eventExecutorManager
* @param startProperties
*/
public FoeiContextImpl(String name,String rootPath,Context objectContext,EventExecutorManager eventExecutorManager,Map<String,String> startProperties,FoeiProcessManager foeiProcessManager) {
public FoeiContextImpl(String name,Context objectContext,EventExecutorManager eventExecutorManager,Map<String,String> startProperties,FoeiProcessManager foeiProcessManager) {
if(name==null) {
throw new NullPointerException("name may not be null.");
}
if(rootPath==null) {
throw new NullPointerException("rootPath may not be null.");
}
if(objectContext==null) {
throw new NullPointerException("objectContext may not be null.");
}
@ -89,7 +83,6 @@ public class FoeiContextImpl implements FoeiContext
}
this.name=name;
this.rootPath=rootPath;
this.objectContext=objectContext;
this.eventExecutorManager=eventExecutorManager;
this.startProperties=startProperties;
@ -104,13 +97,6 @@ public class FoeiContextImpl implements FoeiContext
return name;
}
/**
* @see FoeiContext#getRootPath()
*/
public String getRootPath() {
return rootPath;
}
/**
* @see FoeiContext#getEventExecutorManager()
*/

View file

@ -7,6 +7,7 @@ import com.idcanet.foei.event.EventOutput;
import com.idcanet.foei.event.EventStep;
import com.idcanet.foei.event.EventStepController;
import com.idcanet.x4o.element.Element;
import com.idcanet.x4o.element.ElementBindingException;
import com.idcanet.x4o.element.ElementBindingHandler;
/**
@ -65,7 +66,7 @@ public class FoeiEventBindingRuleHandler implements ElementBindingHandler {
* @param object2
* @throws ClassCastException
*/
public void doBind(Element element) throws Exception {
public void doBind(Element element) throws ElementBindingException {
Object parent = element.getParent().getElementObject();
Object child = element.getElementObject();
if(parent==null) {

View file

@ -26,12 +26,19 @@
package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.EventExecutor;
import com.idcanet.foei.core.FoeiContext;
import com.idcanet.foei.core.FoeiPortMessage;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.ObjectBindingsManager;
import com.idcanet.foei.event.EventPort;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -59,6 +66,10 @@ public class FoeiProcessImpl implements FoeiProcess {
/** The ObjectBindingsManager */
private ObjectBindingsManager objectBindingsManager = null;
private Queue<FoeiPortMessage> foeiPortMessages = new LinkedBlockingQueue<FoeiPortMessage>();
private Set<EventExecutor> eventExecutors = Collections.synchronizedSet(new HashSet<EventExecutor>(10));
public FoeiProcessImpl(String name,FoeiContext foeiContext,Context eventObjectContext,ObjectBindingsManager objectBindingsManager) {
logger = Logger.getLogger(FoeiProcessImpl.class.getName());
this.name=name;
@ -105,6 +116,14 @@ public class FoeiProcessImpl implements FoeiProcess {
return foeiContext;
}
public Queue<FoeiPortMessage> getWorkQueue() {
return foeiPortMessages;
}
public Set<EventExecutor> getExecutors() {
return eventExecutors;
}
// ================== EventPortExecutor
/**

View file

@ -29,6 +29,7 @@ package com.idcanet.foei.core.x4o;
import com.idcanet.foei.event.EventStep;
import com.idcanet.foei.event.EventStepController;
import com.idcanet.x4o.element.Element;
import com.idcanet.x4o.element.ElementBindingException;
import com.idcanet.x4o.element.ElementBindingHandler;
/**
@ -57,7 +58,7 @@ public class EventStepBindRuleHandler implements ElementBindingHandler {
/**
* @see com.idca.foei.xml.x2o.eld.BindingRuleHandler#doBind(java.lang.Object, java.lang.Object)
*/
public void doBind(Element element) throws Exception {
public void doBind(Element element) throws ElementBindingException {
Object parent = element.getParent().getElementObject();
Object child = element.getElementObject();
((EventStepController)parent).addEventStep((EventStep)child);

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,235 @@
/*
* 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 = 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);
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,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.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;
import com.idcanet.foei.ee.jca.spi.JCAEventExecutorManager;
/**
*
*
* @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());
foeiProcessManager = FoeiConfiguratorImpl.newFoeiProcessManager(properties);
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,92 @@
/*
* 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 beanName = null;
/**
* @see javax.resource.spi.ActivationSpec#validate()
*/
public void validate() throws InvalidPropertyException {
if (beanName==null) {
throw new InvalidPropertyException("beanName is null,please set beanName property.");
}
if (beanName.isEmpty()) {
throw new InvalidPropertyException("beanName is empty,please set beanName property.");
}
}
/**
* @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 beanName
*/
public String getBeanName() {
return beanName;
}
/**
* @param beanName the beanName to set
*/
public void setBeanName(String beanName) {
this.beanName = beanName;
}
}

View file

@ -0,0 +1,63 @@
/*
* 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 com.idcanet.foei.event.AbstractEventInput;
import com.idcanet.foei.event.EventPort;
import com.idcanet.foei.event.IllegalEventPortNameException;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
@SuppressWarnings("serial")
public class FoeiEventWrapper extends AbstractEventInput {
private Logger logger = Logger.getLogger(FoeiEventWrapper.class.getName());
/**
* @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;
//MessageEndpointFactory endpointFactory = null; //(MessageEndpointFactory)"endpointFactory";
//endpoint = endpointFactory.createEndpoint(null);
if (endpoint != null) {
AbstractEventInput input = (AbstractEventInput) endpoint;
input.doEvent(eventPort, object);
} else {
logger.warning("MessageEndPoint is null.");
}
}
}

View file

@ -0,0 +1,123 @@
/*
* 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.Level;
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.MessageEndpoint;
import javax.resource.spi.endpoint.MessageEndpointFactory;
import javax.transaction.xa.XAResource;
import com.idcanet.foei.server.FoeiContextManagerFactory;
/**
*
*
* @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;
/**
* @see javax.resource.spi.ResourceAdapter#start(javax.resource.spi.BootstrapContext)
*/
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
logger.info("Starting FoeiResourceAdapter");
this.bootstrapContext=bootstrapContext;
}
/**
* @see javax.resource.spi.ResourceAdapter#stop()
*/
public void stop() {
logger.info("Stopping FoeiResourceAdapter");
try {
FoeiContextManagerFactory.getFoeiContextManager().destroyAll();
} catch (Exception e) {
logger.log(Level.WARNING,"Error while shutdowning Foei: "+e.getMessage(),e);
throw new RuntimeException(e);
}
}
/**
* @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;
MessageEndpoint endPoint = endPointFactory.createEndpoint(null);
endPoint.release();
//endPoint.
fac.getBeanName();
// reg bean to foei context
}
/**
* @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;
//for (FoeiProcess proc:foeiContext.getFoeiProcessManager().getFoeiProcesses()) {
// proc.removeEventObject(fac.getBeanName());
//}
}
/**
* @return the bootstrapContext
*/
public BootstrapContext getBootstrapContext() {
return bootstrapContext;
}
/**
* @param bootstrapContext the bootstrapContext to set
*/
public void setBootstrapContext(BootstrapContext bootstrapContext) {
this.bootstrapContext = bootstrapContext;
}
}

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

@ -41,8 +41,8 @@ import java.util.logging.Logger;
* @author Willem Cazander
* @version 1.0 Feb 6, 2006
*/
public class FoeiContextManager
{
public class FoeiContextManager {
/** The logger to log to. */
private Logger logger = null;
/** All FoeiContext */

View file

@ -32,8 +32,8 @@ package com.idcanet.foei.server;
* @author Willem Cazander
* @version 1.0 Feb 6, 2006
*/
public class FoeiContextManagerFactory
{
public class FoeiContextManagerFactory {
/** */
static private FoeiContextManager foeiContextManager = null;

View file

@ -81,10 +81,7 @@ public class FoeiStartupListener implements ServletContextListener {
Properties properties = new Properties();
properties.load(foeiProperties);
foeiProperties.close();
properties.put(FoeiConfigurator.ROOT_PATH,event.getServletContext().getRealPath("/"));
foeiContextManager.createFoeiContext(properties);
} catch (Exception e) {
logger.log(Level.WARNING,"Error while starting FoeiContext: "+e.getMessage(),e);
}

View file

@ -66,7 +66,7 @@ public class SimpleFoeiTests extends TestCase {
Properties properties = new Properties();
properties.load(foeiProperties);
foeiProperties.close();
properties.put(FoeiConfigurator.ROOT_PATH,"/tmp");
//properties.put(FoeiConfigurator.ROOT_PATH,"/tmp");
foeiContextManager.createFoeiContext(properties);
test0 = foeiContextManager.getFoeiContext("TEST-0");
@ -126,7 +126,7 @@ public class SimpleFoeiTests extends TestCase {
proc.getFoeiContext().getEventExecutorManager().executeEvent(in.getOutputPort(EventPort.OUTPUT), new Date(), proc);
long endTime = System.currentTimeMillis();
System.out.println("Done sending in: "+(endTime-startTime)+" ms.");
Thread.sleep(50000); // todo: create destory context on end of event que
Thread.sleep(5000); // todo: create destory context on end of event que
System.out.println("End speedtest");
test0.getFoeiProcessManager().destroyFoeiProcess("testSpeed0");
}