diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..c604d75 --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/com/idcanet/foei/components/lang/DestroyFoeiProcess.java b/src/com/idcanet/foei/components/lang/DestroyFoeiProcess.java new file mode 100644 index 0000000..0ed13a4 --- /dev/null +++ b/src/com/idcanet/foei/components/lang/DestroyFoeiProcess.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.components.lang; + +import com.idcanet.foei.core.FoeiProcess; +import com.idcanet.foei.core.FoeiProcessFactory; +import com.idcanet.foei.event.AbstractEventInput; +import com.idcanet.foei.event.EventInput; +import com.idcanet.foei.event.EventPort; +import com.idcanet.foei.event.EventPortType; +import com.idcanet.foei.event.IllegalEventPortNameException; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Destroys an FoeiContext + * + * @author Willem Cazander + * @version 1.0 Mar 3, 2006 + */ +public class DestroyFoeiProcess extends AbstractEventInput { + + /** v1.0 */ + static final long serialVersionUID = 10l; + + private Integer delayTime = null; + + private Logger logger = null; + + public void setDelayTime(Integer delayTime) { + this.delayTime=delayTime; + } + + public Integer getDelayTime() { + return delayTime; + } + + /** + * Creates the output port + */ + public DestroyFoeiProcess() { + logger = Logger.getLogger(DestroyFoeiProcess.class.getName()); + addInputPort(EventPort.INPUT,Object.class); + getInputPort(EventPort.INPUT).setImmediate(false); + setDelayTime(5000); + } + + /** + * Stops the running FoeiProcess. + * (running event wil stil run !!) + * @see EventInput#doEvent(EventPort, Object) + */ + public void doEvent(EventPort eventPort,Object object) throws IllegalEventPortNameException { + if(EventPortType.input!=eventPort.getEventPortType()) { + throw new IllegalEventPortNameException("Not excisting input EventPort: "+eventPort.getName()); + } + FoeiProcess process = FoeiProcessFactory.getFoeiProcess(); + if(delayTime!=null) { + try { + logger.info("Sleeping "+delayTime+" ms before destoying process: "+process.getName()); + Thread.sleep(delayTime); + } catch (Exception e) { + logger.log(Level.WARNING,"Error sleeping: "+e.getMessage(),e); + } + } + // the impl prints an destory line + process.getFoeiContext().getFoeiProcessManager().destroyFoeiProcess(process.getName()); + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/components/lang/DummyOutputPort.java b/src/com/idcanet/foei/components/lang/DummyOutputPort.java new file mode 100644 index 0000000..745572c --- /dev/null +++ b/src/com/idcanet/foei/components/lang/DummyOutputPort.java @@ -0,0 +1,51 @@ +/* + * 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.lang; + +import com.idcanet.foei.event.AbstractEventOutput; +import com.idcanet.foei.event.EventPort; + +/** + * Defines an DummyOutputPort + * + * @author Willem Cazander + * @version 1.0 Feb 12, 2006 + * + * + */ +public class DummyOutputPort extends AbstractEventOutput { + + /** v1.0 */ + static final long serialVersionUID = 10l; + + /** + * Creates the output port + */ + public DummyOutputPort() { + addOutputPort(EventPort.OUTPUT,Object.class); + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/components/lang/EventProxy.java b/src/com/idcanet/foei/components/lang/EventProxy.java new file mode 100644 index 0000000..bd635bc --- /dev/null +++ b/src/com/idcanet/foei/components/lang/EventProxy.java @@ -0,0 +1,69 @@ +/* + * 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.lang; + +import com.idcanet.foei.core.FoeiProcessFactory; +import com.idcanet.foei.event.AbstractEventObject; +import com.idcanet.foei.event.EventInput; +import com.idcanet.foei.event.EventPort; +import com.idcanet.foei.event.EventPortType; +import com.idcanet.foei.event.IllegalEventPortNameException; + +/** + * This is a sort of dummy object. + * It only resends its events to the output. + * + * @author Willem Cazander + * @version 1.0 Feb 27, 2005 + */ +public class EventProxy extends AbstractEventObject +{ + /** v1.0 */ + static final long serialVersionUID = 10l; + + /** + * Creates an EventProxy + */ + public EventProxy() { + addInputPort(EventPort.INPUT,Object.class); // define an input source + addOutputPort(EventPort.OUTPUT,Object.class); // define the outputs source. + } + + /** + * Only proxies the object from the input to the output + * @param inputName + * @param object + * @throws IllegalEventPortNameException + * @see EventInput#doEvent(EventPort, Object) + */ + public void doEvent(EventPort eventPort,Object object) throws IllegalEventPortNameException { + if(EventPortType.input!=eventPort.getEventPortType()) { + throw new IllegalEventPortNameException("Not excisting input EventPort: "+eventPort.getName()); + } + FoeiProcessFactory.getFoeiProcess().executeEvent(getOutputPort(EventPort.OUTPUT),object); + } +} diff --git a/src/com/idcanet/foei/components/lang/Filter.java b/src/com/idcanet/foei/components/lang/Filter.java new file mode 100644 index 0000000..01cd9af --- /dev/null +++ b/src/com/idcanet/foei/components/lang/Filter.java @@ -0,0 +1,102 @@ +/* + * 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.lang; + +import com.idcanet.foei.core.FoeiProcessFactory; +import com.idcanet.foei.event.AbstractEventObjectStepController; +import com.idcanet.foei.event.EventInput; +import com.idcanet.foei.event.EventPort; +import com.idcanet.foei.event.EventPortType; +import com.idcanet.foei.event.EventStep; +import com.idcanet.foei.event.IllegalEventPortNameException; +import com.idcanet.foei.event.annotations.SetEventPort; +import com.idcanet.foei.event.annotations.SetEventPorts; + +/** + * Fiters the object on the Input port throw all + * eventsteps and outputs to pass or drop. + * + * @author Willem Cazander + * @version 1.0 Jan 25, 2006 + */ +/* +@SetEventPorts(ports={ + @SetEventPort(type=EventPortType.input,name=EventPort.INPUT,immediate=EventPort.TRUE), + @SetEventPort(type=EventPortType.output,name=EventPort.DROP), + @SetEventPort(type=EventPortType.output,name=EventPort.PASS), +}) +*/ +public class Filter extends AbstractEventObjectStepController +{ + /** v1.0 */ + static final long serialVersionUID = 10l; + + /** + * Creates an Filter + */ + public Filter() { + addInputPort(EventPort.INPUT,Object.class); // define an input source + addOutputPort(EventPort.DROP); // define the outputs source. + addOutputPort(EventPort.PASS); // defaults to Object.class) + } + + /** + * Filters the object with EventSteps + * @see EventInput#doEvent(EventPort, Object) + */ + public void doEvent(EventPort eventPort,Object object) throws IllegalEventPortNameException { + if(EventPortType.input!=eventPort.getEventPortType()) { + throw new IllegalEventPortNameException("Not excisting input EventPort: "+eventPort.getName()); + } + Object filtered = processEventSteps(object); + if(filtered==null) { + FoeiProcessFactory.getFoeiProcess().executeEvent(getOutputPort(EventPort.DROP),object); + } else { + FoeiProcessFactory.getFoeiProcess().executeEvent(getOutputPort(EventPort.PASS),object); + } + } + + /** + * Make sure that all steps are given the org object .. + */ + @Override + public Object processEventSteps(Object object) { + Object o = object; + for(EventStep e:getEventSteps()) { + if(o==null) { + return null; + } + o = e.processObject(object); + } + // Check for for last(or only) EventStep + if(o==null) { + return null; + } + return object; + } + +} \ No newline at end of file diff --git a/src/com/idcanet/foei/components/lang/GetBeanProperty.java b/src/com/idcanet/foei/components/lang/GetBeanProperty.java new file mode 100644 index 0000000..07ca5ee --- /dev/null +++ b/src/com/idcanet/foei/components/lang/GetBeanProperty.java @@ -0,0 +1,102 @@ +/* + * 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.lang; + +import org.apache.commons.beanutils.BeanUtils; + +import com.idcanet.foei.core.FoeiProcessFactory; +import com.idcanet.foei.event.AbstractEventObject; +import com.idcanet.foei.event.EventInput; +import com.idcanet.foei.event.EventPort; +import com.idcanet.foei.event.IllegalEventPortNameException; + +/** + * Gets the property of an Bean + * + * @author Willem Cazander + * @version 1.0 Jun 5, 2006 + * + */ +public class GetBeanProperty extends AbstractEventObject +{ + /** v1.0 */ + static final long serialVersionUID = 10l; + /** The Property name */ + //static final public String PROPERTY = "property"; + + private String property = null; + + private Object propertyValue = null; + /** + * Creates an SetBeanProperty + */ + public GetBeanProperty() { + addInputPort(EventPort.INPUT,Object.class); + //addInputPort(PROPERTY,Object.class); + addOutputPort(EventPort.OUTPUT); + } + + /** + * Filters the object with EventSteps + * @see EventInput#doEvent(EventPort, Object) + */ + public void doEvent(EventPort eventPort,Object object) throws IllegalEventPortNameException { + + //if(PROPERTY.equals(eventPort.getName())) { + // propertyValue=object; + // return; + //} + if(EventPort.INPUT.equals(eventPort.getName())) { + if(property==null) { + return; + } + try { + object = BeanUtils.getProperty(object,property); // todo: fix error this wil only return String !!!!!!!!!!!!!!!!! + } catch (Exception e) { + e.printStackTrace(); + return; + } + FoeiProcessFactory.getFoeiProcess().executeEvent(getOutputPort(EventPort.OUTPUT),object); + return; + } + throw new IllegalEventPortNameException("Not excisting input EventPort: "+eventPort.getName()); + } + + /** + * @return Returns the property. + */ + public String getProperty() { + return property; + } + + /** + * @param property The property to set. + */ + public void setProperty(String property) { + this.property = property; + } +} diff --git a/src/com/idcanet/foei/components/lang/ObjectChangedBuffer.java b/src/com/idcanet/foei/components/lang/ObjectChangedBuffer.java new file mode 100644 index 0000000..6082d6e --- /dev/null +++ b/src/com/idcanet/foei/components/lang/ObjectChangedBuffer.java @@ -0,0 +1,68 @@ +/* + * Copyright 2006 IDCA. All rights reserved. + * IDCA PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +package com.idcanet.foei.components.lang; + +import com.idcanet.foei.core.FoeiProcessFactory; +import com.idcanet.foei.event.AbstractEventObject; +import com.idcanet.foei.event.EventPort; +import com.idcanet.foei.event.IllegalEventPortNameException; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Logger; + +/** + * Buffers the object and check if it changes + * + * @author Willem Cazander + * @version 1.0 May 22, 2006 + */ +public class ObjectChangedBuffer extends AbstractEventObject { + + /** v1.0 */ + static final long serialVersionUID = 10l; + /** The logger to log to. */ + private Logger logger = null; + /** The last object */ + private Map bufferedObjects = null; + + public static final String NO_CHANGE = "noChange"; + + /** + * Creates an TapFlowWriter + * + */ + public ObjectChangedBuffer() { + logger = Logger.getLogger(ObjectChangedBuffer.class.getName()); + addInputPort(EventPort.INPUT); + addOutputPort(EventPort.OUTPUT); + addOutputPort(NO_CHANGE); + bufferedObjects = Collections.synchronizedMap(new HashMap(2)); + } + + /** + * @see com.idcanet.foei.event.AbstractEventObject#doEvent(com.idcanet.foei.event.EventPort, java.lang.Object) + */ + @Override + public void doEvent(EventPort eventPort, Object object) throws IllegalEventPortNameException { + if(!EventPort.INPUT.equals(eventPort.getName())) { + throw new IllegalEventPortNameException("Not excisting input EventPort: "+eventPort.getName()); + } + if(object==null) { + logger.warning("object null; returning"); + return; + } + if(bufferedObjects.containsKey(object.getClass())) { + if(object.equals(bufferedObjects.get(object.getClass()))) { + FoeiProcessFactory.getFoeiProcess().executeEvent(getOutputPort(NO_CHANGE),object); + return; + } + } + bufferedObjects.put(object.getClass(),object); + FoeiProcessFactory.getFoeiProcess().executeEvent(getOutputPort(EventPort.OUTPUT),object); + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/components/lang/SendEvent.java b/src/com/idcanet/foei/components/lang/SendEvent.java new file mode 100644 index 0000000..3b471cf --- /dev/null +++ b/src/com/idcanet/foei/components/lang/SendEvent.java @@ -0,0 +1,117 @@ +/* + * 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.lang; + +import com.idcanet.foei.core.FoeiProcessFactory; +import com.idcanet.foei.event.AbstractEventInput; +import com.idcanet.foei.event.EventInput; +import com.idcanet.foei.event.EventPort; +import com.idcanet.foei.event.IllegalEventPortNameException; + +/** + * This is a sort of dummy object. + * It only resends its events to the output. + * + * @author Willem Cazander + * @version 1.0 Feb 9, 2006 + */ +public class SendEvent extends AbstractEventInput +{ + /** v1.0 */ + static final long serialVersionUID = 10l; + + /** The output name */ + private String inputName = null; + + /** The FoeiContext jndi name of the EventInput object to send the event to */ + private String to = null; + + /** + * Creates an SendEvent object. + */ + public SendEvent() { + // define an input source + addInputPort(EventPort.INPUT,Object.class); + } + + /** + * Sets the inputName + * @param inputName The inputName to set. + */ + public void setInputName(String inputName) { + this.inputName=inputName; + } + + /** + * Gets the inputName + * @return Returns the inputName. + */ + public String getInputName() { + return inputName; + } + + /** + * Sets the to + * @param to The to to set. + */ + public void setTo(String to) { + this.to=to; + } + + /** + * Returns the to. + * @return The to to set. + */ + public String getTo() { + return to; + } + + /** + * Send an event to "to" an input port "inputname" + * @param inputName + * @param object + * @throws IllegalEventPortNameException + * @see EventInput#doEvent(EventPort, Object) + */ + public void doEvent(EventPort eventPort,Object object) throws IllegalEventPortNameException { + if(!EventPort.INPUT.equals(eventPort.getName())) { + throw new IllegalEventPortNameException("Not excisting input EventPort: "+eventPort.getName()); + } + if(to==null) { + return; + } + if(inputName==null) { + return; + } + Object eo = FoeiProcessFactory.getFoeiProcess().getEventObject(to); + if(!(eo instanceof EventInput)) { + return; + } + EventPort port = ((EventInput)eo).getInputPort(inputName); + FoeiProcessFactory.getFoeiProcess().executeEvent(port,object); + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/components/lang/SetBeanProperty.java b/src/com/idcanet/foei/components/lang/SetBeanProperty.java new file mode 100644 index 0000000..6305955 --- /dev/null +++ b/src/com/idcanet/foei/components/lang/SetBeanProperty.java @@ -0,0 +1,101 @@ +/* + * 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.lang; + +import org.apache.commons.beanutils.BeanUtils; + +import com.idcanet.foei.core.FoeiProcessFactory; +import com.idcanet.foei.event.AbstractEventObject; +import com.idcanet.foei.event.EventInput; +import com.idcanet.foei.event.EventPort; +import com.idcanet.foei.event.IllegalEventPortNameException; + +/** + * Sets an property of an bean which is set on the propery input port. + * + * @author Willem Cazander + * @version 1.0 Feb 12, 2006 + */ +public class SetBeanProperty extends AbstractEventObject +{ + /** v1.0 */ + static final long serialVersionUID = 10l; + /** The Property name */ + static final public String PROPERTY = "property"; + + private String property = null; + + private Object propertyValue = null; + /** + * Creates an SetBeanProperty + */ + public SetBeanProperty() { + addInputPort(EventPort.INPUT,Object.class); + addInputPort(PROPERTY,Object.class); + addOutputPort(EventPort.OUTPUT); + } + + /** + * Filters the object with EventSteps + * @see EventInput#doEvent(EventPort, Object) + */ + public void doEvent(EventPort eventPort,Object object) throws IllegalEventPortNameException { + + if(PROPERTY.equals(eventPort.getName())) { + propertyValue=object; + return; + } + if(EventPort.INPUT.equals(eventPort.getName())) { + if(property==null) { + return; + } + try { + BeanUtils.setProperty(object,property,propertyValue); + } catch (Exception e) { + e.printStackTrace(); + return; + } + FoeiProcessFactory.getFoeiProcess().executeEvent(getOutputPort(EventPort.OUTPUT),object); + return; + } + throw new IllegalEventPortNameException("Not excisting input EventPort: "+eventPort.getName()); + } + + /** + * @return Returns the property. + */ + public String getProperty() { + return property; + } + + /** + * @param property The property to set. + */ + public void setProperty(String property) { + this.property = property; + } +} diff --git a/src/com/idcanet/foei/components/lang/package.html b/src/com/idcanet/foei/components/lang/package.html new file mode 100644 index 0000000..09a59c9 --- /dev/null +++ b/src/com/idcanet/foei/components/lang/package.html @@ -0,0 +1,55 @@ + + + + + + +Some wrappers for standaard java object.
+ + + +

Related Documentation

+ +None. + + + + + \ No newline at end of file diff --git a/src/com/idcanet/foei/core/EventExecutor.java b/src/com/idcanet/foei/core/EventExecutor.java new file mode 100644 index 0000000..4a54b89 --- /dev/null +++ b/src/com/idcanet/foei/core/EventExecutor.java @@ -0,0 +1,57 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions + * and the following disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.foei.core; + +import com.idcanet.foei.event.EventPort; + +/** + * Reuables EventExecutor wich are executed + * in the EcentExecutorManager + * + * @author Willem Cazander + * @version 1.0 Jan 19, 2006 + */ +public interface EventExecutor extends Runnable { + + /** + * Sets the object to process. + * @param object + */ + public void setEventObject(Object object); + + /** + * Sets the eventPort to/from the object needs to go. + * @param eventPort + */ + public void setEventPort(EventPort eventPort); + + /** + * Returns true when this EventExecutor is ready + * @return + */ + public boolean isReady(); +} \ No newline at end of file diff --git a/src/com/idcanet/foei/core/EventExecutorManager.java b/src/com/idcanet/foei/core/EventExecutorManager.java new file mode 100644 index 0000000..cddc2d7 --- /dev/null +++ b/src/com/idcanet/foei/core/EventExecutorManager.java @@ -0,0 +1,81 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions + * and the following disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.foei.core; + +import com.idcanet.foei.event.EventPort; + +import java.util.List; + +/** + * The EventExecutionManager executes the event that + * executes the filter object flow. + * + * @author Willem Cazander + * @version 1.0 Jan 19, 2006 + */ +public interface EventExecutorManager extends EventPortExecutor { + + /** + * Executes an runnable object mostly this will be
+ * an reused EventExecutor. + * @param runnable The runnable to run. + */ + public void execute(Runnable runnable,FoeiProcess foeiProcess); + + /** + * + * @param eventPort + * @param eventObject + * @param foeiProcess + */ + public void executeEvent(EventPort eventPort,Object eventObject,FoeiProcess foeiProcess); + + /** + *Starts the EventExecutionManager + */ + public void start(FoeiContext foeiContext); + + /** + * Stops the EventExecutionManager + */ + public void stop(FoeiContext foeiContext); + + /** + * Gets all EventThreadListeners
+ * These are call when a new Thread is created or stops in the Threadpool of
+ * the EventExecutorManager.
+ * @return Returns all EventThreadListeners + */ + public List getEventThreadListeners(); + + /** + * Adds an EventThreadListener + * @param eventThreadListen er The EventThreadListener to add. + * @throws IllegalStateException When we are started we can't add listeners. + */ + public void addEventThreadListener(EventThreadListener eventThreadListener) throws IllegalStateException; +} \ No newline at end of file diff --git a/src/com/idcanet/foei/core/EventPortExecutor.java b/src/com/idcanet/foei/core/EventPortExecutor.java new file mode 100644 index 0000000..342f66c --- /dev/null +++ b/src/com/idcanet/foei/core/EventPortExecutor.java @@ -0,0 +1,46 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions + * and the following disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.foei.core; + +import com.idcanet.foei.event.EventPort; + +/** + * Executecuts an executeEvent method + * + * @author Willem Cazander + * @version 1.0 Mar 2, 2006 + * + */ +public interface EventPortExecutor { + + /** + * Send the EventObject to the eventPort + * @param eventObject + * @param eventPort + */ + public void executeEvent(EventPort eventPort,Object eventObject); +} \ No newline at end of file diff --git a/src/com/idcanet/foei/core/EventThreadListener.java b/src/com/idcanet/foei/core/EventThreadListener.java new file mode 100644 index 0000000..57a6c04 --- /dev/null +++ b/src/com/idcanet/foei/core/EventThreadListener.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.core; + +/** + * With this interface its possible to inject some + * threadlocals in a foei event thread. + * + * @author Willem Cazander + * @version 1.0 Feb 22, 2006 + */ +public interface EventThreadListener { + + /** + * Gets called when a new Thread is created for the foei thread pool. + * @param foeiContext + */ + public void startThread(FoeiContext foeiContext); + + /** + * Gets callled when a thread is closed in the tread pool. + * @param foeiContext + */ + public void stopThread(FoeiContext foeiContext); +} \ No newline at end of file diff --git a/src/com/idcanet/foei/core/FoeiConfigurator.java b/src/com/idcanet/foei/core/FoeiConfigurator.java new file mode 100644 index 0000000..b166dea --- /dev/null +++ b/src/com/idcanet/foei/core/FoeiConfigurator.java @@ -0,0 +1,86 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions + * and the following disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.foei.core; + +import com.idcanet.foei.core.impl.FoeiConfiguratorImpl; + +import java.util.Map; + +/** + * Start the FoeiContext from which foei in managed. + * + * @author Willem Cazander + * @version 1.0 Jan 20, 2006 + */ +public interface FoeiConfigurator { + + /** The key of the foei fontext name */ + static public final String CONTEXT_NAME = "foei.context_name"; + + /** The key of the root path */ + static public final String ROOT_PATH = "foei.root_path"; + + /** The key of the className of the ObjectBindingsManager */ + static public final String OBJECT_BINDINGS_MANAGER = "foei.object_bindings_manager"; + + /** The key of the className of the EventExecutor */ + static public final String EVENT_EXECUTOR = "foei.event_executor"; + + /** The key of the className of the EventExecutorManager */ + static public final String EVENT_EXECUTOR_MANAGER = "foei.event_executor_manager"; + + /** The key of the integer of the EventExecutor pool core size */ + static public final String EVENT_EXECUTOR_POOL_CORE_SIZE = "foei.event_executor_manager.pool_core_size"; + + /** The key of the integer of the EventExecutor pool max size */ + static public final String EVENT_EXECUTOR_POOL_MAX_SIZE = "foei.event_executor_manager.pool_max_size"; + + /** The key of the integer of the EventExecutor pool keep alive */ + static public final String EVENT_EXECUTOR_POOL_KEEP_ALIVE = "foei.event_executor_manager.pool_keep_alive"; + + /** The key of the className of the ObjectContextFactory */ + static public final String OBJECT_CONTEXT_FACTORY = "foei.initial_object_context_factory"; + + /** The key of the classNames (',' seperated) of the EventThreadListener */ + static public final String EVENT_THREAD_LISTENERS = "foei.event_thread_listeners"; + + /** The key of the className of the FoeiProcessManager */ + static public final String FOEI_PROCESS_MANAGER = "foei.process_manager"; + + /** The key of the rootTag of the X2O parser */ + static public final String X2O_ROOT_TAG = "foei.x2o_root_tag"; + + /** The default FoeiConfigurator */ + static public final Class DEFAULT_FOEI_CONFIGURATOR = FoeiConfiguratorImpl.class; + + /** + * Starts an FoeiContext + * @param properties + * @return + */ + public FoeiContext buildFoeiContext(Map properties) throws FoeiContextBuildingException; +} \ No newline at end of file diff --git a/src/com/idcanet/foei/core/FoeiContext.java b/src/com/idcanet/foei/core/FoeiContext.java new file mode 100644 index 0000000..5450f17 --- /dev/null +++ b/src/com/idcanet/foei/core/FoeiContext.java @@ -0,0 +1,81 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions + * and the following disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.foei.core; + +import java.util.Map; + +import javax.naming.Context; + +/** + * Defines the FoeiContext.
+ * + * @author Willem Cazander + * @version 1.0 Jan 19, 2005 + */ +public interface FoeiContext { + + /** + * Gets the name of the context. + * @return Returns the name of the context. + */ + public String getName(); + + /** + * Gets the root path. + * @return returns the root path. + */ + public String getRootPath(); + + /** + * Gets the EventObjectContext. + * @return Returns the Context + */ + public Context getEventObjectContext(); + + /** + * Gets the EventExecutorManager + * @return Returns the EventExecutorManager + */ + public EventExecutorManager getEventExecutorManager(); + + /** + * Gets the map of the start properties of this context. + * @return + */ + public Map getStartProperties(); + + /** + * Gets the FoeiProcessManager + * @return Returns the FoeiProcessManager + */ + public FoeiProcessManager getFoeiProcessManager(); + + /** + * Stops all stuff in this context + */ + public void destroy(); +} \ No newline at end of file diff --git a/src/com/idcanet/foei/core/FoeiContextBuildingException.java b/src/com/idcanet/foei/core/FoeiContextBuildingException.java new file mode 100644 index 0000000..50edf8d --- /dev/null +++ b/src/com/idcanet/foei/core/FoeiContextBuildingException.java @@ -0,0 +1,71 @@ +/* + * 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; + +/** + * Can gets thrown when building an FoeiContext implementation object. + * + * @author Willem Cazander + * @version 1.0 Jan 24, 2006 + */ +public class FoeiContextBuildingException extends Exception +{ + /** v1.0 */ + static final long serialVersionUID = 10l; + + /** + * Constructs an FoeiContextBuildingException without a detail message. + */ + public FoeiContextBuildingException() { + super(); + } + + /** + * Constructs an FoeiContextBuildingException with a detail message. + * @param message The message of this Exception + */ + public FoeiContextBuildingException(String message) { + super(message); + } + + /** + * Creates an FoeiContextBuildingException from a parent exception and a message + * @param e The parent exception. + * @param message An detail message. + */ + public FoeiContextBuildingException(String message,Exception e) { + super(message,e); + } + + /** + * Creates an FoeiContextBuildingException from a parent exception. + * @param e The parant exception + */ + public FoeiContextBuildingException(Exception e) { + super(e); + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/core/FoeiProcess.java b/src/com/idcanet/foei/core/FoeiProcess.java new file mode 100644 index 0000000..e20c667 --- /dev/null +++ b/src/com/idcanet/foei/core/FoeiProcess.java @@ -0,0 +1,69 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions + * and the following disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.foei.core; + +import javax.naming.Context; + +/** + * Defines an FoeiProcess interface
+ * The FoeiProcess is only accesable from an injected thread local.
+ * From the FoeiProcess we can bind object and fire events.
+ * + * @author Willem Cazander + * @version 1.0 Mar 2, 2006 + */ +public interface FoeiProcess extends ObjectBindingsManager,ObjectContextManager,EventPortExecutor { + + /** + * Gets the name of the process. + * @return Returns the name of the process. + */ + public String getName(); + + /** + * Gets the EventObjectContext. + * @return Returns the Context + */ + public Context getEventObjectContext(); + + /** + * Gets the ObjectBindingsManager + * @return Retuns the ObjectBindingsManager + */ + public ObjectBindingsManager getObjectBindingsManager(); + + /** + * Gets the FoeiContext + * @return + */ + public FoeiContext getFoeiContext(); + + /** + * Stops all stuff in this process + */ + public void destroy(); +} \ No newline at end of file diff --git a/src/com/idcanet/foei/core/FoeiProcessFactory.java b/src/com/idcanet/foei/core/FoeiProcessFactory.java new file mode 100644 index 0000000..721a37b --- /dev/null +++ b/src/com/idcanet/foei/core/FoeiProcessFactory.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.core; + +/** + * This is the only class of the core which is hardcoded.
+ * It retreives the FoeiProcess from the ThreadLocal. + * which is set in the EventExecutor + * + * @author Willem Cazander + * @version 1.0 Feb 2, 2006 + */ +public class FoeiProcessFactory { + + /** The threadlocal storing the FoeiProcess */ + private static final ThreadLocal threadLocal = new ThreadLocal(); + + /** + * Gets the FoeiProcess for the current thread. + * @return Returns the FoeiProcess for the current thread. + * @throws IllegalStateException When no FoeiProcess is set in the current Thread. + */ + static public FoeiProcess getFoeiProcess() { + FoeiProcess foeiProcess = (FoeiProcess)threadLocal.get(); + if(foeiProcess==null) { + throw new IllegalStateException("No FoeiProcess set in current thread ThreadLocal"); + } + return foeiProcess; + } + + /** + * Binds an FoeiProcess to the currentThread. + * @param foeiContext The FoeiProcess to bind. + */ + static public void bindFoeiProcess(FoeiProcess foeiProcess) { + threadLocal.set(foeiProcess); + } + + /** + * Unbinds the current FoeiProcess. + */ + static public void unbindFoeiProcess() { + if(threadLocal.get()==null) { + throw new NullPointerException("Can't unbind from an non binded thread."); + } + threadLocal.set(null); + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/core/FoeiProcessManager.java b/src/com/idcanet/foei/core/FoeiProcessManager.java new file mode 100644 index 0000000..6501a7c --- /dev/null +++ b/src/com/idcanet/foei/core/FoeiProcessManager.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.core; + +import java.util.Collection; + +/** + * The FoeiProcessManager manages all the FoeiProcesses + * which are running in the FoeiContext. + * + * @author Willem Cazander + * @version 1.0 Mar 2, 2006 + */ +public interface FoeiProcessManager { + + /** + * Creates an new FoeiProcess. + * @param name The name of the process + * @param foeiContext The FoeiContext + * @return Returns an FoeiProcess + */ + public FoeiProcess createFoeiProcess(String name,FoeiContext foeiContext); + + /** + * destroy a FoeiProcess by its name. + * @param name + */ + public void destroyFoeiProcess(String name); + + /** + * Gets an FoeiProcess by its id. + * @param name + * @return Returns an FoeiProcess + */ + public FoeiProcess getFoeiProcess(String name); + + /** + * Gets all running FoeiProcess'es + * @return + */ + public Collection getFoeiProcesses(); +} \ No newline at end of file diff --git a/src/com/idcanet/foei/core/ObjectBindingsManager.java b/src/com/idcanet/foei/core/ObjectBindingsManager.java new file mode 100644 index 0000000..e0075cd --- /dev/null +++ b/src/com/idcanet/foei/core/ObjectBindingsManager.java @@ -0,0 +1,68 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions + * and the following disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.foei.core; + +import com.idcanet.foei.event.EventPort; + +import java.util.List; + +/** + * Manages all the Foei EventPort bindings. + * + * @author Willem Cazander + * @version 1.0 1/05/2005 + */ +public interface ObjectBindingsManager +{ + /** + * Adds an binding from the input to the output EventPort. + * @param outputPort The output EventPort + * @param inputPort The input EventPort + */ + public void addBinding(EventPort outputPort,EventPort inputPort); + + /** + * Removes an binding. + * @param inputPort The input EventPort. + * @param outputPort The output EventPort. + */ + public void removeBinding(EventPort inputPort,EventPort outputPort); + + /** + * 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); + + + /** + * Returns the bindings in an xml format to render with dotty. + * @return + */ + public String getBindingsAsXML(); +} diff --git a/src/com/idcanet/foei/core/ObjectContextManager.java b/src/com/idcanet/foei/core/ObjectContextManager.java new file mode 100644 index 0000000..9c51969 --- /dev/null +++ b/src/com/idcanet/foei/core/ObjectContextManager.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.core; + +/** + * ObjectContextManager makes it possible to get and set objects + * + * + * @author Willem Cazander + * @version 1.0 Jan 19, 2005 + */ +public interface ObjectContextManager { + + /** + * Adds an EventObject to the Context + * @param eventObject + */ + public void addEventObject(Object eventObject,String id); + + /** + * removes an EventObject from the Context + * @param eventObject + */ + public void removeEventObject(String id); + + /** + * Gets an EventObject by its id. + * @param id + * @return + */ + public Object getEventObject(String id); +} \ No newline at end of file diff --git a/src/com/idcanet/foei/core/X2OExecutor.java b/src/com/idcanet/foei/core/X2OExecutor.java new file mode 100644 index 0000000..1dbd356 --- /dev/null +++ b/src/com/idcanet/foei/core/X2OExecutor.java @@ -0,0 +1,74 @@ +/* + * Copyright 2004-2006 IDCA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and + * the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions + * and the following disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the authors and + * should not be interpreted as representing official policies, either expressed or implied, of IDCA. + */ + +package com.idcanet.foei.core; + +import java.io.InputStream; + +/** + * Executes an X2O script. + * + * @author Willem Cazander + * @version 1.0 Feb 24, 2006 + */ +public interface X2OExecutor extends Runnable { + + /** + * Sets the fileName to parse. + * @param fileName + */ + public void setFileName(String fileName); + + /** + * Sets the inputStream to parse. + * @param inputStream + */ + public void setInputStream(InputStream inputStream); + + /** + * Sets the xml to parse. + * @param xml + */ + public void setXml(String xml); + + /** + * Sets the debug state of the X2O Parser. + * @param debug The debug state to set. + */ + public void setDebug(boolean debug); + + /** + * Gets the debug state. + * @return Returns the debug state. + */ + public boolean getDebug(); + + /** + * Returns true when this X2OExecutor is ready + * @return + */ + public boolean isReady(); +} \ No newline at end of file diff --git a/src/com/idcanet/foei/core/package.html b/src/com/idcanet/foei/core/package.html new file mode 100644 index 0000000..f2bc7c4 --- /dev/null +++ b/src/com/idcanet/foei/core/package.html @@ -0,0 +1,59 @@ + + + + + + +Defines the Foei Event Core interfaces, exceptions and 1 class.
+ +

Package Specification

+ +The Foei Core objects are fully interfaced so you
+can hook into every core process.
+ + +

Related Documentation

+ +None. + + + + + \ No newline at end of file diff --git a/src/com/idcanet/foei/event/AbstractEventInput.java b/src/com/idcanet/foei/event/AbstractEventInput.java new file mode 100644 index 0000000..6ce4353 --- /dev/null +++ b/src/com/idcanet/foei/event/AbstractEventInput.java @@ -0,0 +1,101 @@ +/* + * 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; + +import com.idcanet.foei.event.EventInput; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +/** + * Defines an AbstractEventInput which implements most
+ * methods needed for an Foei EventInput bean. + * + * @author Willem Cazander + * @version 1.0 Aug 20, 2005 + */ +abstract public class AbstractEventInput implements EventInput { + + /** The input EventPorts */ + private Map inputs = null; + + /** + * The constuctor + */ + public AbstractEventInput() { + inputs = new HashMap(1); + } + + /** + * Adds an input EventPort + * @param inputName The inputName of the EventPort + */ + protected void addInputPort(String inputName) { + addInputPort(inputName,Object.class); + } + + /** + * Adds an input EventPort + * @param inputName The inputName of the EventPort + * @param inputType The inputClass of the EventPort + */ + protected void addInputPort(String inputName,Class inputClass) { + if(inputName==null) { + throw new NullPointerException("inputName may not be null."); + } + if(inputClass==null) { + throw new NullPointerException("inputClass may not be null."); + } + inputs.put(inputName,new EventPort(inputName,inputClass,EventPortType.input,this)); + } + + // ---------------- EventInput + + /** + * Gets all input EventPorts + * @see EventInput#getInputPorts() + * @return Returns an List of input EventPorts + */ + public Collection getInputPorts() { + return inputs.values(); + } + + /** + * + * @param name + * @return + */ + public EventPort getInputPort(String name) { + return inputs.get(name); + } + + /** + * @see EventInput#doEvent(EventPort, Object) + */ + abstract public void doEvent(EventPort eventPort,Object object) throws IllegalEventPortNameException; +} \ No newline at end of file diff --git a/src/com/idcanet/foei/event/AbstractEventInputStepController.java b/src/com/idcanet/foei/event/AbstractEventInputStepController.java new file mode 100644 index 0000000..75d4fbe --- /dev/null +++ b/src/com/idcanet/foei/event/AbstractEventInputStepController.java @@ -0,0 +1,97 @@ +/* + * 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; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +/** + * + * + * @author Willem Cazander + * @version 1.0 Jan 25, 2006 + */ +abstract public class AbstractEventInputStepController extends AbstractEventInput implements EventStepController +{ + /** The EventStep List */ + private List eventSteps = null; + /** The Logger to log to. */ + private Logger logger = null; + + /** + * Creates the EventStep list and the logger. + */ + public AbstractEventInputStepController() { + eventSteps = new ArrayList(); + logger = Logger.getLogger(AbstractEventStepController.class.getName()); + } + + /** + * Adds an EventStep + * @see EventStepController#addEventStep(EventStep) + */ + public void addEventStep(EventStep eventStep) { + logger.finer("Adding EventStep to: "+this); + eventSteps.add(eventStep); + } + + /** + * Removes an EventStep + * @see EventStepController#removeEventStep(EventStep) + */ + public void removeEventStep(EventStep eventStep) { + logger.finer("Removing EventStep to: "+this); + eventSteps.remove(eventStep); + } + + /** + * Gets all EventSteps. + * @see EventStepController#getEventSteps() + * @returns Returns all EventSteps. + */ + public List getEventSteps() { + return eventSteps; + } + + /** + * Process all EventSteps of the EventStepController + * Override for other behavior + * @see EventStepController#processEventSteps(Object) + * @param object The object to pass to the EventSteps + * @return The object or null. + */ + public Object processEventSteps(Object object) { + for(EventStep e:getEventSteps()) { + if(object==null) { + return null; + } + object = e.processObject(object); + } + return object; + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/event/AbstractEventObject.java b/src/com/idcanet/foei/event/AbstractEventObject.java new file mode 100644 index 0000000..ff438de --- /dev/null +++ b/src/com/idcanet/foei/event/AbstractEventObject.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.event; + +import com.idcanet.foei.event.EventInput; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +/** + * Defines an AbstractEventInput which implements most
+ * methods needed for an Foei EventInput and EventOutput bean. + * + * @author Willem Cazander + * @version 1.0 Aug 17, 2005 + */ +abstract public class AbstractEventObject extends AbstractEventOutput implements EventInput +{ + /** The input EventPorts */ + private Map inputs = null; + + public AbstractEventObject() { + inputs = new HashMap(1); + } + + /** + * Adds an input EventPort + * @param inputName The inputName of the EventPort + */ + protected void addInputPort(String inputName) { + addInputPort(inputName,Object.class); + } + + /** + * Adds an input EventPort + * @param inputName The inputName of the EventPort + * @param inputType The inputType of the EventPort + */ + protected void addInputPort(String inputName,Class inputType) { + if(inputName==null) { + throw new NullPointerException("inputName may not be null."); + } + if(inputType==null) { + throw new NullPointerException("inputType may not be null."); + } + inputs.put(inputName,new EventPort(inputName,inputType,EventPortType.input,this)); + } + + // ---------------- EventInput + + /** + * Gets all input EventPorts + * @see EventInput#getInputPorts() + * @return Returns an List of input EventPorts + */ + public Collection getInputPorts() { + return inputs.values(); + } + + /** + * + * @param name + * @return + */ + public EventPort getInputPort(String name) { + return inputs.get(name); + } + + /** + * @see EventInput#doEvent(EventPort, Object) + */ + abstract public void doEvent(EventPort eventPort,Object object) throws IllegalEventPortNameException; +} diff --git a/src/com/idcanet/foei/event/AbstractEventObjectStepController.java b/src/com/idcanet/foei/event/AbstractEventObjectStepController.java new file mode 100644 index 0000000..e7d5838 --- /dev/null +++ b/src/com/idcanet/foei/event/AbstractEventObjectStepController.java @@ -0,0 +1,97 @@ +/* + * 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; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +/** + * + * + * @author Willem Cazander + * @version 1.0 Jan 25, 2006 + */ +abstract public class AbstractEventObjectStepController extends AbstractEventObject implements EventStepController +{ + /** The EventStep List */ + private List eventSteps = null; + /** The Logger to log to. */ + private Logger logger = null; + + /** + * Creates the EventStep list and the logger. + */ + public AbstractEventObjectStepController() { + eventSteps = new ArrayList(); + logger = Logger.getLogger(AbstractEventStepController.class.getName()); + } + + /** + * Adds an EventStep + * @see EventStepController#addEventStep(EventStep) + */ + public void addEventStep(EventStep eventStep) { + logger.finer("Adding EventStep to: "+this); + eventSteps.add(eventStep); + } + + /** + * Removes an EventStep + * @see EventStepController#removeEventStep(EventStep) + */ + public void removeEventStep(EventStep eventStep) { + logger.finer("Removing EventStep to: "+this); + eventSteps.remove(eventStep); + } + + /** + * Gets all EventSteps. + * @see EventStepController#getEventSteps() + * @returns Returns all EventSteps. + */ + public List getEventSteps() { + return eventSteps; + } + + /** + * Process all EventSteps of the EventStepController + * Override for other behavior + * @see EventStepController#processEventSteps(Object) + * @param object The object to pass to the EventSteps + * @return The object or null. + */ + public Object processEventSteps(Object object) { + for(EventStep e:getEventSteps()) { + if(object==null) { + return null; + } + object = e.processObject(object); + } + return object; + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/event/AbstractEventOutput.java b/src/com/idcanet/foei/event/AbstractEventOutput.java new file mode 100644 index 0000000..a76e47a --- /dev/null +++ b/src/com/idcanet/foei/event/AbstractEventOutput.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.event; + +import com.idcanet.foei.event.EventOutput; +import com.idcanet.foei.event.EventPort; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +/** + * Defines an AbstractEventInput which implements most
+ * methods needed for an Foei EventOutput bean. + * + * @author Willem Cazander + * @version 1.0 Aug 17, 2005 + */ +abstract public class AbstractEventOutput implements EventOutput { + + /** The output EventPorts */ + private Map outputs = null; + + /** + * Creates an AbstractEventOutput + */ + public AbstractEventOutput() { + outputs = new HashMap(1); + } + + /** + * Adds an OutputPort to this bean. + * @param outputName The outputName of the EventPort. + */ + protected void addOutputPort(String outputName) { + addOutputPort(outputName,Object.class); + } + + /** + * Adds an Output to this bean which an certain class type. + * @param outputName The outputName of the EventPort. + * @param outputType The output Class type of the EventPort. + */ + protected void addOutputPort(String outputName,Class outputType) { + if(outputName==null) { + throw new NullPointerException("outputName may not be null."); + } + if(outputType==null) { + throw new NullPointerException("outputType may not be null."); + } + outputs.put(outputName,new EventPort(outputName,outputType,EventPortType.output,this)); + } + + // ---------------- EventOutput + + /** + * Returns an List of OutputPorts + * @returns Returns an List of OutputPorts + * @see EventOutput#getOutputPorts() + */ + public Collection getOutputPorts() { + return outputs.values(); + } + + /** + * Gets an output EventPort by its name. + * @param name The name of the outputPort + * @returns Returns the EventPort + * @see EventOutput#getOutputPort(String) + */ + public EventPort getOutputPort(String name) { + return outputs.get(name); + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/event/AbstractEventOutputStepController.java b/src/com/idcanet/foei/event/AbstractEventOutputStepController.java new file mode 100644 index 0000000..1898b2e --- /dev/null +++ b/src/com/idcanet/foei/event/AbstractEventOutputStepController.java @@ -0,0 +1,97 @@ +/* + * 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; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +/** + * + * + * @author Willem Cazander + * @version 1.0 Jan 25, 2006 + */ +abstract public class AbstractEventOutputStepController extends AbstractEventOutput implements EventStepController +{ + /** The EventStep List */ + private List eventSteps = null; + /** The Logger to log to. */ + private Logger logger = null; + + /** + * Creates the EventStep list and the logger. + */ + public AbstractEventOutputStepController() { + eventSteps = new ArrayList(); + logger = Logger.getLogger(AbstractEventStepController.class.getName()); + } + + /** + * Adds an EventStep + * @see EventStepController#addEventStep(EventStep) + */ + public void addEventStep(EventStep eventStep) { + logger.finer("Adding EventStep to: "+this); + eventSteps.add(eventStep); + } + + /** + * Removes an EventStep + * @see EventStepController#removeEventStep(EventStep) + */ + public void removeEventStep(EventStep eventStep) { + logger.finer("Removing EventStep to: "+this); + eventSteps.remove(eventStep); + } + + /** + * Gets all EventSteps. + * @see EventStepController#getEventSteps() + * @returns Returns all EventSteps. + */ + public List getEventSteps() { + return eventSteps; + } + + /** + * Process all EventSteps of the EventStepController + * Override for other behavior + * @see EventStepController#processEventSteps(Object) + * @param object The object to pass to the EventSteps + * @return The object or null. + */ + public Object processEventSteps(Object object) { + for(EventStep e:getEventSteps()) { + if(object==null) { + return null; + } + object = e.processObject(object); + } + return object; + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/event/AbstractEventStep.java b/src/com/idcanet/foei/event/AbstractEventStep.java new file mode 100644 index 0000000..e71d01b --- /dev/null +++ b/src/com/idcanet/foei/event/AbstractEventStep.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.event; + +/** + * Defines an abstract EventStep + * + * @author Willem Cazander + * @version 1.0 Jan 25, 2006 + */ +abstract public class AbstractEventStep implements EventStep { + +} \ No newline at end of file diff --git a/src/com/idcanet/foei/event/AbstractEventStepController.java b/src/com/idcanet/foei/event/AbstractEventStepController.java new file mode 100644 index 0000000..a0124bb --- /dev/null +++ b/src/com/idcanet/foei/event/AbstractEventStepController.java @@ -0,0 +1,97 @@ +/* + * 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; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +/** + * + * + * @author Willem Cazander + * @version 1.0 Jan 25, 2006 + */ +abstract public class AbstractEventStepController extends AbstractEventStep implements EventStepController +{ + /** The EventStep List */ + private List eventSteps = null; + /** The Logger to log to. */ + private Logger logger = null; + + /** + * Should be implemented by the overriding class. + */ + abstract public Object processObject(Object object) throws ClassCastException; + + /** + * Creates the list and the logger. + */ + public AbstractEventStepController() { + eventSteps = new ArrayList(); + logger = Logger.getLogger(AbstractEventStepController.class.getName()); + } + + /** + * + */ + public void addEventStep(EventStep eventStep) { + logger.finer("Adding EventStep to: "+this); + eventSteps.add(eventStep); + } + + /** + * + */ + public void removeEventStep(EventStep eventStep) { + logger.finer("Removing EventStep to: "+this); + eventSteps.remove(eventStep); + } + + /** + * + */ + public List getEventSteps() { + return eventSteps; + } + + /** + * Calls all EventSteps the processObject method + * until one returns null. + * @param object + * @return + */ + public Object processEventSteps(Object object) { + for(EventStep e:getEventSteps()) { + if(object==null) { + return null; + } + object = e.processObject(object); + } + return object; + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/event/EventInput.java b/src/com/idcanet/foei/event/EventInput.java new file mode 100644 index 0000000..a2a71c4 --- /dev/null +++ b/src/com/idcanet/foei/event/EventInput.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.event; + +import java.io.Serializable; +import java.util.Collection; + +/** + * An Object that implments thius interface can receive events.
+ * Which can be directed at different inputs of the object.
+ * + * @author Willem Cazander + * @version 1.0 01/02/2005 + */ +public interface EventInput extends Serializable { + + /** + * Gets the all input EventPorts.
+ * + * @return An List with the current EventPort's. + */ + public Collection getInputPorts(); + + /** + * Gets an input EventPort by its name + * @param name The name of the eventPort + * @return Returns an input EventPort by its name + */ + public EventPort getInputPort(String name); + + /** + * Process an Object.
+ * @param inputPort The input channel name of this object. + * @param object The object this input needs to process. + */ + public void doEvent(EventPort eventPort,Object object) throws IllegalEventPortNameException; +} \ No newline at end of file diff --git a/src/com/idcanet/foei/event/EventOutput.java b/src/com/idcanet/foei/event/EventOutput.java new file mode 100644 index 0000000..c144bf0 --- /dev/null +++ b/src/com/idcanet/foei/event/EventOutput.java @@ -0,0 +1,54 @@ +/* + * 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; + +import java.util.Collection; +import java.io.Serializable; + +/** + * An Object that implments thius interface can send events to
+ * inputsEvent objects.
+ *
+ * So send en event it most use the defined methods in EventBinding class. + * + * @author Willem Cazander + * @version 1.0 01/02/2005 + */ +public interface EventOutput extends Serializable { + /** + * Gets the current list of valid outputs. + * @return A List with the current EventPort's. + */ + public Collection getOutputPorts(); + + /** + * Gets an OutputPort by its name. + * @param name The name of the output port. + * @return Returns the outputPort + */ + public EventPort getOutputPort(String name); +} \ No newline at end of file diff --git a/src/com/idcanet/foei/event/EventPort.java b/src/com/idcanet/foei/event/EventPort.java new file mode 100644 index 0000000..0682a48 --- /dev/null +++ b/src/com/idcanet/foei/event/EventPort.java @@ -0,0 +1,161 @@ +/* + * 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; + +/** + * Defines an EventPort which can be an input or output for + * traveling object.
+ *
+ * All the public final are for progroming + * + * @author Willem Cazander + * @version 1.0 18/04/2005 + */ +public class EventPort { + + static final public String TRUE = "true"; + static final public String FALSE = "false"; + static final public String INPUT = "input"; + static final public String OUTPUT = "output"; + static final public String PASS = "pass"; + static final public String DROP = "drop"; + + /** The name of the port */ + private String name = null; + /** The type of Object class which can be handled by the port.*/ + private Class objectType = null; + /** The total number of events this port has had. */ + private long eventsPassed = 0; + /** The type of event port */ + private EventPortType eventPortType = null; + /**The EventObject of this port */ + private Object eventObject = null; + /** The immediate if true i*/ + private boolean immediate = false; + + /** + * Contructs an EventPort with an name and a certain type. + *
+ * immediate has 2 defaults depending on the EventPortType of the EventPort.
+ * input=true
+ * output=false
+ * This defines the default behouvier of the foei events and newexecutors
+ * + * @param name The name of the EventPort. + * @param objectType The class type which it accepts. + */ + public EventPort(String name,Class objectType,EventPortType eventPortType,Object eventObject) { + if(name==null) { + throw new NullPointerException("name may not be null."); + } + if(objectType==null) { + throw new NullPointerException("eventPortType may not be null."); + } + if(eventPortType==null) { + throw new NullPointerException("eventPortType may not be null."); + } + if(eventObject==null) { + throw new NullPointerException("eventObject may not be null."); + } + this.name=name; + this.objectType=objectType; + this.eventPortType=eventPortType; + this.eventObject=eventObject; + + if(eventPortType==EventPortType.input) { + immediate=true; + } + if(eventPortType==EventPortType.output) { + immediate=false; + } + + } + + /** + * Returns the name of the EventPort. + * @return The name of the EventPort. + */ + public String getName() { + return name; + } + + /** + * Returns the class of the object this EventPort handleds. + * @return the class of the transfering object. + */ + public Class getObjectClass() { + return objectType; + } + + /** + * Adds the event to the eventsPassed value. + */ + public void addEventsPassed() { + eventsPassed++; + } + + + /** + * The number of events that this port has done. + * @return Returns the number of events of this port. + */ + public long getEventsPassed() { + return eventsPassed; + } + + /** + * Returns the EventPortType + * @return Returns the EventPortType. + */ + public EventPortType getEventPortType() { + return eventPortType; + } + + /** + * Gets the EventObject. + * @return Returns the EventObject. + */ + public Object getEventObject() { + return eventObject; + } + + /** + * Gets the immediate + * @return Returns immediate + */ + public boolean isImmediate() { + return immediate; + } + + /** + * Sets the immediate state of this event port + * @param immediate + */ + public void setImmediate(boolean immediate) { + this.immediate=immediate; + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/event/EventPortType.java b/src/com/idcanet/foei/event/EventPortType.java new file mode 100644 index 0000000..5d98081 --- /dev/null +++ b/src/com/idcanet/foei/event/EventPortType.java @@ -0,0 +1,39 @@ +/* + * 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; + +/** + * EventPortType of an EventPort + * + * @author Willem Cazander + * @version 1.0 Mar 3, 2006 + */ +public enum EventPortType { + + input, + output; +} diff --git a/src/com/idcanet/foei/event/EventStep.java b/src/com/idcanet/foei/event/EventStep.java new file mode 100644 index 0000000..29e1566 --- /dev/null +++ b/src/com/idcanet/foei/event/EventStep.java @@ -0,0 +1,46 @@ +/* + * 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; + +import java.io.Serializable; + +/** + * Process an object an gives an object back. + * + * @author Willem Cazander + * @version 1.0 27/02/2005 + */ +public interface EventStep extends Serializable { + + /** + * Process an object and gives it back. + * + * @param object The Object which need to be processed. + * @returns An object or null if not succesfull. + */ + public Object processObject(Object object) throws ClassCastException; +} \ No newline at end of file diff --git a/src/com/idcanet/foei/event/EventStepController.java b/src/com/idcanet/foei/event/EventStepController.java new file mode 100644 index 0000000..4235596 --- /dev/null +++ b/src/com/idcanet/foei/event/EventStepController.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.event; + +import com.idcanet.foei.event.EventStep; + +import java.io.Serializable; +import java.util.List; + +/** + * The implementing object of this interface.
+ * Gets the possibilty to add/remove EventSteps.
+ * + * @author Willem Cazander + * @version 1.0 28/02/2005 + */ +public interface EventStepController extends Serializable { + + /** + * Adds an EventStep to the object. + * @param eventStep The EventStep to be added. + */ + public void addEventStep(EventStep eventStep); + + /** + * Removes an EventStep of the object. + * @param eventStep The EventStep to be removed. + */ + public void removeEventStep(EventStep eventStep); + + /** + * Gets an List of the EventSteps which are registrated to this object. + * @return The List of EventSteps. + */ + public List getEventSteps(); + + /** + * Executes all EventSteps until there is null or we are done. + * @param object + * @return + */ + public Object processEventSteps(Object object); +} diff --git a/src/com/idcanet/foei/event/IllegalEventPortNameException.java b/src/com/idcanet/foei/event/IllegalEventPortNameException.java new file mode 100644 index 0000000..dac860c --- /dev/null +++ b/src/com/idcanet/foei/event/IllegalEventPortNameException.java @@ -0,0 +1,71 @@ +/* + * 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; + +/** + * May be throw when we try to send to in EventPort that doen't excists. + * + * @author Willem Cazander + * @version 1.0 Feb 4, 2006 + */ +public class IllegalEventPortNameException extends Exception +{ + /** Version 1.0 */ + final static long serialVersionUID = 10l; + + /** + * Constructs an IllegalEventPortNameException without a detail message. + */ + public IllegalEventPortNameException() { + super(); + } + + /** + * Constructs an IllegalEventPortNameException with a detail message. + * @param message The message of this Exception + */ + public IllegalEventPortNameException(String message) { + super(message); + } + + /** + * Creates an IllegalEventPortNameException from a parent exception. + * @param e The parent Exception + */ + public IllegalEventPortNameException(Exception e) { + super(e); + } + + /** + * Creates an IllegalEventPortNameException from a parent exception and a detail message + * @param message The message of this Exception + * @param e The parent Exception + */ + public IllegalEventPortNameException(String message,Exception e) { + super(message,e); + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/event/package.html b/src/com/idcanet/foei/event/package.html new file mode 100644 index 0000000..9a13aa3 --- /dev/null +++ b/src/com/idcanet/foei/event/package.html @@ -0,0 +1,61 @@ + + + + + + +Provides abstract classes and interfaces to send/receive events.
+ +

Package Specification

+ +
    +
  • Full J2SE 5 compatible
  • +
  • Small package
  • +
+ + +

Related Documentation

+ +None. + + + + + \ No newline at end of file diff --git a/src/com/idcanet/foei/server/FoeiContextManager.java b/src/com/idcanet/foei/server/FoeiContextManager.java new file mode 100644 index 0000000..a5a6c2f --- /dev/null +++ b/src/com/idcanet/foei/server/FoeiContextManager.java @@ -0,0 +1,112 @@ +/* + * 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; + +import com.idcanet.foei.core.FoeiConfigurator; +import com.idcanet.foei.core.FoeiContext; +import com.idcanet.foei.core.impl.FoeiConfiguratorImpl; + +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Manages the different FoeiContext. + * + * @author Willem Cazander + * @version 1.0 Feb 6, 2006 + */ +public class FoeiContextManager +{ + /** The logger to log to. */ + private Logger logger = null; + /** All FoeiContext */ + private Map contexts = null; + + /** + * Inits the logger and the FoeiContext storage. + */ + public FoeiContextManager() { + logger = Logger.getLogger(FoeiContextManager.class.getName()); + contexts = new HashMap(2); + } + + /** + * Create an FoeiContext. + * @param properties The properties of the FoeiContext. + */ + public void createFoeiContext(Map properties) { + FoeiConfigurator config = null; + try { + config = (FoeiConfigurator) FoeiConfigurator.DEFAULT_FOEI_CONFIGURATOR.newInstance(); + logger.info("Building FoeiContext: "+FoeiConfiguratorImpl.getContextName(properties)); + FoeiContext context = config.buildFoeiContext(properties); + addFoeiContext(context); + } catch (Exception e) { + logger.log(Level.WARNING,"Error while starting FoeiContext: "+e.getMessage(),e); + } + } + + /** + * Add an FoeiContext + * @param foeiContext The FoeiContext to add. + */ + public void addFoeiContext(FoeiContext foeiContext) { + if(foeiContext==null) { + throw new NullPointerException("FoeiContext may not be null."); + } + contexts.put(foeiContext.getName(),foeiContext); + } + + /** + * USE AS LESS AS POSIBLE, MOSTLY NOT !!
+ * + * Be aware that a lot of functions in Foei depent on the + * thread locale being injected in the current thread. + * + * For sake of OO dividing layers its not recommened to do Foei Logic + * in the request/event/etc thread. + * + * Gets an FoeiContext by its name. + * @param name The name of the FoeiContext + * @return Returns the FoeiContext or null if none was found by its name. + */ + public FoeiContext getFoeiContext(String name) { + return contexts.get(name); + } + + + /** + * Destroys all FoeiContexts. + */ + public void destroyAll() { + for(FoeiContext context:contexts.values()) { + context.destroy(); + } + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/server/FoeiContextManagerFactory.java b/src/com/idcanet/foei/server/FoeiContextManagerFactory.java new file mode 100644 index 0000000..7528675 --- /dev/null +++ b/src/com/idcanet/foei/server/FoeiContextManagerFactory.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.server; + +/** + * Provides the method to get the FoeiContextManager + * + * @author Willem Cazander + * @version 1.0 Feb 6, 2006 + */ +public class FoeiContextManagerFactory +{ + /** */ + static private FoeiContextManager foeiContextManager = null; + + /** + * Gets the FoeiContextManager + * @return Returns the FoeiContextManager + */ + static public FoeiContextManager getFoeiContextManager() { + if(foeiContextManager==null) { + throw new IllegalStateException("no FoeiContextManager has been set."); + } + return foeiContextManager; + } + + /** + * Sets an FoeiContextManager.
+ * note: + * May only be set once !. + * + * @param foeiContextManager + */ + static public void setFoeiContextManager(FoeiContextManager foeiContextManager) { + if(foeiContextManager==null) { + throw new NullPointerException("foeiContextManager may not be null."); + } + if(FoeiContextManagerFactory.foeiContextManager!=null) { + throw new IllegalStateException("foeiContextManager may only be set once."); + } + FoeiContextManagerFactory.foeiContextManager=foeiContextManager; + } +} \ No newline at end of file diff --git a/src/com/idcanet/foei/server/package.html b/src/com/idcanet/foei/server/package.html new file mode 100644 index 0000000..97ab0e0 --- /dev/null +++ b/src/com/idcanet/foei/server/package.html @@ -0,0 +1,55 @@ + + + + + + +Foei server objects
+ + + +

Related Documentation

+ +None. + + + + + \ No newline at end of file