3
0
Fork 0

[svn r373] moved to maven

This commit is contained in:
willemc 2008-12-16 14:51:02 +01:00
parent 53855d8aae
commit 8ec7e55ebb
127 changed files with 10761 additions and 11 deletions

View file

@ -1,16 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="tests"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/idcanet-x4o-bin.jar"/>
<classpathentry kind="lib" path="lib/juel-2.1.0-rc1.jar"/>
<classpathentry kind="lib" path="lib/juel-2.1.0-rc1-impl.jar"/>
<classpathentry kind="lib" path="lib/jms-api.jar"/>
<classpathentry kind="lib" path="lib/servlet-api.jar"/>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="melibrary.com.genuitec.eclipse.j2eedt.core.MYECLIPSE_JAVAEE_5_CONTAINER"/>
<classpathentry kind="var" path="jboss4/jboss-jca.jar"/>
<classpathentry kind="var" path="jboss4/jboss-j2ee.jar"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View file

@ -10,8 +10,14 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,8 @@
#Sun Dec 07 05:31:33 CET 2008
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
includeModules=false
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
version=1

23
LICENSE.txt Normal file
View file

@ -0,0 +1,23 @@
Copyright 2004-2009 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.

248
pom.xml Normal file
View file

@ -0,0 +1,248 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.idcanet</groupId>
<artifactId>foei</artifactId>
<packaging>jar</packaging>
<version>0.8-SNAPSHOT</version>
<name>foei</name>
<description>Creates an easy xml layer for objects and creating your own xml language implementions.</description>
<url>http://www.x4o.org/foei</url>
<organization>
<name>IDCA</name>
<url>http://www.idca.nl</url>
</organization>
<issueManagement>
<system>Trac</system>
<url>https://decaid.idca.nl/trac/oss/</url>
</issueManagement>
<scm>
<connection>scm:svn:https://decaid.idca.nl/svn/oss/com.idcanet.foei/</connection>
<developerConnection>scm:svn:https://decaid.idca.nl/svn/oss/com.idcanet.foei/</developerConnection>
<url>https://decaid.idca.nl/svn/oss/com.idcanet.foei/</url>
</scm>
<developers>
<developer>
<id>willem.cazander</id>
<name>Willem Cazander</name>
<email>w.cazander@gmail.com</email>
<organization>IDCA</organization>
<timezone>+2</timezone>
<roles>
<role>Project Manager</role>
<role>Architect</role>
</roles>
</developer>
<developer>
<id>sqrbass</id>
<name>Bas van Oostveen</name>
<email></email>
<organization>IDCA</organization>
<timezone>+2</timezone>
<roles>
<role>Architect Reviewer</role>
</roles>
</developer>
</developers>
<repositories>
<repository>
<id>jboss</id>
<name>JBoss Repository Switchboard</name>
<layout>default</layout>
<url>http://repository.jboss.com/maven2/</url>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<dependencies>
<!-- X4O dependcy -->
<dependency>
<groupId>com.idcanet.x4o</groupId>
<artifactId>x4o-main</artifactId>
<version>0.8-SNAPSHOT</version>
</dependency>
<!-- Serv5 depency -->
<dependency>
<groupId>com.idcanet.serv5</groupId>
<artifactId>serv5-main</artifactId>
<version>0.6-SNAPSHOT</version>
</dependency>
<!-- Unit tests cases -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.8</version>
<scope>test</scope>
<classifier>jdk15</classifier>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Compile source -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<!-- Generate site -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>2.0-beta-7</version>
<configuration>
<outputEncoding>UTF-8</outputEncoding>
</configuration>
</plugin>
<!-- Run tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4</version>
<configuration></configuration>
</plugin>
<!-- Build documention -->
<plugin>
<groupId>com.agilejava.docbkx</groupId>
<artifactId>docbkx-maven-plugin</artifactId>
<!-- Any parameters common to both HTML and PDF go here -->
<configuration>
<sourceDirectory>src/main/docbook/</sourceDirectory>
<targetDirectory>target/site/docbook/</targetDirectory>
<!-- input config -->
<includes>*.xml</includes>
<!-- <foCustomization>src/main/config/docbook-fo.xsl</foCustomization> -->
<!-- runtime config -->
<xincludeSupported>true</xincludeSupported>
<entities><!-- pom vars to docbook vars -->
<entity>
<name>version</name>
<value>${version}</value>
</entity>
</entities>
<!-- output config -->
<chunkedOutput>true</chunkedOutput>
<!-- <htmlStylesheet>http://.....</htmlStylesheet> -->
</configuration>
<executions>
<execution>
<id>create-pdf-docs</id>
<phase>site</phase>
<goals><goal>generate-pdf</goal></goals>
<configuration>
<!-- Any parameters specific to the PDF version go here -->
<imgSrcPath>file:///${basedir}/src/main/docbook/</imgSrcPath>
</configuration>
</execution>
<execution>
<id>create-html-docs</id>
<phase>site</phase>
<goals><goal>generate-html</goal></goals>
<configuration>
<!-- This copies content (images, etc) for the HTML version -->
<preProcess>
<copy todir="target/site/docbook/images">
<fileset dir="src/main/docbook/images"/>
</copy>
</preProcess>
<!-- Any parameters specific to HTML version go here -->
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.docbook</groupId>
<artifactId>docbook-xml</artifactId>
<version>4.4</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>target/site</outputDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>summary</report>
<report>dependencies</report>
<report>project-team</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jxr-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.4.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<version>2.0</version>
<configuration>
<xmlPath>${basedir}/src/site/changes.xml</xmlPath>
</configuration>
<reportSets>
<reportSet>
<reports><report>changes-report</report></reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<!-- END -->
</project>

View file

@ -0,0 +1,72 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.components.io;
import com.idcanet.foei.event.AbstractEventInputStepController;
import com.idcanet.foei.event.EventPort;
import com.idcanet.foei.event.EventPortType;
import com.idcanet.foei.event.EventStep;
import com.idcanet.foei.event.IllegalEventPortNameException;
/**
* Prints the EventSteps to the System.err
*
* @author Willem Cazander
* @version 1.0 Jan 25, 2006
*/
public class ErrorOutput extends AbstractEventInputStepController
{
/** v1.0 */
static final long serialVersionUID = 10l;
/**
* Creates an ErrorOutput
*/
public ErrorOutput() {
addInputPort(EventPort.INPUT);
}
// ----------- EventInput
public void doEvent(EventPort eventPort,Object object) throws IllegalEventPortNameException {
if(EventPortType.input!=eventPort.getEventPortType()) {
throw new IllegalEventPortNameException("Not excisting input EventPort: "+eventPort.getName());
}
System.err.println(processEventSteps(object));
}
public Object processEventSteps(Object object) {
StringBuffer buff = new StringBuffer();
for(EventStep e:getEventSteps()) {
if(object==null) {
return null;
}
buff.append((String)e.processObject(object));
}
return buff;
}
}

View file

@ -0,0 +1,36 @@
package com.idcanet.foei.components.io;
/*
import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
public class FileOutput extends AbstractEventInput
{
static final String INPUT = "input";
private ArrayList printers = new ArrayList(4);
public FileOutput()
{
inputList.add(INPUT);
}
// ----------- EventInput
public void doEvent(String inputName,Object object)
{
Iterator printerWalker = printers.iterator();
//System.out.print("STDOUT:");
while(printerWalker.hasNext())
{
EventStep eventStep = (EventStep)printerWalker.next();
String out = (String)eventStep.processObject(object);
System.out.print(out);
}
System.out.println("");
}
}
*/

View file

@ -0,0 +1,73 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.components.io;
import com.idcanet.foei.event.AbstractEventInputStepController;
import com.idcanet.foei.event.EventPort;
import com.idcanet.foei.event.EventPortType;
import com.idcanet.foei.event.EventStep;
import com.idcanet.foei.event.IllegalEventPortNameException;
/**
* Prints the EventSteps to the System.out
*
* @author Willem Cazander
* @version 1.0 Jan 25, 2006
*/
public class StandardOutput extends AbstractEventInputStepController {
/** v1.0 */
static final long serialVersionUID = 10l;
/**
* Creates an StandardOutput
*
*/
public StandardOutput() {
addInputPort(EventPort.INPUT);
}
// ----------- EventInput
public void doEvent(EventPort eventPort,Object object) throws IllegalEventPortNameException {
if(EventPortType.input!=eventPort.getEventPortType()) {
throw new IllegalEventPortNameException("Not excisting input EventPort: "+eventPort.getName());
}
System.out.println(processEventSteps(object));
}
public Object processEventSteps(Object object) {
StringBuffer buff = new StringBuffer();
for(EventStep e:getEventSteps()) {
if(object==null) {
return null;
}
buff.append((String)e.processObject(object));
}
return buff;
}
}

View file

@ -0,0 +1,106 @@
/*
* 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 (process.getWorkQueue().isEmpty()==false) {
logger.info("WorkQueue not empty sleeping a bit and sending retrigger myself q="+process.getWorkQueue().size()+" for proc: "+process.getName());
try {
Thread.sleep(delayTime+500); // add some minual d
} catch (Exception e) {
logger.log(Level.WARNING,"Error sleeping: "+e.getMessage(),e);
}
process.executeEvent(getInputPort(EventPort.INPUT), "null");
return;
}
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());
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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 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;
/**
* 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 (int i=0;i<getEventSteps().size();i++) {
EventStep e = getEventSteps().get(i); // faster then useing iterator object in j5 for loop
if(o==null) {
return null;
}
o = e.processObject(object);
}
// Check for for last(or only) EventStep
if(o==null) {
return null;
}
return object;
}
}

View file

@ -0,0 +1,105 @@
/*
* 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.IllegalEventPortNameException;
import com.idcanet.x4o.impl.DefaultElementParameterHelper;
/**
* 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;
private DefaultElementParameterHelper helper = null;
/**
* Creates an SetBeanProperty
*/
public GetBeanProperty() {
addInputPort(EventPort.INPUT,Object.class);
//addInputPort(PROPERTY,Object.class);
addOutputPort(EventPort.OUTPUT);
helper = new DefaultElementParameterHelper();
}
/**
* 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 = helper.getParameter(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;
}
}

View file

@ -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<Class<?>,Object> 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<Class<?>,Object>(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);
}
}

View file

@ -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);
}
}

View file

@ -0,0 +1,104 @@
/*
* 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.IllegalEventPortNameException;
import com.idcanet.x4o.impl.DefaultElementParameterHelper;
/**
* 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;
private DefaultElementParameterHelper helper = null;
/**
* Creates an SetBeanProperty
*/
public SetBeanProperty() {
addInputPort(EventPort.INPUT,Object.class);
addInputPort(PROPERTY,Object.class);
addOutputPort(EventPort.OUTPUT);
helper = new DefaultElementParameterHelper();
}
/**
* 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 {
helper.setParameter(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;
}
}

View file

@ -0,0 +1,55 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html 1.00
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.
-->
</head>
<body bgcolor="white">
Some wrappers for standaard java object.<br/>
<!--
<ul>
<li><a href="">hgj</a>
</ul>
-->
<h2>Related Documentation</h2>
None.
<!--
For overviews, tutorials, examples, guides, and tool documentation, please see:
<ul>
<li><a href="http://foei.idca.nl/docs/jmx/example1">Example 1</a>
</ul>
-->
<!-- Put @see and @since tags down here. -->
</body>
</html>

View file

@ -0,0 +1,64 @@
package com.idcanet.foei.components.logging;
/*
package com.mbuyu.foei.handlers.log4j;
import java.net.*;
import java.io.*;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Layout;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.Layout;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.WriterAppender;
import org.apache.log4j.net.SocketNode;
public class RequestCollector implements Runnable {
private Socket reqSocket;
private SocketNode reqNode;
private String host;
private int port;
static final String fileName = "rtrace";
static final Logger logger = Logger.getLogger("RequestCollector.class");
public RequestCollector (int port, String host) {
super();
this.host = host;
this.port = port;
}
public void run() {
try {
BasicConfigurator.configure();
PrintWriter writer = new PrintWriter (new FileWriter(fileName));
Layout layout = new PatternLayout("%d{ABSOLUTE} %c{1} %m\n");
WriterAppender appender = new WriterAppender(layout, writer);
appender.setImmediateFlush(true);
LogManager.getRootLogger().removeAllAppenders();
LogManager.getRootLogger().addAppender(appender);
appender.activateOptions();
logger.addAppender(appender);
reqSocket = new Socket(host, port);
System.out.println("Created Socket");
reqNode = new SocketNode(reqSocket, LogManager.getLoggerRepository());
System.out.println("Created SocketNode");
new Thread(reqNode).start();
System.out.println("After thread (reqNode)");
} catch (Exception e) {
e.printStackTrace();
System.out.println(e);
}
}
public static void main (String args[]) {
System.out.println("B4 Starting");
RequestCollector rq = new RequestCollector(9998, "some-host");
new Thread(rq).start();
System.out.println("Completed");
}
}
*/

View file

@ -0,0 +1,64 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.components.logging;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
/**
*
*
* @author Willem Cazander
* @version 1.0 Jan 25, 2006
*/
public class LoggerHandler extends Handler {
private Logger logger = Logger.getLogger(this.getClass().getName());
private LoggerInput loggerInput = null;
public LoggerHandler(LoggerInput loggerInput) {
this.loggerInput=loggerInput;
logger.addHandler(this);
}
// ------------ handler
public void publish(LogRecord record) {
HashMap<String,String> event = new HashMap<String,String>();
event.put("message",record.getMessage());
event.put("level",record.getLevel().getName());
loggerInput.sendMessage(event);
}
public void flush() {
}
public void close() {
}
}

View file

@ -0,0 +1,65 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.components.logging;
import com.idcanet.foei.core.FoeiProcessFactory;
import com.idcanet.foei.event.AbstractEventOutput;
import com.idcanet.foei.event.EventPort;
import java.util.Map;
/**
* Reseives java logging messages
*
* @author Willem Cazander
* @version 1.0 Jan 25, 2006
*/
public class LoggerInput extends AbstractEventOutput {
/** v1.0 */
static final long serialVersionUID = 10l;
/** */
static final String OUTPUT = "output";
/**
* Creates an LoggerInput
*
*/
public LoggerInput() {
// define an outpur source.
addOutputPort(OUTPUT,Map.class);
new LoggerHandler(this);
}
/**
*
* @param event
*/
public void sendMessage(Map<String,String> event) {
FoeiProcessFactory.getFoeiProcess().executeEvent(getOutputPort(EventPort.OUTPUT),event);
}
}

View file

@ -0,0 +1,55 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html 1.00
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.
-->
</head>
<body bgcolor="white">
Some EventObjects for log handing.<br/>
<!--
<ul>
<li><a href="">hgj</a>
</ul>
-->
<h2>Related Documentation</h2>
None.
<!--
For overviews, tutorials, examples, guides, and tool documentation, please see:
<ul>
<li><a href="http://foei.idca.nl/docs/jmx/example1">Example 1</a>
</ul>
-->
<!-- Put @see and @since tags down here. -->
</body>
</html>

View file

@ -0,0 +1,79 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.components.steps.filters;
import com.idcanet.foei.event.AbstractEventStepController;
/**
* Filters an object and checks for the className.
*
* @author Willem Cazander
* @version 1.0 26/01/2005
*/
public class ClassFilter extends AbstractEventStepController {
/** v1.0 */
static final long serialVersionUID = 10l;
/** The class name to match */
private String className = null;
/**
* Sets the className which the filtered object has to have.
* @param className The className.
*/
public void setClassName(String className) {
this.className=className;
}
/**
* Returns the className on which this filter filters.
* @return The className.
*/
public String getClassName() {
return className;
}
/**
* Process an object.<br>
* This checks if the objects class equals that of the className.
* @return The object or null is not succesfull.
*/
public Object processObject(Object object) {
if(object==null) {
return null;
}
Class<?>[] classes = object.getClass().getClasses();
for(int i=0;i<classes.length;i++) {
if(classes[i].getName().equals(className)) {
Object object2 = processEventSteps(object);
return object2;
}
}
// no match found.
return null;
}
}

View file

@ -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.components.steps.filters;
import com.idcanet.foei.event.AbstractEventStepController;
import java.util.Date;
/**
* Filters an Date object.
*
* @author Willem Cazander
* @version 1.0 26/01/2005
*/
public class DateFilter extends AbstractEventStepController {
/** v1.0 */
static final long serialVersionUID = 10l;
private Date minDate=null;
private Date maxDate=null;
public void setMinDate(Date minDate) {
this.minDate=minDate;
}
public Date getMinDate() {
return minDate;
}
public void setMaxDate(Date maxDate) {
this.maxDate=maxDate;
}
public Date getMaxDate() {
return maxDate;
}
public Object processObject(Object object) {
processEventSteps(object);
return object;
}
}

View file

@ -0,0 +1,96 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.components.steps.filters;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Comparator;
import java.util.Locale;
/**
*
*
* @author Willem Cazander
* @version 1.0 Feb 9, 2006
*/
@SuppressWarnings("unchecked")
public class NumberComparator implements Comparator {
private Locale locale = null;
/**
* @return Returns the locale.
*/
public Locale getLocale() {
return locale;
}
/**
* @param locale The locale to set.
*/
public void setLocale(Locale locale) {
this.locale = locale;
}
/**
* Compares two String as number.
* @param o1
* @param o2
* @return
* @see Comparator#compare(T, T)
*/
public int compare(Object o1, Object o2) {
Double d1 = getDoubleValue((String)o1,locale);
Double d2 = getDoubleValue((String)o2,locale);
return d1.compareTo(d2);
}
/**
* Converts an String to an Number wich is converted to a Double
* @param test The String to parse.
* @param locale The locale of the numberFormat.
* @return An Double
*/
static public Double getDoubleValue(String text,Locale locale) {
try {
NumberFormat nf = NumberFormat.getInstance(locale);
Number n = nf.parse(text);
if(n instanceof Double) {
return (Double)n;
}
if(n instanceof Integer) {
return ((Integer)n).doubleValue();
}
if(n instanceof Long) {
return ((Long)n).doubleValue();
}
} catch(ParseException pe) {
} catch (NumberFormatException e) {
}
return 0.0;
}
}

View file

@ -0,0 +1,115 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.components.steps.filters;
import com.idcanet.foei.event.AbstractEventStepController;
import java.util.Locale;
/**
* Checks when the object is an string/number for the min/max of the number
*
* @author Willem Cazander
* @version 1.0 Feb 9, 2006
*/
public class NumberFilter extends AbstractEventStepController {
/** */
static final long serialVersionUID = 10l;
/** */
private Locale locale = null;
/** */
private String minValue = null;
/** */
private String maxValue = null;
/**
* @return Returns the locale.
*/
public Locale getLocale() {
return locale;
}
/**
* @param locale The locale to set.
*/
public void setLocale(Locale locale) {
this.locale = locale;
}
/**
* @return Returns the maxValue.
*/
public String getMaxValue() {
return maxValue;
}
/**
* @param maxValue The maxValue to set.
*/
public void setMaxValue(String maxValue) {
if("".equals(maxValue)) {
maxValue=null;
}
this.maxValue = maxValue;
}
/**
* @return Returns the minValue.
*/
public String getMinValue() {
return minValue;
}
/**
* @param minValue The minValue to set.
*/
public void setMinValue(String minValue) {
if("".equals(minValue)) {
minValue=null;
}
this.minValue = minValue;
}
/**
*
*/
public Object processObject(Object object) {
if(locale==null) {
locale=Locale.getDefault();
}
NumberComparator c = new NumberComparator();
c.setLocale(locale);
if(minValue!=null && c.compare(object,minValue)<0) {
return null;
}
if(maxValue!=null && c.compare(object,maxValue)>0) {
return null;
}
return object;
}
}

View file

@ -0,0 +1,150 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.components.steps.filters;
import com.idcanet.foei.event.AbstractEventStepController;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Filters an String object.
*
* @author Willem Cazander
* @version 1.0 26/01/2005
*/
public class StringFilter extends AbstractEventStepController {
/** v1.0 */
static final long serialVersionUID = 10l;
private int minLength=0;
private int maxLength=0;
private Pattern pattern = null;
// -------------- (bean)properties.
/**
* Sets the regulare expression on which this object filters an String.<br>
* <br>
* When set to <code>Null</code> matching is disabled.<br>
*
* @param regex The regulare expression to match to.
*/
public void setRegEx(String regex) {
pattern = Pattern.compile(regex);
}
/**
* Returns the current regulare expression.
* @return The regulare expression.
*/
public String getRegEx() {
if(pattern==null) {
return null;
}
return pattern.pattern();
}
/**
* Set the minimal length the filtered object has to be.<br>
* <br>
* When set to -1 testing is disabled.<br>
*
* @param minLength The minimal length to match.
*/
public void setMinLength(int minLength) {
this.minLength=minLength;
}
/**
* Returns the current minimal length of this filter.
* @return The minimal length.
*/
public int getMinLength() {
return minLength;
}
/**
* Set the maximal length of the filters string object.<br>
* <br>
* When set to -1 testing is disabled.<br>
*
* @param maxLength
*/
public void setMaxLength(int maxLength) {
this.maxLength=maxLength;
}
/**
* Returns the current maximal length.
* @return the maximal length.
*/
public int getMaxLength() {
return maxLength;
}
// -------------- eventStep
/**
* Filters an Object.
* If it not an String then null will be returned.
* Likewise when the String object has not matched to an certain
* propertie then also null will be returned.
*
* @param object The Object thats get filtered.
* @return null if object was not mached else the object returns.
*/
public Object processObject(Object object) {
if(!(object instanceof String)) {
return null;
}
String string = (String)object;
if(pattern==null) {
}
if(pattern!=null) {
// test if regex matches
Matcher m = pattern.matcher(string);
if(!m.find()) {
return null;
}
}
// test min length
if(minLength!=0 && string.length()>minLength) {
return null;
}
// test max length
if(maxLength!=0 && string.length()<maxLength) {
return null;
}
object = processEventSteps(object);
return object;
}
}

View file

@ -0,0 +1,55 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html 1.00
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.
-->
</head>
<body bgcolor="white">
EventSteps which filter an Object.<br/>
<!--
<ul>
<li><a href="">hgj</a>
</ul>
-->
<h2>Related Documentation</h2>
None.
<!--
For overviews, tutorials, examples, guides, and tool documentation, please see:
<ul>
<li><a href="http://foei.idca.nl/docs/jmx/example1">Example 1</a>
</ul>
-->
<!-- Put @see and @since tags down here. -->
</body>
</html>

View file

@ -0,0 +1,82 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.components.steps.lang;
import com.idcanet.foei.event.AbstractEventStepController;
import com.idcanet.x4o.impl.DefaultElementParameterHelper;
/**
* Gets the property of an java bean.
*
* @author Willem Cazander
* @version 1.0 Feb 9, 2006
*/
public class GetBeanPropertyStep extends AbstractEventStepController {
/** v1.0 */
static final long serialVersionUID = 10l;
/** Holds the key which contains the object in the map. */
private String property = null;
private DefaultElementParameterHelper helper = null;
public GetBeanPropertyStep() {
helper = new DefaultElementParameterHelper();
}
//----------- get/set functions
public void setProperty(String property) {
this.property=property;
}
public String getProperty() {
return property;
}
// -------------------- EventStep
/**
* Proces an Object, when property is correcly found then
* it is processed by the eventSteps of the object.
*/
public Object processObject(Object object) {
if(property==null) {
return null;
}
Object result = null;
try {
result = helper.getParameter(object,property);
} catch (Exception e) {
//logger.log(Level.WARNING,"property:"+property+" is not an property of object: "+object.getClass().getName(),e);
e.printStackTrace();
return null;
}
return processEventSteps(result);
}
}

View file

@ -0,0 +1,82 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.components.steps.lang;
import com.idcanet.foei.event.AbstractEventStepController;
import java.util.List;
/**
* Gets an Value out of an List
*
* @author Willem Cazander
* @version 1.0 Feb 9, 2006
*/
public class ListValue extends AbstractEventStepController {
/** v1.0 */
static final long serialVersionUID = 10l;
/** Holds the index which contains the object in the map. */
private String index = null;
static private final String FIRST = "FIRST";
static private final String LAST = "LAST";
// bean
public void setIndex(String index) {
this.index=index;
}
public String getIndex() {
return index;
}
@SuppressWarnings("unchecked")
public Object processObject(Object object) {
if(!(object instanceof List)) {
return null;
}
List list = (List)object;
if(FIRST.equalsIgnoreCase(index)) {
return processEventSteps(list.get(0));
}
if(LAST.equalsIgnoreCase(index)) {
return processEventSteps(list.get(list.size()));
}
try {
int listIndex = new Integer(index);
return processEventSteps(list.get(listIndex));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View file

@ -0,0 +1,89 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.components.steps.lang;
import com.idcanet.foei.event.AbstractEventStepController;
import java.util.Map;
/**
* This EventStep can have nesting EventSteps.
* It it get the object out of the map object which is processed and
* let is process by an added EventStep object.
*
* @author Willem Cazander
* @version 1.0 28/03/2004
*/
public class MapValue extends AbstractEventStepController {
/** v1.0 */
static final long serialVersionUID = 10l;
/** Holds the key which contains the object in the map. */
private String key = null;
//----------- get/set functions
/**
* Sets the key which is used to lookup an object in an Map.<br>
* Which gets returned by the processObject() of EventStep.<br>
* @param key The key of an object in an Map.
*/
public void setKey(String key) {
this.key=key;
}
/**
* Gets the key of the Map.
* @return The current key.
*/
public String getKey() {
return key;
}
// -------------------- EventStep
/**
* Process an object.<br>
* This is done by the EventStep Object which is added.<br>
* <Br>
* Current implementation returns only the object which is returned<br>
* by the last EventStep in the List.<br>
*
*/
@SuppressWarnings("unchecked")
public Object processObject(Object object) {
if(key==null) {
return null;
}
Map map = (Map)object;
object = map.get(key);
return processEventSteps(object);
}
}

View file

@ -0,0 +1,57 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html 1.00
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.
-->
</head>
<body bgcolor="white">
EventSteps which Gets of object from an Object.<br/>
<h2>Package Specification</h2>
<!--
<ul>
<li><a href="">hgj</a>
</ul>
-->
<h2>Related Documentation</h2>
None.
<!--
For overviews, tutorials, examples, guides, and tool documentation, please see:
<ul>
<li><a href="http://foei.idca.nl/docs/jmx/example1">Example 1</a>
</ul>
-->
<!-- Put @see and @since tags down here. -->
</body>
</html>

View file

@ -0,0 +1,88 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.components.steps.printers;
import com.idcanet.foei.event.AbstractEventStep;
import java.util.Date;
import java.text.SimpleDateFormat;
/**
* Print an <code>Date</code> object.
*
* @author Willem Cazander
* @version 1.0 26/01/2005
*/
public class DatePrinter extends AbstractEventStep
{
/** v1.0 */
static final long serialVersionUID = 10l;
/** An SimpleDateFormat formated date format template string */
private SimpleDateFormat dateFormat=null;
/**
* Emty constructor
*/
public DatePrinter() {
}
/**
* Set the format in which the Date object is printed.
* @param pattern An SimpleDateFormat formatted string.
*/
public void setSimpleDateFormat(String pattern) {
// else use defaults !!!
// TODO log this event ... but don't let is stop it.
try {
dateFormat = new SimpleDateFormat(pattern);
} catch (NullPointerException npe) {
dateFormat = new SimpleDateFormat();
} catch (IllegalArgumentException iae) {
dateFormat = new SimpleDateFormat();
}
}
/**
* Returns the SimpleDateFormat formatted string being used to format an Date.
* @return The SimpleDateFormat string.
*/
public String getSimpleDateFormat() {
return dateFormat.toPattern();
}
/**
* Prints an Date object.<br>
* <br>
* If object is not an Date "" is printed.<br>
*
* @param object The Object being printed.
* @return The String format of the object.
*/
public Object processObject(Object object) {
Date date = (Date)object;
return dateFormat.format(date);
}
}

View file

@ -0,0 +1,98 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.components.steps.printers;
import com.idcanet.foei.event.AbstractEventStep;
/**
* Prints the toString of any java object.<br>
* With an optioneal pre/post-fix.<br>
*
* @author Willem Cazander
* @version 1.0 17/11/2004
*/
public class DefaultPrinter extends AbstractEventStep
{
/** v1.0 */
static final long serialVersionUID = 10l;
/** The preFix */
private String preFix = null;
/** The postFix */
private String postFix = null;
/**
* Sets the prefix
* @param preFix The String printed before the object.
*/
public void setPreFix(String preFix) {
this.preFix=preFix;
}
/**
* Returns the prefix.
* @return The String printed before the object.
*/
public String getPreFix() {
return preFix;
}
/**
* Sets the postfix.
* @param postFix The String printed after the object.
*/
public void setPostFix(String postFix) {
this.postFix=postFix;
}
/**
* Returns the postfix.
* @return The String printed after the object.
*/
public String getPostFix() {
return postFix;
}
/**
*This methode returns an String represantation of an object
*in the default toSting() of the object.
*@param object The object which need to be printed.
*@return The string represantation of the object.
*/
public Object processObject(Object object) {
String returnString = "";
if(preFix!=null) {
returnString = preFix;
}
if(object!=null) {
returnString += object.toString();
}
if(postFix!=null) {
returnString += postFix;
}
return returnString;
}
}

View file

@ -0,0 +1,61 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html 1.00
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.
-->
</head>
<body bgcolor="white">
EventSteps which print objects<br/>
<h2>Package Specification</h2>
<ul>
<li>Full J2SE 5 compatible</li>
<li>Small package</li>
</ul>
<!--
<ul>
<li><a href="">hgj</a>
</ul>
-->
<h2>Related Documentation</h2>
None.
<!--
For overviews, tutorials, examples, guides, and tool documentation, please see:
<ul>
<li><a href="http://foei.idca.nl/docs/jmx/example1">Example 1</a>
</ul>
-->
<!-- Put @see and @since tags down here. -->
</body>
</html>

View file

@ -0,0 +1,50 @@
/*
* 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;
/**
* Reuables EventExecutor wich are executed
* in the EcentExecutorManager
*
* @author Willem Cazander
* @version 1.0 Jan 19, 2006
*/
public interface EventExecutor extends Runnable {
/**
* Sets the foei process
* @param object
*/
public void setFoeiProcess(FoeiProcess foeiProcess);
/**
* Returns true when this EventExecutor is ready
* @return
*/
public boolean isReady();
}

View file

@ -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<br/>
* 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<br/>
* These are call when a new Thread is created or stops in the Threadpool of<br/>
* the EventExecutorManager.<br/>
* @return Returns all EventThreadListeners
*/
public List<EventThreadListener> 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;
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -0,0 +1,83 @@
/*
* 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 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<String,String> properties) throws FoeiContextBuildingException;
}

View file

@ -0,0 +1,75 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core;
import java.util.Map;
import javax.naming.Context;
/**
* Defines the FoeiContext.<br/>
*
* @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 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<String,String> getStartProperties();
/**
* Gets the FoeiProcessManager
* @return Returns the FoeiProcessManager
*/
public FoeiProcessManager getFoeiProcessManager();
/**
* Stops all stuff in this context
*/
public void destroy();
}

View file

@ -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);
}
}

View file

@ -0,0 +1,85 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core;
import com.idcanet.foei.event.EventPort;
/**
* Message block used in work queue to store non-immatiate port events.
*
* @author Willem Cazander
* @version 1.0 Apr 9, 2008
*/
public class FoeiPortMessage {
/** The event obect. */
private Object eventObject = null;
/** The eventport */
private EventPort eventPort = null;
public FoeiPortMessage() {
}
public FoeiPortMessage(Object eventObject,EventPort eventPort) {
setEventObject(eventObject);
setEventPort(eventPort);
}
/**
* @return the eventObject
*/
public Object getEventObject() {
return eventObject;
}
/**
* @param eventObject the eventObject to set
*/
public void setEventObject(Object eventObject) {
if (eventObject==null) {
throw new NullPointerException("May not set null eventObject");
}
this.eventObject = eventObject;
}
/**
* @return the eventPort
*/
public EventPort getEventPort() {
return eventPort;
}
/**
* @param eventPort the eventPort to set
*/
public void setEventPort(EventPort eventPort) {
if (eventPort==null) {
throw new NullPointerException("May not set null eventPort");
}
this.eventPort = eventPort;
}
}

View file

@ -0,0 +1,80 @@
/*
* 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.Queue;
import java.util.Set;
import javax.naming.Context;
/**
* Defines an FoeiProcess interface<br/>
* The FoeiProcess is only accesable from an injected thread local.<br/>
* From the FoeiProcess we can bind object and fire events.<br/>
*
* @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();
/**
* Returns the work queue for this foei process
* @return
*/
public Queue<FoeiPortMessage> getWorkQueue();
public Set<EventExecutor> getExecutors();
}

View file

@ -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.<br/>
* 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<FoeiProcess> threadLocal = new ThreadLocal<FoeiProcess>();
/**
* 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);
}
}

View file

@ -0,0 +1,42 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core;
/**
* Gets called when process is created or destroyed.<br/>
*
*
* @author Willem Cazander
* @version 1.0 Apr 26, 2008
*/
public interface FoeiProcessListener {
public void foeiProcessCreated(FoeiProcess process);
public void foeiProcessDestroyed(FoeiProcess process);
}

View file

@ -0,0 +1,70 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core;
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<FoeiProcess> getFoeiProcesses();
public void addFoeiProcessListener(FoeiProcessListener foeiProcessListener);
public void removeFoeiProcessListener(FoeiProcessListener foeiProcessListener);
}

View file

@ -0,0 +1,67 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core;
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<EventPort> getBindings(EventPort eventPort);
/**
* Returns the bindings in an xml format to render with dotty.
* @return
*/
public String getBindingsAsXML();
}

View file

@ -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);
}

View file

@ -0,0 +1,62 @@
/*
* 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);
/**
* Returns true when this X2OExecutor is ready
* @return
*/
public boolean isReady();
}

View file

@ -0,0 +1,148 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.EventExecutor;
import com.idcanet.foei.core.FoeiPortMessage;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessFactory;
import com.idcanet.foei.event.EventInput;
import com.idcanet.foei.event.EventPort;
import com.idcanet.foei.event.EventPortType;
import com.idcanet.foei.event.IllegalEventPortNameException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Reuable EventExecutors
*
* @author Willem Cazander
* @version 1.0 Jan 19, 2006
*/
public class EventExecutorImpl implements EventExecutor {
/** The logger to log to. */
private Logger logger = null;
/** The foei process to execute for */
private FoeiProcess foeiProcess = null;
/** True when ready */
private volatile boolean ready = false;
/**
* Creates an EventExecutor
*/
public EventExecutorImpl() {
logger = Logger.getLogger(EventExecutorImpl.class.getName());
}
/**
* @see EventExecutor#setEventObject(Object)
*/
public void setFoeiProcess(FoeiProcess foeiProcess) {
this.foeiProcess=foeiProcess;
}
/**
* @see EventExecutor#isReady()
*/
public boolean isReady() {
return ready;
}
/**
* @see Runnable#run()
*/
public void run() {
if(foeiProcess==null) {
logger.warning("Can't execute event on null foeiProcess.");
return;
}
ready = false;
int processed = 0;
try {
FoeiProcessFactory.bindFoeiProcess(foeiProcess);
FoeiPortMessage msg = foeiProcess.getWorkQueue().poll();
while (msg!=null) {
process(msg);
processed++;
msg = foeiProcess.getWorkQueue().poll();
// try 3 times to get new work, if not found then exit, EventExecutorManagerImpl work auto create new EventExecutor on new work.
if (msg==null) {
Thread.sleep(200);
msg = foeiProcess.getWorkQueue().poll();
}
if (msg==null) {
Thread.sleep(200);
msg = foeiProcess.getWorkQueue().poll();
}
if (msg==null) {
Thread.sleep(200);
msg = foeiProcess.getWorkQueue().poll();
}
}
} catch (Exception e) {
logger.log(Level.WARNING,"Error while Executing Event",e);
} finally {
ready = true;
FoeiProcessFactory.unbindFoeiProcess();
foeiProcess.getExecutors().remove(this);
logger.info(Thread.currentThread().getName()+"--"+this.toString()+" executed: "+processed);
}
}
private void process(FoeiPortMessage msg) throws IllegalEventPortNameException {
EventPort eventPort = msg.getEventPort();
Object eventObject = msg.getEventObject();
if(eventPort.getEventPortType()==EventPortType.input) {
EventInput eventInput = (EventInput)eventPort.getEventObject();
eventPort.addEventsPassed(); // inc input port
eventInput.doEvent(eventPort,eventObject);
return;
}
if(eventPort.getEventPortType()==EventPortType.output) {
eventPort.addEventsPassed(); // inc output port
List<EventPort> bindings = foeiProcess.getBindings(eventPort);
for (int i=0;i<bindings.size();i++) {
EventPort port = bindings.get(i); // faster then using iterator (auto)
EventInput eventInput = (EventInput)port.getEventObject();
if(port.isImmediate()) {
port.addEventsPassed(); // inc Immediate import port
eventInput.doEvent(port,eventObject);
} else {
foeiProcess.executeEvent(eventPort, eventObject);
}
}
return;
}
}
}

View file

@ -0,0 +1,207 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.EventExecutor;
import com.idcanet.foei.core.EventExecutorManager;
import com.idcanet.foei.core.EventThreadListener;
import com.idcanet.foei.core.FoeiContext;
import com.idcanet.foei.core.FoeiPortMessage;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessFactory;
import com.idcanet.foei.event.EventPort;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Defines the EventExecutorManager implementation
*
* @author Willem Cazander
* @version 1.0 Jan 20, 2006
*/
public class EventExecutorManagerImpl implements EventExecutorManager {
/** The logger to log to. */
private Logger logger = null;
/** The thread pool */
private ThreadPoolExecutor threadPoolExecutor = null;
/** The EventThreadListeners */
private List<EventThreadListener> eventThreadListeners = null;
/** The class for the EventExecutor */
private Class<?> eventExecutorClass = null;
/**
* Creates an EventExecutorManagerImpl ans inits the logger.
*/
public EventExecutorManagerImpl() {
logger = Logger.getLogger(EventExecutorManagerImpl.class.getName());
eventThreadListeners = new ArrayList<EventThreadListener>(1);
}
// ============= EventExecutorManager
/**
* Executes an Event mostly send from an EventObject.
* @see EventExecutorManager#executeEvent(Object, EventPort)
*/
public void executeEvent(EventPort eventPort,Object eventObject) {
executeEvent(eventPort,eventObject,FoeiProcessFactory.getFoeiProcess());
}
/**
* Executes an EventPort with object in an FoeiProcess.
* @param eventPort
* @param eventObject
* @param foeiProcess
*/
public void executeEvent(EventPort eventPort,Object eventObject,FoeiProcess foeiProcess) {
FoeiPortMessage msg = new FoeiPortMessage();
msg.setEventObject(eventObject);
msg.setEventPort(eventPort);
foeiProcess.getWorkQueue().add(msg);
if (foeiProcess.getExecutors().size()>3) {
return;
}
EventExecutor e = null;
try {
e = (EventExecutor)eventExecutorClass.newInstance();
} catch (Exception ee) {
logger.log(Level.WARNING,"Error Creating EventExecutor: "+ee.getMessage(),ee);
return;
}
e.setFoeiProcess(foeiProcess);
foeiProcess.getExecutors().add(e); // else to much will be created on 1st X objects.
threadPoolExecutor.execute(e);
}
/**
* Executes an event.
* @see EventExecutorManager#execute(Runnable)
*/
public void execute(Runnable runnable,FoeiProcess foeiProcess) {
if(threadPoolExecutor==null) {
throw new IllegalStateException("EventExecutorManager has not been started.");
}
threadPoolExecutor.execute(new FoeiProcessRunnableWrapper(runnable,foeiProcess));
}
/**
* Starts the ThreadPool
* @see EventExecutorManager#start()
*/
public void start(FoeiContext foeiContext) {
if(foeiContext==null) {
throw new NullPointerException("FoeiContext may not be null.");
}
logger.info("Starting EventExecutorManagerImpl");
try {
eventExecutorClass = FoeiConfiguratorImpl.newEventExecutorClass(foeiContext.getStartProperties());
} catch (ClassNotFoundException cce) {
logger.log(Level.WARNING,"Error getting eventExecutor class: "+cce.getMessage(),cce);
throw new RuntimeException("Could not get EventExecutor class: "+cce.getMessage(),cce);
}
EventExecutorThreadFactory tf = new EventExecutorThreadFactory(foeiContext);
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor (
FoeiConfiguratorImpl.getEventExecutorPoolCoreSize(foeiContext.getStartProperties()),
FoeiConfiguratorImpl.getEventExecutorPoolMaxSize(foeiContext.getStartProperties()),
FoeiConfiguratorImpl.getEventExecutorPoolKeepAlive(foeiContext.getStartProperties()),
TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(),
tf
);
threadPoolExecutor.prestartAllCoreThreads();
setThreadPoolExecutor(threadPoolExecutor);
}
/**
* Stops the ThreadPool
* @see EventExecutorManager#stop()
*/
public void stop(FoeiContext foeiContext) {
if(threadPoolExecutor==null) {
throw new IllegalStateException("EventExecutorManager has not been started.");
}
logger.info("Stoping EventExecutorManagerImpl");
threadPoolExecutor.shutdown();
threadPoolExecutor=null;
}
/**
* @see EventExecutorManager#getEventThreadListeners()
*/
public List<EventThreadListener> getEventThreadListeners() {
return eventThreadListeners;
}
/**
* @see EventExecutorManager#addEventThreadListener(EventThreadListener)
*/
public void addEventThreadListener(EventThreadListener eventThreadListener) throws IllegalStateException {
if(eventThreadListener==null) {
throw new NullPointerException("eventThreadListener may not be null.");
}
if(threadPoolExecutor!=null) {
throw new IllegalStateException("threadPoolExecutor is already started.");
}
eventThreadListeners.add(eventThreadListener);
}
// ========== other methods:
/**
* Can be used when override from this class.
* note:
* This method is not an interface method.
* @param threadPoolExecutor
*/
public void setThreadPoolExecutor(ThreadPoolExecutor threadPoolExecutor) {
if(this.threadPoolExecutor!=null) {
throw new IllegalStateException("ThreadPoolExecutor may only be set once");
}
this.threadPoolExecutor=threadPoolExecutor;
}
/**
* Returns the ThreadPoolExecutor
*/
public ThreadPoolExecutor getThreadPoolExecutor() {
if(threadPoolExecutor==null) {
throw new IllegalStateException("EventExecutorManager has not been started.");
}
return threadPoolExecutor;
}
}

View file

@ -0,0 +1,91 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.FoeiContext;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
/**
* Creates Thread for the threadpool and injects the threadpool runnable object with the
* FoeiContext.
*
* @author Willem Cazander
* @version 1.0 Feb 7, 2006
*/
public class EventExecutorThreadFactory implements ThreadFactory {
/** The pool number. */
static private final AtomicInteger poolNumber = new AtomicInteger(1);
/** The thread group. */
private final ThreadGroup group;
/** The thread number. */
private final AtomicInteger threadNumber = new AtomicInteger(1);
/** The name prefix. */
private String namePrefix = null;
/** The FoeiContext to wrap in the thread. */
private FoeiContext foeiContext = null;
/** The logger to log to. */
private Logger logger = null;
/**
* Creates an EventExecutorThreadFactory
* @param foeiContext
*/
public EventExecutorThreadFactory(FoeiContext foeiContext) {
if(foeiContext==null) {
throw new NullPointerException("FoeiContext may not be null.");
}
logger = Logger.getLogger(EventExecutorThreadFactory.class.getName());
this.foeiContext=foeiContext;
SecurityManager s = System.getSecurityManager();
group = (s != null)? s.getThreadGroup():Thread.currentThread().getThreadGroup();
namePrefix = "foei"+poolNumber.getAndIncrement()+"-"+foeiContext.getName()+"-";
}
/**
* Creates an new Thread and wrappes the Runnable with the FoeiContextRunnableWrapper
*/
public Thread newThread(Runnable r) {
Runnable runnable = new EventThreadListenersRunnableWrapper(r,foeiContext);
Thread t = new Thread(group,runnable,namePrefix+threadNumber.getAndIncrement(),0);
logger.info("Created new Executor Thread: "+t.getName());
if (t.isDaemon()) {
t.setDaemon(false);
}
if (t.getPriority() != Thread.NORM_PRIORITY) {
t.setPriority(Thread.NORM_PRIORITY);
}
return t;
}
}

View file

@ -0,0 +1,75 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.EventThreadListener;
import com.idcanet.foei.core.FoeiContext;
/**
* Call all EventTheadListeners of an FoeiContext
*
* @author Willem Cazander
* @version 1.0 Feb 8, 2006
*/
public class EventThreadListenersRunnableWrapper implements Runnable {
/** The wrapped runnable object. */
private Runnable runnable = null;
/** The FoeiContext for this thread. */
private FoeiContext foeiContext = null;
/**
* creates an EventThreadListenersRunnableWrapper
* @param runnable
* @param foeiContext
*/
public EventThreadListenersRunnableWrapper(Runnable runnable,FoeiContext foeiContext) {
if(runnable==null) {
throw new NullPointerException("runnable may not be null.");
}
if(foeiContext==null) {
throw new NullPointerException("FoeiContext may not be null.");
}
this.runnable=runnable;
this.foeiContext=foeiContext;
}
/**
* Call all EventThreadListeners
*/
public void run() {
for(EventThreadListener eth:foeiContext.getEventExecutorManager().getEventThreadListeners()) {
eth.startThread(foeiContext);
}
// Executer the runnable object we wrapped.
// this is the runnable executor of the default thread pool in java 1.5
runnable.run();
for(EventThreadListener eth:foeiContext.getEventExecutorManager().getEventThreadListeners()) {
eth.stopThread(foeiContext);
}
}
}

View file

@ -0,0 +1,263 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.EventExecutorManager;
import com.idcanet.foei.core.EventThreadListener;
import com.idcanet.foei.core.FoeiConfigurator;
import com.idcanet.foei.core.FoeiContext;
import com.idcanet.foei.core.FoeiContextBuildingException;
import com.idcanet.foei.core.FoeiProcessManager;
import com.idcanet.foei.core.ObjectBindingsManager;
import com.idcanet.foei.utils.jndi.MemoryContextFactory;
import java.util.Hashtable;
import java.util.Map;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.spi.InitialContextFactory;
/**
* Creates an default implemention an of FoeiContext.
* Which is config with the objects.
*
*
* @author Willem Cazander
* @version 1.0 Jan 20, 2006
*/
public class FoeiConfiguratorImpl implements FoeiConfigurator {
static private Logger logger = Logger.getLogger(FoeiConfiguratorImpl.class.getName());
/**
* Creates an FoeiContext
*/
public FoeiContext buildFoeiContext(Map<String,String> properties) throws FoeiContextBuildingException {
if(properties==null) {
throw new NullPointerException("properties may not be null.");
}
String name = getContextName(properties);
Context objectContext = null;
EventExecutorManager eventExecutorManager = null;
FoeiProcessManager foeiProcessManager = null;
try {
objectContext = newContext(properties);
eventExecutorManager = newEventExecutorManager(properties);
foeiProcessManager = newFoeiProcessManager(properties);
loadEventThreadListeners(properties,eventExecutorManager);
} catch (Exception e) {
throw new FoeiContextBuildingException("Error while building childs objects:",e);
}
return new FoeiContextImpl(name,objectContext,eventExecutorManager,properties,foeiProcessManager);
}
/**
* Gets the contextName from the properties map.
* @param properties The properties map.
* @return Returns the contextName from the properties map.
*/
static public String getContextName(Map<String,String> properties) {
String contextName = properties.get(FoeiConfigurator.CONTEXT_NAME);
if(contextName==null) {
throw new NullPointerException("contextName needs to be set in properties as: "+FoeiConfigurator.CONTEXT_NAME);
}
return contextName;
}
/**
*
* @param properties
* @return
* @throws ClassNotFoundException
* @throws InstantiationException
* @throws IllegalAccessException
*/
static public ObjectBindingsManager newObjectBindingsManager(Map<String,String> properties) throws ClassNotFoundException,InstantiationException, IllegalAccessException {
String className = properties.get(FoeiConfigurator.OBJECT_BINDINGS_MANAGER);
if(className==null) {
return new ObjectBindingsManagerImpl();
}
return (ObjectBindingsManager)loadClass(className).newInstance();
}
/**
*
* @param properties
* @return
* @throws ClassNotFoundException
* @throws InstantiationException
* @throws IllegalAccessException
* @throws NamingException
*/
static public Context newContext(Map<String,String> properties) throws ClassNotFoundException,InstantiationException, IllegalAccessException,NamingException {
String className = properties.get(FoeiConfigurator.OBJECT_CONTEXT_FACTORY);
if(className==null) {
return new MemoryContextFactory().getInitialContext(new Hashtable<String,String>(properties));
}
return ((InitialContextFactory)loadClass(className).newInstance()).getInitialContext(new Hashtable<String,String>(properties));
}
/**
*
* @param properties
* @return
* @throws ClassNotFoundException
* @throws InstantiationException
* @throws IllegalAccessException
*/
static public EventExecutorManager newEventExecutorManager(Map<String,String> properties) throws ClassNotFoundException,InstantiationException, IllegalAccessException {
String className = properties.get(FoeiConfigurator.EVENT_EXECUTOR_MANAGER);
if(className==null) {
return new EventExecutorManagerImpl();
}
return (EventExecutorManager)loadClass(className).newInstance();
}
/**
* Loads and adds all the EventThreadListener.
* @param properties
* @param eventExecutorManager
* @throws Exception
*/
static public void loadEventThreadListeners(Map<String,String> properties,EventExecutorManager eventExecutorManager) throws Exception {
String classNames = properties.get(FoeiConfigurator.EVENT_THREAD_LISTENERS);
if(classNames==null) {
logger.finer("No EventThreadListeners loading");
return;
}
for(String className:classNames.split(",")) {
logger.finest("Loading class: "+className);
EventThreadListener eventThreadListener = (EventThreadListener)loadClass(className).newInstance();
eventExecutorManager.addEventThreadListener(eventThreadListener);
}
}
/**
* Gets the Pool Core Size for the EventExecutor
* @param properties
* @return
* @throws NumberFormatException
*/
static public Integer getEventExecutorPoolCoreSize(Map<String,String> properties) throws NumberFormatException {
String size = properties.get(FoeiConfigurator.EVENT_EXECUTOR_POOL_CORE_SIZE);
if(size==null) {
return 3;
}
return new Integer(size);
}
/**
* Gets the Pool Max Size for the EventExecutor
* @param properties
* @return
* @throws NumberFormatException
*/
static public Integer getEventExecutorPoolMaxSize(Map<String,String> properties) throws NumberFormatException {
String size = properties.get(FoeiConfigurator.EVENT_EXECUTOR_POOL_MAX_SIZE);
if(size==null) {
return 5;
}
return new Integer(size);
}
/**
* Gets the Pool Keep Alive Time in second for the EventExecutor
* @param properties
* @return
* @throws NumberFormatException
*/
static public Integer getEventExecutorPoolKeepAlive(Map<String,String> properties) throws NumberFormatException {
String size = properties.get(FoeiConfigurator.EVENT_EXECUTOR_POOL_KEEP_ALIVE);
if(size==null) {
return 180;
}
return new Integer(size);
}
/**
* Creates an new EventExecutor class
* @param properties
* @return
* @throws ClassNotFoundException
*/
static public Class<?> newEventExecutorClass(Map<String,String> properties) throws ClassNotFoundException {
String className = properties.get(FoeiConfigurator.EVENT_EXECUTOR);
if(className==null) {
return EventExecutorImpl.class;
}
return loadClass(className);
}
/**
* Gets the X2O root tag
* @param properties
* @return The X2ORootTag
*/
static public String getX2ORootTag(Map<String,String> properties) {
String rootTag = properties.get(FoeiConfigurator.X2O_ROOT_TAG);
if(rootTag==null) {
return "foei";
}
return rootTag;
}
/**
*
* @param properties
* @return
* @throws ClassNotFoundException
* @throws InstantiationException
* @throws IllegalAccessException
*/
static public FoeiProcessManager newFoeiProcessManager(Map<String,String> properties) throws ClassNotFoundException,InstantiationException, IllegalAccessException {
String className = properties.get(FoeiConfigurator.FOEI_PROCESS_MANAGER);
if(className==null) {
return new FoeiProcessManagerImpl();
}
return (FoeiProcessManager)loadClass(className).newInstance();
}
/**
* Loads a Class from the ContextClassLoader and if that is not set, then
* uses the class of the String parameters
* @param className The class name to load
* @return The loaded class
* @throws Exception throws exception if class not loaded.
*/
static public Class<?> loadClass(String className) throws ClassNotFoundException {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null) {
cl = className.getClass().getClassLoader(); // fallback
}
return cl.loadClass(className);
}
}

View file

@ -0,0 +1,135 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.EventExecutorManager;
import com.idcanet.foei.core.FoeiContext;
import com.idcanet.foei.core.FoeiProcessManager;
import java.util.Map;
import javax.naming.Context;
/**
* Defines the FoeiContext implemention.
*
* @see FoeiContext
* @author Willem Cazander
* @version 1.0 Jan 19, 2006
*/
public class FoeiContextImpl implements FoeiContext {
/** The name of this Instance **/
private String name = null;
/** The FoeiContext where all objects are stored. **/
private Context objectContext = null;
/** The EventExecutorManager */
private EventExecutorManager eventExecutorManager = null;
/** The start properties */
private Map<String,String> startProperties = null;
/** The FoeiProcessManager */
private FoeiProcessManager foeiProcessManager = null;
/**
* Creates an new FoeiContextImpl
*
* @param name
* @param rootPath
* @param objectBindingsManager
* @param objectContext
* @param eventExecutorManager
* @param startProperties
*/
public FoeiContextImpl(String name,Context objectContext,EventExecutorManager eventExecutorManager,Map<String,String> startProperties,FoeiProcessManager foeiProcessManager) {
if(name==null) {
throw new NullPointerException("name may not be null.");
}
if(objectContext==null) {
throw new NullPointerException("objectContext may not be null.");
}
if(eventExecutorManager==null) {
throw new NullPointerException("eventExecutorManager may not be null.");
}
if(foeiProcessManager==null) {
throw new NullPointerException("foeiProcessManager may not be null.");
}
this.name=name;
this.objectContext=objectContext;
this.eventExecutorManager=eventExecutorManager;
this.startProperties=startProperties;
this.foeiProcessManager=foeiProcessManager;
eventExecutorManager.start(this);
}
/**
* @see FoeiContext#getName()
*/
public String getName() {
return name;
}
/**
* @see FoeiContext#getEventExecutorManager()
*/
public EventExecutorManager getEventExecutorManager() {
return eventExecutorManager;
}
/**
* @see FoeiContext#getEventObjectContext()
*/
public Context getEventObjectContext() {
return objectContext;
}
/**
* @see FoeiContext#getStartProperties()
*/
public Map<String,String> getStartProperties() {
return startProperties;
}
/**
* @see FoeiContext#destroy()
*/
public void destroy() {
getEventExecutorManager().stop(this);
}
/**
* Gets the FoeiProcessManager
* @return Returns the FoeiProcessManager
*/
public FoeiProcessManager getFoeiProcessManager() {
return foeiProcessManager;
}
}

View file

@ -0,0 +1,79 @@
package com.idcanet.foei.core.impl;
import com.idcanet.foei.event.EventInput;
import com.idcanet.foei.event.EventOutput;
import com.idcanet.foei.event.EventStep;
import com.idcanet.foei.event.EventStepController;
import com.idcanet.x4o.element.Element;
import com.idcanet.x4o.element.ElementBindingException;
import com.idcanet.x4o.element.ElementBindingHandler;
/**
*
* MM maybe move this class
*
* @author Willem Cazander
* @version 1.0 Feb 24, 2006
*/
public class FoeiEventBindingRuleHandler implements ElementBindingHandler {
/**
*
* @param object1
* @param object2
* @return
*/
public boolean canBind(Element element) {
Object parent = element.getParent().getElementObject();
Object child = element.getElementObject();
Object object1 = parent;
Object object2 = child; // is correct ??
if(object1==null) {
throw new NullPointerException("object1 may not be null.");
}
if(object2==null) {
throw new NullPointerException("object2 may not be null.");
}
if(object1 instanceof EventInput) {
if(object2 instanceof EventOutput) {
return true;
}
}
if(object1 instanceof EventOutput) {
if(object2 instanceof EventInput) {
return true;
}
}
if(object1 instanceof EventStep) {
if(object2 instanceof EventStepController) {
return true;
}
}
if(object1 instanceof EventStepController) {
if(object2 instanceof EventStep) {
return true;
}
}
return false;
}
/**
*
* @param object1
* @param object2
* @throws ClassCastException
*/
public void doBind(Element element) throws ElementBindingException {
Object parent = element.getParent().getElementObject();
Object child = element.getElementObject();
if(parent==null) {
throw new NullPointerException("object1 may not be null.");
}
if(child==null) {
throw new NullPointerException("object2 may not be null.");
}
}
}

View file

@ -0,0 +1,206 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.EventExecutor;
import com.idcanet.foei.core.FoeiContext;
import com.idcanet.foei.core.FoeiPortMessage;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.ObjectBindingsManager;
import com.idcanet.foei.event.EventPort;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.NameAlreadyBoundException;
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
/**
* Defines the default FoeiProcess implementation
*
* @author Willem Cazander
* @version 1.0 Mar 2, 2006
*/
public class FoeiProcessImpl implements FoeiProcess {
/** The FoeiContext */
private FoeiContext foeiContext = null;
/** The Logger */
private Logger logger = null;
/** The name */
private String name = null;
/** The eventObjectContext */
private Context eventObjectContext = null;
/** The ObjectBindingsManager */
private ObjectBindingsManager objectBindingsManager = null;
private Queue<FoeiPortMessage> foeiPortMessages = new LinkedBlockingQueue<FoeiPortMessage>();
private Set<EventExecutor> eventExecutors = Collections.synchronizedSet(new HashSet<EventExecutor>(10));
public FoeiProcessImpl(String name,FoeiContext foeiContext,Context eventObjectContext,ObjectBindingsManager objectBindingsManager) {
logger = Logger.getLogger(FoeiProcessImpl.class.getName());
this.name=name;
this.foeiContext=foeiContext;
this.eventObjectContext=eventObjectContext;
this.objectBindingsManager=objectBindingsManager;
logger.info("Creating FoeiProcess: "+getName());
}
// ========= FoeiProcess
/**
* @see com.idcanet.foei.core.FoeiProcess#getName()
*/
public String getName() {
return name;
}
/**
* @see com.idcanet.foei.core.FoeiProcess#getEventObjectContext()
*/
public Context getEventObjectContext() {
return eventObjectContext;
}
/**
* @see com.idcanet.foei.core.FoeiProcess#getObjectBindingsManager()
*/
public ObjectBindingsManager getObjectBindingsManager() {
return objectBindingsManager;
}
/**
* @see com.idcanet.foei.core.FoeiProcess#destroy()
*/
public void destroy() {
logger.info("Destroying FoeiProcess: "+getName());
}
/**
* @see com.idcanet.foei.core.FoeiProcess#getFoeiContext()
*/
public FoeiContext getFoeiContext() {
return foeiContext;
}
public Queue<FoeiPortMessage> getWorkQueue() {
return foeiPortMessages;
}
public Set<EventExecutor> getExecutors() {
return eventExecutors;
}
// ================== EventPortExecutor
/**
* @see com.idcanet.foei.core.EventPortExecutor#executeEvent(com.idcanet.foei.event.EventPort, java.lang.Object)
*/
public void executeEvent(EventPort eventPort, Object eventObject) {
getFoeiContext().getEventExecutorManager().executeEvent(eventPort,eventObject);
}
// ============= ObjectContextManager
/**
* @see com.idcanet.foei.core.ObjectContextManager#addEventObject(com.idcanet.foei.event.EventObject)
*/
public void addEventObject(Object eventObject,String id) {
try {
getEventObjectContext().bind(id,eventObject);
} catch (NameAlreadyBoundException nabe) {
logger.log(Level.WARNING,"NameAlreadyBoundException: "+nabe.getMessage(),nabe);
} catch (NamingException ne) {
logger.log(Level.WARNING,"NamingException: "+ne.getMessage(),ne);
}
}
/**
* @see com.idcanet.foei.core.ObjectContextManager#getEventObject(java.lang.String)
*/
public Object getEventObject(String id) {
try {
return getEventObjectContext().lookup(id);
} catch (NamingException ne) {
logger.log(Level.WARNING,"NamingException: "+ne.getMessage(),ne);
}
return null;
}
/**
* @see com.idcanet.foei.core.ObjectContextManager#removeEventObject(com.idcanet.foei.event.EventObject)
*/
public void removeEventObject(String id) {
try {
getEventObjectContext().unbind(id);
} catch (NameNotFoundException nnfe) {
logger.log(Level.WARNING,"NamingNotFoundException: "+nnfe.getMessage(),nnfe);
} catch (NamingException ne) {
logger.log(Level.WARNING,"NamingException: "+ne.getMessage(),ne);
}
}
// ============ ObjectBindingsManager
/**
* @see com.idcanet.foei.core.ObjectBindingsManager#addBinding(com.idcanet.foei.event.EventPort, com.idcanet.foei.event.EventPort)
*/
public void addBinding(EventPort outputPort, EventPort inputPort) {
getObjectBindingsManager().addBinding(outputPort,inputPort);
}
/**
* @see com.idcanet.foei.core.ObjectBindingsManager#getBindings(com.idcanet.foei.event.EventPort)
*/
public List<EventPort> getBindings(EventPort eventPort) {
return getObjectBindingsManager().getBindings(eventPort);
}
/**
* @see com.idcanet.foei.core.ObjectBindingsManager#getBindingsAsXML()
*/
public String getBindingsAsXML() {
return getObjectBindingsManager().getBindingsAsXML();
}
/**
* @see com.idcanet.foei.core.ObjectBindingsManager#removeBinding(com.idcanet.foei.event.EventPort, com.idcanet.foei.event.EventPort)
*/
public void removeBinding(EventPort inputPort, EventPort outputPort) {
getObjectBindingsManager().removeBinding(inputPort,outputPort);
}
}

View file

@ -0,0 +1,152 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.FoeiContext;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessListener;
import com.idcanet.foei.core.FoeiProcessManager;
import com.idcanet.foei.core.ObjectBindingsManager;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
/**
* Defines the default FoeiProcessManager implementation
*
* @author Willem Cazander
* @version 1.0 Mar 2, 2006
*/
public class FoeiProcessManagerImpl implements FoeiProcessManager {
/** Stores all foeiProcesses */
private Map<String,FoeiProcess> foeiProcesses = null;
/** The logger to log to. */
private Logger logger = null;
private List<FoeiProcessListener> foeiProcessListeners = null;
/**
* Creates an FoeiProcessManagerImpl
*/
public FoeiProcessManagerImpl() {
logger = Logger.getLogger(FoeiProcessManagerImpl.class.getName());
foeiProcesses = new HashMap<String,FoeiProcess>(5);
foeiProcessListeners = new ArrayList<FoeiProcessListener>(5);
}
/**
* @see com.idcanet.foei.core.FoeiProcessManager#createFoeiProcess(java.lang.String, FoeiContext)
*/
public FoeiProcess createFoeiProcess(String name,FoeiContext foeiContext) {
if(name==null) {
throw new NullPointerException("name may not be null.");
}
if(foeiContext==null) {
throw new NullPointerException("foeiContext may not be null.");
}
try {
Context c = foeiContext.getEventObjectContext().createSubcontext(name);
ObjectBindingsManager objectBindingsManager = FoeiConfiguratorImpl.newObjectBindingsManager(foeiContext.getStartProperties());
FoeiProcess fp = new FoeiProcessImpl(name,foeiContext,c,objectBindingsManager);
synchronized (foeiProcesses) {
foeiProcesses.put(fp.getName(),fp);
}
for (FoeiProcessListener l:foeiProcessListeners) {
l.foeiProcessCreated(fp);
}
logger.finer("FoeiProcess created and added total processes: "+foeiProcesses.size());
return fp;
} catch (Exception e) {
logger.log(Level.WARNING,"Error whiile creating FoeiProcess: "+e.getMessage(),e);
return null;
}
}
/**
* @see com.idcanet.foei.core.FoeiProcessManager#destroyFoeiProcess(java.lang.String)
*/
public void destroyFoeiProcess(String name) {
FoeiProcess p = getFoeiProcess(name);
if(p==null) {
throw new NullPointerException("No FoeiProcess found with id: "+name);
}
p.destroy();
synchronized (foeiProcesses) {
foeiProcesses.remove(p.getName());
}
for (FoeiProcessListener l:foeiProcessListeners) {
l.foeiProcessDestroyed(p);
}
logger.finer("FoeiProcess destroyed total processes: "+foeiProcesses.size());
try {
p.getFoeiContext().getEventObjectContext().destroySubcontext(p.getName());
} catch (Exception e) {
logger.log(Level.WARNING,"Error while removing process context from foei context; "+e.getMessage(),e);
}
}
/**
* @see com.idcanet.foei.core.FoeiProcessManager#getFoeiProcess(java.lang.String)
*/
public FoeiProcess getFoeiProcess(String name) {
if(name==null) {
throw new NullPointerException("name may not be null.");
}
return foeiProcesses.get(name);
}
/**
* @see com.idcanet.foei.core.FoeiProcessManager#getFoeiProcesses()
*/
public Collection<FoeiProcess> getFoeiProcesses() {
return foeiProcesses.values();
}
/**
* @see com.idcanet.foei.core.FoeiProcessManager#addFoeiProcessListener(com.idcanet.foei.core.FoeiProcessListener)
*/
public void addFoeiProcessListener(FoeiProcessListener foeiProcessListener) {
foeiProcessListeners.add(foeiProcessListener);
}
/**
* @see com.idcanet.foei.core.FoeiProcessManager#removeFoeiProcessListener(com.idcanet.foei.core.FoeiProcessListener)
*/
public void removeFoeiProcessListener(FoeiProcessListener foeiProcessListener) {
foeiProcessListeners.remove(foeiProcessListener);
}
}

View file

@ -0,0 +1,73 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessFactory;
/**
* Wraps an Runnable object so it binds the FoeiProcess before running
* and unbinds it also.
*
* @author Willem Cazander
* @version 1.0 Mar 3, 2006
*/
public class FoeiProcessRunnableWrapper implements Runnable {
/** The wrapped runnable object. */
private Runnable runnable = null;
/** The FoeiProcess for this Runnable. */
private FoeiProcess foeiProcess = null;
/**
* creates an FoeiProcessRunnableWrapper
* @param runnable
* @param foeiProcess
*/
public FoeiProcessRunnableWrapper(Runnable runnable,FoeiProcess foeiProcess) {
if(runnable==null) {
throw new NullPointerException("runnable may not be null.");
}
if(foeiProcess==null) {
throw new NullPointerException("FoeiProcess may not be null.");
}
this.runnable=runnable;
this.foeiProcess=foeiProcess;
}
/**
* Binds and unbinds the FoeiProcess and call the runnalbe run method.
*/
public void run() {
FoeiProcessFactory.bindFoeiProcess(foeiProcess);
try {
runnable.run();
} finally {
FoeiProcessFactory.unbindFoeiProcess();
}
}
}

View file

@ -0,0 +1,197 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.ObjectBindingsManager;
import com.idcanet.foei.event.EventPort;
import com.idcanet.foei.event.EventPortType;
import com.idcanet.foei.event.EventStep;
import com.idcanet.foei.event.EventStepController;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
/**
* Defines the ObjectBindingsManager implamentation.
*
* @author Willem Cazander
* @version 1.0 20/04/2005
*/
public class ObjectBindingsManagerImpl implements ObjectBindingsManager {
/** */
private Map<EventPort,List<EventPort>> bindingsOutput = null;
/** Works like: eventPort(input) -> List (EventPorts(output) */
private Map<EventPort,List<EventPort>> bindingsInput = null;
/** The logger to log to. */
private Logger logger = null;
/**
* Creates the defaults implementation of the ObjectBindingsManager.<br/>
* inits the logger and de input and output Map mappings.
*/
public ObjectBindingsManagerImpl() {
logger = Logger.getLogger(ObjectBindingsManagerImpl.class.getName());
bindingsOutput = new HashMap<EventPort,List<EventPort>>(50);
bindingsInput = new HashMap<EventPort,List<EventPort>>(50);
logger.finer("BindingsManager Created");
}
/**
*
* @see ObjectBindingsManager#addBinding(EventPort, EventPort)
*/
public void addBinding(EventPort outputPort,EventPort inputPort) {
if(inputPort==null) {
throw new NullPointerException("inputPort may not be null.");
}
if(inputPort.getEventPortType()!=EventPortType.input) {
throw new IllegalArgumentException("inputPort needs to be input type.");
}
if(outputPort==null) {
throw new NullPointerException("outputPort may not be null.");
}
if(outputPort.getEventPortType()!=EventPortType.output) {
throw new IllegalArgumentException("inputPort needs to be ouput type.");
}
List<EventPort> inputPorts = bindingsInput.get(inputPort);
List<EventPort> outputPorts = bindingsOutput.get(outputPort);
if(inputPorts==null) {
inputPorts = new ArrayList<EventPort>(5);
bindingsInput.put(inputPort,inputPorts);
}
if(outputPorts==null) {
outputPorts = new ArrayList<EventPort>(5);
bindingsOutput.put(outputPort,outputPorts);
}
// disables to bind twice
if(inputPorts.contains(outputPort) || outputPorts.contains(inputPort) ) {
throw new IllegalArgumentException("inputPort is already bind to outputPort");
}
inputPorts.add(outputPort);
outputPorts.add(inputPort);
logger.fine("Bind completed: "+inputPort.getEventObject()+":"+inputPort.getName()+" to "+outputPort.getEventObject()+":"+outputPort.getName());
}
/**
*
* @see ObjectBindingsManager#removeBinding(EventPort, EventPort)
*/
public void removeBinding(EventPort inputPort,EventPort outputPort) {
if(inputPort==null) {
throw new NullPointerException("inputPort may not be null.");
}
if(inputPort.getEventPortType()!=EventPortType.input) {
throw new IllegalArgumentException("inputPort needs to be input type.");
}
if(outputPort==null) {
throw new NullPointerException("outputPort may not be null.");
}
if(outputPort.getEventPortType()!=EventPortType.output) {
throw new IllegalArgumentException("inputPort needs to be ouput type.");
}
List<EventPort> inputPorts = bindingsInput.get(inputPort);
List<EventPort> outputPorts = bindingsOutput.get(outputPort);
if(inputPorts==null || outputPorts==null) {
throw new IllegalArgumentException("Can not remove not binded ports.");
}
inputPorts.remove(outputPort);
outputPorts.remove(inputPort);
if(inputPorts.isEmpty()) {
bindingsInput.remove(inputPort);
}
if(outputPorts.isEmpty()) {
bindingsOutput.remove(outputPort);
}
logger.fine("Bind removed: "+inputPort.getEventObject()+":"+inputPort.getName()+" to "+outputPort.getEventObject()+":"+outputPort.getName());
}
/**
* Gets the bindings of an EventPort
* @param eventPort The EventPort to retreive the bindings.
* @return Returns an List of the binded EventPorts
*/
public List<EventPort> getBindings(EventPort eventPort) {
if(eventPort==null) {
throw new NullPointerException("eventPort may not be null.");
}
if (EventPortType.output.equals(eventPort.getEventPortType())) {
List<EventPort> inputPorts = bindingsOutput.get(eventPort);
if(inputPorts!=null) {
return inputPorts;
}
List<EventPort> result = new ArrayList<EventPort>(0);
return result;
} else {
List<EventPort> outputPorts = bindingsInput.get(eventPort);
if(outputPorts!=null) {
return outputPorts;
}
List<EventPort> result = new ArrayList<EventPort>(0);
return result;
}
}
/**
* Returns the dotty xml bindings
*/
public String getBindingsAsXML() {
StringBuffer result = new StringBuffer();
result.append("<?xml version=\"1.0\"?>\n");
result.append("<bindings>\n");
//FoeiProcess process = FoeiProcessFactory.getFoeiProcess();
// todo: ID nameing should go automatic, and be reverse lookup'ale
for(EventPort port:bindingsOutput.keySet()) {
for(EventPort b:getBindings(port)) {
result.append("\t<binding outputClass=\""+port.getEventObject()+"\" outputPortName=\""+port.getName());
result.append("\" inputClass=\""+b.getEventObject()+"\" inputPortName=\""+b.getName()+"\" inputPortPassed=\""+b.getEventsPassed());
Object o = port.getEventObject();
if (o instanceof EventStepController) {
result.append("\">\n");
EventStepController e = (EventStepController)o;
for(EventStep es:e.getEventSteps()) {
result.append("\t\t<step stepClass=\""+es+"\"/>\n");
}
result.append("\t</binding>\n");
} else {
result.append("\"/>\n");
}
}
}
result.append("</bindings>");
return result.toString();
}
}

View file

@ -0,0 +1,135 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core.impl;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessFactory;
import com.idcanet.foei.core.X2OExecutor;
import com.idcanet.x4o.core.X4OParser;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* The default X2OExecutor implemention
*
* @author Willem Cazander
* @version 1.0 Feb 24, 2006
*
*/
public class X2OExecutorImpl implements X2OExecutor {
private String parseFileName = null;
private InputStream parseInputStream = null;
private String parseXml = null;
private boolean ready = false;
private Logger logger = null;
/**
* Constructs an X2OExecutorImpl
*/
public X2OExecutorImpl() {
logger = Logger.getLogger(X2OExecutorImpl.class.getName());
}
/**
* @see java.lang.Runnable#run()
*/
public void run() {
try {
// config parser
FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess();
X4OParser parser = new X4OParser("foei");
parser.preStart();
parser.getElementContext().getProperties().putAll(foeiProcess.getFoeiContext().getStartProperties());
logger.info("Executing X2O Parsing.");
if(parseFileName!=null) {
try {
logger.finer("Parsing File: "+parseFileName);
parser.parseFile(parseFileName);
} catch (Exception e) {
logger.log(Level.SEVERE,"Error while loading config file:"+e.getMessage(),e);
}
}
if(parseInputStream!=null) {
try {
logger.finer("Parsing InputStream");
parser.parse(parseInputStream);
} catch (Exception e) {
logger.log(Level.SEVERE,"Error while loading inputStream:"+e.getMessage(),e);
}
}
if(parseXml!=null) {
try {
logger.finer("Parsing XML");
parser.parseXml(parseXml);
} catch (Exception e) {
logger.log(Level.SEVERE,"Error while loading xml:"+e.getMessage(),e);
}
}
} catch (Throwable t) {
logger.log(Level.WARNING,"Error in X2O thread: "+t.getMessage(),t);
} finally {
ready = true;
}
}
/**
* @see com.idcanet.foei.core.X2OExecutor#isReady()
*/
public boolean isReady() {
return ready;
}
/**
* @see com.idcanet.foei.core.X2OExecutor#setFileName(java.lang.String)
*/
public void setFileName(String fileName) {
parseFileName=fileName;
}
/**
* @see com.idcanet.foei.core.X2OExecutor#setInputStream(java.io.InputStream)
*/
public void setInputStream(InputStream inputStream) {
parseInputStream=inputStream;
}
/**
* @see com.idcanet.foei.core.X2OExecutor#setXml(java.lang.String)
*/
public void setXml(String xml) {
parseXml=xml;
}
}

View file

@ -0,0 +1,58 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html 1.00
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.
-->
</head>
<body bgcolor="white">
Defines the Foei Event Core Implemention.<br/>
Some classes are build to be used for overriding classes so<br/>
they have method to make live easer.<br/>
<!--
<ul>
<li><a href="">hgj</a>
</ul>
-->
<h2>Related Documentation</h2>
None.
<!--
For overviews, tutorials, examples, guides, and tool documentation, please see:
<ul>
<li><a href="http://foei.idca.nl/docs/jmx/example1">Example 1</a>
</ul>
-->
<!-- Put @see and @since tags down here. -->
</body>
</html>

View file

@ -0,0 +1,59 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html 1.00
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.
-->
</head>
<body bgcolor="white">
Defines the Foei Event Core interfaces, exceptions and 1 class.<br/>
<h2>Package Specification</h2>
The Foei Core objects are fully interfaced so you<br/>
can hook into every core process.<br/>
<!--
<ul>
<li><a href="">hgj</a>
</ul>
-->
<h2>Related Documentation</h2>
None.
<!--
For overviews, tutorials, examples, guides, and tool documentation, please see:
<ul>
<li><a href="http://foei.idca.nl/docs/jmx/example1">Example 1</a>
</ul>
-->
<!-- Put @see and @since tags down here. -->
</body>
</html>

View file

@ -0,0 +1,83 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core.x4o;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessFactory;
import com.idcanet.foei.event.EventInput;
import com.idcanet.foei.event.EventOutput;
import com.idcanet.foei.event.EventPort;
import com.idcanet.x4o.element.AbstractElementParameterHandler;
import com.idcanet.x4o.element.Element;
import com.idcanet.x4o.element.ElementException;
/**
* Handlers the "bind" attribute
*
* @author Willem Cazander
* @version 1.0 Apr 15, 2006
*/
public class BindAttributeHandler extends AbstractElementParameterHandler {
/**
* @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doParameter(java.lang.Object, java.lang.String)
*/
@Override
public void doParameterStartTag(Element element) throws ElementException {
String parameterValue = element.getAttributes().get(getParameterName());
String[] port = parameterValue.split(":");
if(port.length!=2) {
return;
}
try {
EventInput in = (EventInput)element.getElementObject();
if(in==null) {
throw new ElementException("Could not find EventObject from inputID");
}
EventOutput out = (EventOutput)element.getParent().getElementObject();
if(out==null) {
throw new ElementException("Could not find EventObject from outputID");
}
EventPort inputEventPort = in.getInputPort(port[1]);
EventPort outputEventPort = out.getOutputPort(port[0]);
FoeiProcess foei = FoeiProcessFactory.getFoeiProcess();
if(inputEventPort==null) {
throw new ElementException("Could not find EventPort from inputPort");
}
if(outputEventPort==null) {
throw new ElementException("Could not find EventPort from outputPort");
}
foei.addBinding(outputEventPort,inputEventPort);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View file

@ -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.x4o;
import com.idcanet.foei.event.EventStep;
import com.idcanet.foei.event.EventStepController;
import com.idcanet.x4o.element.Element;
import com.idcanet.x4o.element.ElementBindingException;
import com.idcanet.x4o.element.ElementBindingHandler;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 16, 2006
*/
public class EventStepBindRuleHandler implements ElementBindingHandler {
/**
* @see com.idca.foei.xml.x2o.eld.BindingRuleHandler#canBind(java.lang.Object, java.lang.Object)
*/
public boolean canBind(Element element) {
Object parent = element.getParent().getElementObject();
Object child = element.getElementObject();
if(!(parent instanceof EventStepController)) {
return false;
}
if(!(child instanceof EventStep)) {
return false;
}
return true;
}
/**
* @see com.idca.foei.xml.x2o.eld.BindingRuleHandler#doBind(java.lang.Object, java.lang.Object)
*/
public void doBind(Element element) throws ElementBindingException {
Object parent = element.getParent().getElementObject();
Object child = element.getElementObject();
((EventStepController)parent).addEventStep((EventStep)child);
}
}

View file

@ -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.x4o;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessFactory;
import com.idcanet.x4o.element.AbstractElementParameterHandler;
import com.idcanet.x4o.element.Element;
import com.idcanet.x4o.element.ElementException;
/**
* Handles the id
*
* @author Willem Cazander
* @version 1.0 Jul 8, 2006
*/
public class IdAttributeHandler extends AbstractElementParameterHandler {
/**
* @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doParameter(java.lang.Object, java.lang.String)
*/
@Override
public void doParameterStartTag(Element element) throws ElementException {
// add to objext context
String parameterValue = element.getAttributes().get(getParameterName());
if(element.getElementObject()==null | "".equals(parameterValue)) {
parameterValue= "auto."+Integer.toHexString(element.getElementObject().hashCode());
//logger.finest("Generated auto id: "+parameterValue);
}
FoeiProcess process = FoeiProcessFactory.getFoeiProcess();
process.addEventObject(element.getElementObject(),parameterValue);
}
}

View file

@ -0,0 +1,85 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.core.x4o;
import java.util.Map;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessFactory;
import com.idcanet.foei.event.EventInput;
import com.idcanet.foei.event.EventOutput;
import com.idcanet.foei.event.EventPort;
import com.idcanet.x4o.element.AbstractElement;
import com.idcanet.x4o.element.ElementException;
/**
*
*
* @author Willem Cazander
* @version 1.0 Mar 2, 2006
*/
public class ObjectBindingElement extends AbstractElement {
private String outputID = null;
private String outputPort = null;
private String inputID = null;
private String inputPort = null;
/**
* Do the element
*/
@Override
public void doElementStart() throws ElementException {
Map<String,String> attributes = getAttributes();
outputID = attributes.get("outputID");
outputPort = attributes.get("outputPort");
inputID = attributes.get("inputID");
inputPort = attributes.get("inputPort");
FoeiProcess foei = FoeiProcessFactory.getFoeiProcess();
Object in = foei.getEventObject(inputID);
if(in==null) {
throw new ElementException("Could not find EventObject from inputID");
}
Object out = foei.getEventObject(outputID);
if(out==null) {
throw new ElementException("Could not find EventObject from outputID");
}
EventPort inputEventPort = ((EventInput)in).getInputPort(inputPort);
EventPort outputEventPort = ((EventOutput)out).getOutputPort(outputPort);
if(inputEventPort==null) {
throw new ElementException("Could not find EventPort from inputPort");
}
if(outputEventPort==null) {
throw new ElementException("Could not find EventPort from outputPort");
}
foei.addBinding(outputEventPort,inputEventPort);
}
}

View file

@ -0,0 +1,55 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html 1.00
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.
-->
</head>
<body bgcolor="white">
Special Element object for foei xml.<br/>
<!--
<ul>
<li><a href="">hgj</a>
</ul>
-->
<h2>Related Documentation</h2>
None.
<!--
For overviews, tutorials, examples, guides, and tool documentation, please see:
<ul>
<li><a href="http://foei.idca.nl/docs/jmx/example1">Example 1</a>
</ul>
-->
<!-- Put @see and @since tags down here. -->
</body>
</html>

View file

@ -0,0 +1,85 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import javax.resource.spi.endpoint.MessageEndpointFactory;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessListener;
import com.idcanet.foei.ee.jca.spi.FoeiActivationSpec;
import com.idcanet.foei.ee.jca.spi.FoeiEventWrapper;
import com.idcanet.foei.ee.jca.spi.FoeiResourceAdapter;
/**
* Injects the ejb3 beans in the process.<br/>
*
*
* @author Willem Cazander
* @version 1.0 Apr 26, 2008
*/
public class EJBFoeiProcessListener implements FoeiProcessListener {
private FoeiResourceAdapter foeiResourceAdapter = null;
public EJBFoeiProcessListener(FoeiResourceAdapter foeiResourceAdapter) {
this.foeiResourceAdapter=foeiResourceAdapter;
}
/**
* @see com.idcanet.foei.core.FoeiProcessListener#foeiProcessCreated(com.idcanet.foei.core.FoeiProcess)
*/
public void foeiProcessCreated(FoeiProcess process) {
// list all beans.
for (String name:foeiResourceAdapter.getEJBFoeiBeanNames()) {
FoeiActivationSpec foeiActivationSpec = foeiResourceAdapter.getFoeiActivationSpec(name);
MessageEndpointFactory endpointFactory = foeiResourceAdapter.getMessageEndpointFactory(name);
// check context name
if (process.getFoeiContext().getName().matches(foeiActivationSpec.getFoeiContextName())) {
// check process name
if (process.getName().matches(foeiActivationSpec.getFoeiProcessName())) {
// create wrapper for in foei, which can get an instance of the EJB bean.
FoeiEventWrapper wrapper = new FoeiEventWrapper(endpointFactory,process);
// inject bean
process.addEventObject(wrapper, foeiActivationSpec.getFoeiBeanName());
}
}
}
}
/**
* @see com.idcanet.foei.core.FoeiProcessListener#foeiProcessDestroyed(com.idcanet.foei.core.FoeiProcess)
*/
public void foeiProcessDestroyed(FoeiProcess process) {
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import javax.resource.ResourceException;
import com.idcanet.foei.core.FoeiContext;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public interface FoeiConnection {
/**
* Retrieves instance of the Foei Context
* @return File Retriever connection instance
* @throws ResourceException in case of any problem
*/
public FoeiContext getFoeiContext() throws ResourceException;
public void close() throws ResourceException;
}

View file

@ -0,0 +1,45 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import javax.resource.ResourceException;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public interface FoeiConnectionFactory {
/**
* Retrieves instance of the Foei Context Connection
* @return File Retriever connection instance
* @throws ResourceException in case of any problem
*/
public FoeiConnection getFoeiConnection() throws ResourceException;
}

View file

@ -0,0 +1,88 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import java.io.Serializable;
import javax.naming.NamingException;
import javax.naming.Reference;
import javax.resource.Referenceable;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ManagedConnectionFactory;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
@SuppressWarnings("serial")
public class FoeiConnectionFactoryImpl implements FoeiConnectionFactory, Serializable, Referenceable {
/** Managed connection factory */
private ManagedConnectionFactory mcf;
/** Connection manager */
private ConnectionManager cm;
/** JNDI reference */
private Reference reference;
/**
* The constructor
* @param factory managed connection factory
* @param cm connection manager
*/
public FoeiConnectionFactoryImpl(ManagedConnectionFactory factory,ConnectionManager cm) {
this.mcf = factory;
this.cm = cm;
}
/**
* @see javax.resource.Referenceable#setReference(javax.naming.Reference)
*/
public void setReference(Reference reference) {
this.reference=reference;
}
/**
* @see javax.naming.Referenceable#getReference()
*/
public Reference getReference() throws NamingException {
return reference;
}
/**
* @see com.idcanet.foei.jca.cci.FoeiConnectionFactory#getFoeiConnection()
*/
public FoeiConnection getFoeiConnection() throws ResourceException {
return (FoeiConnection) cm.allocateConnection(mcf, null);
}
}

View file

@ -0,0 +1,84 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import javax.resource.ResourceException;
import com.idcanet.foei.core.FoeiContext;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public class FoeiConnectionImpl implements FoeiConnection {
/** Underlying physical connection instance */
private FoeiManagedConnection mc;
/**
* The constructor
* @param mc underlying physical connection instance
*/
public FoeiConnectionImpl(FoeiManagedConnection mc) {
this.mc = mc;
}
/**
* Associates this handle with given underlying physical
* connection instance
* @param newMc underlying physical connection instance
*/
public void associateConnection(FoeiManagedConnection newMc) {
this.mc.removeConnection(this);
newMc.addConnection(this);
this.mc = newMc;
}
/**
* Invalidates the connection
*/
public void invalidate() {
mc = null;
}
/**
* @see com.idcanet.foei.jca.cci.FoeiContextConnection#getFoeiContext()
*/
public FoeiContext getFoeiContext() throws ResourceException {
return mc.getFoeiContext();
}
/**oeiContextConnection#close()
*/
public void close() throws ResourceException {
mc.close(this);
}
}

View file

@ -0,0 +1,237 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.resource.NotSupportedException;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionEvent;
import javax.resource.spi.ConnectionEventListener;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.LocalTransaction;
import javax.resource.spi.ManagedConnection;
import javax.resource.spi.ManagedConnectionMetaData;
import javax.security.auth.Subject;
import javax.transaction.xa.XAResource;
import com.idcanet.foei.core.FoeiContext;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public class FoeiManagedConnection implements ManagedConnection {
/** Log writer */
private PrintWriter writer;
/** List of listeners */
private List<ConnectionEventListener> listeners;
/** Set of application-level handlers */
private Set<FoeiConnectionImpl> connectionSet;
private FoeiContext foeiContext = null;
/**
* The constructor
* @param conReqInfo {@link ConnectionRequestInfo}
* @param writer log writer of the factory that calls this constructor
* @param repositoryPath path to the repository containing files to retireve
*/
public FoeiManagedConnection(ConnectionRequestInfo conReqInfo,PrintWriter writer, FoeiContext foeiContext) {
this.writer = writer;
this.listeners = new ArrayList<ConnectionEventListener>(10);
this.connectionSet = new HashSet<FoeiConnectionImpl>(10);
this.foeiContext = foeiContext;
}
/**
* @see javax.resource.spi.ManagedConnection#getConnection(javax.security.auth.Subject,
* javax.resource.spi.ConnectionRequestInfo)
*/
public Object getConnection(Subject subj, ConnectionRequestInfo conReqInfo) throws ResourceException {
if (this.foeiContext == null) {
throw new ResourceException("foeiContext is null");
}
FoeiConnectionImpl conn = new FoeiConnectionImpl(this);
addConnection(conn);
return conn;
}
/**
* @see javax.resource.spi.ManagedConnection#destroy()
*/
public void destroy() throws ResourceException {
invalidateAllConnections();
synchronized (this.listeners) {
listeners = null;
}
foeiContext.destroy();
foeiContext = null;
}
/**
* @see javax.resource.spi.ManagedConnection#cleanup()
*/
public void cleanup() throws ResourceException {
invalidateAllConnections();
}
/**
* @see javax.resource.spi.ManagedConnection#associateConnection(java.lang.Object)
*/
public void associateConnection(Object conn) throws ResourceException {
if (!(conn instanceof FoeiConnectionImpl)) {
throw new ResourceException("Connection has an incorrect type");
}
((FoeiConnectionImpl)conn).associateConnection(this);
}
/**
* @see javax.resource.spi.ManagedConnection#addConnectionEventListener(javax.resource.spi.ConnectionEventListener)
*/
public void addConnectionEventListener(ConnectionEventListener listener) {
synchronized (this.listeners) {
listeners.add(listener);
}
}
/**
* @see javax.resource.spi.ManagedConnection#removeConnectionEventListener(javax.resource.spi.ConnectionEventListener)
*/
public void removeConnectionEventListener(ConnectionEventListener listener) {
synchronized (this.listeners) {
listeners.remove(listener);
}
}
/**
* @see javax.resource.spi.ManagedConnection#getXAResource()
*/
public XAResource getXAResource() throws ResourceException {
throw new NotSupportedException("XA transactions are not supported");
}
/**
* @see javax.resource.spi.ManagedConnection#getLocalTransaction()
*/
public LocalTransaction getLocalTransaction() throws ResourceException {
throw new NotSupportedException("Transactions are not supported");
}
/**
* @see javax.resource.spi.ManagedConnection#getMetaData()
*/
public ManagedConnectionMetaData getMetaData() throws ResourceException {
return new FoeiManagedConnectionMetaData();
}
/**
* @see javax.resource.spi.ManagedConnection#setLogWriter(java.io.PrintWriter)
*/
public void setLogWriter(PrintWriter out) throws ResourceException {
this.writer = out;
}
/**
* @see javax.resource.spi.ManagedConnection#getLogWriter()
*/
public PrintWriter getLogWriter() throws ResourceException {
return writer;
}
/**
* Removes application-level handler from handlers set
* @param con handler to remove
* @see FileRetrieverConnectionImpl#associateConnection(FileRetrieverManagedConnection)
*/
void removeConnection(FoeiConnectionImpl con) {
synchronized (this.connectionSet) {
connectionSet.remove(con);
}
}
/**
* Adds application-level handler to handlers set
* @param con handler to add
* @see FileRetrieverConnectionImpl#associateConnection(FileRetrieverManagedConnection)
*/
void addConnection(FoeiConnectionImpl con) {
synchronized (this.connectionSet) {
connectionSet.add(con);
}
}
/**
* Invalidate all application-level handlers and clears handlers set
*/
void invalidateAllConnections() {
synchronized (this.connectionSet) {
Iterator<FoeiConnectionImpl> itr = connectionSet.iterator();
while (itr.hasNext()) {
FoeiConnectionImpl con = itr.next();
con.invalidate();
}
connectionSet.clear();
}
}
public FoeiContext getFoeiContext() {
return foeiContext;
}
/**
* Closes connection
* @param con connection to close
*/
public void close(FoeiConnectionImpl con) {
ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
event.setConnectionHandle(con);
synchronized (this.listeners) {
Iterator<ConnectionEventListener> itr = listeners.iterator();
while (itr.hasNext()) {
try {
itr.next().connectionClosed(event);
} catch (Throwable e) {
}
}
}
con.invalidate();
removeConnection(con);
}
}

View file

@ -0,0 +1,204 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.ManagedConnection;
import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.ResourceAdapter;
import javax.resource.spi.ResourceAdapterAssociation;
import javax.security.auth.Subject;
import com.idcanet.foei.core.EventExecutorManager;
import com.idcanet.foei.core.FoeiContext;
import com.idcanet.foei.core.FoeiProcessManager;
import com.idcanet.foei.core.impl.FoeiConfiguratorImpl;
import com.idcanet.foei.core.impl.FoeiContextImpl;
import com.idcanet.foei.ee.jca.spi.FoeiResourceAdapter;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
@SuppressWarnings("serial")
public class FoeiManagedConnectionFactory implements ManagedConnectionFactory,ResourceAdapterAssociation {
private Logger logger = Logger.getLogger(FoeiManagedConnectionFactory.class.getName());
/** Log writer */
private transient PrintWriter writer;
/** Path to file system repository */
private String foeiContextName = null;
private FoeiContext foeiContext = null;
private ResourceAdapter resourceAdapter = null;
/**
* @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory(javax.resource.spi.ConnectionManager)
*/
public Object createConnectionFactory(ConnectionManager cm) throws ResourceException {
if (foeiContext==null) {
logger.info("Starting foeiContext: "+foeiContextName);
Context objectContext = null;
EventExecutorManager eventExecutorManager = null;
FoeiProcessManager foeiProcessManager = null;
Map<String,String> properties = new HashMap<String,String>(0);
try {
objectContext = FoeiConfiguratorImpl.newContext(properties);
//eventExecutorManager = new JCAEventExecutorManager((FoeiResourceAdapter)getResourceAdapter());
eventExecutorManager = FoeiConfiguratorImpl.newEventExecutorManager(properties);
foeiProcessManager = FoeiConfiguratorImpl.newFoeiProcessManager(properties);
// inject ejb beans per process
foeiProcessManager.addFoeiProcessListener(new EJBFoeiProcessListener((FoeiResourceAdapter)getResourceAdapter()));
FoeiConfiguratorImpl.loadEventThreadListeners(properties,eventExecutorManager);
} catch (Exception e) {
throw new ResourceException("Error while building childs objects:",e);
}
foeiContext = new FoeiContextImpl(foeiContextName,objectContext,eventExecutorManager,properties,foeiProcessManager);
}
return new FoeiConnectionFactoryImpl(this, cm);
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#createConnectionFactory()
*/
public Object createConnectionFactory() throws ResourceException {
return createConnectionFactory(null);
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#createManagedConnection(javax.security.auth.Subject, javax.resource.spi.ConnectionRequestInfo)
*/
public ManagedConnection createManagedConnection(Subject subj,ConnectionRequestInfo conReqInfo) throws ResourceException {
return new FoeiManagedConnection(conReqInfo, writer, foeiContext);
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#matchManagedConnections(java.util.Set, javax.security.auth.Subject, javax.resource.spi.ConnectionRequestInfo)
*/
@SuppressWarnings("unchecked")
public ManagedConnection matchManagedConnections(Set set, Subject subj, ConnectionRequestInfo conReqInfo) throws ResourceException {
Iterator itr = set.iterator();
if (itr.hasNext()) {
Object obj = itr.next();
if (obj instanceof FoeiManagedConnection) {
return (FoeiManagedConnection)obj;
}
}
return null;
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#setLogWriter(java.io.PrintWriter)
*/
public void setLogWriter(PrintWriter out) throws ResourceException {
this.writer = out;
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#getLogWriter()
*/
public PrintWriter getLogWriter() throws ResourceException {
return writer;
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#hashCode()
*/
public int hashCode() {
if (foeiContextName == null) {
return super.hashCode();
} else {
return foeiContextName.hashCode();
}
}
/**
* @see javax.resource.spi.ManagedConnectionFactory#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof FoeiManagedConnectionFactory)) {
return false;
}
if (foeiContextName == null) {
return false;
}
return foeiContextName.equals(((FoeiManagedConnectionFactory)obj).getFoeiContextName());
}
/**
* @return the foeiContextName
*/
public String getFoeiContextName() {
return foeiContextName;
}
/**
* @param foeiContextName the foeiContextName to set
*/
public void setFoeiContextName(String foeiContextName) {
this.foeiContextName = foeiContextName;
}
/**
* @see javax.resource.spi.ResourceAdapterAssociation#getResourceAdapter()
*/
public ResourceAdapter getResourceAdapter() {
return resourceAdapter;
}
/**
* @see javax.resource.spi.ResourceAdapterAssociation#setResourceAdapter(javax.resource.spi.ResourceAdapter)
*/
public void setResourceAdapter(ResourceAdapter resourceAdapter) throws ResourceException {
this.resourceAdapter=resourceAdapter;
}
}

View file

@ -0,0 +1,70 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.cci;
import javax.resource.ResourceException;
import javax.resource.spi.ManagedConnectionMetaData;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public class FoeiManagedConnectionMetaData implements ManagedConnectionMetaData {
/** Default instance of the class */
public final static FoeiManagedConnectionMetaData INSTANCE = new FoeiManagedConnectionMetaData();
/**
* @see javax.resource.spi.ManagedConnectionMetaData#getEISProductName()
*/
public String getEISProductName() throws ResourceException {
return "Foei EE EIS";
}
/**
* @see javax.resource.spi.ManagedConnectionMetaData#getEISProductVersion()
*/
public String getEISProductVersion() throws ResourceException {
return "1.0";
}
/**
* @see javax.resource.spi.ManagedConnectionMetaData#getMaxConnections()
*/
public int getMaxConnections() throws ResourceException {
return 0;
}
/**
* @see javax.resource.spi.ManagedConnectionMetaData#getUserName()
*/
public String getUserName() throws ResourceException {
return "IDCANET";
}
}

View file

@ -0,0 +1,45 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.spi;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.event.EventInput;
import com.idcanet.foei.event.EventOutput;
import com.idcanet.foei.event.EventPort;
import com.idcanet.foei.event.IllegalEventPortNameException;
/**
* Gets called when process is created or destroyed.<br/>
*
*
* @author Willem Cazander
* @version 1.0 Apr 26, 2008
*/
public interface EJBFoeiBean extends EventInput,EventOutput {
public void doEvent(FoeiProcess process,FoeiEventWrapper wrapper,EventPort eventPort,Object object) throws IllegalEventPortNameException;
}

View file

@ -0,0 +1,144 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.spi;
import java.io.Serializable;
import javax.resource.ResourceException;
import javax.resource.spi.ActivationSpec;
import javax.resource.spi.InvalidPropertyException;
import javax.resource.spi.ResourceAdapter;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
@SuppressWarnings("serial")
public class FoeiActivationSpec implements ActivationSpec, Serializable {
/** The resource adapter */
private transient ResourceAdapter resourceAdapter = null;
private String foeiBeanName = null;
private String foeiProcessName = null;
private String foeiContextName = null;
/**
* @see javax.resource.spi.ActivationSpec#validate()
*/
public void validate() throws InvalidPropertyException {
if (foeiBeanName==null) {
throw new InvalidPropertyException("foeiBeanName is null,please set foeiBeanName property.");
}
if (foeiBeanName.isEmpty()) {
throw new InvalidPropertyException("foeiBeanName is empty,please set foeiBeanName property.");
}
if (foeiProcessName==null) {
foeiProcessName=".*";
}
if (foeiProcessName.isEmpty()) {
foeiProcessName=".*";
}
if ("*".equals(foeiProcessName)) {
foeiProcessName=".*";
}
if (foeiContextName==null) {
foeiContextName=".*";
}
if (foeiContextName.isEmpty()) {
foeiContextName=".*";
}
if ("*".equals(foeiContextName)) {
foeiContextName=".*";
}
// TODO: check if is regex
}
/**
* @see javax.resource.spi.ResourceAdapterAssociation#getResourceAdapter()
*/
public ResourceAdapter getResourceAdapter() {
return resourceAdapter;
}
/**
* @see javax.resource.spi.ResourceAdapterAssociation#setResourceAdapter(javax.resource.spi.ResourceAdapter)
*/
public void setResourceAdapter(ResourceAdapter resourceAdapter) throws ResourceException {
if (resourceAdapter==null) {
throw new ResourceException("ResourceAdapter may not be null.");
}
this.resourceAdapter=resourceAdapter;
}
/**
* @return the foeiBeanName
*/
public String getFoeiBeanName() {
return foeiBeanName;
}
/**
* @param foeiBeanName the foeiBeanName to set
*/
public void setFoeiBeanName(String foeiBeanName) {
this.foeiBeanName = foeiBeanName;
}
/**
* @return the foeiProcessName
*/
public String getFoeiProcessName() {
return foeiProcessName;
}
/**
* @param foeiProcessName the foeiProcessName to set
*/
public void setFoeiProcessName(String foeiProcessName) {
this.foeiProcessName = foeiProcessName;
}
/**
* @return the foeiContextName
*/
public String getFoeiContextName() {
return foeiContextName;
}
/**
* @param foeiContextName the foeiContextName to set
*/
public void setFoeiContextName(String foeiContextName) {
this.foeiContextName = foeiContextName;
}
}

View file

@ -0,0 +1,113 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.spi;
import java.util.logging.Logger;
import javax.resource.spi.endpoint.MessageEndpoint;
import javax.resource.spi.endpoint.MessageEndpointFactory;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.event.AbstractEventObject;
import com.idcanet.foei.event.EventPort;
import com.idcanet.foei.event.IllegalEventPortNameException;
/**
* Wrappers the ejb bean into the foei executing context.
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
@SuppressWarnings("serial")
public class FoeiEventWrapper extends AbstractEventObject {
private Logger logger = Logger.getLogger(FoeiEventWrapper.class.getName());
private MessageEndpointFactory endpointFactory = null;
private FoeiProcess foeiProcess = null;
public FoeiEventWrapper(MessageEndpointFactory endpointFactory,FoeiProcess foeiProcess) {
this.endpointFactory=endpointFactory;
this.foeiProcess=foeiProcess;
MessageEndpoint endpoint = null;
try {
endpoint = endpointFactory.createEndpoint(null); // creates new EJB3 bean instance !!
if (endpoint != null) {
EJBFoeiBean bean = (EJBFoeiBean) endpoint;
// copy ports, todo: go to annotations
// TODO: check if has input port at all...
for (EventPort p:bean.getInputPorts()) {
this.addInputPort(p.getName(), p.getObjectClass());
}
for (EventPort p:bean.getOutputPorts()) {
this.addOutputPort(p.getName(), p.getObjectClass());
}
} else {
logger.warning("MessageEndPoint is null.");
}
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (endpoint != null) {
endpoint.release();
}
}
}
/**
* @see com.idcanet.foei.event.AbstractEventInput#doEvent(com.idcanet.foei.event.EventPort, java.lang.Object)
*/
@Override
public void doEvent(EventPort eventPort, Object object) throws IllegalEventPortNameException {
MessageEndpoint endpoint = null;
try {
endpoint = endpointFactory.createEndpoint(null); // creates new EJB3 bean instance !!
if (endpoint != null) {
EJBFoeiBean input = (EJBFoeiBean) endpoint;
// mmm needed ?
// yes for normaly equals ..
EventPort port = input.getInputPort(eventPort.getName());
input.doEvent(foeiProcess,this,port, object);
} else {
logger.warning("MessageEndPoint is null.");
}
} catch (Exception e) {
throw new IllegalEventPortNameException(e);
} finally {
if (endpoint != null) {
endpoint.release(); // release ejb bean
}
}
}
}

View file

@ -0,0 +1,135 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.spi;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import javax.resource.ResourceException;
import javax.resource.spi.ActivationSpec;
import javax.resource.spi.BootstrapContext;
import javax.resource.spi.ResourceAdapter;
import javax.resource.spi.ResourceAdapterInternalException;
import javax.resource.spi.endpoint.MessageEndpointFactory;
import javax.transaction.xa.XAResource;
/**
*
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public class FoeiResourceAdapter implements ResourceAdapter {
private Logger logger = Logger.getLogger(FoeiResourceAdapter.class.getName());
private BootstrapContext bootstrapContext = null;
private Map<String,SpecBean> ejbs = null;
/**
* @see javax.resource.spi.ResourceAdapter#start(javax.resource.spi.BootstrapContext)
*/
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
logger.info("Starting FoeiResourceAdapter");
ejbs = new HashMap<String,SpecBean>(5);
this.bootstrapContext=bootstrapContext;
}
/**
* @see javax.resource.spi.ResourceAdapter#stop()
*/
public void stop() {
logger.info("Stopping FoeiResourceAdapter");
ejbs.clear();
bootstrapContext=null;
}
/**
* @see javax.resource.spi.ResourceAdapter#getXAResources(javax.resource.spi.ActivationSpec[])
*/
public XAResource[] getXAResources(ActivationSpec[] specs) throws ResourceException {
return null;
}
/**
* @see javax.resource.spi.ResourceAdapter#endpointActivation(javax.resource.spi.endpoint.MessageEndpointFactory, javax.resource.spi.ActivationSpec)
*/
public void endpointActivation(MessageEndpointFactory endPointFactory,ActivationSpec spec) throws ResourceException {
FoeiActivationSpec fac = (FoeiActivationSpec)spec;
logger.info("Activation of: "+fac.getFoeiBeanName());
SpecBean s = new SpecBean();
s.messageEndpointFactory=endPointFactory;
s.foeiActivationSpec=fac;
ejbs.put(fac.getFoeiBeanName(),s);
}
/**
* @see javax.resource.spi.ResourceAdapter#endpointDeactivation(javax.resource.spi.endpoint.MessageEndpointFactory, javax.resource.spi.ActivationSpec)
*/
public void endpointDeactivation(MessageEndpointFactory endPointFactory,ActivationSpec spec) {
FoeiActivationSpec fac = (FoeiActivationSpec)spec;
logger.info("Deactivation of "+fac.getFoeiBeanName());
ejbs.remove(fac.getFoeiBeanName());
}
/**
* @return the bootstrapContext
*/
public BootstrapContext getBootstrapContext() {
return bootstrapContext;
}
/**
* @param bootstrapContext the bootstrapContext to set
*/
public void setBootstrapContext(BootstrapContext bootstrapContext) {
this.bootstrapContext = bootstrapContext;
}
public List<String> getEJBFoeiBeanNames() {
return new ArrayList<String>(ejbs.keySet());
}
public FoeiActivationSpec getFoeiActivationSpec(String name) {
SpecBean s = ejbs.get(name);
return s.foeiActivationSpec;
}
public MessageEndpointFactory getMessageEndpointFactory(String name) {
SpecBean s = ejbs.get(name);
return s.messageEndpointFactory;
}
private class SpecBean {
FoeiActivationSpec foeiActivationSpec;
MessageEndpointFactory messageEndpointFactory;
}
}

View file

@ -0,0 +1,200 @@
/*
* Copyright 2004-2008 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.ee.jca.spi;
import com.idcanet.foei.core.EventExecutor;
import com.idcanet.foei.core.EventExecutorManager;
import com.idcanet.foei.core.EventThreadListener;
import com.idcanet.foei.core.FoeiContext;
import com.idcanet.foei.core.FoeiPortMessage;
import com.idcanet.foei.core.FoeiProcess;
import com.idcanet.foei.core.FoeiProcessFactory;
import com.idcanet.foei.core.impl.FoeiConfiguratorImpl;
import com.idcanet.foei.core.impl.FoeiProcessRunnableWrapper;
import com.idcanet.foei.event.EventPort;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.resource.spi.work.Work;
import javax.resource.spi.work.WorkException;
/**
* Defines the EventExecutorManager implementation
*
* @author Willem Cazander
* @version 1.0 Apr 19, 2008
*/
public class JCAEventExecutorManager implements EventExecutorManager {
/** The logger to log to. */
private Logger logger = null;
/** The EventThreadListeners */
private List<EventThreadListener> eventThreadListeners = null;
/** The class for the EventExecutor */
private Class<?> eventExecutorClass = null;
private FoeiResourceAdapter foeiResourceAdapter = null;
/**
* Creates an EventExecutorManagerImpl ans inits the logger.
*/
public JCAEventExecutorManager(FoeiResourceAdapter foeiResourceAdapter) {
logger = Logger.getLogger(JCAEventExecutorManager.class.getName());
eventThreadListeners = new ArrayList<EventThreadListener>(1);
this.foeiResourceAdapter=foeiResourceAdapter;
}
// ============= EventExecutorManager
/**
* Executes an Event mostly send from an EventObject.
* @see EventExecutorManager#executeEvent(Object, EventPort)
*/
public void executeEvent(EventPort eventPort,Object eventObject) {
executeEvent(eventPort,eventObject,FoeiProcessFactory.getFoeiProcess());
}
/**
* Executes an EventPort with object in an FoeiProcess.
* @param eventPort
* @param eventObject
* @param foeiProcess
*/
public void executeEvent(EventPort eventPort,Object eventObject,FoeiProcess foeiProcess) {
FoeiPortMessage msg = new FoeiPortMessage();
msg.setEventObject(eventObject);
msg.setEventPort(eventPort);
foeiProcess.getWorkQueue().add(msg);
if (foeiProcess.getExecutors().size()>3) {
return;
}
EventExecutor e = null;
try {
e = (EventExecutor)eventExecutorClass.newInstance();
} catch (Exception ee) {
logger.log(Level.WARNING,"Error Creating EventExecutor: "+ee.getMessage(),ee);
return;
}
e.setFoeiProcess(foeiProcess);
foeiProcess.getExecutors().add(e);
try {
logger.info("Setting work to EE workmanager");
foeiResourceAdapter.getBootstrapContext().getWorkManager().scheduleWork(new WorkWrapper(e));
} catch (WorkException ee) {
ee.printStackTrace();
}
}
/**
* Executes an event.
* @see EventExecutorManager#execute(Runnable)
*/
public void execute(Runnable runnable,FoeiProcess foeiProcess) {
try {
foeiResourceAdapter.getBootstrapContext().getWorkManager().scheduleWork(new WorkWrapper(new FoeiProcessRunnableWrapper(runnable,foeiProcess)));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Starts the ThreadPool
* @see EventExecutorManager#start()
*/
public void start(FoeiContext foeiContext) {
if(foeiContext==null) {
throw new NullPointerException("FoeiContext may not be null.");
}
logger.info("Starting EventExecutorManagerImpl");
try {
eventExecutorClass = FoeiConfiguratorImpl.newEventExecutorClass(foeiContext.getStartProperties());
} catch (ClassNotFoundException cce) {
logger.log(Level.WARNING,"Error getting eventExecutor class: "+cce.getMessage(),cce);
throw new RuntimeException("Could not get EventExecutor class: "+cce.getMessage(),cce);
}
}
/**
* Stops the ThreadPool
* @see EventExecutorManager#stop()
*/
public void stop(FoeiContext foeiContext) {
}
/**
* @see EventExecutorManager#getEventThreadListeners()
*/
public List<EventThreadListener> getEventThreadListeners() {
return eventThreadListeners;
}
/**
* @see EventExecutorManager#addEventThreadListener(EventThreadListener)
*/
public void addEventThreadListener(EventThreadListener eventThreadListener) throws IllegalStateException {
if(eventThreadListener==null) {
throw new NullPointerException("eventThreadListener may not be null.");
}
eventThreadListeners.add(eventThreadListener);
}
}
class WorkWrapper implements Work {
private Runnable run = null;
private Logger logger = Logger.getLogger(WorkWrapper.class.getName());
public WorkWrapper(Runnable run) {
this.run=run;
}
/**
* @see javax.resource.spi.work.Work#release()
*/
public void release() {
logger.info("Releasing jca foei adapter.");
}
/**
* @see java.lang.Runnable#run()
*/
public void run() {
try {
logger.info("Executing job: "+run);
run.run();
} catch (Throwable e) {
logger.log(Level.WARNING,"Error in jca foei work unit: "+e.getMessage(),e);
} finally {
logger.info("Done running jobs");
}
}
}

View file

@ -0,0 +1,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<br/>
* 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<String,EventPort> inputs = null;
/**
* The constuctor
*/
public AbstractEventInput() {
inputs = new HashMap<String,EventPort>(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<EventPort> 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;
}

View file

@ -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<EventStep> eventSteps = null;
/** The Logger to log to. */
private Logger logger = null;
/**
* Creates the EventStep list and the logger.
*/
public AbstractEventInputStepController() {
eventSteps = new ArrayList<EventStep>();
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<EventStep> 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;
}
}

View file

@ -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<br/>
* 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<String,EventPort> inputs = null;
public AbstractEventObject() {
inputs = new HashMap<String,EventPort>(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<EventPort> 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;
}

View file

@ -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<EventStep> eventSteps = null;
/** The Logger to log to. */
private Logger logger = null;
/**
* Creates the EventStep list and the logger.
*/
public AbstractEventObjectStepController() {
eventSteps = new ArrayList<EventStep>();
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<EventStep> 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;
}
}

View file

@ -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<br/>
* 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<String,EventPort> outputs = null;
/**
* Creates an AbstractEventOutput
*/
public AbstractEventOutput() {
outputs = new HashMap<String,EventPort>(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<EventPort> 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);
}
}

View file

@ -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<EventStep> eventSteps = null;
/** The Logger to log to. */
private Logger logger = null;
/**
* Creates the EventStep list and the logger.
*/
public AbstractEventOutputStepController() {
eventSteps = new ArrayList<EventStep>();
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<EventStep> 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;
}
}

View file

@ -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 {
}

View file

@ -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<EventStep> 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<EventStep>();
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<EventStep> 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;
}
}

View file

@ -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.<br>
* Which can be directed at different inputs of the object.<br>
*
* @author Willem Cazander
* @version 1.0 01/02/2005
*/
public interface EventInput extends Serializable {
/**
* Gets the all input EventPorts.<br>
*
* @return An List with the current EventPort's.
*/
public Collection<EventPort> 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.<br>
* @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;
}

View file

@ -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<br>
* inputsEvent objects.<br>
* <br>
* 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<EventPort> getOutputPorts();
/**
* Gets an OutputPort by its name.
* @param name The name of the output port.
* @return Returns the outputPort
*/
public EventPort getOutputPort(String name);
}

View file

@ -0,0 +1,167 @@
/*
* 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.<br/>
* <br/>
* All the public final are for progroming
*
* @author Willem Cazander
* @version 1.0 18/04/2005
*/
public class EventPort {
/** public type for defining TRUE */
static final public String TRUE = "true";
/** public type for defining FALSE */
static final public String FALSE = "false";
/** public type for defining INPUT */
static final public String INPUT = "input";
/** public type for defining OUTPUT */
static final public String OUTPUT = "output";
/** public type for defining PASS */
static final public String PASS = "pass";
/** public type for defining DROP */
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.
* <br/>
* immediate has 2 defaults depending on the EventPortType of the EventPort.<br/>
* input=true<br/>
* output=false<br/>
* This defines the default behouvier of the foei events and newexecutors<br/>
*
* @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;
}
}

View file

@ -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;
/**
* EventPortType of an EventPort
*
* @author Willem Cazander
* @version 1.0 Mar 3, 2006
*/
public enum EventPortType {
/**
* Type for input ports
*/
input,
/**
* Type for output ports
*/
output;
}

View file

@ -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;
}

View file

@ -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.<br>
* Gets the possibilty to add/remove EventSteps.<br>
*
* @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<EventStep> getEventSteps();
/**
* Executes all EventSteps until there is null or we are done.
* @param object
* @return
*/
public Object processEventSteps(Object object);
}

View file

@ -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);
}
}

View file

@ -0,0 +1,70 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.event.annotations;
import com.idcanet.foei.event.EventPortType;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Defines an input EventPort
*
* @author Willem Cazander
* @version 1.0 Jan 20, 2006
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SetEventPort {
/**
*
* @return
*/
EventPortType type();
/**
* Gets the name of the input EventPort
* @return Returns the name of the input EventPort
*/
String name();
/**
* Gets the objectType of the input EventPort
* it defaults to Object.class but is lookuped in the annotated method.
* @return Returns the objectType of the input EventPort
*/
Class objectType() default Object.class;
/**
*
* @return
*/
String immediate() default "null";
}

View file

@ -0,0 +1,49 @@
/*
* Copyright 2004-2006 IDCA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the authors and
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
*/
package com.idcanet.foei.event.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Defines an output EventPort
*
* @author Willem Cazander
* @version 1.0 Jan 20, 2006
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface SetEventPorts {
/**
* An array of SetEventPort annotations
* @return Returns an array of SetEventPort annotations
*/
SetEventPort[] ports();
}

View file

@ -0,0 +1,61 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html 1.00
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.
-->
</head>
<body bgcolor="white">
Provides abstract classes and interfaces to send/receive events.<br/>
<h2>Package Specification</h2>
<ul>
<li>Full J2SE 5 compatible</li>
<li>Small package</li>
</ul>
<!--
<ul>
<li><a href="">hgj</a>
</ul>
-->
<h2>Related Documentation</h2>
None.
<!--
For overviews, tutorials, examples, guides, and tool documentation, please see:
<ul>
<li><a href="http://foei.idca.nl/docs/jmx/example1">Example 1</a>
</ul>
-->
<!-- Put @see and @since tags down here. -->
</body>
</html>

View file

@ -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<String,FoeiContext> contexts = null;
/**
* Inits the logger and the FoeiContext storage.
*/
public FoeiContextManager() {
logger = Logger.getLogger(FoeiContextManager.class.getName());
contexts = new HashMap<String,FoeiContext>(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 !!<br/>
*
* 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();
}
}
}

Some files were not shown because too many files have changed in this diff Show more