diff --git a/.classpath b/.classpath
index c604d75..2ed30db 100644
--- a/.classpath
+++ b/.classpath
@@ -3,5 +3,7 @@
+
+
diff --git a/lib/commons-beanutils.jar b/lib/commons-beanutils.jar
new file mode 100644
index 0000000..b1b89c9
Binary files /dev/null and b/lib/commons-beanutils.jar differ
diff --git a/lib/idcanet-x4o-bin.jar b/lib/idcanet-x4o-bin.jar
new file mode 100644
index 0000000..e62c464
Binary files /dev/null and b/lib/idcanet-x4o-bin.jar differ
diff --git a/src/META-INF/events.eld b/src/META-INF/events.eld
new file mode 100644
index 0000000..fa7a08b
--- /dev/null
+++ b/src/META-INF/events.eld
@@ -0,0 +1,33 @@
+
+
+
+
+ events.eld
+ All event foei objects
+
+
+
\ No newline at end of file
diff --git a/src/META-INF/filters.eld b/src/META-INF/filters.eld
new file mode 100644
index 0000000..bc43aef
--- /dev/null
+++ b/src/META-INF/filters.eld
@@ -0,0 +1,57 @@
+
+
+
+
+ filters.eld
+ All core foei objects
+
+
+
+ filter
+ Filters an object by its eventSteps
+ com.idcanet.foei.components.lang.Filter
+
+
+
+ stringFilter
+ filters an String on a regex
+ com.idcanet.foei.components.steps.filters.StringFilter
+
+
+
+ classFilter
+ filters for a class on an object
+ com.idcanet.foei.components.steps.filters.ClassFilter
+
+
+
+ dateFilter
+ filters an date of an Date
+ com.idcanet.foei.components.steps.filters.DateFilter
+
+
+
\ No newline at end of file
diff --git a/src/META-INF/foei-context-defaults.xml b/src/META-INF/foei-context-defaults.xml
new file mode 100644
index 0000000..ef2c196
--- /dev/null
+++ b/src/META-INF/foei-context-defaults.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+ com.idcanet.foei.core.impl.ObjectBindingsManagerImpl
+
+
diff --git a/src/META-INF/foei-namespaces.properties b/src/META-INF/foei-namespaces.properties
new file mode 100644
index 0000000..a7404d9
--- /dev/null
+++ b/src/META-INF/foei-namespaces.properties
@@ -0,0 +1,18 @@
+
+code.http\://foei.idca.nl/eld/events.eld=com.idcanet.x4o.core.DefaultX4OEldElementProvider
+file.http\://foei.idca.nl/eld/events.eld=/META-INF/events.eld
+
+code.http\://foei.idca.nl/eld/filters.eld=com.idcanet.x4o.core.DefaultX4OEldElementProvider
+file.http\://foei.idca.nl/eld/filters.eld=/META-INF/filters.eld
+
+code.http\://foei.idca.nl/eld/io.eld=com.idcanet.x4o.core.DefaultX4OEldElementProvider
+file.http\://foei.idca.nl/eld/io.eld=/META-INF/io.eld
+
+code.http\://foei.idca.nl/eld/lang.eld=com.idcanet.x4o.core.DefaultX4OEldElementProvider
+file.http\://foei.idca.nl/eld/lang.eld=/META-INF/lang.eld
+
+code.http\://foei.idca.nl/eld/logging.eld=com.idcanet.x4o.core.DefaultX4OEldElementProvider
+file.http\://foei.idca.nl/eld/logging.eld=/META-INF/logging.eld
+
+code.http\://foei.idca.nl/eld/printers.eld=com.idcanet.x4o.core.DefaultX4OEldElementProvider
+file.http\://foei.idca.nl/eld/printers.eld=/META-INF/printers.eld
\ No newline at end of file
diff --git a/src/META-INF/io.eld b/src/META-INF/io.eld
new file mode 100644
index 0000000..4d9c2e6
--- /dev/null
+++ b/src/META-INF/io.eld
@@ -0,0 +1,53 @@
+
+
+
+
+
+ io.eld
+ io foei objects
+
+
+
+ standardOutput
+ This Object printer prints to the std-out
+ com.idcanet.foei.components.io.StandardOutput
+
+
+
+
+ errorOutput
+ This Object printer prints to the err-out
+ com.idcanet.foei.components.io.ErrorOutput
+
+
+
+ fileOutput
+ This Object printer prints to a file
+ com.idcanet.foei.components.io.FileOutput
+
+
+
\ No newline at end of file
diff --git a/src/META-INF/lang.eld b/src/META-INF/lang.eld
new file mode 100644
index 0000000..69ecdb7
--- /dev/null
+++ b/src/META-INF/lang.eld
@@ -0,0 +1,105 @@
+
+
+
+
+ lang.eld
+ All core lang foei objects
+
+
+
+ bind
+ com.idcanet.foei.core.x4o.BindAttributeHandler
+ Binds the EventPort to getter
+
+
+
+ id
+ com.idcanet.foei.core.x4o.IdAttributeHandler
+ Adds the object into the context
+
+
+
+ com.idcanet.foei.core.x4o.EventStepBindRuleHandler
+
+
+
+
+ bind
+ Binds 2 eventPorts together
+ com.idcanet.foei.core.x4o.ObjectBindingElement
+
+
+
+ dummyOutputPort
+ An dummy output, mostly used to send events into foei.
+ com.idcanet.foei.components.lang.DummyOutputPort
+
+
+
+ objectChangedBuffer
+ Buffers objects an only fires when it is not equal
+ com.idcanet.foei.components.lang.ObjectChangedBuffer
+
+
+
+ destroyFoeiProcess
+ Destroys the current process
+ com.idcanet.foei.components.lang.DestroyFoeiProcess
+
+
+
+ setBeanProperty
+ Sets an property on a bean.
+ com.idcanet.foei.components.lang.SetBeanProperty
+
+
+
+ getBeanProperty
+ Gets an property on a bean.
+ com.idcanet.foei.components.lang.GetBeanProperty
+
+
+
+
+ getBeanPropertyStep
+ gets an property of an obeject
+ com.idcanet.foei.components.steps.lang.GetBeanPropertyStep
+
+
+
+ mapValue
+ gets an Value out of an Map
+ com.idcanet.foei.components.steps.lang.MapValue
+
+
+
+ listValue
+ gets an Value out of an List
+ com.idcanet.foei.components.steps.lang.ListValue
+
+
+
\ No newline at end of file
diff --git a/src/META-INF/logging.eld b/src/META-INF/logging.eld
new file mode 100644
index 0000000..71e9e59
--- /dev/null
+++ b/src/META-INF/logging.eld
@@ -0,0 +1,35 @@
+
+
+
+
+
+ loggerInput
+ Java Logger InputHandler
+ com.idcanet.foei.components.logging.LoggerInput
+
+
+
\ No newline at end of file
diff --git a/src/META-INF/printers.eld b/src/META-INF/printers.eld
new file mode 100644
index 0000000..0a5e19d
--- /dev/null
+++ b/src/META-INF/printers.eld
@@ -0,0 +1,61 @@
+
+
+
+
+
+ printers.eld
+ A few standaard (step)printers
+
+
+
+
+ defaultPrinter
+ This EventStep uses to toString() to print an object.
+ com.idcanet.foei.components.steps.printers.DefaultPrinter
+
+
+ prefix
+ java.lang.String
+ null
+ Prints the prefix of this printer
+
+
+ postfix
+ java.lang.String
+ null
+ Prints the postfix of this printer
+
+
+
+
+
+ datePrinter
+ This eventStep prints an date object including formating
+ com.idcanet.foei.components.steps.printers.DatePrinter
+
+
+
\ No newline at end of file
diff --git a/src/com/idcanet/foei/components/io/ErrorOutput.java b/src/com/idcanet/foei/components/io/ErrorOutput.java
new file mode 100644
index 0000000..9ea4d17
--- /dev/null
+++ b/src/com/idcanet/foei/components/io/ErrorOutput.java
@@ -0,0 +1,72 @@
+/*
+ * 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.components.io;
+
+import com.idcanet.foei.event.AbstractEventInputStepController;
+import com.idcanet.foei.event.EventPort;
+import com.idcanet.foei.event.EventPortType;
+import com.idcanet.foei.event.EventStep;
+import com.idcanet.foei.event.IllegalEventPortNameException;
+
+/**
+ * Prints the EventSteps to the System.err
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 25, 2006
+ */
+public class ErrorOutput extends AbstractEventInputStepController
+{
+ /** v1.0 */
+ static final long serialVersionUID = 10l;
+
+ /**
+ * Creates an ErrorOutput
+ */
+ public ErrorOutput() {
+ addInputPort(EventPort.INPUT);
+ }
+
+ // ----------- EventInput
+
+ public void doEvent(EventPort eventPort,Object object) throws IllegalEventPortNameException {
+ if(EventPortType.input!=eventPort.getEventPortType()) {
+ throw new IllegalEventPortNameException("Not excisting input EventPort: "+eventPort.getName());
+ }
+ System.err.println(processEventSteps(object));
+ }
+
+ public Object processEventSteps(Object object) {
+ StringBuffer buff = new StringBuffer();
+ for(EventStep e:getEventSteps()) {
+ if(object==null) {
+ return null;
+ }
+ buff.append((String)e.processObject(object));
+ }
+ return buff;
+ }
+}
diff --git a/src/com/idcanet/foei/components/io/FileOutput.java b/src/com/idcanet/foei/components/io/FileOutput.java
new file mode 100644
index 0000000..f4cb001
--- /dev/null
+++ b/src/com/idcanet/foei/components/io/FileOutput.java
@@ -0,0 +1,36 @@
+
+package com.idcanet.foei.components.io;
+/*
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Iterator;
+
+public class FileOutput extends AbstractEventInput
+{
+ static final String INPUT = "input";
+ private ArrayList printers = new ArrayList(4);
+
+ public FileOutput()
+ {
+ inputList.add(INPUT);
+ }
+
+
+ // ----------- EventInput
+
+ public void doEvent(String inputName,Object object)
+ {
+ Iterator printerWalker = printers.iterator();
+ //System.out.print("STDOUT:");
+ while(printerWalker.hasNext())
+ {
+ EventStep eventStep = (EventStep)printerWalker.next();
+ String out = (String)eventStep.processObject(object);
+ System.out.print(out);
+ }
+ System.out.println("");
+ }
+
+}
+*/
\ No newline at end of file
diff --git a/src/com/idcanet/foei/components/io/StandardOutput.java b/src/com/idcanet/foei/components/io/StandardOutput.java
new file mode 100644
index 0000000..e9524aa
--- /dev/null
+++ b/src/com/idcanet/foei/components/io/StandardOutput.java
@@ -0,0 +1,73 @@
+/*
+ * 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.components.io;
+
+import com.idcanet.foei.event.AbstractEventInputStepController;
+import com.idcanet.foei.event.EventPort;
+import com.idcanet.foei.event.EventPortType;
+import com.idcanet.foei.event.EventStep;
+import com.idcanet.foei.event.IllegalEventPortNameException;
+
+/**
+ * Prints the EventSteps to the System.out
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 25, 2006
+ */
+public class StandardOutput extends AbstractEventInputStepController {
+
+ /** v1.0 */
+ static final long serialVersionUID = 10l;
+
+ /**
+ * Creates an StandardOutput
+ *
+ */
+ public StandardOutput() {
+ addInputPort(EventPort.INPUT);
+ }
+
+ // ----------- EventInput
+
+ public void doEvent(EventPort eventPort,Object object) throws IllegalEventPortNameException {
+ if(EventPortType.input!=eventPort.getEventPortType()) {
+ throw new IllegalEventPortNameException("Not excisting input EventPort: "+eventPort.getName());
+ }
+ System.out.println(processEventSteps(object));
+ }
+
+ public Object processEventSteps(Object object) {
+ StringBuffer buff = new StringBuffer();
+ for(EventStep e:getEventSteps()) {
+ if(object==null) {
+ return null;
+ }
+ buff.append((String)e.processObject(object));
+ }
+ return buff;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/components/logging/Log4jInput.java b/src/com/idcanet/foei/components/logging/Log4jInput.java
new file mode 100644
index 0000000..cddb382
--- /dev/null
+++ b/src/com/idcanet/foei/components/logging/Log4jInput.java
@@ -0,0 +1,64 @@
+package com.idcanet.foei.components.logging;
+/*
+
+package com.mbuyu.foei.handlers.log4j;
+
+import java.net.*;
+import java.io.*;
+
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Layout;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.log4j.Layout;
+import org.apache.log4j.PatternLayout;
+import org.apache.log4j.WriterAppender;
+import org.apache.log4j.net.SocketNode;
+
+public class RequestCollector implements Runnable {
+
+ private Socket reqSocket;
+ private SocketNode reqNode;
+ private String host;
+ private int port;
+ static final String fileName = "rtrace";
+ static final Logger logger = Logger.getLogger("RequestCollector.class");
+
+ public RequestCollector (int port, String host) {
+ super();
+ this.host = host;
+ this.port = port;
+ }
+
+ public void run() {
+ try {
+ BasicConfigurator.configure();
+ PrintWriter writer = new PrintWriter (new FileWriter(fileName));
+ Layout layout = new PatternLayout("%d{ABSOLUTE} %c{1} %m\n");
+ WriterAppender appender = new WriterAppender(layout, writer);
+ appender.setImmediateFlush(true);
+ LogManager.getRootLogger().removeAllAppenders();
+ LogManager.getRootLogger().addAppender(appender);
+ appender.activateOptions();
+ logger.addAppender(appender);
+ reqSocket = new Socket(host, port);
+ System.out.println("Created Socket");
+ reqNode = new SocketNode(reqSocket, LogManager.getLoggerRepository());
+ System.out.println("Created SocketNode");
+ new Thread(reqNode).start();
+ System.out.println("After thread (reqNode)");
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println(e);
+ }
+ }
+
+ public static void main (String args[]) {
+ System.out.println("B4 Starting");
+ RequestCollector rq = new RequestCollector(9998, "some-host");
+ new Thread(rq).start();
+ System.out.println("Completed");
+ }
+}
+*/
\ No newline at end of file
diff --git a/src/com/idcanet/foei/components/logging/LoggerHandler.java b/src/com/idcanet/foei/components/logging/LoggerHandler.java
new file mode 100644
index 0000000..e25767c
--- /dev/null
+++ b/src/com/idcanet/foei/components/logging/LoggerHandler.java
@@ -0,0 +1,65 @@
+/*
+ * 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.components.logging;
+
+import java.util.HashMap;
+import java.util.logging.Logger;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 25, 2006
+ */
+public class LoggerHandler extends Handler
+{
+ private Logger logger = Logger.getLogger(this.getClass().getName());
+ private LoggerInput loggerInput = null;
+
+ public LoggerHandler(LoggerInput loggerInput)
+ {
+ this.loggerInput=loggerInput;
+ logger.addHandler(this);
+ }
+
+ // ------------ handler
+
+ public void publish(LogRecord record) {
+ HashMap event = new HashMap();
+ event.put("message",record.getMessage());
+ event.put("level",record.getLevel().getName());
+ loggerInput.sendMessage(event);
+ }
+
+ public void flush() {
+ }
+
+ public void close() {
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/components/logging/LoggerInput.java b/src/com/idcanet/foei/components/logging/LoggerInput.java
new file mode 100644
index 0000000..704c132
--- /dev/null
+++ b/src/com/idcanet/foei/components/logging/LoggerInput.java
@@ -0,0 +1,67 @@
+/*
+ * 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.components.logging;
+
+import com.idcanet.foei.core.FoeiProcessFactory;
+import com.idcanet.foei.event.AbstractEventOutput;
+import com.idcanet.foei.event.EventPort;
+
+import java.util.Map;
+
+/**
+ * Reseives java logging messages
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 25, 2006
+ */
+public class LoggerInput extends AbstractEventOutput
+{
+ /** v1.0 */
+ static final long serialVersionUID = 10l;
+ /** */
+ static final String OUTPUT = "output";
+
+ /**
+ * Creates an LoggerInput
+ *
+ */
+ public LoggerInput() {
+ // define an outpur source.
+ addOutputPort(OUTPUT,Map.class);
+ new LoggerHandler(this);
+ }
+
+ /**
+ *
+ * @param event
+ */
+ public void sendMessage(Map event) {
+ FoeiProcessFactory.getFoeiProcess().executeEvent(getOutputPort(EventPort.OUTPUT),event);
+ //FoeiInstance foeiInstance = FoeiServer.getFoeiInstance();
+ //foeiInstance.getObjectBindingsManager().sendEventOutput(getID(),OUTPUT,event);
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/components/logging/package.html b/src/com/idcanet/foei/components/logging/package.html
new file mode 100644
index 0000000..ee5a4dc
--- /dev/null
+++ b/src/com/idcanet/foei/components/logging/package.html
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+Some EventObjects for log handing.
+
+
+
+Related Documentation
+
+None.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/idcanet/foei/components/steps/filters/ClassFilter.java b/src/com/idcanet/foei/components/steps/filters/ClassFilter.java
new file mode 100644
index 0000000..84caf0f
--- /dev/null
+++ b/src/com/idcanet/foei/components/steps/filters/ClassFilter.java
@@ -0,0 +1,88 @@
+/*
+ * 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.components.steps.filters;
+
+import com.idcanet.foei.event.AbstractEventStepController;
+
+/**
+ * Filters an object and checks for the className.
+ *
+ * @author Willem Cazander
+ * @version 1.0 26/01/2005
+ */
+public class ClassFilter extends AbstractEventStepController
+{
+ /** v1.0 */
+ static final long serialVersionUID = 10l;
+ /** The class name to match */
+ private String className = null;
+
+ /**
+ * Sets the className which the filtered object has to have.
+ * @param className The className.
+ */
+ public void setClassName(String className)
+ {
+ this.className=className;
+ }
+
+ /**
+ * Returns the className on which this filter filters.
+ * @return The className.
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Process an object.
+ * This checks if the objects class equals that of the className.
+ * @return The object or null is not succesfull.
+ */
+ public Object processObject(Object object)
+ {
+ if(object==null)
+ {
+ return null;
+ }
+ Class[] classes = object.getClass().getClasses();
+ System.out.println("ClassFilter filter: "+object+" on "+className+" classes: "+classes.length);
+ for(int i=0;i0) {
+ return null;
+ }
+ return object;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/components/steps/filters/StringFilter.java b/src/com/idcanet/foei/components/steps/filters/StringFilter.java
new file mode 100644
index 0000000..db7bd9e
--- /dev/null
+++ b/src/com/idcanet/foei/components/steps/filters/StringFilter.java
@@ -0,0 +1,158 @@
+/*
+ * 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.components.steps.filters;
+
+import com.idcanet.foei.event.AbstractEventStepController;
+
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Filters an String object.
+ *
+ * @author Willem Cazander
+ * @version 1.0 26/01/2005
+ */
+public class StringFilter extends AbstractEventStepController
+{
+ /** v1.0 */
+ static final long serialVersionUID = 10l;
+ private int minLength=0;
+ private int maxLength=0;
+ private Logger logger = Logger.getLogger(this.getClass().getName());
+ private Pattern pattern = null;
+
+ /**
+ * Emty constuctor.
+ */
+ public StringFilter() {
+ }
+
+ // -------------- (bean)properties.
+
+ /**
+ * Sets the regulare expression on which this object filters an String.
+ *
+ * When set to Null
matching is disabled.
+ *
+ * @param regex The regulare expression to match to.
+ */
+ public void setRegEx(String regex) {
+ pattern = Pattern.compile(regex);
+ }
+ /**
+ * Returns the current regulare expression.
+ * @return The regulare expression.
+ */
+ public String getRegEx() {
+ if(pattern==null) {
+ return null;
+ }
+ return pattern.pattern();
+ }
+
+ /**
+ * Set the minimal length the filtered object has to be.
+ *
+ * When set to -1 testing is disabled.
+ *
+ * @param minLength The minimal length to match.
+ */
+ public void setMinLength(int minLength) {
+ this.minLength=minLength;
+ }
+
+ /**
+ * Returns the current minimal length of this filter.
+ * @return The minimal length.
+ */
+ public int getMinLength() {
+ return minLength;
+ }
+
+ /**
+ * Set the maximal length of the filters string object.
+ *
+ * When set to -1 testing is disabled.
+ *
+ * @param maxLength
+ */
+ public void setMaxLength(int maxLength) {
+ this.maxLength=maxLength;
+ }
+
+ /**
+ * Returns the current maximal length.
+ * @return the maximal length.
+ */
+ public int getMaxLength() {
+ return maxLength;
+ }
+
+ // -------------- eventStep
+
+ /**
+ * Filters an Object.
+ * If it not an String then null will be returned.
+ * Likewise when the String object has not matched to an certain
+ * propertie then also null will be returned.
+ *
+ * @param object The Object thats get filtered.
+ * @return null if object was not mached else the object returns.
+ */
+ public Object processObject(Object object) {
+
+ if(!(object instanceof String)) {
+ return null;
+ }
+ String string = (String)object;
+
+ if(pattern==null) {
+
+ }
+
+ if(pattern!=null) {
+ // test if regex matches
+ Matcher m = pattern.matcher(string);
+ if(!m.find()) {
+ return null;
+ }
+ }
+
+ // test min length
+ if(minLength!=0 && string.length()>minLength) {
+ return null;
+ }
+ // test max length
+ if(maxLength!=0 && string.length()
+
+
+
+
+
+EventSteps which filter an Object.
+
+
+
+Related Documentation
+
+None.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/idcanet/foei/components/steps/lang/GetBeanPropertyStep.java b/src/com/idcanet/foei/components/steps/lang/GetBeanPropertyStep.java
new file mode 100644
index 0000000..245fe89
--- /dev/null
+++ b/src/com/idcanet/foei/components/steps/lang/GetBeanPropertyStep.java
@@ -0,0 +1,78 @@
+/*
+ * 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.components.steps.lang;
+
+import com.idcanet.foei.event.AbstractEventStepController;
+
+import org.apache.commons.beanutils.BeanUtils;
+
+/**
+ * Gets the property of an java bean.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Feb 9, 2006
+ */
+public class GetBeanPropertyStep extends AbstractEventStepController
+{
+ /** v1.0 */
+ static final long serialVersionUID = 10l;
+ /** Holds the key which contains the object in the map. */
+ private String property = null;
+
+
+ //----------- get/set functions
+
+ public void setProperty(String property) {
+ this.property=property;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ // -------------------- EventStep
+
+ /**
+ * Proces an Object, when property is correcly found then
+ * it is processed by the eventSteps of the object.
+ */
+ public Object processObject(Object object) {
+ if(property==null) {
+ return null;
+ }
+ Object result = null;
+ try {
+ result = BeanUtils.getProperty(object,property);
+ } catch (Exception e) {
+ //logger.log(Level.WARNING,"property:"+property+" is not an property of object: "+object.getClass().getName(),e);
+ e.printStackTrace();
+ return null;
+ }
+ return processEventSteps(result);
+ }
+}
+
diff --git a/src/com/idcanet/foei/components/steps/lang/ListValue.java b/src/com/idcanet/foei/components/steps/lang/ListValue.java
new file mode 100644
index 0000000..1c4f5ef
--- /dev/null
+++ b/src/com/idcanet/foei/components/steps/lang/ListValue.java
@@ -0,0 +1,79 @@
+/*
+ * 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.components.steps.lang;
+
+import com.idcanet.foei.event.AbstractEventStepController;
+
+import java.util.List;
+
+/**
+ * Gets an Value out of an List
+ *
+ * @author Willem Cazander
+ * @version 1.0 Feb 9, 2006
+ */
+public class ListValue extends AbstractEventStepController
+{
+ /** v1.0 */
+ static final long serialVersionUID = 10l;
+ /** Holds the index which contains the object in the map. */
+ private String index = null;
+
+ static private final String FIRST = "FIRST";
+ static private final String LAST = "LAST";
+
+ // bean
+
+ public void setIndex(String index) {
+ this.index=index;
+ }
+ public String getIndex() {
+ return index;
+ }
+ public Object processObject(Object object) {
+
+ if(!(object instanceof List)) {
+ return null;
+ }
+ List list = (List)object;
+
+ if(FIRST.equalsIgnoreCase(index)) {
+ return processEventSteps(list.get(0));
+ }
+ if(LAST.equalsIgnoreCase(index)) {
+ return processEventSteps(list.get(list.size()));
+ }
+ try {
+ int listIndex = new Integer(index);
+ return processEventSteps(list.get(listIndex));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/components/steps/lang/MapValue.java b/src/com/idcanet/foei/components/steps/lang/MapValue.java
new file mode 100644
index 0000000..2237e5d
--- /dev/null
+++ b/src/com/idcanet/foei/components/steps/lang/MapValue.java
@@ -0,0 +1,88 @@
+/*
+ * 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.components.steps.lang;
+
+import com.idcanet.foei.event.AbstractEventStepController;
+
+import java.util.Map;
+
+/**
+ * This EventStep can have nesting EventSteps.
+ * It it get the object out of the map object which is processed and
+ * let is process by an added EventStep object.
+ *
+ * @author Willem Cazander
+ * @version 1.0 28/03/2004
+ */
+public class MapValue extends AbstractEventStepController
+{
+ /** v1.0 */
+ static final long serialVersionUID = 10l;
+ /** Holds the key which contains the object in the map. */
+ private String key = null;
+
+
+ //----------- get/set functions
+
+ /**
+ * Sets the key which is used to lookup an object in an Map.
+ * Which gets returned by the processObject() of EventStep.
+ * @param key The key of an object in an Map.
+ */
+ public void setKey(String key) {
+ this.key=key;
+ }
+
+ /**
+ * Gets the key of the Map.
+ * @return The current key.
+ */
+ public String getKey() {
+ return key;
+ }
+
+
+ // -------------------- EventStep
+
+ /**
+ * Process an object.
+ * This is done by the EventStep Object which is added.
+ *
+ * Current implementation returns only the object which is returned
+ * by the last EventStep in the List.
+ *
+ */
+ public Object processObject(Object object) {
+ if(key==null) {
+ return null;
+ }
+ Map map = (Map)object;
+ object = map.get(key);
+ return processEventSteps(object);
+ }
+}
+
diff --git a/src/com/idcanet/foei/components/steps/lang/package.html b/src/com/idcanet/foei/components/steps/lang/package.html
new file mode 100644
index 0000000..e0601c5
--- /dev/null
+++ b/src/com/idcanet/foei/components/steps/lang/package.html
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+EventSteps which Gets of object from an Object.
+
+Package Specification
+
+
+
+Related Documentation
+
+None.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/idcanet/foei/components/steps/printers/DatePrinter.java b/src/com/idcanet/foei/components/steps/printers/DatePrinter.java
new file mode 100644
index 0000000..f43bb2d
--- /dev/null
+++ b/src/com/idcanet/foei/components/steps/printers/DatePrinter.java
@@ -0,0 +1,88 @@
+/*
+ * 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.components.steps.printers;
+
+import com.idcanet.foei.event.AbstractEventStep;
+
+import java.util.Date;
+import java.text.SimpleDateFormat;
+
+/**
+ * Print an Date
object.
+ *
+ * @author Willem Cazander
+ * @version 1.0 26/01/2005
+ */
+public class DatePrinter extends AbstractEventStep
+{
+ /** v1.0 */
+ static final long serialVersionUID = 10l;
+ /** An SimpleDateFormat formated date format template string */
+ private SimpleDateFormat dateFormat=null;
+
+ /**
+ * Emty constructor
+ */
+ public DatePrinter() {
+ }
+
+ /**
+ * Set the format in which the Date object is printed.
+ * @param pattern An SimpleDateFormat formatted string.
+ */
+ public void setSimpleDateFormat(String pattern) {
+ // else use defaults !!!
+ // TODO log this event ... but don't let is stop it.
+ try {
+ dateFormat = new SimpleDateFormat(pattern);
+ } catch (NullPointerException npe) {
+ dateFormat = new SimpleDateFormat();
+ } catch (IllegalArgumentException iae) {
+ dateFormat = new SimpleDateFormat();
+ }
+ }
+ /**
+ * Returns the SimpleDateFormat formatted string being used to format an Date.
+ * @return The SimpleDateFormat string.
+ */
+ public String getSimpleDateFormat() {
+ return dateFormat.toPattern();
+ }
+
+ /**
+ * Prints an Date object.
+ *
+ * If object is not an Date "" is printed.
+ *
+ * @param object The Object being printed.
+ * @return The String format of the object.
+ */
+ public Object processObject(Object object) {
+ Date date = (Date)object;
+ return dateFormat.format(date);
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/components/steps/printers/DefaultPrinter.java b/src/com/idcanet/foei/components/steps/printers/DefaultPrinter.java
new file mode 100644
index 0000000..7558a2e
--- /dev/null
+++ b/src/com/idcanet/foei/components/steps/printers/DefaultPrinter.java
@@ -0,0 +1,98 @@
+/*
+ * 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.components.steps.printers;
+
+import com.idcanet.foei.event.AbstractEventStep;
+
+/**
+ * Prints the toString of any java object.
+ * With an optioneal pre/post-fix.
+ *
+ * @author Willem Cazander
+ * @version 1.0 17/11/2004
+ */
+public class DefaultPrinter extends AbstractEventStep
+{
+ /** v1.0 */
+ static final long serialVersionUID = 10l;
+ /** The preFix */
+ private String preFix = null;
+ /** The postFix */
+ private String postFix = null;
+
+ /**
+ * Sets the prefix
+ * @param preFix The String printed before the object.
+ */
+ public void setPreFix(String preFix) {
+ this.preFix=preFix;
+ }
+
+ /**
+ * Returns the prefix.
+ * @return The String printed before the object.
+ */
+ public String getPreFix() {
+ return preFix;
+ }
+
+ /**
+ * Sets the postfix.
+ * @param postFix The String printed after the object.
+ */
+ public void setPostFix(String postFix) {
+ this.postFix=postFix;
+ }
+
+ /**
+ * Returns the postfix.
+ * @return The String printed after the object.
+ */
+ public String getPostFix() {
+ return postFix;
+ }
+
+ /**
+ *This methode returns an String represantation of an object
+ *in the default toSting() of the object.
+ *@param object The object which need to be printed.
+ *@return The string represantation of the object.
+ */
+ public Object processObject(Object object) {
+ String returnString = "";
+ if(preFix!=null) {
+ returnString = preFix;
+ }
+ if(object!=null) {
+ returnString += object.toString();
+ }
+ if(postFix!=null) {
+ returnString += postFix;
+ }
+ return returnString;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/components/steps/printers/package.html b/src/com/idcanet/foei/components/steps/printers/package.html
new file mode 100644
index 0000000..c9b2d83
--- /dev/null
+++ b/src/com/idcanet/foei/components/steps/printers/package.html
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+EventSteps which print objects
+
+Package Specification
+
+
+ - Full J2SE 5 compatible
+ - Small package
+
+
+
+Related Documentation
+
+None.
+
+
+
+
+
\ 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
new file mode 100644
index 0000000..ee98e9f
--- /dev/null
+++ b/src/com/idcanet/foei/core/impl/EventExecutorImpl.java
@@ -0,0 +1,126 @@
+/*
+ * 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.impl;
+
+import com.idcanet.foei.core.EventExecutor;
+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 java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Reuable EventExecutors
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 19, 2006
+ */
+public class EventExecutorImpl implements EventExecutor {
+
+ /** The logger to log to. */
+ private Logger logger = null;
+ /** The event obect. */
+ private Object eventObject = null;
+ /** The eventport */
+ private EventPort eventPort = null;
+ /** True when ready */
+ private boolean ready = false;
+
+ /**
+ * Creates an EventExecutor
+ */
+ public EventExecutorImpl() {
+ logger = Logger.getLogger(EventExecutorImpl.class.getName());
+ }
+
+ /**
+ * @see EventExecutor#setEventObject(Object)
+ */
+ public void setEventObject(Object eventObject) {
+ 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.");
+ }
+ this.eventPort=eventPort;
+ ready = false;
+ }
+
+ /**
+ * @see EventExecutor#isReady()
+ */
+ public boolean isReady() {
+ return ready;
+ }
+
+ /**
+ * @see Runnable#run()
+ */
+ public void run() {
+ if(eventPort==null) {
+ logger.warning("Can't execute event on null eventPort.");
+ return;
+ }
+ ready = false;
+ try {
+ FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess();
+ if(eventPort.getEventPortType()==EventPortType.input) {
+ EventInput eventInput = (EventInput)eventPort.getEventObject();
+ eventInput.doEvent(eventPort,eventObject);
+ return;
+ }
+ if(eventPort.getEventPortType()==EventPortType.output) {
+ List bindings = foeiProcess.getBindings(eventPort);
+ for(EventPort port:bindings) {
+ EventInput eventInput = (EventInput)port.getEventObject();
+ if(port.isImmediate()) {
+ logger.finer("Executing event of: "+port.getEventObject()+" port:"+port.getName()+" object: "+eventObject);
+ eventInput.doEvent(port,eventObject);
+ } else {
+ logger.finest("Adding event to event queue");
+ foeiProcess.executeEvent(port,eventObject);
+ }
+ }
+ return;
+ }
+ } catch (Exception e) {
+ logger.log(Level.WARNING,"Error while Executing Event",e);
+ } finally {
+ ready = true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/impl/EventExecutorManagerImpl.java b/src/com/idcanet/foei/core/impl/EventExecutorManagerImpl.java
new file mode 100644
index 0000000..e55dc61
--- /dev/null
+++ b/src/com/idcanet/foei/core/impl/EventExecutorManagerImpl.java
@@ -0,0 +1,201 @@
+/*
+ * 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.impl;
+
+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.FoeiProcess;
+import com.idcanet.foei.core.FoeiProcessFactory;
+import com.idcanet.foei.event.EventPort;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Defines the EventExecutorManager implementation
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 20, 2006
+ */
+public class EventExecutorManagerImpl implements EventExecutorManager {
+
+ /** The logger to log to. */
+ private Logger logger = null;
+ /** The thread pool */
+ private ThreadPoolExecutor threadPoolExecutor = null;
+ /** The EventThreadListeners */
+ private List eventThreadListeners = null;
+ /** The class for the EventExecutor */
+ private Class eventExecutorClass = null;
+ /**
+ * Creates an EventExecutorManagerImpl ans inits the logger.
+ */
+ public EventExecutorManagerImpl() {
+ logger = Logger.getLogger(EventExecutorManagerImpl.class.getName());
+ eventThreadListeners = new ArrayList(1);
+ }
+
+ // ============= 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) {
+ EventExecutor e = null;
+ try {
+ e = (EventExecutor)eventExecutorClass.newInstance();
+ } catch (Exception ee) {
+ logger.log(Level.WARNING,"Error Creating EventExecutor: "+ee.getMessage(),ee);
+ return;
+ }
+ e.setEventObject(eventObject);
+ e.setEventPort(eventPort);
+ if(eventPort.isImmediate()) {
+ e.run();
+ } else {
+ // mmmm
+ execute(e,foeiProcess);
+ }
+ }
+
+ /**
+ * Executes an event.
+ * @see EventExecutorManager#execute(Runnable)
+ */
+ public void execute(Runnable runnable,FoeiProcess foeiProcess) {
+ if(threadPoolExecutor==null) {
+ throw new IllegalStateException("EventExecutorManager has not been started.");
+ }
+ threadPoolExecutor.execute(new FoeiProcessRunnableWrapper(runnable,foeiProcess));
+ }
+
+ /**
+ * 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);
+ }
+
+ EventExecutorThreadFactory tf = new EventExecutorThreadFactory(foeiContext);
+ ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor (
+ FoeiConfiguratorImpl.getEventExecutorPoolCoreSize(foeiContext.getStartProperties()),
+ FoeiConfiguratorImpl.getEventExecutorPoolMaxSize(foeiContext.getStartProperties()),
+ FoeiConfiguratorImpl.getEventExecutorPoolKeepAlive(foeiContext.getStartProperties()),
+ TimeUnit.SECONDS,
+ new LinkedBlockingQueue(),
+ tf
+ );
+ threadPoolExecutor.prestartAllCoreThreads();
+ setThreadPoolExecutor(threadPoolExecutor);
+ }
+
+ /**
+ * Stops the ThreadPool
+ * @see EventExecutorManager#stop()
+ */
+ public void stop(FoeiContext foeiContext) {
+ if(threadPoolExecutor==null) {
+ throw new IllegalStateException("EventExecutorManager has not been started.");
+ }
+ logger.info("Stoping EventExecutorManagerImpl");
+ threadPoolExecutor.shutdown();
+ threadPoolExecutor=null;
+ }
+
+ /**
+ * @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.");
+ }
+ if(threadPoolExecutor!=null) {
+ throw new IllegalStateException("threadPoolExecutor is already started.");
+ }
+ eventThreadListeners.add(eventThreadListener);
+ }
+
+ // ========== other methods:
+
+ /**
+ * Can be used when override from this class.
+ * note:
+ * This method is not an interface method.
+ * @param threadPoolExecutor
+ */
+ public void setThreadPoolExecutor(ThreadPoolExecutor threadPoolExecutor) {
+ if(this.threadPoolExecutor!=null) {
+ throw new IllegalStateException("ThreadPoolExecutor may only be set once");
+ }
+ this.threadPoolExecutor=threadPoolExecutor;
+ }
+
+ /**
+ * Returns the ThreadPoolExecutor
+ */
+ public ThreadPoolExecutor getThreadPoolExecutor() {
+ if(threadPoolExecutor==null) {
+ throw new IllegalStateException("EventExecutorManager has not been started.");
+ }
+ return threadPoolExecutor;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/impl/EventExecutorThreadFactory.java b/src/com/idcanet/foei/core/impl/EventExecutorThreadFactory.java
new file mode 100644
index 0000000..9c250f4
--- /dev/null
+++ b/src/com/idcanet/foei/core/impl/EventExecutorThreadFactory.java
@@ -0,0 +1,91 @@
+/*
+ * 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.impl;
+
+import com.idcanet.foei.core.FoeiContext;
+
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.Logger;
+
+/**
+ * Creates Thread for the threadpool and injects the threadpool runnable object with the
+ * FoeiContext.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Feb 7, 2006
+ */
+public class EventExecutorThreadFactory implements ThreadFactory
+{
+ /** The pool number. */
+ static private final AtomicInteger poolNumber = new AtomicInteger(1);
+ /** The thread group. */
+ private final ThreadGroup group;
+ /** The thread number. */
+ private final AtomicInteger threadNumber = new AtomicInteger(1);
+ /** The name prefix. */
+ private String namePrefix = null;
+ /** The FoeiContext to wrap in the thread. */
+ private FoeiContext foeiContext = null;
+ /** The logger to log to. */
+ private Logger logger = null;
+
+ /**
+ * Creates an EventExecutorThreadFactory
+ * @param foeiContext
+ */
+ public EventExecutorThreadFactory(FoeiContext foeiContext) {
+ if(foeiContext==null) {
+ throw new NullPointerException("FoeiContext may not be null.");
+ }
+ logger = Logger.getLogger(EventExecutorThreadFactory.class.getName());
+ this.foeiContext=foeiContext;
+ SecurityManager s = System.getSecurityManager();
+ group = (s != null)? s.getThreadGroup():Thread.currentThread().getThreadGroup();
+ namePrefix = "foei-"+poolNumber.getAndIncrement()+"-thread-";
+ }
+
+ /**
+ * Creates an new Thread and wrappes the Runnable with the FoeiContextRunnableWrapper
+ */
+ public Thread newThread(Runnable r) {
+ Runnable runnable = new EventThreadListenersRunnableWrapper(r,foeiContext);
+ Thread t = new Thread(group,runnable,namePrefix+threadNumber.getAndIncrement(),0);
+ logger.info("Created new Executor Thread: "+t.getName());
+ if (t.isDaemon()) {
+ t.setDaemon(false);
+ }
+ if (t.getPriority() != Thread.NORM_PRIORITY) {
+ t.setPriority(Thread.NORM_PRIORITY);
+ }
+ return t;
+ }
+}
+
+
+
+
diff --git a/src/com/idcanet/foei/core/impl/EventThreadListenersRunnableWrapper.java b/src/com/idcanet/foei/core/impl/EventThreadListenersRunnableWrapper.java
new file mode 100644
index 0000000..d4b1e65
--- /dev/null
+++ b/src/com/idcanet/foei/core/impl/EventThreadListenersRunnableWrapper.java
@@ -0,0 +1,75 @@
+/*
+ * 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.impl;
+
+import com.idcanet.foei.core.EventThreadListener;
+import com.idcanet.foei.core.FoeiContext;
+
+/**
+ * Call all EventTheadListeners of an FoeiContext
+ *
+ * @author Willem Cazander
+ * @version 1.0 Feb 8, 2006
+ */
+public class EventThreadListenersRunnableWrapper implements Runnable {
+
+ /** The wrapped runnable object. */
+ private Runnable runnable = null;
+ /** The FoeiContext for this thread. */
+ private FoeiContext foeiContext = null;
+
+ /**
+ * creates an EventThreadListenersRunnableWrapper
+ * @param runnable
+ * @param foeiContext
+ */
+ public EventThreadListenersRunnableWrapper(Runnable runnable,FoeiContext foeiContext) {
+ if(runnable==null) {
+ throw new NullPointerException("runnable may not be null.");
+ }
+ if(foeiContext==null) {
+ throw new NullPointerException("FoeiContext may not be null.");
+ }
+ this.runnable=runnable;
+ this.foeiContext=foeiContext;
+ }
+
+ /**
+ * Call all EventThreadListeners
+ */
+ public void run() {
+ for(EventThreadListener eth:foeiContext.getEventExecutorManager().getEventThreadListeners()) {
+ eth.startThread(foeiContext);
+ }
+ // Executer the runnable object we wrapped.
+ // this is the runnable executor of the default thread pool in java 1.5
+ runnable.run();
+ for(EventThreadListener eth:foeiContext.getEventExecutorManager().getEventThreadListeners()) {
+ eth.stopThread(foeiContext);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/impl/FoeiConfiguratorImpl.java b/src/com/idcanet/foei/core/impl/FoeiConfiguratorImpl.java
new file mode 100644
index 0000000..44b4c63
--- /dev/null
+++ b/src/com/idcanet/foei/core/impl/FoeiConfiguratorImpl.java
@@ -0,0 +1,264 @@
+/*
+ * 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.impl;
+
+import com.idcanet.foei.core.EventExecutorManager;
+import com.idcanet.foei.core.EventThreadListener;
+import com.idcanet.foei.core.FoeiConfigurator;
+import com.idcanet.foei.core.FoeiContext;
+import com.idcanet.foei.core.FoeiContextBuildingException;
+import com.idcanet.foei.core.FoeiProcessManager;
+import com.idcanet.foei.core.ObjectBindingsManager;
+import com.idcanet.foei.utils.jndi.MemoryContextFactory;
+
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+
+/**
+ * Creates an default implemention an of FoeiContext.
+ * Which is config with the objects.
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 20, 2006
+ */
+public class FoeiConfiguratorImpl implements FoeiConfigurator {
+
+ static private Logger logger = Logger.getLogger(FoeiConfiguratorImpl.class.getName());
+
+ /**
+ * Creates an FoeiContext
+ */
+ public FoeiContext buildFoeiContext(Map properties) throws FoeiContextBuildingException {
+
+ if(properties==null) {
+ 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);
+ loadEventThreadListeners(properties,eventExecutorManager);
+ } catch (Exception e) {
+ throw new FoeiContextBuildingException("Error while building childs objects:",e);
+ }
+ return new FoeiContextImpl(name,rootPath,objectContext,eventExecutorManager,properties,foeiProcessManager);
+ }
+
+ /**
+ * Gets the contextName from the properties map.
+ * @param properties The properties map.
+ * @return Returns the contextName from the properties map.
+ */
+ static public String getContextName(Map properties) {
+ String contextName = properties.get(FoeiConfigurator.CONTEXT_NAME);
+ if(contextName==null) {
+ throw new NullPointerException("contextName needs to be set in properties as: "+FoeiConfigurator.CONTEXT_NAME);
+ }
+ 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
+ * @return
+ * @throws ClassNotFoundException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ static public ObjectBindingsManager newObjectBindingsManager(Map properties) throws ClassNotFoundException,InstantiationException, IllegalAccessException {
+ String className = properties.get(FoeiConfigurator.OBJECT_BINDINGS_MANAGER);
+ if(className==null) {
+ return new ObjectBindingsManagerImpl();
+ }
+ return (ObjectBindingsManager)Class.forName(className).newInstance();
+ }
+
+ /**
+ *
+ * @param properties
+ * @return
+ * @throws ClassNotFoundException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ * @throws NamingException
+ */
+ static public Context newContext(Map properties) throws ClassNotFoundException,InstantiationException, IllegalAccessException,NamingException {
+ String className = properties.get(FoeiConfigurator.OBJECT_CONTEXT_FACTORY);
+ if(className==null) {
+ return new MemoryContextFactory().getInitialContext(new Hashtable(properties));
+ }
+ return ((InitialContextFactory)Class.forName(className).newInstance()).getInitialContext(new Hashtable(properties));
+ }
+
+ /**
+ *
+ * @param properties
+ * @return
+ * @throws ClassNotFoundException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ static public EventExecutorManager newEventExecutorManager(Map properties) throws ClassNotFoundException,InstantiationException, IllegalAccessException {
+ String className = properties.get(FoeiConfigurator.EVENT_EXECUTOR_MANAGER);
+ if(className==null) {
+ return new EventExecutorManagerImpl();
+ }
+ return (EventExecutorManager)Class.forName(className).newInstance();
+ }
+
+ /**
+ * Loads and adds all the EventThreadListener.
+ * @param properties
+ * @param eventExecutorManager
+ * @throws Exception
+ */
+ static public void loadEventThreadListeners(Map properties,EventExecutorManager eventExecutorManager) throws Exception {
+ String classNames = properties.get(FoeiConfigurator.EVENT_THREAD_LISTENERS);
+ if(classNames==null) {
+ logger.finer("No EventThreadListeners loading");
+ return;
+ }
+ for(String className:classNames.split(",")) {
+ logger.finest("Loading class: "+className);
+ EventThreadListener eventThreadListener = (EventThreadListener)Class.forName(className).newInstance();
+ eventExecutorManager.addEventThreadListener(eventThreadListener);
+ }
+ }
+
+ /**
+ * Gets the Pool Core Size for the EventExecutor
+ * @param properties
+ * @return
+ * @throws NumberFormatException
+ */
+ static public Integer getEventExecutorPoolCoreSize(Map properties) throws NumberFormatException {
+ String size = properties.get(FoeiConfigurator.EVENT_EXECUTOR_POOL_CORE_SIZE);
+ if(size==null) {
+ return 3;
+ }
+ return new Integer(size);
+ }
+
+ /**
+ * Gets the Pool Max Size for the EventExecutor
+ * @param properties
+ * @return
+ * @throws NumberFormatException
+ */
+ static public Integer getEventExecutorPoolMaxSize(Map properties) throws NumberFormatException {
+ String size = properties.get(FoeiConfigurator.EVENT_EXECUTOR_POOL_MAX_SIZE);
+ if(size==null) {
+ return 5;
+ }
+ return new Integer(size);
+ }
+
+ /**
+ * Gets the Pool Keep Alive Time in second for the EventExecutor
+ * @param properties
+ * @return
+ * @throws NumberFormatException
+ */
+ static public Integer getEventExecutorPoolKeepAlive(Map properties) throws NumberFormatException {
+ String size = properties.get(FoeiConfigurator.EVENT_EXECUTOR_POOL_KEEP_ALIVE);
+ if(size==null) {
+ return 180;
+ }
+ return new Integer(size);
+ }
+
+ /**
+ * Creates an new EventExecutor class
+ * @param properties
+ * @return
+ * @throws ClassNotFoundException
+ */
+ static public Class newEventExecutorClass(Map properties) throws ClassNotFoundException {
+ String className = properties.get(FoeiConfigurator.EVENT_EXECUTOR);
+ if(className==null) {
+ return EventExecutorImpl.class;
+ }
+ return Class.forName(className);
+ }
+
+ /**
+ * Gets the X2O root tag
+ * @param properties
+ * @return The X2ORootTag
+ */
+ static public String getX2ORootTag(Map properties) {
+ String rootTag = properties.get(FoeiConfigurator.X2O_ROOT_TAG);
+ if(rootTag==null) {
+ return "foei";
+ }
+ return rootTag;
+ }
+
+ /**
+ *
+ * @param properties
+ * @return
+ * @throws ClassNotFoundException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ static public FoeiProcessManager newFoeiProcessManager(Map properties) throws ClassNotFoundException,InstantiationException, IllegalAccessException {
+ String className = properties.get(FoeiConfigurator.FOEI_PROCESS_MANAGER);
+ if(className==null) {
+ return new FoeiProcessManagerImpl();
+ }
+ return (FoeiProcessManager)Class.forName(className).newInstance();
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/impl/FoeiContextImpl.java b/src/com/idcanet/foei/core/impl/FoeiContextImpl.java
new file mode 100644
index 0000000..bcb25e3
--- /dev/null
+++ b/src/com/idcanet/foei/core/impl/FoeiContextImpl.java
@@ -0,0 +1,149 @@
+/*
+ * 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.impl;
+
+import com.idcanet.foei.core.EventExecutorManager;
+import com.idcanet.foei.core.FoeiContext;
+import com.idcanet.foei.core.FoeiProcessManager;
+
+import java.util.Map;
+import javax.naming.Context;
+
+/**
+ * Defines the FoeiContext implemention.
+ *
+ * @see FoeiContext
+ * @author Willem Cazander
+ * @version 1.0 Jan 19, 2006
+ */
+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;
+
+ /** The EventExecutorManager */
+ private EventExecutorManager eventExecutorManager = null;
+
+ /** The start properties */
+ private Map startProperties = null;
+
+ /** The FoeiProcessManager */
+ private FoeiProcessManager foeiProcessManager = null;
+
+ /**
+ * Creates an new FoeiContextImpl
+ *
+ * @param name
+ * @param rootPath
+ * @param objectBindingsManager
+ * @param objectContext
+ * @param eventExecutorManager
+ * @param startProperties
+ */
+ public FoeiContextImpl(String name,String rootPath,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.");
+ }
+ if(eventExecutorManager==null) {
+ throw new NullPointerException("eventExecutorManager may not be null.");
+ }
+ if(foeiProcessManager==null) {
+ throw new NullPointerException("foeiProcessManager may not be null.");
+ }
+
+ this.name=name;
+ this.rootPath=rootPath;
+ this.objectContext=objectContext;
+ this.eventExecutorManager=eventExecutorManager;
+ this.startProperties=startProperties;
+ this.foeiProcessManager=foeiProcessManager;
+ eventExecutorManager.start(this);
+ }
+
+ /**
+ * @see FoeiContext#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see FoeiContext#getRootPath()
+ */
+ public String getRootPath() {
+ return rootPath;
+ }
+
+ /**
+ * @see FoeiContext#getEventExecutorManager()
+ */
+ public EventExecutorManager getEventExecutorManager() {
+ return eventExecutorManager;
+ }
+
+ /**
+ * @see FoeiContext#getEventObjectContext()
+ */
+ public Context getEventObjectContext() {
+ return objectContext;
+ }
+
+ /**
+ * @see FoeiContext#getStartProperties()
+ */
+ public Map getStartProperties() {
+ return startProperties;
+ }
+
+ /**
+ * @see FoeiContext#destroy()
+ */
+ public void destroy() {
+ getEventExecutorManager().stop(this);
+ }
+
+ /**
+ * Gets the FoeiProcessManager
+ * @return Returns the FoeiProcessManager
+ */
+ public FoeiProcessManager getFoeiProcessManager() {
+ return foeiProcessManager;
+ }
+}
diff --git a/src/com/idcanet/foei/core/impl/FoeiEventBindingRuleHandler.java b/src/com/idcanet/foei/core/impl/FoeiEventBindingRuleHandler.java
new file mode 100644
index 0000000..a6e1194
--- /dev/null
+++ b/src/com/idcanet/foei/core/impl/FoeiEventBindingRuleHandler.java
@@ -0,0 +1,88 @@
+
+
+package com.idcanet.foei.core.impl;
+
+import com.idcanet.foei.event.EventInput;
+import com.idcanet.foei.event.EventOutput;
+import com.idcanet.foei.event.EventStep;
+import com.idcanet.foei.event.EventStepController;
+import com.idcanet.x4o.eld.BindingRuleHandler;
+import com.idcanet.x4o.element.Element;
+
+import java.util.Map;
+
+/**
+ *
+ * MM maybe move this class
+ *
+ * @author Willem Cazander
+ * @version 1.0 Feb 24, 2006
+ */
+public class FoeiEventBindingRuleHandler implements BindingRuleHandler {
+
+ /**
+ *
+ * @param parameters
+ */
+ public void setParameters(Map parameters) {
+
+ }
+
+ /**
+ *
+ * @param object1
+ * @param object2
+ * @return
+ */
+ public boolean canBind(Element element) {
+ Object parent = element.getParent().getElementObject();
+ Object child = element.getElementObject();
+
+ Object object1 = parent;
+ Object object2 = child; // is correct ??
+ if(object1==null) {
+ throw new NullPointerException("object1 may not be null.");
+ }
+ if(object2==null) {
+ throw new NullPointerException("object2 may not be null.");
+ }
+ if(object1 instanceof EventInput) {
+ if(object2 instanceof EventOutput) {
+ return true;
+ }
+ }
+ if(object1 instanceof EventOutput) {
+ if(object2 instanceof EventInput) {
+ return true;
+ }
+ }
+ if(object1 instanceof EventStep) {
+ if(object2 instanceof EventStepController) {
+ return true;
+ }
+ }
+ if(object1 instanceof EventStepController) {
+ if(object2 instanceof EventStep) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * @param object1
+ * @param object2
+ * @throws ClassCastException
+ */
+ public void doBind(Element element) throws Exception {
+ Object parent = element.getParent().getElementObject();
+ Object child = element.getElementObject();
+ if(parent==null) {
+ throw new NullPointerException("object1 may not be null.");
+ }
+ if(child==null) {
+ throw new NullPointerException("object2 may not be null.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/impl/FoeiProcessImpl.java b/src/com/idcanet/foei/core/impl/FoeiProcessImpl.java
new file mode 100644
index 0000000..a92ed4f
--- /dev/null
+++ b/src/com/idcanet/foei/core/impl/FoeiProcessImpl.java
@@ -0,0 +1,187 @@
+/*
+ * 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.impl;
+
+import com.idcanet.foei.core.FoeiContext;
+import com.idcanet.foei.core.FoeiProcess;
+import com.idcanet.foei.core.ObjectBindingsManager;
+import com.idcanet.foei.event.EventPort;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.naming.Context;
+import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+/**
+ * Defines the default FoeiProcess implementation
+ *
+ * @author Willem Cazander
+ * @version 1.0 Mar 2, 2006
+ */
+public class FoeiProcessImpl implements FoeiProcess {
+
+ /** The FoeiContext */
+ private FoeiContext foeiContext = null;
+ /** The Logger */
+ private Logger logger = null;
+ /** The name */
+ private String name = null;
+ /** The eventObjectContext */
+ private Context eventObjectContext = null;
+ /** The ObjectBindingsManager */
+ private ObjectBindingsManager objectBindingsManager = null;
+
+ public FoeiProcessImpl(String name,FoeiContext foeiContext,Context eventObjectContext,ObjectBindingsManager objectBindingsManager) {
+ logger = Logger.getLogger(FoeiProcessImpl.class.getName());
+ this.name=name;
+ this.foeiContext=foeiContext;
+ this.eventObjectContext=eventObjectContext;
+ this.objectBindingsManager=objectBindingsManager;
+ logger.info("Creating FoeiProcess: "+getName());
+ }
+
+ // ========= FoeiProcess
+
+ /**
+ * @see com.idcanet.foei.core.FoeiProcess#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @see com.idcanet.foei.core.FoeiProcess#getEventObjectContext()
+ */
+ public Context getEventObjectContext() {
+ return eventObjectContext;
+ }
+
+ /**
+ * @see com.idcanet.foei.core.FoeiProcess#getObjectBindingsManager()
+ */
+ public ObjectBindingsManager getObjectBindingsManager() {
+ return objectBindingsManager;
+ }
+
+ /**
+ * @see com.idcanet.foei.core.FoeiProcess#destroy()
+ */
+ public void destroy() {
+ logger.info("Destroying FoeiProcess: "+getName());
+ }
+
+ /**
+ * @see com.idcanet.foei.core.FoeiProcess#getFoeiContext()
+ */
+ public FoeiContext getFoeiContext() {
+ return foeiContext;
+ }
+
+ // ================== EventPortExecutor
+
+ /**
+ * @see com.idcanet.foei.core.EventPortExecutor#executeEvent(com.idcanet.foei.event.EventPort, java.lang.Object)
+ */
+ public void executeEvent(EventPort eventPort, Object eventObject) {
+ getFoeiContext().getEventExecutorManager().executeEvent(eventPort,eventObject);
+ }
+
+ // ============= ObjectContextManager
+
+ /**
+ * @see com.idcanet.foei.core.ObjectContextManager#addEventObject(com.idcanet.foei.event.EventObject)
+ */
+ public void addEventObject(Object eventObject,String id) {
+ try {
+ getEventObjectContext().bind(id,eventObject);
+ } catch (NameAlreadyBoundException nabe) {
+ logger.log(Level.WARNING,"NameAlreadyBoundException: "+nabe.getMessage(),nabe);
+ } catch (NamingException ne) {
+ logger.log(Level.WARNING,"NamingException: "+ne.getMessage(),ne);
+ }
+ }
+
+ /**
+ * @see com.idcanet.foei.core.ObjectContextManager#getEventObject(java.lang.String)
+ */
+ public Object getEventObject(String id) {
+ try {
+ return getEventObjectContext().lookup(id);
+ } catch (NamingException ne) {
+ logger.log(Level.WARNING,"NamingException: "+ne.getMessage(),ne);
+ }
+ return null;
+ }
+
+ /**
+ * @see com.idcanet.foei.core.ObjectContextManager#removeEventObject(com.idcanet.foei.event.EventObject)
+ */
+ public void removeEventObject(String id) {
+ try {
+ getEventObjectContext().unbind(id);
+ } catch (NameNotFoundException nnfe) {
+ logger.log(Level.WARNING,"NamingNotFoundException: "+nnfe.getMessage(),nnfe);
+ } catch (NamingException ne) {
+ logger.log(Level.WARNING,"NamingException: "+ne.getMessage(),ne);
+ }
+ }
+
+
+ // ============ ObjectBindingsManager
+
+ /**
+ * @see com.idcanet.foei.core.ObjectBindingsManager#addBinding(com.idcanet.foei.event.EventPort, com.idcanet.foei.event.EventPort)
+ */
+ public void addBinding(EventPort outputPort, EventPort inputPort) {
+ getObjectBindingsManager().addBinding(outputPort,inputPort);
+ }
+
+ /**
+ * @see com.idcanet.foei.core.ObjectBindingsManager#getBindings(com.idcanet.foei.event.EventPort)
+ */
+ public List getBindings(EventPort eventPort) {
+ return getObjectBindingsManager().getBindings(eventPort);
+ }
+
+ /**
+ * @see com.idcanet.foei.core.ObjectBindingsManager#getBindingsAsXML()
+ */
+ public String getBindingsAsXML() {
+ return getObjectBindingsManager().getBindingsAsXML();
+ }
+
+ /**
+ * @see com.idcanet.foei.core.ObjectBindingsManager#removeBinding(com.idcanet.foei.event.EventPort, com.idcanet.foei.event.EventPort)
+ */
+ public void removeBinding(EventPort inputPort, EventPort outputPort) {
+ getObjectBindingsManager().removeBinding(inputPort,outputPort);
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/impl/FoeiProcessManagerImpl.java b/src/com/idcanet/foei/core/impl/FoeiProcessManagerImpl.java
new file mode 100644
index 0000000..1c5bc89
--- /dev/null
+++ b/src/com/idcanet/foei/core/impl/FoeiProcessManagerImpl.java
@@ -0,0 +1,125 @@
+/*
+ * 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.impl;
+
+import com.idcanet.foei.core.FoeiContext;
+import com.idcanet.foei.core.FoeiProcess;
+import com.idcanet.foei.core.FoeiProcessManager;
+import com.idcanet.foei.core.ObjectBindingsManager;
+
+import java.util.Collection;
+import java.util.HashMap;
+
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.naming.Context;
+
+/**
+ * Defines the default FoeiProcessManager implementation
+ *
+ * @author Willem Cazander
+ * @version 1.0 Mar 2, 2006
+ */
+public class FoeiProcessManagerImpl implements FoeiProcessManager {
+
+ /** Stores all foeiProcesses */
+ private Map foeiProcesses = null;
+ /** The logger to log to. */
+ private Logger logger = null;
+
+ /**
+ * Creates an FoeiProcessManagerImpl
+ */
+ public FoeiProcessManagerImpl() {
+ logger = Logger.getLogger(FoeiProcessManagerImpl.class.getName());
+ foeiProcesses = new HashMap(5);
+ }
+
+ /**
+ * @see com.idcanet.foei.core.FoeiProcessManager#createFoeiProcess(java.lang.String, FoeiContext)
+ */
+ public FoeiProcess createFoeiProcess(String name,FoeiContext foeiContext) {
+ if(name==null) {
+ throw new NullPointerException("name may not be null.");
+ }
+ if(foeiContext==null) {
+ throw new NullPointerException("foeiContext may not be null.");
+ }
+ try {
+ Context c = foeiContext.getEventObjectContext().createSubcontext(name);
+ ObjectBindingsManager objectBindingsManager = FoeiConfiguratorImpl.newObjectBindingsManager(foeiContext.getStartProperties());
+ FoeiProcess fp = new FoeiProcessImpl(name,foeiContext,c,objectBindingsManager);
+ synchronized (foeiProcesses) {
+ foeiProcesses.put(fp.getName(),fp);
+ }
+ logger.finer("FoeiProcess created and added total processes: "+foeiProcesses.size());
+ return fp;
+ } catch (Exception e) {
+ logger.log(Level.WARNING,"Error whiile creating FoeiProcess: "+e.getMessage(),e);
+ return null;
+ }
+ }
+
+ /**
+ * @see com.idcanet.foei.core.FoeiProcessManager#destroyFoeiProcess(java.lang.String)
+ */
+ public void destroyFoeiProcess(String name) {
+ FoeiProcess p = getFoeiProcess(name);
+ if(p==null) {
+ throw new NullPointerException("No FoeiProcess found with id: "+name);
+ }
+ p.destroy();
+ synchronized (foeiProcesses) {
+ foeiProcesses.remove(p.getName());
+ }
+ logger.finer("FoeiProcess destroyed total processes: "+foeiProcesses.size());
+ try {
+ p.getFoeiContext().getEventObjectContext().destroySubcontext(p.getName());
+ } catch (Exception e) {
+ logger.log(Level.WARNING,"Error while removing process context from foei context; "+e.getMessage(),e);
+ }
+ }
+
+ /**
+ * @see com.idcanet.foei.core.FoeiProcessManager#getFoeiProcess(java.lang.String)
+ */
+ public FoeiProcess getFoeiProcess(String name) {
+ if(name==null) {
+ throw new NullPointerException("name may not be null.");
+ }
+ return foeiProcesses.get(name);
+ }
+
+ /**
+ * @see com.idcanet.foei.core.FoeiProcessManager#getFoeiProcesses()
+ */
+ public Collection getFoeiProcesses() {
+ return foeiProcesses.values();
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/impl/FoeiProcessRunnableWrapper.java b/src/com/idcanet/foei/core/impl/FoeiProcessRunnableWrapper.java
new file mode 100644
index 0000000..cb88570
--- /dev/null
+++ b/src/com/idcanet/foei/core/impl/FoeiProcessRunnableWrapper.java
@@ -0,0 +1,70 @@
+/*
+ * 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.impl;
+
+import com.idcanet.foei.core.FoeiProcess;
+import com.idcanet.foei.core.FoeiProcessFactory;
+
+/**
+ * Wraps an Runnable object so it binds the FoeiProcess before running
+ * and unbinds it also.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Mar 3, 2006
+ */
+public class FoeiProcessRunnableWrapper implements Runnable {
+
+ /** The wrapped runnable object. */
+ private Runnable runnable = null;
+ /** The FoeiProcess for this Runnable. */
+ private FoeiProcess foeiProcess = null;
+
+ /**
+ * creates an FoeiProcessRunnableWrapper
+ * @param runnable
+ * @param foeiProcess
+ */
+ public FoeiProcessRunnableWrapper(Runnable runnable,FoeiProcess foeiProcess) {
+ if(runnable==null) {
+ throw new NullPointerException("runnable may not be null.");
+ }
+ if(foeiProcess==null) {
+ throw new NullPointerException("FoeiProcess may not be null.");
+ }
+ this.runnable=runnable;
+ this.foeiProcess=foeiProcess;
+ }
+
+ /**
+ * Binds and unbinds the FoeiProcess and call the runnalbe run method.
+ */
+ public void run() {
+ FoeiProcessFactory.bindFoeiProcess(foeiProcess);
+ runnable.run();
+ FoeiProcessFactory.unbindFoeiProcess();
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/impl/ObjectBindingsManagerImpl.java b/src/com/idcanet/foei/core/impl/ObjectBindingsManagerImpl.java
new file mode 100644
index 0000000..e6e09dc
--- /dev/null
+++ b/src/com/idcanet/foei/core/impl/ObjectBindingsManagerImpl.java
@@ -0,0 +1,179 @@
+/*
+ * 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.impl;
+
+import com.idcanet.foei.core.ObjectBindingsManager;
+import com.idcanet.foei.event.EventPort;
+import com.idcanet.foei.event.EventPortType;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+/**
+ * Defines the ObjectBindingsManager implamentation.
+ *
+ * @author Willem Cazander
+ * @version 1.0 20/04/2005
+ */
+public class ObjectBindingsManagerImpl implements ObjectBindingsManager
+{
+ /** */
+ private Map> bindingsOutput = null;
+ /** Works like: eventPort(input) -> List (EventPorts(output) */
+ private Map> bindingsInput = null;
+ /** The logger to log to. */
+ private Logger logger = null;
+
+ /**
+ * Creates the defaults implementation of the ObjectBindingsManager.
+ * inits the logger and de input and output Map mappings.
+ */
+ public ObjectBindingsManagerImpl() {
+ logger = Logger.getLogger(ObjectBindingsManagerImpl.class.getName());
+ bindingsOutput = new HashMap>(50);
+ bindingsInput = new HashMap>(50);
+ logger.finer("BindingsManager Created");
+ }
+
+ /**
+ *
+ * @see ObjectBindingsManager#addBinding(EventPort, EventPort)
+ */
+ public void addBinding(EventPort outputPort,EventPort inputPort) {
+ if(inputPort==null) {
+ throw new NullPointerException("inputPort may not be null.");
+ }
+ if(inputPort.getEventPortType()!=EventPortType.input) {
+ throw new IllegalArgumentException("inputPort needs to be input type.");
+ }
+ if(outputPort==null) {
+ throw new NullPointerException("outputPort may not be null.");
+ }
+ if(outputPort.getEventPortType()!=EventPortType.output) {
+ throw new IllegalArgumentException("inputPort needs to be ouput type.");
+ }
+
+ List inputPorts = bindingsInput.get(inputPort);
+ List outputPorts = bindingsOutput.get(outputPort);
+ if(inputPorts==null) {
+ inputPorts = new ArrayList(5);
+ bindingsInput.put(inputPort,inputPorts);
+ }
+ if(outputPorts==null) {
+ outputPorts = new ArrayList(5);
+ bindingsOutput.put(outputPort,outputPorts);
+ }
+
+ // disables to bind twice
+ if(inputPorts.contains(outputPort) || outputPorts.contains(inputPort) ) {
+ throw new IllegalArgumentException("inputPort is already bind to outputPort");
+ }
+ inputPorts.add(outputPort);
+ outputPorts.add(inputPort);
+ logger.fine("Bind completed: "+inputPort.getEventObject()+":"+inputPort.getName()+" to "+outputPort.getEventObject()+":"+outputPort.getName());
+ }
+
+ /**
+ *
+ * @see ObjectBindingsManager#removeBinding(EventPort, EventPort)
+ */
+ public void removeBinding(EventPort inputPort,EventPort outputPort) {
+ if(inputPort==null) {
+ throw new NullPointerException("inputPort may not be null.");
+ }
+ if(inputPort.getEventPortType()!=EventPortType.input) {
+ throw new IllegalArgumentException("inputPort needs to be input type.");
+ }
+ if(outputPort==null) {
+ throw new NullPointerException("outputPort may not be null.");
+ }
+ if(outputPort.getEventPortType()!=EventPortType.output) {
+ throw new IllegalArgumentException("inputPort needs to be ouput type.");
+ }
+
+ List inputPorts = bindingsInput.get(inputPort);
+ List outputPorts = bindingsOutput.get(outputPort);
+
+ if(inputPorts==null || outputPorts==null) {
+ throw new IllegalArgumentException("Can not remove not binded ports.");
+ }
+
+ inputPorts.remove(outputPort);
+ outputPorts.remove(inputPort);
+
+ if(inputPorts.isEmpty()) {
+ bindingsInput.remove(inputPort);
+ }
+ if(outputPorts.isEmpty()) {
+ bindingsOutput.remove(outputPort);
+ }
+ logger.fine("Bind removed: "+inputPort.getEventObject()+":"+inputPort.getName()+" to "+outputPort.getEventObject()+":"+outputPort.getName());
+ }
+
+ /**
+ * Gets the bindings of an EventPort
+ * @param eventPort The EventPort to retreive the bindings.
+ * @return Returns an List of the binded EventPorts
+ */
+ public List getBindings(EventPort eventPort) {
+ if(eventPort==null) {
+ throw new NullPointerException("eventPort may not be null.");
+ }
+ List result = new ArrayList(0);
+ List inputPorts = bindingsInput.get(eventPort);
+ List outputPorts = bindingsOutput.get(eventPort);
+ if(inputPorts!=null) {
+ result.addAll(inputPorts);
+ }
+ if(outputPorts!=null) {
+ result.addAll(outputPorts);
+ }
+ return result;
+ }
+
+ /**
+ * Returns the dotty xml bindings
+ */
+ public String getBindingsAsXML() {
+ StringBuffer result = new StringBuffer();
+ result.append("\n");
+ result.append("\n");
+ for(EventPort port:bindingsOutput.keySet()) {
+ for(EventPort b:getBindings(port)) {
+ result.append("\n");
+
+ }
+ }
+ result.append("");
+ return result.toString();
+ }
+}
diff --git a/src/com/idcanet/foei/core/impl/X2OExecutorImpl.java b/src/com/idcanet/foei/core/impl/X2OExecutorImpl.java
new file mode 100644
index 0000000..b205c05
--- /dev/null
+++ b/src/com/idcanet/foei/core/impl/X2OExecutorImpl.java
@@ -0,0 +1,150 @@
+/*
+ * 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.impl;
+
+import com.idcanet.foei.core.FoeiProcess;
+import com.idcanet.foei.core.FoeiProcessFactory;
+import com.idcanet.foei.core.X2OExecutor;
+import com.idcanet.x4o.core.X4OParser;
+
+import java.io.InputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * The default X2OExecutor implemention
+ *
+ * @author Willem Cazander
+ * @version 1.0 Feb 24, 2006
+ *
+ */
+public class X2OExecutorImpl implements X2OExecutor {
+
+ private String parseFileName = null;
+ private InputStream parseInputStream = null;
+ private String parseXml = null;
+ private boolean debug = false;
+ private boolean ready = false;
+ private Logger logger = null;
+
+ /**
+ * Constructs an X2OExecutorImpl
+ */
+ public X2OExecutorImpl() {
+ logger = Logger.getLogger(X2OExecutorImpl.class.getName());
+ }
+
+
+ /**
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ try {
+
+ // config parser
+ FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess();
+ X4OParser parser = new X4OParser(FoeiConfiguratorImpl.getX2ORootTag(foeiProcess.getFoeiContext().getStartProperties()),"foei");
+ parser.setDebug(debug);
+ parser.getParsingContext().getProperties().putAll(foeiProcess.getFoeiContext().getStartProperties());
+
+ logger.info("Executing X2O Parsing.");
+
+ if(parseFileName!=null) {
+ try {
+ logger.finer("Parsing File: "+parseFileName);
+ parser.parseFile(parseFileName);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE,"Error while loading config file:"+e.getMessage(),e);
+ }
+ }
+
+ if(parseInputStream!=null) {
+ try {
+ logger.finer("Parsing InputStream");
+ parser.parse(parseInputStream);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE,"Error while loading inputStream:"+e.getMessage(),e);
+ }
+ }
+
+ if(parseXml!=null) {
+ try {
+ logger.finer("Parsing XML");
+ parser.parseXml(parseXml);
+ } catch (Exception e) {
+ logger.log(Level.SEVERE,"Error while loading xml:"+e.getMessage(),e);
+ }
+ }
+ } catch (Throwable t) {
+ logger.log(Level.WARNING,"Error in X2O thread: "+t.getMessage(),t);
+ } finally {
+ ready = true;
+ }
+ }
+
+ /**
+ * @see com.idcanet.foei.core.X2OExecutor#isReady()
+ */
+ public boolean isReady() {
+ return ready;
+ }
+
+ /**
+ * @see com.idcanet.foei.core.X2OExecutor#getDebug()
+ */
+ public boolean getDebug() {
+ return debug;
+ }
+
+ /**
+ * @see com.idcanet.foei.core.X2OExecutor#setDebug(boolean)
+ */
+ public void setDebug(boolean debug) {
+ this.debug=debug;
+ }
+
+ /**
+ * @see com.idcanet.foei.core.X2OExecutor#setFileName(java.lang.String)
+ */
+ public void setFileName(String fileName) {
+ parseFileName=fileName;
+ }
+
+ /**
+ * @see com.idcanet.foei.core.X2OExecutor#setInputStream(java.io.InputStream)
+ */
+ public void setInputStream(InputStream inputStream) {
+ parseInputStream=inputStream;
+ }
+
+ /**
+ * @see com.idcanet.foei.core.X2OExecutor#setXml(java.lang.String)
+ */
+ public void setXml(String xml) {
+ parseXml=xml;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/impl/package.html b/src/com/idcanet/foei/core/impl/package.html
new file mode 100644
index 0000000..fed3fbf
--- /dev/null
+++ b/src/com/idcanet/foei/core/impl/package.html
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+Defines the Foei Event Core Implemention.
+
+Some classes are build to be used for overriding classes so
+they have method to make live easer.
+
+
+
+Related Documentation
+
+None.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/x4o/BindAttributeHandler.java b/src/com/idcanet/foei/core/x4o/BindAttributeHandler.java
new file mode 100644
index 0000000..53593bc
--- /dev/null
+++ b/src/com/idcanet/foei/core/x4o/BindAttributeHandler.java
@@ -0,0 +1,94 @@
+/*
+ * 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.x4o;
+
+import com.idcanet.foei.core.FoeiProcess;
+import com.idcanet.foei.core.FoeiProcessFactory;
+import com.idcanet.foei.event.EventInput;
+import com.idcanet.foei.event.EventOutput;
+import com.idcanet.foei.event.EventPort;
+import com.idcanet.x4o.eld.GlobalParameterHandler;
+import com.idcanet.x4o.element.Element;
+import com.idcanet.x4o.element.ElementException;
+
+/**
+ * Handlers the "bind" attribute
+ *
+ * @author Willem Cazander
+ * @version 1.0 Apr 15, 2006
+ */
+public class BindAttributeHandler implements GlobalParameterHandler {
+
+ private String parameterName =null;
+
+ /**
+ * @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doParameter(java.lang.Object, java.lang.String)
+ */
+ public void doParameter(Element element,String parameterValue) {
+ String[] port = parameterValue.split(":");
+ if(port.length!=2) {
+ return;
+ }
+ try {
+
+ EventInput in = (EventInput)element.getElementObject();
+ if(in==null) {
+ throw new ElementException("Could not find EventObject from inputID");
+ }
+ EventOutput out = (EventOutput)element.getParent().getElementObject();
+ if(out==null) {
+ throw new ElementException("Could not find EventObject from outputID");
+ }
+ EventPort inputEventPort = in.getInputPort(port[1]);
+ EventPort outputEventPort = out.getOutputPort(port[0]);
+
+ FoeiProcess foei = FoeiProcessFactory.getFoeiProcess();
+
+ if(inputEventPort==null) {
+ throw new ElementException("Could not find EventPort from inputPort");
+ }
+ if(outputEventPort==null) {
+ throw new ElementException("Could not find EventPort from outputPort");
+ }
+ foei.addBinding(outputEventPort,inputEventPort);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#getParameterName()
+ */
+ public String getParameterName() {
+ return parameterName;
+ }
+
+ public void setParameterName(String parameterName) {
+ this.parameterName=parameterName;
+ }
+}
diff --git a/src/com/idcanet/foei/core/x4o/EventStepBindRuleHandler.java b/src/com/idcanet/foei/core/x4o/EventStepBindRuleHandler.java
new file mode 100644
index 0000000..4b4ef52
--- /dev/null
+++ b/src/com/idcanet/foei/core/x4o/EventStepBindRuleHandler.java
@@ -0,0 +1,76 @@
+/*
+ * 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.x4o;
+
+import com.idcanet.foei.event.EventStep;
+import com.idcanet.foei.event.EventStepController;
+import com.idcanet.x4o.eld.BindingRuleHandler;
+import com.idcanet.x4o.element.Element;
+
+import java.util.Map;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Apr 16, 2006
+ */
+public class EventStepBindRuleHandler implements BindingRuleHandler {
+
+ private Map parameters = null;
+
+ /**
+ * @see com.idca.foei.xml.x2o.eld.BindingRuleHandler#canBind(java.lang.Object, java.lang.Object)
+ */
+ public boolean canBind(Element element) {
+ Object parent = element.getParent().getElementObject();
+ Object child = element.getElementObject();
+ if(!(parent instanceof EventStepController)) {
+ return false;
+ }
+ if(!(child instanceof EventStep)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @see com.idca.foei.xml.x2o.eld.BindingRuleHandler#doBind(java.lang.Object, java.lang.Object)
+ */
+ public void doBind(Element element) throws Exception {
+ Object parent = element.getParent().getElementObject();
+ Object child = element.getElementObject();
+ ((EventStepController)parent).addEventStep((EventStep)child);
+ }
+
+ /**
+ * @see com.idca.foei.xml.x2o.eld.BindingRuleHandler#setParameters(java.util.Map)
+ */
+ public void setParameters(Map parameters) {
+ this.parameters=parameters;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/x4o/IdAttributeHandler.java b/src/com/idcanet/foei/core/x4o/IdAttributeHandler.java
new file mode 100644
index 0000000..4442cf6
--- /dev/null
+++ b/src/com/idcanet/foei/core/x4o/IdAttributeHandler.java
@@ -0,0 +1,67 @@
+/*
+ * 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.x4o;
+
+import com.idcanet.foei.core.FoeiProcess;
+import com.idcanet.foei.core.FoeiProcessFactory;
+import com.idcanet.x4o.eld.GlobalParameterHandler;
+import com.idcanet.x4o.element.Element;
+
+/**
+ * Handles the id
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jul 8, 2006
+ */
+public class IdAttributeHandler implements GlobalParameterHandler {
+
+ private String parameterName =null;
+
+ /**
+ * @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doParameter(java.lang.Object, java.lang.String)
+ */
+ public void doParameter(Element element,String parameterValue) {
+ // add to objext context
+ if(element.getElementObject()==null | "".equals(parameterValue)) {
+ parameterValue= "auto."+Integer.toHexString(element.getElementObject().hashCode());
+ //logger.finest("Generated auto id: "+parameterValue);
+ }
+ FoeiProcess process = FoeiProcessFactory.getFoeiProcess();
+ process.addEventObject(element.getElementObject(),parameterValue);
+ }
+
+ /**
+ * @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#getParameterName()
+ */
+ public String getParameterName() {
+ return parameterName;
+ }
+
+ public void setParameterName(String parameterName) {
+ this.parameterName=parameterName;
+ }
+}
diff --git a/src/com/idcanet/foei/core/x4o/ObjectBindingElement.java b/src/com/idcanet/foei/core/x4o/ObjectBindingElement.java
new file mode 100644
index 0000000..f34757b
--- /dev/null
+++ b/src/com/idcanet/foei/core/x4o/ObjectBindingElement.java
@@ -0,0 +1,150 @@
+/*
+ * 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.x4o;
+
+import com.idcanet.foei.core.FoeiProcess;
+import com.idcanet.foei.core.FoeiProcessFactory;
+import com.idcanet.foei.event.EventInput;
+import com.idcanet.foei.event.EventOutput;
+import com.idcanet.foei.event.EventPort;
+import com.idcanet.x4o.element.AbstractElement;
+import com.idcanet.x4o.element.ElementException;
+
+import org.xml.sax.Attributes;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Mar 2, 2006
+ */
+public class ObjectBindingElement extends AbstractElement {
+
+ /** The Object which is configed */
+ //private Object parentObject = null;
+ //private Object childObject = null;
+
+ private String outputID = null;
+ private String outputPort = null;
+ private String inputID = null;
+ private String inputPort = null;
+
+ /**
+ * Do the element
+ */
+ public void doElementStart(Attributes attributes) throws ElementException {
+
+ outputID = attributes.getValue("outputID");
+ outputPort = attributes.getValue("outputPort");
+ inputID = attributes.getValue("inputID");
+ inputPort = attributes.getValue("inputPort");
+
+ FoeiProcess foei = FoeiProcessFactory.getFoeiProcess();
+
+ Object in = foei.getEventObject(inputID);
+ if(in==null) {
+ throw new ElementException("Could not find EventObject from inputID");
+ }
+ Object out = foei.getEventObject(outputID);
+ if(out==null) {
+ throw new ElementException("Could not find EventObject from outputID");
+ }
+ EventPort inputEventPort = ((EventInput)in).getInputPort(inputPort);
+ EventPort outputEventPort = ((EventOutput)out).getOutputPort(outputPort);
+ if(inputEventPort==null) {
+ throw new ElementException("Could not find EventPort from inputPort");
+ }
+ if(outputEventPort==null) {
+ throw new ElementException("Could not find EventPort from outputPort");
+ }
+ foei.addBinding(outputEventPort,inputEventPort);
+
+
+ /*
+ if(outputID==null) {
+ //outputID = foei.getObjectConfigurator().getParameter(parentObject,"id").toString();
+ }
+ if(outputPort==null) {
+ if(parentObject instanceof EventOutput) {
+ EventOutput eventOutput = (EventOutput)parentObject;
+ if(eventOutput.getOutputPorts().size()>0) {
+ EventPort port = (EventPort)eventOutput.getOutputPorts().get(0);
+ outputPort = port.getName();
+ } else {
+ // no output ports
+ throw new ElementException("parentObject(EventOutput) is no output ports defined");
+ }
+ } else {
+ // np EventOutput ..
+ throw new ElementException("parentObject: "+parentObject+" is not an EventOutput");
+ }
+ }
+ */
+ }
+
+ // HACK routines
+ /*
+ public String getOutputID() {
+ return outputID;
+ }
+ public String getOutputPort() {
+ return outputPort;
+ }
+ */
+
+ public void doElementEnd() {
+ /*
+ FoeiProcess foei = FoeiProcessFactory.getFoeiProcess();
+ if(inputID!=null & inputPort!=null & outputID!=null & outputPort!=null) {
+ // Add binding
+ foei.addBinding()
+ foeiInstance.getObjectBindingsManager().addBinding(outputID,outputPort,inputID,inputPort);
+ } else {
+ System.err.println("Coudn't addbinding: inID="+inputID+" inPort="+inputPort+" outID="+outputID+" outPort="+outputPort);
+ }
+ */
+ }
+
+
+ //------------------ ElementObject
+
+ /**
+ * Get the object this elements configs.
+ * @return The object this Element controlles
+ */
+ /*
+ public Object getElementObject() {
+ return parentObject;
+ //return object;
+ }
+
+ public void setElementObject(Object object) {
+ // TODO: this is an quich hack see FoeiTagHandler
+ //this.object=object;
+ }
+ */
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/x4o/SetParameterElement.java b/src/com/idcanet/foei/core/x4o/SetParameterElement.java
new file mode 100644
index 0000000..c9d976c
--- /dev/null
+++ b/src/com/idcanet/foei/core/x4o/SetParameterElement.java
@@ -0,0 +1,88 @@
+/*
+ * 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.x4o;
+
+
+import org.xml.sax.Attributes;
+
+import com.idcanet.x4o.element.AbstractElement;
+import com.idcanet.x4o.element.ElementException;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Mar 2, 2006
+ */
+public class SetParameterElement extends AbstractElement {
+ /** The Object which is configed */
+ private Object object = null;
+
+ private Object eventObject = null;
+ private String parameterName = null;
+ private Object parameterValue = null;
+
+ public SetParameterElement() {
+ }
+
+ /**
+ * Do the element
+ */
+ public void doElementStart(Attributes attributes) throws ElementException
+ {
+ // the EventObject for the parent element is also this its elementObject.
+ Object o = getParent().getElementObject();
+ /*
+ if(!(o instanceof EventObject)) {
+ throw new ElementException("parent ElementObject is not EventObject");
+ }
+ eventObject = (EventObject)o;
+ */
+ parameterName = attributes.getValue("name");
+ parameterValue = attributes.getValue("value");
+ }
+
+ public void doElementEnd()
+ {
+
+ }
+
+
+ //------------------ ElementObject
+
+ /**
+ * Get the object this elements configs.
+ * @return The object this Element controlles
+ */
+ public Object getElementObject() {
+ return object;
+ }
+
+ public void setElementObject(Object object) {
+ this.object=object;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/core/x4o/package.html b/src/com/idcanet/foei/core/x4o/package.html
new file mode 100644
index 0000000..0117f6e
--- /dev/null
+++ b/src/com/idcanet/foei/core/x4o/package.html
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+Special Element object for foei xml.
+
+
+
+Related Documentation
+
+None.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/idcanet/foei/event/annotations/SetEventPort.java b/src/com/idcanet/foei/event/annotations/SetEventPort.java
new file mode 100644
index 0000000..b352b42
--- /dev/null
+++ b/src/com/idcanet/foei/event/annotations/SetEventPort.java
@@ -0,0 +1,70 @@
+/*
+ * 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.event.annotations;
+
+import com.idcanet.foei.event.EventPortType;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Defines an input EventPort
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 20, 2006
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface SetEventPort {
+
+ /**
+ *
+ * @return
+ */
+ EventPortType type();
+
+ /**
+ * Gets the name of the input EventPort
+ * @return Returns the name of the input EventPort
+ */
+ String name();
+
+ /**
+ * Gets the objectType of the input EventPort
+ * it defaults to Object.class but is lookuped in the annotated method.
+ * @return Returns the objectType of the input EventPort
+ */
+ Class objectType() default Object.class;
+
+ /**
+ *
+ * @return
+ */
+ String immediate() default "null";
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/event/annotations/SetEventPorts.java b/src/com/idcanet/foei/event/annotations/SetEventPorts.java
new file mode 100644
index 0000000..8fcc109
--- /dev/null
+++ b/src/com/idcanet/foei/event/annotations/SetEventPorts.java
@@ -0,0 +1,49 @@
+/*
+ * 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.event.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Defines an output EventPort
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 20, 2006
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface SetEventPorts {
+
+ /**
+ * An array of SetEventPort annotations
+ * @return Returns an array of SetEventPort annotations
+ */
+ SetEventPort[] ports();
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/server/config/FoeiConfigContext.java b/src/com/idcanet/foei/server/config/FoeiConfigContext.java
new file mode 100644
index 0000000..03de6a9
--- /dev/null
+++ b/src/com/idcanet/foei/server/config/FoeiConfigContext.java
@@ -0,0 +1,37 @@
+/*
+ * 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.server.config;
+
+import java.util.Map;
+
+public class FoeiConfigContext {
+
+ private String name = null;
+ private Map properties = null;
+ private Map processes = null;
+
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/server/config/FoeiConfigParser.java b/src/com/idcanet/foei/server/config/FoeiConfigParser.java
new file mode 100644
index 0000000..bd0352b
--- /dev/null
+++ b/src/com/idcanet/foei/server/config/FoeiConfigParser.java
@@ -0,0 +1,70 @@
+/*
+ * 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.server.config;
+
+import com.idca.foei.xml.AbstractXMLParser;
+import com.idca.foei.xml.XMLDebugTagHandler;
+import com.idca.foei.xml.XMLHandler;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.SAXException;
+
+/**
+ * Parses the foei-config.xml file
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jun 23, 2006
+ */
+public class FoeiConfigParser extends AbstractXMLParser {
+
+ /**
+ * Parsesn the input stream as a X2O document
+ */
+ public void parse(InputStream inputStream) throws ParserConfigurationException,SAXException,IOException {
+ XMLHandler handler = new XMLHandler();
+ if(isDebug()) {
+ handler.addXMLTagHandler(new XMLDebugTagHandler("DEBUG"));
+ }
+ /*
+ X2OTagHandler xth = new X2OTagHandler(rootTag,parsingContext);
+ xth.setDebug(debug);
+ handler.addXMLTagHandler(xth);
+ */
+
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ SAXParser saxParser = factory.newSAXParser();
+ saxParser.parse(inputStream,handler);
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/server/config/FoeiContextXMLTagHandler.java b/src/com/idcanet/foei/server/config/FoeiContextXMLTagHandler.java
new file mode 100644
index 0000000..7d9398c
--- /dev/null
+++ b/src/com/idcanet/foei/server/config/FoeiContextXMLTagHandler.java
@@ -0,0 +1,65 @@
+/*
+ * 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.server.config;
+
+import com.idca.foei.xml.AbstractXMLTagHandler;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ *
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jun 23, 2006
+ */
+public class FoeiContextXMLTagHandler extends AbstractXMLTagHandler {
+
+
+ @Override
+ public void startElement(String nameSpace,String tag,String qName,Attributes attributes) throws SAXException {
+
+ }
+
+ @Override
+ public void endElement(String nameSpace,String tag,String qName) throws SAXException {
+
+ }
+
+ /**
+ * @see AbstractXMLTagHandler#characters(String)
+ */
+ @Override
+ public void characters(String text) {/*
+ if(this.text==null) {
+ this.text=text;
+ } else {
+ this.text+=text;
+ } */
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/server/config/package.html b/src/com/idcanet/foei/server/config/package.html
new file mode 100644
index 0000000..bdf2d88
--- /dev/null
+++ b/src/com/idcanet/foei/server/config/package.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+Provides some startup util classes for starting and config multipe Foei instances in a ServletContainer.
+
+Package Specification
+
+We can access an FoeiContext here in the FoeiContextManager.
+Use with care !!
+
+To be sure of your code use something like:
+
+ FoeiContext foeiContext = FoeiContextManagerFactory.getFoeiContextManager().getFoeiContext("Test-Context");
+ FoeiContextFactory.bindFoeiContext(foeiContext);
+ // Do your stuff here.
+ //....
+ FoeiContextFactory.unbindFoeiContext();
+
+
+
+
+Related Documentation
+
+None.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/idcanet/foei/server/startup/FoeiStartupListener.java b/src/com/idcanet/foei/server/startup/FoeiStartupListener.java
new file mode 100644
index 0000000..b61a913
--- /dev/null
+++ b/src/com/idcanet/foei/server/startup/FoeiStartupListener.java
@@ -0,0 +1,107 @@
+/*
+ * 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.server.startup;
+
+import com.idcanet.foei.core.FoeiConfigurator;
+import com.idcanet.foei.core.FoeiContext;
+import com.idcanet.foei.server.FoeiContextManager;
+import com.idcanet.foei.server.FoeiContextManagerFactory;
+
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+/**
+ * Helps to startup Foei in a J2EE context.
+ *
+ * Its creates the FoeiContextManager and builds FoeiContext for us.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 20, 2006
+ */
+public class FoeiStartupListener implements ServletContextListener {
+
+ /** The logger to log to. */
+ private Logger logger = null;
+
+ /** The key for in web.xml */
+ static public final String FOEI_CONFIG_RESOURCES = "FOEI_CONFIG_RESOURCES";
+
+ /**
+ * Starts Foei
+ */
+ public void contextInitialized(ServletContextEvent event) {
+ logger = Logger.getLogger(FoeiStartupListener.class.getName());
+
+ // Creates FoeiContextManager
+ FoeiContextManager foeiContextManager = new FoeiContextManager();
+ FoeiContextManagerFactory.setFoeiContextManager(foeiContextManager);
+
+ String resources = event.getServletContext().getInitParameter(FOEI_CONFIG_RESOURCES);
+ if(resources==null) {
+ logger.warning("No "+FOEI_CONFIG_RESOURCES+" defined in web.xml not starting foei.");
+ return;
+ }
+
+ String[] resource = resources.split(",");
+ for(String className:resource) {
+ try {
+ InputStream foeiProperties = this.getClass().getResourceAsStream(className);
+ if(foeiProperties==null) {
+ logger.warning("Can't load: '"+className+"'");
+ continue;
+ }
+ 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);
+ }
+ }
+ }
+
+ /**
+ * Stop Foei
+ */
+ public void contextDestroyed(ServletContextEvent event) {
+ logger.info("Stopping Foei Contexts");
+ try {
+ FoeiContextManagerFactory.getFoeiContextManager().destroyAll();
+ } catch (Exception e) {
+ logger.log(Level.WARNING,"Error while shutdowning Foei: "+e.getMessage(),e);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/server/startup/package.html b/src/com/idcanet/foei/server/startup/package.html
new file mode 100644
index 0000000..bdf2d88
--- /dev/null
+++ b/src/com/idcanet/foei/server/startup/package.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+Provides some startup util classes for starting and config multipe Foei instances in a ServletContainer.
+
+Package Specification
+
+We can access an FoeiContext here in the FoeiContextManager.
+Use with care !!
+
+To be sure of your code use something like:
+
+ FoeiContext foeiContext = FoeiContextManagerFactory.getFoeiContextManager().getFoeiContext("Test-Context");
+ FoeiContextFactory.bindFoeiContext(foeiContext);
+ // Do your stuff here.
+ //....
+ FoeiContextFactory.unbindFoeiContext();
+
+
+
+
+Related Documentation
+
+None.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/idcanet/foei/utils/beans/BeanProperty.java b/src/com/idcanet/foei/utils/beans/BeanProperty.java
new file mode 100644
index 0000000..ff03b37
--- /dev/null
+++ b/src/com/idcanet/foei/utils/beans/BeanProperty.java
@@ -0,0 +1,40 @@
+/*
+ * 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.utils.beans;
+
+/**
+ * Gets ans Set properties of an java bean
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 18, 2006
+ */
+public class BeanProperty {
+
+
+
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/utils/beans/BeanPropertyComparator.java b/src/com/idcanet/foei/utils/beans/BeanPropertyComparator.java
new file mode 100644
index 0000000..b21b3c5
--- /dev/null
+++ b/src/com/idcanet/foei/utils/beans/BeanPropertyComparator.java
@@ -0,0 +1,174 @@
+/*
+ * 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.utils.beans;
+
+import java.lang.Comparable;
+import java.util.Comparator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.commons.beanutils.BeanUtils;
+
+/**
+ * Compares a property of a java bean.
+ * The property should be Comparable.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 11, 2006
+ */
+public class BeanPropertyComparator implements Comparator {
+
+ /** The propery of the bean to compare. */
+ private String property = null;
+ /** The logger to log to. */
+ private Logger logger = null;
+ /** The ascending */
+ private boolean ascending = true;
+
+ /**
+ * The constructor inits the logger.
+ */
+ public BeanPropertyComparator() {
+ logger = Logger.getLogger(BeanPropertyComparator.class.getName());
+ }
+
+ /**
+ * Creates an BeanPropertyComparator with an property
+ * @param property
+ */
+ public BeanPropertyComparator(String property) {
+ this();
+ setProperty(property);
+ }
+
+ /**
+ * Creates an BeanPropertyComparator with an property
+ * @param property
+ */
+ public BeanPropertyComparator(String property,boolean ascending) {
+ this();
+ setProperty(property);
+ setAscending(ascending);
+ }
+
+ /**
+ * Compares 2 objects by the propery
+ * @see Comparator#compare(T, T);
+ * @param o1 Object 1
+ * @param o2 Object 2
+ * @return the differce between the objects.
+ */
+ public int compare(Object o1,Object o2) throws ClassCastException {
+
+ Comparable c1 = getComparableProperty(o1);
+ Comparable c2 = getComparableProperty(o2);
+
+ if(c1==null && c2==null) {
+ return 0;
+ }
+ if(c1==null) {
+ if(ascending) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
+ if(c2==null) {
+ if(ascending) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
+
+ if(ascending) {
+ return c1.compareTo(c2);
+ } else {
+ return c2.compareTo(c1);
+ }
+ }
+
+ /**
+ * Returns the Comparable property of the object.
+ * @param object
+ * @return
+ * @throws ClassCastException
+ */
+ private Comparable getComparableProperty(Object object) throws ClassCastException {
+
+ if(property==null) {
+ throw new IllegalStateException("property is not set.");
+ }
+ Object result = null;
+ try {
+ result = BeanUtils.getProperty(object,property);
+ } catch (Exception e) {
+ logger.log(Level.WARNING,"property:"+property+" is not an property of object: "+object.getClass().getName(),e);
+ }
+ try {
+ Comparable c = (Comparable)result;
+ return c;
+ } catch (ClassCastException e) {
+ logger.log(Level.WARNING,"property:"+property+" is not Comparable",e);
+ throw e;
+ }
+ }
+
+ /**
+ * @return Returns the property.
+ */
+ public String getProperty() {
+ return property;
+ }
+
+ /**
+ * @param property The property to set.
+ */
+ public void setProperty(String property) {
+ if(property==null) {
+ throw new NullPointerException("property may not be null");
+ }
+ this.property = property;
+ logger.finest("property="+property);
+ }
+
+ /**
+ * @return Returns the ascending.
+ */
+ public boolean isAscending() {
+ return ascending;
+ }
+
+ /**
+ * @param ascending The ascending to set.
+ */
+ public void setAscending(boolean ascending) {
+ this.ascending = ascending;
+ logger.finest("ascending="+ascending);
+ }
+}
+
diff --git a/src/com/idcanet/foei/utils/beans/NumberComparator.java b/src/com/idcanet/foei/utils/beans/NumberComparator.java
new file mode 100644
index 0000000..947fa43
--- /dev/null
+++ b/src/com/idcanet/foei/utils/beans/NumberComparator.java
@@ -0,0 +1,95 @@
+/*
+ * 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.utils.beans;
+
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Comparator;
+import java.util.Locale;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Feb 9, 2006
+ */
+public class NumberComparator implements Comparator {
+
+ private Locale locale = null;
+
+ /**
+ * @return Returns the locale.
+ */
+ public Locale getLocale() {
+ return locale;
+ }
+
+ /**
+ * @param locale The locale to set.
+ */
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ /**
+ * Compares two String as number.
+ * @param o1
+ * @param o2
+ * @return
+ * @see Comparator#compare(T, T)
+ */
+ public int compare(Object o1, Object o2) {
+ Double d1 = getDoubleValue((String)o1,locale);
+ Double d2 = getDoubleValue((String)o2,locale);
+ return d1.compareTo(d2);
+ }
+
+ /**
+ * Converts an String to an Number wich is converted to a Double
+ * @param test The String to parse.
+ * @param locale The locale of the numberFormat.
+ * @return An Double
+ */
+ static public Double getDoubleValue(String text,Locale locale) {
+ try {
+ NumberFormat nf = NumberFormat.getInstance(locale);
+ Number n = nf.parse(text);
+ if(n instanceof Double) {
+ return (Double)n;
+ }
+ if(n instanceof Integer) {
+ return ((Integer)n).doubleValue();
+ }
+ if(n instanceof Long) {
+ return ((Long)n).doubleValue();
+ }
+ } catch(ParseException pe) {
+ } catch (NumberFormatException e) {
+ }
+ return 0.0;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/utils/beans/package.html b/src/com/idcanet/foei/utils/beans/package.html
new file mode 100644
index 0000000..547a56e
--- /dev/null
+++ b/src/com/idcanet/foei/utils/beans/package.html
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+Provides some handy classes for working with java beans.
+
+Package Specification
+
+
+ - Full J2SE 5 compatible
+ - Small package
+
+
+
+Related Documentation
+
+None.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/idcanet/foei/utils/jdbc/ConnectionFactory.java b/src/com/idcanet/foei/utils/jdbc/ConnectionFactory.java
new file mode 100644
index 0000000..788da2f
--- /dev/null
+++ b/src/com/idcanet/foei/utils/jdbc/ConnectionFactory.java
@@ -0,0 +1,56 @@
+/*
+ * 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.utils.jdbc;
+
+import java.sql.Connection;
+
+/**
+ * Java code can get a DB connections here.
+ * Its retreived from the ConnectionProviderManager.
+ *
+ * @author Willem Cazander
+ * @version 1.0
+ */
+public class ConnectionFactory
+{
+ /**
+ * Returns a connection by its name
+ * @param name The name of the connection
+ * @return Returns the Connection.
+ */
+ static public Connection getConnection(String name) {
+ return getConnectionProviderManager().getConnection(name);
+ }
+
+ /**
+ * Gets the instance of the ConnectionProviderManager.
+ * @return Returns the ConnectionProviderManager.
+ */
+ static public ConnectionProviderManager getConnectionProviderManager() {
+ return ConnectionProviderManager.getSharedInstance();
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/utils/jdbc/ConnectionProvider.java b/src/com/idcanet/foei/utils/jdbc/ConnectionProvider.java
new file mode 100644
index 0000000..7f34bc8
--- /dev/null
+++ b/src/com/idcanet/foei/utils/jdbc/ConnectionProvider.java
@@ -0,0 +1,55 @@
+/*
+ * 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.utils.jdbc;
+
+import java.sql.Connection;
+
+/**
+ * The ConnectionProvider is an interface which
+ * lets objects returns a Connection.
+ *
+ * We normally registrates an ConnectionProvider to the
+ * ConnectionProviderManager so objects can use it.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 4, 2006
+ */
+public interface ConnectionProvider
+{
+ /**
+ * Gets the connection name for which this
+ * ConnectionProvider handles connections.
+ * @return Returns the connection name.
+ */
+ public String getConnectionName();
+
+ /**
+ * Gets an connection of this ConnectionProvider.
+ * @return Returns an Connection
+ */
+ public Connection getConnection();
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/utils/jdbc/ConnectionProviderManager.java b/src/com/idcanet/foei/utils/jdbc/ConnectionProviderManager.java
new file mode 100644
index 0000000..a943a4d
--- /dev/null
+++ b/src/com/idcanet/foei/utils/jdbc/ConnectionProviderManager.java
@@ -0,0 +1,115 @@
+/*
+ * 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.utils.jdbc;
+
+import java.sql.Connection;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+
+/**
+ * Manages the different ConnectionProviders.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 4, 2006
+ */
+public class ConnectionProviderManager
+{
+ /** The logger to log to */
+ private Logger logger = null;
+ /** The map with all connection providers */
+ private Map connectionProviders = null;
+ /** The ConnectionProviderManager instance */
+ static private ConnectionProviderManager connectionProviderManager = null;
+
+ static {
+ try {
+ connectionProviderManager = new ConnectionProviderManager();
+ } catch (Exception e) {
+ throw new RuntimeException("Error while creating ConnectionProviderManager",e);
+ }
+ }
+
+ /**
+ * Creates an private ConnectionProviderManager
+ *
+ */
+ private ConnectionProviderManager() {
+ logger = Logger.getLogger(ConnectionProviderManager.class.getName());
+ logger.fine("Creating an ConnectionProviderManager");
+ connectionProviders = new HashMap(3);
+ }
+
+ /**
+ * Returns the singleton object of the ConnectionProviderManager.
+ * @return
+ */
+ static public ConnectionProviderManager getSharedInstance() {
+ return connectionProviderManager;
+ }
+
+ // ============ END SINGLETON
+
+ /**
+ * Gets an Connection by its connectionName
+ * @param connectionName The connection name.
+ * @return Returns the Connection
+ */
+ public Connection getConnection(String connectionName) {
+ return getConnectionProvider(connectionName).getConnection();
+ }
+
+ /**
+ * Adds an ConnectionProvider
+ * @param connectionProvider The ConnectionProvider to add.
+ */
+ public void addConnectionProvider(ConnectionProvider connectionProvider) {
+ if(connectionProvider==null) {
+ throw new NullPointerException("connectionProvider may not be null.");
+ }
+ logger.fine("Adding ConnnectionProvider for connection: "+connectionProvider.getConnectionName());
+ connectionProviders.put(connectionProvider.getConnectionName(),connectionProvider);
+ }
+
+ /**
+ * Gets an ConnectionProvider by its connectionName
+ * @param connectionName The connection name
+ * @return Returns the ConnectionProvider for this connectionName.
+ */
+ public ConnectionProvider getConnectionProvider(String connectionName) {
+ return connectionProviders.get(connectionName);
+ }
+
+ /**
+ * Gets all ConnectionProviders
+ * @return Returns all ConnectionProviders.
+ */
+ public Collection getConnectionProviders() {
+ return connectionProviders.values();
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/utils/jdbc/JndiDataSourceProvider.java b/src/com/idcanet/foei/utils/jdbc/JndiDataSourceProvider.java
new file mode 100644
index 0000000..0715a9e
--- /dev/null
+++ b/src/com/idcanet/foei/utils/jdbc/JndiDataSourceProvider.java
@@ -0,0 +1,163 @@
+/*
+ * 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.utils.jdbc;
+
+import java.sql.Connection;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
+/**
+ * The JndiDataSourceProvider is an ConnectionProvider which gets its connection
+ * from a jndi context.
+ * @author Willem Cazander
+ * @version 1.0 Jan 4, 2006
+ */
+public class JndiDataSourceProvider implements ConnectionProvider
+{
+ /** The context in which database datasources are found. */
+ private static final String DATASOURCE_CONTEXT = "java:comp/env/jdbc/";
+ /** The connectionName for this Provider */
+ private String connectionName = null;
+ /** The jndi context to search for the dataSource. */
+ private String dataSourceContext = null;
+ /** The logger to log to. */
+ private Logger logger = null;
+
+ /**
+ * Creates an JndiDataSourceProvider and inits the Logger
+ */
+ public JndiDataSourceProvider() {
+ logger = Logger.getLogger(JndiDataSourceProvider.class.getName());
+ }
+
+ /**
+ * Creates JndiDataSourceProvider and sets its connectionName.
+ * @param connectionName
+ */
+ public JndiDataSourceProvider(String connectionName) {
+ this();
+ setConnectionName(connectionName);
+ }
+
+ /**
+ * Creates an JndiDataSourceProvider and inits the Logger
+ * @param connectionName The connection name which this provider handles
+ * @param dataSourceContext The JNDI datasource prefix for getting the DataSource
+ */
+ public JndiDataSourceProvider(String connectionName,String dataSourceContext) {
+ this(connectionName);
+ setDataSourceContext(dataSourceContext);
+ }
+
+ /**
+ * Gets an DataSource out of the jndi context.
+ * @param name The name of the datasource in the jndi context.
+ * @return The datasource.
+ */
+ static public DataSource getDataSource(String name) {
+
+ try {
+ Context initialContext = new InitialContext();
+ if(initialContext == null) {
+ throw new RuntimeException("Init: Cannot get Initial Context");
+ }
+ DataSource datasource = (DataSource) initialContext.lookup(name);
+ if(datasource == null) {
+ throw new RuntimeException("Init: Cannot lookup datasource: '"+name+"'");
+ }
+ return datasource;
+ } catch (NamingException ex) {
+ throw new RuntimeException("Init: Cannot get connection " + ex);
+ }
+ }
+
+ //========= ConnectionProvider
+
+ /**
+ * Gets the connection name for which this
+ * ConnectionProvider handles connections.
+ * @return Returns the connection name.
+ * @see ConnectionProvider#getConnectionName()
+ */
+ public String getConnectionName() {
+ return connectionName;
+ }
+
+ /**
+ * Gets an connection of this ConnectionProvider.
+ * @return Returns an Connection
+ * @see ConnectionProvider#getConnection()
+ */
+ public Connection getConnection() {
+ try {
+ if(dataSourceContext==null) {
+ dataSourceContext=DATASOURCE_CONTEXT;
+ }
+ logger.finest("Trying retreiving DataSource of connectionName="+connectionName);
+ return getDataSource(dataSourceContext+connectionName).getConnection();
+ } catch (Exception e) {
+ logger.log(Level.WARNING,"Error while getting DataSource",e);
+ throw new NullPointerException("No datasource");
+ }
+ }
+
+ // ==== set/getter
+
+ /**
+ * Sets the connectionName.
+ * @param connectionName The connectionName to set.
+ */
+ public void setConnectionName(String connectionName) {
+ if(connectionName==null) {
+ throw new NullPointerException("connectionName may not be null.");
+ }
+ logger.finest("setting connectionName="+connectionName);
+ this.connectionName=connectionName;
+ }
+
+ /**
+ * @return Returns the dataSourceContext.
+ */
+ public String getDataSourceContext() {
+ return dataSourceContext;
+ }
+
+ /**
+ * When set to null(default) then
+ * DATASOURCE_CONTEXT is used. ("java:comp/env/jdbc/")
+ * @param dataSourceContext The dataSourceContext to set.
+ */
+ public void setDataSourceContext(String dataSourceContext) {
+ logger.finest("setting dataSourceContext="+dataSourceContext);
+ this.dataSourceContext = dataSourceContext;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/utils/jdbc/package.html b/src/com/idcanet/foei/utils/jdbc/package.html
new file mode 100644
index 0000000..6992623
--- /dev/null
+++ b/src/com/idcanet/foei/utils/jdbc/package.html
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+An generic ConnectionProvider with default jndi support.
+
+Package Specification
+
+
+ - Full J2SE 5 compatible
+ - Small package
+
+
+
+Related Documentation
+
+None.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/idcanet/foei/utils/jndi/ContextListWriter.java b/src/com/idcanet/foei/utils/jndi/ContextListWriter.java
new file mode 100644
index 0000000..c771bc3
--- /dev/null
+++ b/src/com/idcanet/foei/utils/jndi/ContextListWriter.java
@@ -0,0 +1,70 @@
+/*
+ * 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.utils.jndi;
+
+import javax.naming.Binding;
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import java.io.PrintStream;
+
+/**
+ * A util recursive method which prints the jndi tree.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 18, 2006
+ */
+public class ContextListWriter
+{
+ /**
+ * writes an context tree to the printstream out.
+ * @param out The printstream to which the text line are printed.
+ * @param ctx The context to list.
+ * @param indent The intext text for sub contexts.
+ */
+ public static void writeContextTree(PrintStream out,Context ctx, String indent) {
+
+ if(out==null | ctx==null | indent==null) {
+ return;
+ }
+ try {
+ NamingEnumeration list = ctx.listBindings("");
+ while (list.hasMore()) {
+ Binding item = (Binding)list.next();
+ String className = item.getClassName();
+ String name = item.getName();
+ out.println(indent+" class: "+className+" name="+name);
+ Object o = item.getObject();
+ if (o instanceof javax.naming.Context) {
+ writeContextTree(out,(Context)o,indent+indent);
+ }
+ }
+ } catch (NamingException ne) {
+ out.println("Nameing Exception: "+ne.getMessage());
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/utils/jndi/MemoryContext.java b/src/com/idcanet/foei/utils/jndi/MemoryContext.java
new file mode 100644
index 0000000..3906a4a
--- /dev/null
+++ b/src/com/idcanet/foei/utils/jndi/MemoryContext.java
@@ -0,0 +1,669 @@
+/*
+ * 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.utils.jndi;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.NoSuchElementException;
+
+import javax.naming.Binding;
+import javax.naming.CompositeName;
+import javax.naming.Context;
+import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameClassPair;
+import javax.naming.NameNotFoundException;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.NotContextException;
+import javax.naming.OperationNotSupportedException;
+import javax.naming.spi.NamingManager;
+
+
+/**
+ * A sample service provider that implements a hierarchical namespace in memory.
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 18, 2006
+ */
+public class MemoryContext implements Context
+{
+ protected Hashtable myEnv;
+ protected Hashtable bindings = new Hashtable(11);
+ protected final static NameParser myParser = new MemoryContextNameParser();
+ protected MemoryContext parent = null;
+ protected String myAtomicName = null;
+
+ /**
+ * Creates an new FoeiContext without an everment
+ * note:
+ * This should be done via an Factrory
+ * but then the server loader can not easaly load this class
+ */
+ public MemoryContext()
+ {
+ //super()FoeiContext(null);
+ }
+
+ MemoryContext(Hashtable inEnv)
+ {
+ myEnv = (inEnv != null)
+ ? (Hashtable)(inEnv.clone())
+ : null;
+ }
+
+ protected MemoryContext(MemoryContext parent, String name, Hashtable inEnv,Hashtable bindings)
+ {
+ this(inEnv);
+ this.parent = parent;
+ myAtomicName = name;
+ this.bindings = (Hashtable)bindings.clone();
+ }
+
+ protected Context createFoeiContext(MemoryContext parent, String name, Hashtable inEnv)
+ {
+ return new MemoryContext(parent, name, inEnv, new Hashtable(11));
+ }
+
+ protected Context cloneCtx()
+ {
+ return new MemoryContext(parent, myAtomicName, myEnv, bindings);
+ }
+
+ /**
+ * Utility method for processing composite/compound name.
+ * @param name The non-null composite or compound name to process.
+ * @return The non-null string name in this namespace to be processed.
+ */
+ protected Name getMyComponents(Name name) throws NamingException
+ {
+ if (name instanceof CompositeName)
+ {
+ if (name.size() > 1)
+ {
+ throw new InvalidNameException(name.toString()+" has more components than namespace can handle");
+ }
+ // Turn component that belongs to us into compound name
+ return myParser.parse(name.get(0));
+ }
+ // Already parsed
+ return name;
+ }
+
+ public Object lookup(String name) throws NamingException
+ {
+ return lookup(new CompositeName(name));
+ }
+
+ public Object lookup(Name name) throws NamingException
+ {
+ if (name.isEmpty())
+ {
+ return cloneCtx();
+ }
+
+ // Extract components that belong to this namespace
+ Name nm = getMyComponents(name);
+ String atom = nm.get(0);
+ Object inter = bindings.get(atom);
+
+ if (nm.size() == 1)
+ {
+ // Atomic name: Find object in internal data structure
+ if (inter == null)
+ {
+ throw new NameNotFoundException(name + " not found");
+ }
+
+ // Call getObjectInstance for using any object factories
+ try
+ {
+ return NamingManager.getObjectInstance(inter,new CompositeName().add(atom),this, myEnv);
+ }
+ catch (Exception e)
+ {
+ NamingException ne = new NamingException("getObjectInstance failed");
+ ne.setRootCause(e);
+ throw ne;
+ }
+ }
+ // else
+ // {
+ // Intermediate name: Consume name in this context and continue
+ if (!(inter instanceof Context))
+ {
+ throw new NotContextException(atom+" does not name a context");
+ }
+ return ((Context)inter).lookup(nm.getSuffix(1));
+ // }
+ }
+
+ public void bind(String name, Object obj) throws NamingException
+ {
+ bind(new CompositeName(name), obj);
+ }
+
+ public void bind(Name name, Object obj) throws NamingException
+ {
+ if (name.isEmpty())
+ {
+ throw new InvalidNameException("Cannot bind empty name");
+ }
+
+ Name nm = getMyComponents(name);
+ String atom = nm.get(0);
+ Object inter = bindings.get(atom);
+
+ if (nm.size() == 1)
+ {
+ // Atomic name: Find object in internal data structure
+ if (inter != null)
+ {
+ throw new NameAlreadyBoundException("Use rebind to override");
+ }
+
+ // Call getStateToBind for using any state factories
+ obj = NamingManager.getStateToBind(obj,new CompositeName().add(atom),this, myEnv);
+
+ // Add object to internal data structure
+ bindings.put(atom, obj);
+ }
+ else
+ {
+ // Intermediate name: Consume name in this context and continue
+ if(inter==null)
+ {
+ // auto create sub context.
+ inter = createSubcontext(atom);
+ }
+
+ if (!(inter instanceof Context))
+ {
+ throw new NotContextException(atom+" does not name a context");
+ }
+ ((Context)inter).bind(nm.getSuffix(1), obj);
+ }
+ }
+
+ public void rebind(String name, Object obj) throws NamingException
+ {
+ rebind(new CompositeName(name), obj);
+ }
+
+ public void rebind(Name name, Object obj) throws NamingException
+ {
+ if (name.isEmpty())
+ {
+ throw new InvalidNameException("Cannot bind empty name");
+ }
+
+ // Extract components that belong to this namespace
+ Name nm = getMyComponents(name);
+ String atom = nm.get(0);
+
+ if (nm.size() == 1)
+ {
+ // Atomic name
+ // Call getStateToBind for using any state factories
+ obj = NamingManager.getStateToBind(obj,new CompositeName().add(atom),this, myEnv);
+
+ // Add object to internal data structure
+ bindings.put(atom, obj);
+ }
+ else
+ {
+ // Intermediate name: Consume name in this context and continue
+ Object inter = bindings.get(atom);
+ if(inter==null)
+ {
+ // auto create sub context.
+ inter = createSubcontext(atom);
+ }
+
+ if (!(inter instanceof Context))
+ {
+ throw new NotContextException(atom+" does not name a context");
+ }
+ ((Context)inter).rebind(nm.getSuffix(1), obj);
+ }
+ }
+
+ public void unbind(String name) throws NamingException
+ {
+ unbind(new CompositeName(name));
+ }
+
+ public void unbind(Name name) throws NamingException
+ {
+ if (name.isEmpty())
+ {
+ throw new InvalidNameException("Cannot unbind empty name");
+ }
+
+ // Extract components that belong to this namespace
+ Name nm = getMyComponents(name);
+ String atom = nm.get(0);
+
+ // Remove object from internal data structure
+ if (nm.size() == 1)
+ {
+ // Atomic name: Find object in internal data structure
+ bindings.remove(atom);
+ }
+ else
+ {
+ // Intermediate name: Consume name in this context and continue
+ Object inter = bindings.get(atom);
+ if (!(inter instanceof Context))
+ {
+ throw new NotContextException(atom+" does not name a context");
+ }
+ ((Context)inter).unbind(nm.getSuffix(1));
+ }
+ }
+
+ public void rename(String oldName, String newName) throws NamingException
+ {
+ rename(new CompositeName(oldName), new CompositeName(newName));
+ }
+
+ public void rename(Name oldname, Name newname) throws NamingException
+ {
+ if (oldname.isEmpty() || newname.isEmpty())
+ {
+ throw new InvalidNameException("Cannot rename empty name");
+ }
+
+ Name oldnm = getMyComponents(oldname);
+ Name newnm = getMyComponents(newname);
+
+ // Simplistic implementation: support only rename within same context
+ if (oldnm.size() != newnm.size())
+ {
+ throw new OperationNotSupportedException("Do not support rename across different contexts");
+ }
+
+ String oldatom = oldnm.get(0);
+ String newatom = newnm.get(0);
+
+ if (oldnm.size() == 1)
+ {
+ if (bindings.get(newatom) != null)
+ {
+ throw new NameAlreadyBoundException(newname.toString()+" is already bound");
+ }
+
+ // Check if old name is bound
+ Object oldBinding = bindings.remove(oldatom);
+ if (oldBinding == null)
+ {
+ throw new NameNotFoundException(oldname.toString() + " not bound");
+ }
+ bindings.put(newatom, oldBinding);
+ }
+ else
+ {
+ if (!oldatom.equals(newatom))
+ {
+ throw new OperationNotSupportedException("Do not support rename across different contexts");
+ }
+
+ // Intermediate name: Consume name in this context and continue
+ Object inter = bindings.get(oldatom);
+ if (!(inter instanceof Context))
+ {
+ throw new NotContextException(oldatom+" does not name a context");
+ }
+ ((Context)inter).rename(oldnm.getSuffix(1), newnm.getSuffix(1));
+ }
+ }
+
+ public NamingEnumeration list(String name) throws NamingException
+ {
+ return list(new CompositeName(name));
+ }
+
+ public NamingEnumeration list(Name name) throws NamingException
+ {
+ if (name.isEmpty())
+ {
+ // listing this context
+ return new ListOfNames(bindings.keys());
+ }
+
+ // Perhaps 'name' names a context
+ Object target = lookup(name);
+ if (target instanceof Context)
+ {
+ return ((Context)target).list("");
+ }
+ throw new NotContextException(name + " cannot be listed");
+ }
+
+ public NamingEnumeration listBindings(String name) throws NamingException
+ {
+ return listBindings(new CompositeName(name));
+ }
+
+ public NamingEnumeration listBindings(Name name) throws NamingException
+ {
+ //System.err.println("FoeiContext list bindings is called "+this+" map size:"+bindings.size());
+
+ if (name.isEmpty()) {
+ // listing this context
+ return new ListOfBindings(bindings.keys());
+ }
+
+ // Perhaps 'name' names a context
+ Object target = lookup(name);
+ if (target instanceof Context) {
+ return ((Context)target).listBindings("");
+ }
+ throw new NotContextException(name + " cannot be listed");
+ }
+
+ public void destroySubcontext(String name) throws NamingException {
+ destroySubcontext(new CompositeName(name));
+ }
+
+ public void destroySubcontext(Name name) throws NamingException
+ {
+ if (name.isEmpty())
+ {
+ throw new InvalidNameException("Cannot destroy context using empty name");
+ }
+
+ // Simplistic implementation: not checking for nonempty context first
+ // Use same implementation as unbind
+ unbind(name);
+ }
+
+ public Context createSubcontext(String name) throws NamingException
+ {
+ return createSubcontext(new CompositeName(name));
+ }
+
+ public Context createSubcontext(Name name) throws NamingException
+ {
+ if (name.isEmpty())
+ {
+ throw new InvalidNameException("Cannot bind empty name");
+ }
+
+ // Extract components that belong to this namespace
+ Name nm = getMyComponents(name);
+ String atom = nm.get(0);
+ Object inter = bindings.get(atom);
+
+ if (nm.size() == 1)
+ {
+ // Atomic name: Find object in internal data structure
+ if (inter != null)
+ {
+ throw new NameAlreadyBoundException("Use rebind to override");
+ }
+
+ // Create child
+ Context child = createFoeiContext(this, atom, myEnv);
+
+ // Add child to internal data structure
+ bindings.put(atom, child);
+ return child;
+ }
+ else
+ {
+ // Intermediate name: Consume name in this context and continue
+ if (!(inter instanceof Context))
+ {
+ throw new NotContextException(atom+" does not name a context");
+ }
+ return ((Context)inter).createSubcontext(nm.getSuffix(1));
+ }
+ }
+
+ public Object lookupLink(String name) throws NamingException
+ {
+ return lookupLink(new CompositeName(name));
+ }
+
+ public Object lookupLink(Name name) throws NamingException
+ {
+ return lookup(name);
+ }
+
+ public NameParser getNameParser(String name) throws NamingException
+ {
+ return getNameParser(new CompositeName(name));
+ }
+
+ public NameParser getNameParser(Name name) throws NamingException
+ {
+ // Do lookup to verify name exists
+ Object obj = lookup(name);
+ if (obj instanceof Context)
+ {
+ ((Context)obj).close();
+ }
+ return myParser;
+ }
+
+ public String composeName(String name, String prefix) throws NamingException
+ {
+ Name result = composeName(new CompositeName(name),new CompositeName(prefix));
+ return result.toString();
+ }
+
+ public Name composeName(Name name, Name prefix) throws NamingException
+ {
+ Name result;
+
+ // Both are compound names, compose using compound name rules
+ if (!(name instanceof CompositeName) && !(prefix instanceof CompositeName))
+ {
+ result = (Name)(prefix.clone());
+ result.addAll(name);
+ return new CompositeName().add(result.toString());
+ }
+
+ // Simplistic implementation: do not support federation
+ throw new OperationNotSupportedException("Do not support composing composite names");
+ }
+
+ public Object addToEnvironment(String propName, Object propVal) throws NamingException
+ {
+ if (myEnv == null)
+ {
+ myEnv = new Hashtable(5, 0.75f);
+ }
+ return myEnv.put(propName, propVal);
+ }
+
+ public Object removeFromEnvironment(String propName) throws NamingException
+ {
+ if (myEnv == null)
+ {
+ return null;
+ }
+ return myEnv.remove(propName);
+ }
+
+ public Hashtable getEnvironment() throws NamingException
+ {
+ if (myEnv == null)
+ {
+ return new Hashtable(3, 0.75f);
+ }
+ else
+ {
+ return (Hashtable)myEnv.clone();
+ }
+ }
+
+ public String getNameInNamespace() throws NamingException
+ {
+ MemoryContext ancestor = parent;
+
+ // No ancestor
+ if (ancestor == null)
+ {
+ return "";
+ }
+
+ Name name = myParser.parse("");
+ name.add(myAtomicName);
+
+ // Get parent's names
+ while (ancestor != null && ancestor.myAtomicName != null)
+ {
+ name.add(0, ancestor.myAtomicName);
+ ancestor = ancestor.parent;
+ }
+ return name.toString();
+ }
+
+ public String toString()
+ {
+ if (myAtomicName != null)
+ {
+ return myAtomicName;
+ }
+ else
+ {
+ return "ROOT CONTEXT";
+ }
+ }
+
+ public void close() throws NamingException
+ {
+ }
+
+ // Class for enumerating name/class pairs
+ class ListOfNames implements NamingEnumeration {
+ protected Enumeration names;
+
+ ListOfNames (Enumeration names) {
+ this.names = names;
+ }
+
+ public boolean hasMoreElements() {
+ try {
+ return hasMore();
+ } catch (NamingException e) {
+ return false;
+ }
+ }
+
+ public boolean hasMore() throws NamingException {
+ return names.hasMoreElements();
+ }
+
+ public Object next() throws NamingException {
+ String name = (String)names.nextElement();
+ String className = bindings.get(name).getClass().getName();
+ return new NameClassPair(name, className);
+ }
+
+ public Object nextElement() {
+ try {
+ return next();
+ } catch (NamingException e) {
+ throw new NoSuchElementException(e.toString());
+ }
+ }
+
+ public void close() {
+ }
+ }
+
+ // Class for enumerating bindings
+ class ListOfBindings extends ListOfNames {
+
+ ListOfBindings(Enumeration names) {
+ super(names);
+ }
+
+ public Object next() throws NamingException {
+ String name = (String)names.nextElement();
+ Object obj = bindings.get(name);
+
+ try {
+ obj = NamingManager.getObjectInstance(obj,
+ new CompositeName().add(name), MemoryContext.this,
+ MemoryContext.this.myEnv);
+ } catch (Exception e) {
+ NamingException ne = new NamingException(
+ "getObjectInstance failed");
+ ne.setRootCause(e);
+ throw ne;
+ }
+
+ return new Binding(name, obj);
+ }
+ }
+
+ /*
+ static FoeiContext testRoot;
+ static {
+ try {
+ testRoot = new FoeiContext(null);
+
+ Context a = testRoot.createSubcontext("a");
+ Context b = a.createSubcontext("b");
+ Context c = b.createSubcontext("c");
+
+ testRoot.createSubcontext("x");
+ testRoot.createSubcontext("y");
+ } catch (NamingException e) {
+ }
+ }
+
+ public static Context getStaticNamespace(Hashtable env) {
+ return testRoot;
+ }
+
+ public static void main(String[] args) {
+ try {
+ Context ctx = new FoeiContext(null);
+
+ Context a = ctx.createSubcontext("a");
+ Context b = a.createSubcontext("b");
+ Context c = b.createSubcontext("c");
+
+ System.out.println(c.getNameInNamespace());
+
+ System.out.println(ctx.lookup(""));
+ System.out.println(ctx.lookup("a"));
+ System.out.println(ctx.lookup("b.a"));
+ System.out.println(a.lookup("c.b"));
+ } catch (NamingException e) {
+ e.printStackTrace();
+ }
+ }
+ */
+}
diff --git a/src/com/idcanet/foei/utils/jndi/MemoryContextFactory.java b/src/com/idcanet/foei/utils/jndi/MemoryContextFactory.java
new file mode 100644
index 0000000..1759b50
--- /dev/null
+++ b/src/com/idcanet/foei/utils/jndi/MemoryContextFactory.java
@@ -0,0 +1,61 @@
+/*
+ * 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.utils.jndi;
+
+import java.util.Hashtable;
+import javax.naming.spi.InitialContextFactory;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+
+/**
+ * Creates an new MemoryContext
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 18, 2006
+ *
+ */
+public class MemoryContextFactory implements InitialContextFactory
+{
+ /** Stores the jvm wide instance of the FoeiContext */
+ static private Context context = null;
+
+ /**
+ * Returns the FoeiContext
+ * @param environment
+ * @return
+ * @throws NamingException
+ */
+ public Context getInitialContext(Hashtable environment) throws NamingException {
+
+ if(context!=null) {
+ return context;
+ }
+ context = new MemoryContext(environment);
+ return context;
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/utils/jndi/MemoryContextNameParser.java b/src/com/idcanet/foei/utils/jndi/MemoryContextNameParser.java
new file mode 100644
index 0000000..bf818bf
--- /dev/null
+++ b/src/com/idcanet/foei/utils/jndi/MemoryContextNameParser.java
@@ -0,0 +1,66 @@
+/*
+ * 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.utils.jndi;
+
+import java.util.Properties;
+import javax.naming.NameParser;
+import javax.naming.Name;
+import javax.naming.CompoundName;
+import javax.naming.NamingException;
+
+/**
+ * A jndi name parser
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jan 18, 2006
+ */
+class MemoryContextNameParser implements NameParser {
+
+ /** The syntax to use. */
+ private static Properties syntax = null;
+
+ static {
+ try {
+ syntax = new Properties();
+ syntax.put("jndi.syntax.direction", "left_to_right");
+ syntax.put("jndi.syntax.separator", ".");
+ syntax.put("jndi.syntax.ignorecase", "false");
+ syntax.put("jndi.syntax.escape", "\\");
+ syntax.put("jndi.syntax.beginquote", "'");
+ } catch (Exception e) {
+ throw new RuntimeException("Error while creating FoeiNameParser",e);
+ }
+ }
+
+ /**
+ * Parses the String name into an Jndi name.
+ * @see NameParser#parse(java.lang.String)
+ */
+ public Name parse(String name) throws NamingException {
+ return new CompoundName(name, syntax);
+ }
+}
\ No newline at end of file
diff --git a/src/com/idcanet/foei/utils/jndi/package.html b/src/com/idcanet/foei/utils/jndi/package.html
new file mode 100644
index 0000000..31461d4
--- /dev/null
+++ b/src/com/idcanet/foei/utils/jndi/package.html
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+Defines an MemoryContext for storing object in a jndi tree.
+
+Package Specification
+
+
+ - Full J2SE 5 compatible
+ - Small package
+
+
+
+Related Documentation
+
+None.
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/com/META-INF/foei-config.xml b/tests/com/META-INF/foei-config.xml
new file mode 100644
index 0000000..05f5afd
--- /dev/null
+++ b/tests/com/META-INF/foei-config.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/com/META-INF/foei.properties b/tests/com/META-INF/foei.properties
new file mode 100644
index 0000000..4bcc195
--- /dev/null
+++ b/tests/com/META-INF/foei.properties
@@ -0,0 +1,26 @@
+
+foei.context_name=TEST-0
+
+foei.event_thread_listeners=tests.TestEventThreadListener
+
+foei.event_executor_manager.pool_core_size=5
+foei.event_executor_manager.pool_max_size=10
+foei.event_executor_manager.pool_keep_alive=300
+
+############
+## DEFAULTS ##
+############
+#
+#foei.context_name=
+#foei.root_path=
+#
+#foei.object_bindings_manager=com.idca.foei.core.impl.ObjectBindingsManagerImpl
+#foei.event_executor=com.idca.foei.core.impl.EventExecutorImpl
+#foei.event_executor_manager=com.idca.foei.core.impl.EventExecutorManagerImpl
+#foei.event_executor_manager.pool_core_size=3
+#foei.event_executor_manager.pool_max_size=5
+#foei.event_executor_manager.pool_keep_alive=180
+#foei.initial_object_context_factory=com.idca.foei.utils.jndi.MemoryContextFactory
+#foei.event_thread_listeners=
+#foei.x2o_root_tag=foei
+#foei.x2o_default_element_configurator=com.idca.foei.xml.x2o.DefaultX2OElementConfigurator
diff --git a/tests/com/idcanet/foei/tests/SimpleFoeiTests.java b/tests/com/idcanet/foei/tests/SimpleFoeiTests.java
index 6eb88fd..6df99cc 100644
--- a/tests/com/idcanet/foei/tests/SimpleFoeiTests.java
+++ b/tests/com/idcanet/foei/tests/SimpleFoeiTests.java
@@ -1,3 +1,14 @@
-dfg
\ No newline at end of file
+package com.idcanet.foei.tests;
+
+
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jul 27, 2006
+ */
+public class SimpleFoeiTests {
+}
\ No newline at end of file
diff --git a/tests/com/idcanet/foei/tests/TestEventThreadListener.java b/tests/com/idcanet/foei/tests/TestEventThreadListener.java
new file mode 100644
index 0000000..3bcf79b
--- /dev/null
+++ b/tests/com/idcanet/foei/tests/TestEventThreadListener.java
@@ -0,0 +1,22 @@
+
+package com.idcanet.foei.tests;
+
+import com.idcanet.foei.core.EventThreadListener;
+import com.idcanet.foei.core.FoeiContext;
+
+/**
+ *
+ *
+ * @author Willem Cazander
+ * @version 1.0 Jul 27, 2006
+ */
+public class TestEventThreadListener implements EventThreadListener {
+
+ public void startThread(FoeiContext foeiContext) {
+ System.out.println("START: "+Thread.currentThread().getName()+" context: "+foeiContext.getName());
+ }
+
+ public void stopThread(FoeiContext foeiContext) {
+ System.out.println("STOP: "+Thread.currentThread().getName()+" context: "+foeiContext.getName());
+ }
+}
\ No newline at end of file