diff --git a/.classpath b/.classpath
index e934150..15875b2 100644
--- a/.classpath
+++ b/.classpath
@@ -9,5 +9,8 @@
+
+
+
diff --git a/build/build-jca.xml b/build/build-jca.xml
new file mode 100644
index 0000000..bf62916
--- /dev/null
+++ b/build/build-jca.xml
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/build.properties b/build/build.properties
new file mode 100644
index 0000000..98eb309
--- /dev/null
+++ b/build/build.properties
@@ -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
diff --git a/doc/todo.txt b/doc/todo.txt
index a1cd25a..457a1c9 100644
--- a/doc/todo.txt
+++ b/doc/todo.txt
@@ -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
diff --git a/lib/idcanet-x4o-bin.jar b/lib/idcanet-x4o-bin.jar
index 5a7c348..d87fffd 100644
Binary files a/lib/idcanet-x4o-bin.jar and b/lib/idcanet-x4o-bin.jar differ
diff --git a/meta/jboss/foei-ds.xml b/meta/jboss/foei-ds.xml
new file mode 100644
index 0000000..89d602d
--- /dev/null
+++ b/meta/jboss/foei-ds.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+ foei/datafeeds
+ foei-ra.rar
+ com.idcanet.foei.ee.jca.cci.FoeiConnectionFactory
+ datafeeds
+
+ 2
+ 200
+ 32123
+ 1
+
+
+
+
+ foei/m4n
+ foei-ra.rar
+ com.idcanet.foei.ee.jca.cci.FoeiConnectionFactory
+ m4n
+
+
+ 2
+ 200
+ 32888
+ 1
+
+
+
+
diff --git a/meta/jboss/ra.xml b/meta/jboss/ra.xml
new file mode 100644
index 0000000..5b36428
--- /dev/null
+++ b/meta/jboss/ra.xml
@@ -0,0 +1,78 @@
+
+
+
+
+ FoeiJCA
+ IDCA
+ Foei Adapter
+ 1.0
+
+
+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.
+
+ true
+
+
+
+ com.idcanet.foei.ee.jca.spi.FoeiResourceAdapter
+
+
+
+ com.idcanet.foei.ee.jca.cci.FoeiManagedConnectionFactory
+
+ The foei context name.
+ foeiContextName
+ java.lang.String
+
+ com.idcanet.foei.ee.jca.cci.FoeiConnectionFactory
+ com.idcanet.foei.ee.jca.cci.FoeiConnectionFactoryImpl
+ com.idcanet.foei.ee.jca.cci.FoeiConnection
+ com.idcanet.foei.ee.jca.cci.FoeiConnectionImpl
+
+ NoTransaction
+ false
+
+
+
+
+
+ com.idcanet.foei.event.EventInput
+
+ com.idcanet.foei.ee.jca.spi.FoeiActivationSpec
+
+ beanName
+
+
+
+
+
+
+
+
+
diff --git a/src/com/idcanet/foei/components/lang/DestroyFoeiProcess.java b/src/com/idcanet/foei/components/lang/DestroyFoeiProcess.java
index 0ed13a4..2d52428 100644
--- a/src/com/idcanet/foei/components/lang/DestroyFoeiProcess.java
+++ b/src/com/idcanet/foei/components/lang/DestroyFoeiProcess.java
@@ -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());
diff --git a/src/com/idcanet/foei/core/EventExecutor.java b/src/com/idcanet/foei/core/EventExecutor.java
index 4a54b89..9aa672a 100644
--- a/src/com/idcanet/foei/core/EventExecutor.java
+++ b/src/com/idcanet/foei/core/EventExecutor.java
@@ -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
diff --git a/src/com/idcanet/foei/core/FoeiConfigurator.java b/src/com/idcanet/foei/core/FoeiConfigurator.java
index 918d7c0..421aeb4 100644
--- a/src/com/idcanet/foei/core/FoeiConfigurator.java
+++ b/src/com/idcanet/foei/core/FoeiConfigurator.java
@@ -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";
diff --git a/src/com/idcanet/foei/core/FoeiContext.java b/src/com/idcanet/foei/core/FoeiContext.java
index 5450f17..80025a4 100644
--- a/src/com/idcanet/foei/core/FoeiContext.java
+++ b/src/com/idcanet/foei/core/FoeiContext.java
@@ -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
diff --git a/src/com/idcanet/foei/core/FoeiPortMessage.java b/src/com/idcanet/foei/core/FoeiPortMessage.java
new file mode 100644
index 0000000..1756ccd
--- /dev/null
+++ b/src/com/idcanet/foei/core/FoeiPortMessage.java
@@ -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;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/FoeiProcess.java b/src/com/idcanet/foei/core/FoeiProcess.java
index e20c667..4c47ef5 100644
--- a/src/com/idcanet/foei/core/FoeiProcess.java
+++ b/src/com/idcanet/foei/core/FoeiProcess.java
@@ -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 getWorkQueue();
+
+ public Set getExecutors();
}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/impl/EventExecutorImpl.java b/src/com/idcanet/foei/core/impl/EventExecutorImpl.java
index cb9b61b..69bc00d 100644
--- a/src/com/idcanet/foei/core/impl/EventExecutorImpl.java
+++ b/src/com/idcanet/foei/core/impl/EventExecutorImpl.java
@@ -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,43 +97,74 @@ 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();
- if(eventPort.getEventPortType()==EventPortType.input) {
- EventInput eventInput = (EventInput)eventPort.getEventObject();
- eventPort.addEventsPassed(); // inc input port
- eventInput.doEvent(eventPort,eventObject);
- return;
+ //FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess();
+ FoeiProcessFactory.bindFoeiProcess(foeiProcess);
+
+ FoeiPortMessage msg = foeiProcess.getWorkQueue().poll();
+ while (msg!=null) {
+ process(msg);
+ processed++;
+ msg = foeiProcess.getWorkQueue().poll();
}
- if(eventPort.getEventPortType()==EventPortType.output) {
- eventPort.addEventsPassed(); // inc output port
-
- // uses the faster routine to get bindings ...,
- //List bindings = foeiProcess.getBindings(eventPort);
- List bindings = foeiProcess.getBindingsInputPorts(eventPort);
-
- for (int i=0;i bindings = foeiProcess.getBindings(eventPort);
+ List bindings = foeiProcess.getBindingsInputPorts(eventPort);
+
+ for (int i=0;i3) {
+ 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);
+ //}
}
/**
diff --git a/src/com/idcanet/foei/core/impl/FoeiConfiguratorImpl.java b/src/com/idcanet/foei/core/impl/FoeiConfiguratorImpl.java
index e260c7f..5b0a194 100644
--- a/src/com/idcanet/foei/core/impl/FoeiConfiguratorImpl.java
+++ b/src/com/idcanet/foei/core/impl/FoeiConfiguratorImpl.java
@@ -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 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
diff --git a/src/com/idcanet/foei/core/impl/FoeiContextImpl.java b/src/com/idcanet/foei/core/impl/FoeiContextImpl.java
index bcb25e3..e5a5c91 100644
--- a/src/com/idcanet/foei/core/impl/FoeiContextImpl.java
+++ b/src/com/idcanet/foei/core/impl/FoeiContextImpl.java
@@ -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 startProperties,FoeiProcessManager foeiProcessManager) {
+ public FoeiContextImpl(String name,Context objectContext,EventExecutorManager eventExecutorManager,Map 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()
*/
diff --git a/src/com/idcanet/foei/core/impl/FoeiEventBindingRuleHandler.java b/src/com/idcanet/foei/core/impl/FoeiEventBindingRuleHandler.java
index 5071a26..29a8daf 100644
--- a/src/com/idcanet/foei/core/impl/FoeiEventBindingRuleHandler.java
+++ b/src/com/idcanet/foei/core/impl/FoeiEventBindingRuleHandler.java
@@ -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) {
diff --git a/src/com/idcanet/foei/core/impl/FoeiProcessImpl.java b/src/com/idcanet/foei/core/impl/FoeiProcessImpl.java
index 8364510..bc6d0ba 100644
--- a/src/com/idcanet/foei/core/impl/FoeiProcessImpl.java
+++ b/src/com/idcanet/foei/core/impl/FoeiProcessImpl.java
@@ -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 foeiPortMessages = new LinkedBlockingQueue();
+
+ private Set eventExecutors = Collections.synchronizedSet(new HashSet(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 getWorkQueue() {
+ return foeiPortMessages;
+ }
+
+ public Set getExecutors() {
+ return eventExecutors;
+ }
+
// ================== EventPortExecutor
/**
diff --git a/src/com/idcanet/foei/core/x4o/EventStepBindRuleHandler.java b/src/com/idcanet/foei/core/x4o/EventStepBindRuleHandler.java
index c982f76..8c74253 100644
--- a/src/com/idcanet/foei/core/x4o/EventStepBindRuleHandler.java
+++ b/src/com/idcanet/foei/core/x4o/EventStepBindRuleHandler.java
@@ -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);
diff --git a/src/com/idcanet/foei/ee/jca/cci/FoeiConnection.java b/src/com/idcanet/foei/ee/jca/cci/FoeiConnection.java
new file mode 100644
index 0000000..2c0a9e0
--- /dev/null
+++ b/src/com/idcanet/foei/ee/jca/cci/FoeiConnection.java
@@ -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;
+}
diff --git a/src/com/idcanet/foei/ee/jca/cci/FoeiConnectionFactory.java b/src/com/idcanet/foei/ee/jca/cci/FoeiConnectionFactory.java
new file mode 100644
index 0000000..399e3be
--- /dev/null
+++ b/src/com/idcanet/foei/ee/jca/cci/FoeiConnectionFactory.java
@@ -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;
+}
diff --git a/src/com/idcanet/foei/ee/jca/cci/FoeiConnectionFactoryImpl.java b/src/com/idcanet/foei/ee/jca/cci/FoeiConnectionFactoryImpl.java
new file mode 100644
index 0000000..665effa
--- /dev/null
+++ b/src/com/idcanet/foei/ee/jca/cci/FoeiConnectionFactoryImpl.java
@@ -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);
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/ee/jca/cci/FoeiConnectionImpl.java b/src/com/idcanet/foei/ee/jca/cci/FoeiConnectionImpl.java
new file mode 100644
index 0000000..31e80a5
--- /dev/null
+++ b/src/com/idcanet/foei/ee/jca/cci/FoeiConnectionImpl.java
@@ -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);
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/ee/jca/cci/FoeiManagedConnection.java b/src/com/idcanet/foei/ee/jca/cci/FoeiManagedConnection.java
new file mode 100644
index 0000000..6d36fba
--- /dev/null
+++ b/src/com/idcanet/foei/ee/jca/cci/FoeiManagedConnection.java
@@ -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 listeners;
+
+ /** Set of application-level handlers */
+ private Set 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(10);
+ this.connectionSet = new HashSet(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 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 itr = listeners.iterator();
+ while (itr.hasNext()) {
+ try {
+ itr.next().connectionClosed(event);
+ } catch (Throwable e) {
+ }
+ }
+ }
+ con.invalidate();
+ removeConnection(con);
+ }
+}
diff --git a/src/com/idcanet/foei/ee/jca/cci/FoeiManagedConnectionFactory.java b/src/com/idcanet/foei/ee/jca/cci/FoeiManagedConnectionFactory.java
new file mode 100644
index 0000000..b8b9caa
--- /dev/null
+++ b/src/com/idcanet/foei/ee/jca/cci/FoeiManagedConnectionFactory.java
@@ -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 properties = new HashMap(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;
+ }
+}
diff --git a/src/com/idcanet/foei/ee/jca/cci/FoeiManagedConnectionMetaData.java b/src/com/idcanet/foei/ee/jca/cci/FoeiManagedConnectionMetaData.java
new file mode 100644
index 0000000..38e2f0f
--- /dev/null
+++ b/src/com/idcanet/foei/ee/jca/cci/FoeiManagedConnectionMetaData.java
@@ -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";
+ }
+}
diff --git a/src/com/idcanet/foei/ee/jca/spi/FoeiActivationSpec.java b/src/com/idcanet/foei/ee/jca/spi/FoeiActivationSpec.java
new file mode 100644
index 0000000..e80ddc3
--- /dev/null
+++ b/src/com/idcanet/foei/ee/jca/spi/FoeiActivationSpec.java
@@ -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;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/ee/jca/spi/FoeiEventWrapper.java b/src/com/idcanet/foei/ee/jca/spi/FoeiEventWrapper.java
new file mode 100644
index 0000000..cc82780
--- /dev/null
+++ b/src/com/idcanet/foei/ee/jca/spi/FoeiEventWrapper.java
@@ -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.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/ee/jca/spi/FoeiResourceAdapter.java b/src/com/idcanet/foei/ee/jca/spi/FoeiResourceAdapter.java
new file mode 100644
index 0000000..06318d1
--- /dev/null
+++ b/src/com/idcanet/foei/ee/jca/spi/FoeiResourceAdapter.java
@@ -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;
+ }
+}
diff --git a/src/com/idcanet/foei/ee/jca/spi/JCAEventExecutorManager.java b/src/com/idcanet/foei/ee/jca/spi/JCAEventExecutorManager.java
new file mode 100644
index 0000000..9a49917
--- /dev/null
+++ b/src/com/idcanet/foei/ee/jca/spi/JCAEventExecutorManager.java
@@ -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 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(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 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");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/server/FoeiContextManager.java b/src/com/idcanet/foei/server/FoeiContextManager.java
index a5a6c2f..6e8a71d 100644
--- a/src/com/idcanet/foei/server/FoeiContextManager.java
+++ b/src/com/idcanet/foei/server/FoeiContextManager.java
@@ -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 */
diff --git a/src/com/idcanet/foei/server/FoeiContextManagerFactory.java b/src/com/idcanet/foei/server/FoeiContextManagerFactory.java
index 7528675..8a7a71b 100644
--- a/src/com/idcanet/foei/server/FoeiContextManagerFactory.java
+++ b/src/com/idcanet/foei/server/FoeiContextManagerFactory.java
@@ -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;
diff --git a/src/com/idcanet/foei/server/startup/FoeiStartupListener.java b/src/com/idcanet/foei/server/startup/FoeiStartupListener.java
index 0272d02..f7424aa 100644
--- a/src/com/idcanet/foei/server/startup/FoeiStartupListener.java
+++ b/src/com/idcanet/foei/server/startup/FoeiStartupListener.java
@@ -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);
}
diff --git a/tests/com/idcanet/foei/SimpleFoeiTests.java b/tests/com/idcanet/foei/SimpleFoeiTests.java
index d34eed8..b40693f 100644
--- a/tests/com/idcanet/foei/SimpleFoeiTests.java
+++ b/tests/com/idcanet/foei/SimpleFoeiTests.java
@@ -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");
}