[svn r115] added the rest of foei
This commit is contained in:
parent
a9ea03e737
commit
ed5da52253
|
@ -3,5 +3,7 @@
|
|||
<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/commons-beanutils.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
BIN
lib/commons-beanutils.jar
Normal file
BIN
lib/commons-beanutils.jar
Normal file
Binary file not shown.
BIN
lib/idcanet-x4o-bin.jar
Normal file
BIN
lib/idcanet-x4o-bin.jar
Normal file
Binary file not shown.
33
src/META-INF/events.eld
Normal file
33
src/META-INF/events.eld
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<XMLElements>
|
||||
<eld-info>
|
||||
<name>events.eld</name>
|
||||
<description>All event foei objects</description>
|
||||
</eld-info>
|
||||
|
||||
</XMLElements>
|
57
src/META-INF/filters.eld
Normal file
57
src/META-INF/filters.eld
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<XMLElements>
|
||||
<eld-info>
|
||||
<name>filters.eld</name>
|
||||
<description>All core foei objects</description>
|
||||
</eld-info>
|
||||
|
||||
<element>
|
||||
<name>filter</name>
|
||||
<description>Filters an object by its eventSteps</description>
|
||||
<class>com.idcanet.foei.components.lang.Filter</class>
|
||||
</element>
|
||||
|
||||
<element>
|
||||
<name>stringFilter</name>
|
||||
<description>filters an String on a regex</description>
|
||||
<class>com.idcanet.foei.components.steps.filters.StringFilter</class>
|
||||
</element>
|
||||
|
||||
<element>
|
||||
<name>classFilter</name>
|
||||
<description>filters for a class on an object</description>
|
||||
<class>com.idcanet.foei.components.steps.filters.ClassFilter</class>
|
||||
</element>
|
||||
|
||||
<element>
|
||||
<name>dateFilter</name>
|
||||
<description>filters an date of an Date</description>
|
||||
<class>com.idcanet.foei.components.steps.filters.DateFilter</class>
|
||||
</element>
|
||||
|
||||
</XMLElements>
|
23
src/META-INF/foei-context-defaults.xml
Normal file
23
src/META-INF/foei-context-defaults.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
|
||||
<properties>
|
||||
<!-- THE FOEI PROPERTIES DEFAULTS -->
|
||||
|
||||
<!--
|
||||
#foei.object_bindings_manager=com.idca.foei.core.impl.ObjectBindingsManagerImpl
|
||||
#foei.event_executor=com.idca.foei.core.impl.EventExecutorImpl
|
||||
#foei.event_executor_manager=com.idca.foei.core.impl.EventExecutorManagerImpl
|
||||
#foei.event_executor_manager.pool_core_size=3
|
||||
#foei.event_executor_manager.pool_max_size=5
|
||||
#foei.event_executor_manager.pool_keep_alive=180
|
||||
#foei.initial_object_context_factory=com.idca.foei.utils.jndi.MemoryContextFactory
|
||||
#foei.event_thread_listeners=<empty>
|
||||
#foei.x2o_root_tag=foei
|
||||
#foei.x2o_default_element_configurator=com.idca.foei.xml.x2o.DefaultX2OElementConfigurator
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<entry key="foei.object_bindings_manager">com.idcanet.foei.core.impl.ObjectBindingsManagerImpl</entry>
|
||||
|
||||
</properties>
|
18
src/META-INF/foei-namespaces.properties
Normal file
18
src/META-INF/foei-namespaces.properties
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
code.http\://foei.idca.nl/eld/events.eld=com.idcanet.x4o.core.DefaultX4OEldElementProvider
|
||||
file.http\://foei.idca.nl/eld/events.eld=/META-INF/events.eld
|
||||
|
||||
code.http\://foei.idca.nl/eld/filters.eld=com.idcanet.x4o.core.DefaultX4OEldElementProvider
|
||||
file.http\://foei.idca.nl/eld/filters.eld=/META-INF/filters.eld
|
||||
|
||||
code.http\://foei.idca.nl/eld/io.eld=com.idcanet.x4o.core.DefaultX4OEldElementProvider
|
||||
file.http\://foei.idca.nl/eld/io.eld=/META-INF/io.eld
|
||||
|
||||
code.http\://foei.idca.nl/eld/lang.eld=com.idcanet.x4o.core.DefaultX4OEldElementProvider
|
||||
file.http\://foei.idca.nl/eld/lang.eld=/META-INF/lang.eld
|
||||
|
||||
code.http\://foei.idca.nl/eld/logging.eld=com.idcanet.x4o.core.DefaultX4OEldElementProvider
|
||||
file.http\://foei.idca.nl/eld/logging.eld=/META-INF/logging.eld
|
||||
|
||||
code.http\://foei.idca.nl/eld/printers.eld=com.idcanet.x4o.core.DefaultX4OEldElementProvider
|
||||
file.http\://foei.idca.nl/eld/printers.eld=/META-INF/printers.eld
|
53
src/META-INF/io.eld
Normal file
53
src/META-INF/io.eld
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<XMLElements>
|
||||
|
||||
<eld-info>
|
||||
<name>io.eld</name>
|
||||
<description>io foei objects</description>
|
||||
</eld-info>
|
||||
|
||||
<element>
|
||||
<name>standardOutput</name>
|
||||
<description>This Object printer prints to the std-out</description>
|
||||
<class>com.idcanet.foei.components.io.StandardOutput</class>
|
||||
</element>
|
||||
|
||||
|
||||
<element>
|
||||
<name>errorOutput</name>
|
||||
<description>This Object printer prints to the err-out</description>
|
||||
<class>com.idcanet.foei.components.io.ErrorOutput</class>
|
||||
</element>
|
||||
|
||||
<element>
|
||||
<name>fileOutput</name>
|
||||
<description>This Object printer prints to a file</description>
|
||||
<class>com.idcanet.foei.components.io.FileOutput</class>
|
||||
</element>
|
||||
|
||||
</XMLElements>
|
105
src/META-INF/lang.eld
Normal file
105
src/META-INF/lang.eld
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<XMLElements>
|
||||
<eld-info>
|
||||
<name>lang.eld</name>
|
||||
<description>All core lang foei objects</description>
|
||||
</eld-info>
|
||||
|
||||
<global-parameter>
|
||||
<parameter-name>bind</parameter-name>
|
||||
<parameter-handler>com.idcanet.foei.core.x4o.BindAttributeHandler</parameter-handler>
|
||||
<parameter-description>Binds the EventPort to getter</parameter-description>
|
||||
</global-parameter>
|
||||
|
||||
<global-parameter>
|
||||
<parameter-name>id</parameter-name>
|
||||
<parameter-handler>com.idcanet.foei.core.x4o.IdAttributeHandler</parameter-handler>
|
||||
<parameter-description>Adds the object into the context</parameter-description>
|
||||
</global-parameter>
|
||||
|
||||
<element-bindings>
|
||||
<rule-handler>com.idcanet.foei.core.x4o.EventStepBindRuleHandler</rule-handler>
|
||||
<rule-description></rule-description>
|
||||
</element-bindings>
|
||||
|
||||
<element>
|
||||
<name>bind</name>
|
||||
<description>Binds 2 eventPorts together</description>
|
||||
<configurator>com.idcanet.foei.core.x4o.ObjectBindingElement</configurator>
|
||||
</element>
|
||||
|
||||
<element>
|
||||
<name>dummyOutputPort</name>
|
||||
<description>An dummy output, mostly used to send events into foei.</description>
|
||||
<class>com.idcanet.foei.components.lang.DummyOutputPort</class>
|
||||
</element>
|
||||
|
||||
<element>
|
||||
<name>objectChangedBuffer</name>
|
||||
<description>Buffers objects an only fires when it is not equal</description>
|
||||
<class>com.idcanet.foei.components.lang.ObjectChangedBuffer</class>
|
||||
</element>
|
||||
|
||||
<element>
|
||||
<name>destroyFoeiProcess</name>
|
||||
<description>Destroys the current process</description>
|
||||
<class>com.idcanet.foei.components.lang.DestroyFoeiProcess</class>
|
||||
</element>
|
||||
|
||||
<element>
|
||||
<name>setBeanProperty</name>
|
||||
<description>Sets an property on a bean.</description>
|
||||
<class>com.idcanet.foei.components.lang.SetBeanProperty</class>
|
||||
</element>
|
||||
|
||||
<element>
|
||||
<name>getBeanProperty</name>
|
||||
<description>Gets an property on a bean.</description>
|
||||
<class>com.idcanet.foei.components.lang.GetBeanProperty</class>
|
||||
</element>
|
||||
|
||||
|
||||
<element>
|
||||
<name>getBeanPropertyStep</name>
|
||||
<description>gets an property of an obeject</description>
|
||||
<class>com.idcanet.foei.components.steps.lang.GetBeanPropertyStep</class>
|
||||
</element>
|
||||
|
||||
<element>
|
||||
<name>mapValue</name>
|
||||
<description>gets an Value out of an Map</description>
|
||||
<class>com.idcanet.foei.components.steps.lang.MapValue</class>
|
||||
</element>
|
||||
|
||||
<element>
|
||||
<name>listValue</name>
|
||||
<description>gets an Value out of an List</description>
|
||||
<class>com.idcanet.foei.components.steps.lang.ListValue</class>
|
||||
</element>
|
||||
|
||||
</XMLElements>
|
35
src/META-INF/logging.eld
Normal file
35
src/META-INF/logging.eld
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<XMLElements>
|
||||
|
||||
<element>
|
||||
<name>loggerInput</name>
|
||||
<description>Java Logger InputHandler</description>
|
||||
<class>com.idcanet.foei.components.logging.LoggerInput</class>
|
||||
</element>
|
||||
|
||||
</XMLElements>
|
61
src/META-INF/printers.eld
Normal file
61
src/META-INF/printers.eld
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<XMLElements>
|
||||
|
||||
<eld-info>
|
||||
<name>printers.eld</name>
|
||||
<description>A few standaard (step)printers</description>
|
||||
</eld-info>
|
||||
|
||||
|
||||
<element>
|
||||
<name>defaultPrinter</name>
|
||||
<description>This EventStep uses to toString() to print an object.</description>
|
||||
<class>com.idcanet.foei.components.steps.printers.DefaultPrinter</class>
|
||||
<parameters>
|
||||
<parameter>
|
||||
<parameter-name>prefix</parameter-name>
|
||||
<parameter-type>java.lang.String</parameter-type>
|
||||
<parameter-default>null</parameter-default>
|
||||
<parameter-description>Prints the prefix of this printer</parameter-description>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<parameter-name>postfix</parameter-name>
|
||||
<parameter-type>java.lang.String</parameter-type>
|
||||
<parameter-default>null</parameter-default>
|
||||
<parameter-description>Prints the postfix of this printer</parameter-description>
|
||||
</parameter>
|
||||
</parameters>
|
||||
</element>
|
||||
|
||||
<element>
|
||||
<name>datePrinter</name>
|
||||
<description>This eventStep prints an date object including formating</description>
|
||||
<class>com.idcanet.foei.components.steps.printers.DatePrinter</class>
|
||||
</element>
|
||||
|
||||
</XMLElements>
|
72
src/com/idcanet/foei/components/io/ErrorOutput.java
Normal file
72
src/com/idcanet/foei/components/io/ErrorOutput.java
Normal 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;
|
||||
}
|
||||
}
|
36
src/com/idcanet/foei/components/io/FileOutput.java
Normal file
36
src/com/idcanet/foei/components/io/FileOutput.java
Normal 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("");
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
73
src/com/idcanet/foei/components/io/StandardOutput.java
Normal file
73
src/com/idcanet/foei/components/io/StandardOutput.java
Normal 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;
|
||||
}
|
||||
}
|
64
src/com/idcanet/foei/components/logging/Log4jInput.java
Normal file
64
src/com/idcanet/foei/components/logging/Log4jInput.java
Normal 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");
|
||||
}
|
||||
}
|
||||
*/
|
65
src/com/idcanet/foei/components/logging/LoggerHandler.java
Normal file
65
src/com/idcanet/foei/components/logging/LoggerHandler.java
Normal 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 java.util.HashMap;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 25, 2006
|
||||
*/
|
||||
public class LoggerHandler extends Handler
|
||||
{
|
||||
private Logger logger = Logger.getLogger(this.getClass().getName());
|
||||
private LoggerInput loggerInput = null;
|
||||
|
||||
public LoggerHandler(LoggerInput loggerInput)
|
||||
{
|
||||
this.loggerInput=loggerInput;
|
||||
logger.addHandler(this);
|
||||
}
|
||||
|
||||
// ------------ handler
|
||||
|
||||
public void publish(LogRecord record) {
|
||||
HashMap event = new HashMap();
|
||||
event.put("message",record.getMessage());
|
||||
event.put("level",record.getLevel().getName());
|
||||
loggerInput.sendMessage(event);
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
}
|
||||
|
||||
public void close() {
|
||||
}
|
||||
}
|
67
src/com/idcanet/foei/components/logging/LoggerInput.java
Normal file
67
src/com/idcanet/foei/components/logging/LoggerInput.java
Normal 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.components.logging;
|
||||
|
||||
import com.idcanet.foei.core.FoeiProcessFactory;
|
||||
import com.idcanet.foei.event.AbstractEventOutput;
|
||||
import com.idcanet.foei.event.EventPort;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Reseives java logging messages
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 25, 2006
|
||||
*/
|
||||
public class LoggerInput extends AbstractEventOutput
|
||||
{
|
||||
/** v1.0 */
|
||||
static final long serialVersionUID = 10l;
|
||||
/** */
|
||||
static final String OUTPUT = "output";
|
||||
|
||||
/**
|
||||
* Creates an LoggerInput
|
||||
*
|
||||
*/
|
||||
public LoggerInput() {
|
||||
// define an outpur source.
|
||||
addOutputPort(OUTPUT,Map.class);
|
||||
new LoggerHandler(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
public void sendMessage(Map event) {
|
||||
FoeiProcessFactory.getFoeiProcess().executeEvent(getOutputPort(EventPort.OUTPUT),event);
|
||||
//FoeiInstance foeiInstance = FoeiServer.getFoeiInstance();
|
||||
//foeiInstance.getObjectBindingsManager().sendEventOutput(getID(),OUTPUT,event);
|
||||
}
|
||||
}
|
55
src/com/idcanet/foei/components/logging/package.html
Normal file
55
src/com/idcanet/foei/components/logging/package.html
Normal 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>
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.components.steps.filters;
|
||||
|
||||
import com.idcanet.foei.event.AbstractEventStepController;
|
||||
|
||||
/**
|
||||
* Filters an object and checks for the className.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 26/01/2005
|
||||
*/
|
||||
public class ClassFilter extends AbstractEventStepController
|
||||
{
|
||||
/** v1.0 */
|
||||
static final long serialVersionUID = 10l;
|
||||
/** The class name to match */
|
||||
private String className = null;
|
||||
|
||||
/**
|
||||
* Sets the className which the filtered object has to have.
|
||||
* @param className The className.
|
||||
*/
|
||||
public void setClassName(String className)
|
||||
{
|
||||
this.className=className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the className on which this filter filters.
|
||||
* @return The className.
|
||||
*/
|
||||
public String getClassName()
|
||||
{
|
||||
return className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process an object.<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();
|
||||
System.out.println("ClassFilter filter: "+object+" on "+className+" classes: "+classes.length);
|
||||
for(int i=0;i<classes.length;i++)
|
||||
{
|
||||
System.err.println("test:"+classes[i].getName());
|
||||
if(classes[i].getName().equals(className))
|
||||
{
|
||||
Object object2 = processEventSteps(object);
|
||||
System.err.println("ClassFilter filter: "+object+" childFilter: "+object2);
|
||||
return object2;
|
||||
}
|
||||
}
|
||||
// no match found.
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Emty constuctor.
|
||||
*
|
||||
*/
|
||||
public DateFilter()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
116
src/com/idcanet/foei/components/steps/filters/NumberFilter.java
Normal file
116
src/com/idcanet/foei/components/steps/filters/NumberFilter.java
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* 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 com.idcanet.foei.utils.beans.NumberComparator;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
158
src/com/idcanet/foei/components/steps/filters/StringFilter.java
Normal file
158
src/com/idcanet/foei/components/steps/filters/StringFilter.java
Normal file
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.components.steps.filters;
|
||||
|
||||
import com.idcanet.foei.event.AbstractEventStepController;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Filters an String object.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 26/01/2005
|
||||
*/
|
||||
public class StringFilter extends AbstractEventStepController
|
||||
{
|
||||
/** v1.0 */
|
||||
static final long serialVersionUID = 10l;
|
||||
private int minLength=0;
|
||||
private int maxLength=0;
|
||||
private Logger logger = Logger.getLogger(this.getClass().getName());
|
||||
private Pattern pattern = null;
|
||||
|
||||
/**
|
||||
* Emty constuctor.
|
||||
*/
|
||||
public StringFilter() {
|
||||
}
|
||||
|
||||
// -------------- (bean)properties.
|
||||
|
||||
/**
|
||||
* Sets the regulare expression on which this object filters an String.<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;
|
||||
}
|
||||
}
|
55
src/com/idcanet/foei/components/steps/filters/package.html
Normal file
55
src/com/idcanet/foei/components/steps/filters/package.html
Normal 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>
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.components.steps.lang;
|
||||
|
||||
import com.idcanet.foei.event.AbstractEventStepController;
|
||||
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
|
||||
/**
|
||||
* Gets the property of an java bean.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 9, 2006
|
||||
*/
|
||||
public class GetBeanPropertyStep extends AbstractEventStepController
|
||||
{
|
||||
/** v1.0 */
|
||||
static final long serialVersionUID = 10l;
|
||||
/** Holds the key which contains the object in the map. */
|
||||
private String property = null;
|
||||
|
||||
|
||||
//----------- get/set functions
|
||||
|
||||
public void setProperty(String property) {
|
||||
this.property=property;
|
||||
}
|
||||
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
// -------------------- EventStep
|
||||
|
||||
/**
|
||||
* Proces an Object, when property is correcly found then
|
||||
* it is processed by the eventSteps of the object.
|
||||
*/
|
||||
public Object processObject(Object object) {
|
||||
if(property==null) {
|
||||
return null;
|
||||
}
|
||||
Object result = null;
|
||||
try {
|
||||
result = BeanUtils.getProperty(object,property);
|
||||
} catch (Exception e) {
|
||||
//logger.log(Level.WARNING,"property:"+property+" is not an property of object: "+object.getClass().getName(),e);
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return processEventSteps(result);
|
||||
}
|
||||
}
|
||||
|
79
src/com/idcanet/foei/components/steps/lang/ListValue.java
Normal file
79
src/com/idcanet/foei/components/steps/lang/ListValue.java
Normal 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.lang;
|
||||
|
||||
import com.idcanet.foei.event.AbstractEventStepController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Gets an Value out of an List
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 9, 2006
|
||||
*/
|
||||
public class ListValue extends AbstractEventStepController
|
||||
{
|
||||
/** v1.0 */
|
||||
static final long serialVersionUID = 10l;
|
||||
/** Holds the index which contains the object in the map. */
|
||||
private String index = null;
|
||||
|
||||
static private final String FIRST = "FIRST";
|
||||
static private final String LAST = "LAST";
|
||||
|
||||
// bean
|
||||
|
||||
public void setIndex(String index) {
|
||||
this.index=index;
|
||||
}
|
||||
public String getIndex() {
|
||||
return index;
|
||||
}
|
||||
public Object processObject(Object object) {
|
||||
|
||||
if(!(object instanceof List)) {
|
||||
return null;
|
||||
}
|
||||
List list = (List)object;
|
||||
|
||||
if(FIRST.equalsIgnoreCase(index)) {
|
||||
return processEventSteps(list.get(0));
|
||||
}
|
||||
if(LAST.equalsIgnoreCase(index)) {
|
||||
return processEventSteps(list.get(list.size()));
|
||||
}
|
||||
try {
|
||||
int listIndex = new Integer(index);
|
||||
return processEventSteps(list.get(listIndex));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
88
src/com/idcanet/foei/components/steps/lang/MapValue.java
Normal file
88
src/com/idcanet/foei/components/steps/lang/MapValue.java
Normal 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.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>
|
||||
*
|
||||
*/
|
||||
public Object processObject(Object object) {
|
||||
if(key==null) {
|
||||
return null;
|
||||
}
|
||||
Map map = (Map)object;
|
||||
object = map.get(key);
|
||||
return processEventSteps(object);
|
||||
}
|
||||
}
|
||||
|
57
src/com/idcanet/foei/components/steps/lang/package.html
Normal file
57
src/com/idcanet/foei/components/steps/lang/package.html
Normal 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>
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
61
src/com/idcanet/foei/components/steps/printers/package.html
Normal file
61
src/com/idcanet/foei/components/steps/printers/package.html
Normal 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>
|
126
src/com/idcanet/foei/core/impl/EventExecutorImpl.java
Normal file
126
src/com/idcanet/foei/core/impl/EventExecutorImpl.java
Normal file
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.core.impl;
|
||||
|
||||
import com.idcanet.foei.core.EventExecutor;
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.core.FoeiProcessFactory;
|
||||
import com.idcanet.foei.event.EventInput;
|
||||
import com.idcanet.foei.event.EventPort;
|
||||
import com.idcanet.foei.event.EventPortType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Reuable EventExecutors
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 19, 2006
|
||||
*/
|
||||
public class EventExecutorImpl implements EventExecutor {
|
||||
|
||||
/** The logger to log to. */
|
||||
private Logger logger = null;
|
||||
/** The event obect. */
|
||||
private Object eventObject = null;
|
||||
/** The eventport */
|
||||
private EventPort eventPort = null;
|
||||
/** True when ready */
|
||||
private boolean ready = false;
|
||||
|
||||
/**
|
||||
* Creates an EventExecutor
|
||||
*/
|
||||
public EventExecutorImpl() {
|
||||
logger = Logger.getLogger(EventExecutorImpl.class.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventExecutor#setEventObject(Object)
|
||||
*/
|
||||
public void setEventObject(Object eventObject) {
|
||||
this.eventObject=eventObject;
|
||||
ready = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventExecutor#setEventPort(EventPort)
|
||||
*/
|
||||
public void setEventPort(EventPort eventPort) {
|
||||
if(eventPort==null) {
|
||||
throw new NullPointerException("EventPort may not be null.");
|
||||
}
|
||||
this.eventPort=eventPort;
|
||||
ready = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EventExecutor#isReady()
|
||||
*/
|
||||
public boolean isReady() {
|
||||
return ready;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Runnable#run()
|
||||
*/
|
||||
public void run() {
|
||||
if(eventPort==null) {
|
||||
logger.warning("Can't execute event on null eventPort.");
|
||||
return;
|
||||
}
|
||||
ready = false;
|
||||
try {
|
||||
FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess();
|
||||
if(eventPort.getEventPortType()==EventPortType.input) {
|
||||
EventInput eventInput = (EventInput)eventPort.getEventObject();
|
||||
eventInput.doEvent(eventPort,eventObject);
|
||||
return;
|
||||
}
|
||||
if(eventPort.getEventPortType()==EventPortType.output) {
|
||||
List<EventPort> bindings = foeiProcess.getBindings(eventPort);
|
||||
for(EventPort port:bindings) {
|
||||
EventInput eventInput = (EventInput)port.getEventObject();
|
||||
if(port.isImmediate()) {
|
||||
logger.finer("Executing event of: "+port.getEventObject()+" port:"+port.getName()+" object: "+eventObject);
|
||||
eventInput.doEvent(port,eventObject);
|
||||
} else {
|
||||
logger.finest("Adding event to event queue");
|
||||
foeiProcess.executeEvent(port,eventObject);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,"Error while Executing Event",e);
|
||||
} finally {
|
||||
ready = true;
|
||||
}
|
||||
}
|
||||
}
|
201
src/com/idcanet/foei/core/impl/EventExecutorManagerImpl.java
Normal file
201
src/com/idcanet/foei/core/impl/EventExecutorManagerImpl.java
Normal file
|
@ -0,0 +1,201 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.core.impl;
|
||||
|
||||
import com.idcanet.foei.core.EventExecutor;
|
||||
import com.idcanet.foei.core.EventExecutorManager;
|
||||
import com.idcanet.foei.core.EventThreadListener;
|
||||
import com.idcanet.foei.core.FoeiContext;
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.core.FoeiProcessFactory;
|
||||
import com.idcanet.foei.event.EventPort;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Defines the EventExecutorManager implementation
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 20, 2006
|
||||
*/
|
||||
public class EventExecutorManagerImpl implements EventExecutorManager {
|
||||
|
||||
/** The logger to log to. */
|
||||
private Logger logger = null;
|
||||
/** The thread pool */
|
||||
private ThreadPoolExecutor threadPoolExecutor = null;
|
||||
/** The EventThreadListeners */
|
||||
private List<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) {
|
||||
EventExecutor e = null;
|
||||
try {
|
||||
e = (EventExecutor)eventExecutorClass.newInstance();
|
||||
} catch (Exception ee) {
|
||||
logger.log(Level.WARNING,"Error Creating EventExecutor: "+ee.getMessage(),ee);
|
||||
return;
|
||||
}
|
||||
e.setEventObject(eventObject);
|
||||
e.setEventPort(eventPort);
|
||||
if(eventPort.isImmediate()) {
|
||||
e.run();
|
||||
} else {
|
||||
// mmmm
|
||||
execute(e,foeiProcess);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes an event.
|
||||
* @see EventExecutorManager#execute(Runnable)
|
||||
*/
|
||||
public void execute(Runnable runnable,FoeiProcess foeiProcess) {
|
||||
if(threadPoolExecutor==null) {
|
||||
throw new IllegalStateException("EventExecutorManager has not been started.");
|
||||
}
|
||||
threadPoolExecutor.execute(new FoeiProcessRunnableWrapper(runnable,foeiProcess));
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the ThreadPool
|
||||
* @see EventExecutorManager#start()
|
||||
*/
|
||||
public void start(FoeiContext foeiContext) {
|
||||
if(foeiContext==null) {
|
||||
throw new NullPointerException("FoeiContext may not be null.");
|
||||
}
|
||||
logger.info("Starting EventExecutorManagerImpl");
|
||||
|
||||
try {
|
||||
eventExecutorClass = FoeiConfiguratorImpl.newEventExecutorClass(foeiContext.getStartProperties());
|
||||
} catch (ClassNotFoundException cce) {
|
||||
logger.log(Level.WARNING,"Error getting eventExecutor class: "+cce.getMessage(),cce);
|
||||
throw new RuntimeException("Could not get EventExecutor class: "+cce.getMessage(),cce);
|
||||
}
|
||||
|
||||
EventExecutorThreadFactory tf = new EventExecutorThreadFactory(foeiContext);
|
||||
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor (
|
||||
FoeiConfiguratorImpl.getEventExecutorPoolCoreSize(foeiContext.getStartProperties()),
|
||||
FoeiConfiguratorImpl.getEventExecutorPoolMaxSize(foeiContext.getStartProperties()),
|
||||
FoeiConfiguratorImpl.getEventExecutorPoolKeepAlive(foeiContext.getStartProperties()),
|
||||
TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.core.impl;
|
||||
|
||||
import com.idcanet.foei.core.FoeiContext;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Creates Thread for the threadpool and injects the threadpool runnable object with the
|
||||
* FoeiContext.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 7, 2006
|
||||
*/
|
||||
public class EventExecutorThreadFactory implements ThreadFactory
|
||||
{
|
||||
/** The pool number. */
|
||||
static private final AtomicInteger poolNumber = new AtomicInteger(1);
|
||||
/** The thread group. */
|
||||
private final ThreadGroup group;
|
||||
/** The thread number. */
|
||||
private final AtomicInteger threadNumber = new AtomicInteger(1);
|
||||
/** The name prefix. */
|
||||
private String namePrefix = null;
|
||||
/** The FoeiContext to wrap in the thread. */
|
||||
private FoeiContext foeiContext = null;
|
||||
/** The logger to log to. */
|
||||
private Logger logger = null;
|
||||
|
||||
/**
|
||||
* Creates an EventExecutorThreadFactory
|
||||
* @param foeiContext
|
||||
*/
|
||||
public EventExecutorThreadFactory(FoeiContext foeiContext) {
|
||||
if(foeiContext==null) {
|
||||
throw new NullPointerException("FoeiContext may not be null.");
|
||||
}
|
||||
logger = Logger.getLogger(EventExecutorThreadFactory.class.getName());
|
||||
this.foeiContext=foeiContext;
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
group = (s != null)? s.getThreadGroup():Thread.currentThread().getThreadGroup();
|
||||
namePrefix = "foei-"+poolNumber.getAndIncrement()+"-thread-";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an new Thread and wrappes the Runnable with the FoeiContextRunnableWrapper
|
||||
*/
|
||||
public Thread newThread(Runnable r) {
|
||||
Runnable runnable = new EventThreadListenersRunnableWrapper(r,foeiContext);
|
||||
Thread t = new Thread(group,runnable,namePrefix+threadNumber.getAndIncrement(),0);
|
||||
logger.info("Created new Executor Thread: "+t.getName());
|
||||
if (t.isDaemon()) {
|
||||
t.setDaemon(false);
|
||||
}
|
||||
if (t.getPriority() != Thread.NORM_PRIORITY) {
|
||||
t.setPriority(Thread.NORM_PRIORITY);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
264
src/com/idcanet/foei/core/impl/FoeiConfiguratorImpl.java
Normal file
264
src/com/idcanet/foei/core/impl/FoeiConfiguratorImpl.java
Normal file
|
@ -0,0 +1,264 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.core.impl;
|
||||
|
||||
import com.idcanet.foei.core.EventExecutorManager;
|
||||
import com.idcanet.foei.core.EventThreadListener;
|
||||
import com.idcanet.foei.core.FoeiConfigurator;
|
||||
import com.idcanet.foei.core.FoeiContext;
|
||||
import com.idcanet.foei.core.FoeiContextBuildingException;
|
||||
import com.idcanet.foei.core.FoeiProcessManager;
|
||||
import com.idcanet.foei.core.ObjectBindingsManager;
|
||||
import com.idcanet.foei.utils.jndi.MemoryContextFactory;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.spi.InitialContextFactory;
|
||||
|
||||
/**
|
||||
* Creates an default implemention an of FoeiContext.
|
||||
* Which is config with the objects.
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 20, 2006
|
||||
*/
|
||||
public class FoeiConfiguratorImpl implements FoeiConfigurator {
|
||||
|
||||
static private Logger logger = Logger.getLogger(FoeiConfiguratorImpl.class.getName());
|
||||
|
||||
/**
|
||||
* Creates an FoeiContext
|
||||
*/
|
||||
public FoeiContext buildFoeiContext(Map<String,String> properties) throws FoeiContextBuildingException {
|
||||
|
||||
if(properties==null) {
|
||||
throw new NullPointerException("properties may not be null.");
|
||||
}
|
||||
String name = getContextName(properties);
|
||||
String rootPath = null;
|
||||
Context objectContext = null;
|
||||
EventExecutorManager eventExecutorManager = null;
|
||||
FoeiProcessManager foeiProcessManager = null;
|
||||
|
||||
try {
|
||||
rootPath = getRootPath(properties);
|
||||
objectContext = newContext(properties);
|
||||
eventExecutorManager = newEventExecutorManager(properties);
|
||||
foeiProcessManager = newFoeiProcessManager(properties);
|
||||
loadEventThreadListeners(properties,eventExecutorManager);
|
||||
} catch (Exception e) {
|
||||
throw new FoeiContextBuildingException("Error while building childs objects:",e);
|
||||
}
|
||||
return new FoeiContextImpl(name,rootPath,objectContext,eventExecutorManager,properties,foeiProcessManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the contextName from the properties map.
|
||||
* @param properties The properties map.
|
||||
* @return Returns the contextName from the properties map.
|
||||
*/
|
||||
static public String getContextName(Map<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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the root path from the properties Map.
|
||||
* @param properties The properties map.
|
||||
* @return Returns the rootpath from the properties map.
|
||||
*/
|
||||
static public String getRootPath(Map<String,String> properties) {
|
||||
String rootPath = properties.get(FoeiConfigurator.ROOT_PATH);
|
||||
if(rootPath==null) {
|
||||
throw new NullPointerException("rootPath needs to be set in properties as: "+FoeiConfigurator.ROOT_PATH);
|
||||
}
|
||||
return rootPath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param properties
|
||||
* @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)Class.forName(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)Class.forName(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)Class.forName(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)Class.forName(className).newInstance();
|
||||
eventExecutorManager.addEventThreadListener(eventThreadListener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Pool Core Size for the EventExecutor
|
||||
* @param properties
|
||||
* @return
|
||||
* @throws NumberFormatException
|
||||
*/
|
||||
static public Integer getEventExecutorPoolCoreSize(Map<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 Class.forName(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)Class.forName(className).newInstance();
|
||||
}
|
||||
|
||||
}
|
149
src/com/idcanet/foei/core/impl/FoeiContextImpl.java
Normal file
149
src/com/idcanet/foei/core/impl/FoeiContextImpl.java
Normal file
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.core.impl;
|
||||
|
||||
import com.idcanet.foei.core.EventExecutorManager;
|
||||
import com.idcanet.foei.core.FoeiContext;
|
||||
import com.idcanet.foei.core.FoeiProcessManager;
|
||||
|
||||
import java.util.Map;
|
||||
import javax.naming.Context;
|
||||
|
||||
/**
|
||||
* Defines the FoeiContext implemention.
|
||||
*
|
||||
* @see FoeiContext
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 19, 2006
|
||||
*/
|
||||
public class FoeiContextImpl implements FoeiContext
|
||||
{
|
||||
/** The name of this Instance **/
|
||||
private String name = null;
|
||||
|
||||
/** The root path of this instance **/
|
||||
private String rootPath = null;
|
||||
|
||||
/** The FoeiContext where all objects are stored. **/
|
||||
private Context objectContext = null;
|
||||
|
||||
/** The EventExecutorManager */
|
||||
private EventExecutorManager eventExecutorManager = null;
|
||||
|
||||
/** The start properties */
|
||||
private Map<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,String rootPath,Context objectContext,EventExecutorManager eventExecutorManager,Map<String,String> startProperties,FoeiProcessManager foeiProcessManager) {
|
||||
|
||||
if(name==null) {
|
||||
throw new NullPointerException("name may not be null.");
|
||||
}
|
||||
if(rootPath==null) {
|
||||
throw new NullPointerException("rootPath may not be null.");
|
||||
}
|
||||
if(objectContext==null) {
|
||||
throw new NullPointerException("objectContext may not be null.");
|
||||
}
|
||||
if(eventExecutorManager==null) {
|
||||
throw new NullPointerException("eventExecutorManager may not be null.");
|
||||
}
|
||||
if(foeiProcessManager==null) {
|
||||
throw new NullPointerException("foeiProcessManager may not be null.");
|
||||
}
|
||||
|
||||
this.name=name;
|
||||
this.rootPath=rootPath;
|
||||
this.objectContext=objectContext;
|
||||
this.eventExecutorManager=eventExecutorManager;
|
||||
this.startProperties=startProperties;
|
||||
this.foeiProcessManager=foeiProcessManager;
|
||||
eventExecutorManager.start(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FoeiContext#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FoeiContext#getRootPath()
|
||||
*/
|
||||
public String getRootPath() {
|
||||
return rootPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FoeiContext#getEventExecutorManager()
|
||||
*/
|
||||
public EventExecutorManager getEventExecutorManager() {
|
||||
return eventExecutorManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FoeiContext#getEventObjectContext()
|
||||
*/
|
||||
public Context getEventObjectContext() {
|
||||
return objectContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FoeiContext#getStartProperties()
|
||||
*/
|
||||
public Map<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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
|
||||
|
||||
package com.idcanet.foei.core.impl;
|
||||
|
||||
import com.idcanet.foei.event.EventInput;
|
||||
import com.idcanet.foei.event.EventOutput;
|
||||
import com.idcanet.foei.event.EventStep;
|
||||
import com.idcanet.foei.event.EventStepController;
|
||||
import com.idcanet.x4o.eld.BindingRuleHandler;
|
||||
import com.idcanet.x4o.element.Element;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* MM maybe move this class
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 24, 2006
|
||||
*/
|
||||
public class FoeiEventBindingRuleHandler implements BindingRuleHandler {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parameters
|
||||
*/
|
||||
public void setParameters(Map<String,String> parameters) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param object1
|
||||
* @param object2
|
||||
* @return
|
||||
*/
|
||||
public boolean canBind(Element element) {
|
||||
Object parent = element.getParent().getElementObject();
|
||||
Object child = element.getElementObject();
|
||||
|
||||
Object object1 = parent;
|
||||
Object object2 = child; // is correct ??
|
||||
if(object1==null) {
|
||||
throw new NullPointerException("object1 may not be null.");
|
||||
}
|
||||
if(object2==null) {
|
||||
throw new NullPointerException("object2 may not be null.");
|
||||
}
|
||||
if(object1 instanceof EventInput) {
|
||||
if(object2 instanceof EventOutput) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(object1 instanceof EventOutput) {
|
||||
if(object2 instanceof EventInput) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(object1 instanceof EventStep) {
|
||||
if(object2 instanceof EventStepController) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(object1 instanceof EventStepController) {
|
||||
if(object2 instanceof EventStep) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param object1
|
||||
* @param object2
|
||||
* @throws ClassCastException
|
||||
*/
|
||||
public void doBind(Element element) throws Exception {
|
||||
Object parent = element.getParent().getElementObject();
|
||||
Object child = element.getElementObject();
|
||||
if(parent==null) {
|
||||
throw new NullPointerException("object1 may not be null.");
|
||||
}
|
||||
if(child==null) {
|
||||
throw new NullPointerException("object2 may not be null.");
|
||||
}
|
||||
}
|
||||
}
|
187
src/com/idcanet/foei/core/impl/FoeiProcessImpl.java
Normal file
187
src/com/idcanet/foei/core/impl/FoeiProcessImpl.java
Normal file
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.core.impl;
|
||||
|
||||
import com.idcanet.foei.core.FoeiContext;
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.core.ObjectBindingsManager;
|
||||
import com.idcanet.foei.event.EventPort;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NameAlreadyBoundException;
|
||||
import javax.naming.NameNotFoundException;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
/**
|
||||
* Defines the default FoeiProcess implementation
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 2, 2006
|
||||
*/
|
||||
public class FoeiProcessImpl implements FoeiProcess {
|
||||
|
||||
/** The FoeiContext */
|
||||
private FoeiContext foeiContext = null;
|
||||
/** The Logger */
|
||||
private Logger logger = null;
|
||||
/** The name */
|
||||
private String name = null;
|
||||
/** The eventObjectContext */
|
||||
private Context eventObjectContext = null;
|
||||
/** The ObjectBindingsManager */
|
||||
private ObjectBindingsManager objectBindingsManager = null;
|
||||
|
||||
public FoeiProcessImpl(String name,FoeiContext foeiContext,Context eventObjectContext,ObjectBindingsManager objectBindingsManager) {
|
||||
logger = Logger.getLogger(FoeiProcessImpl.class.getName());
|
||||
this.name=name;
|
||||
this.foeiContext=foeiContext;
|
||||
this.eventObjectContext=eventObjectContext;
|
||||
this.objectBindingsManager=objectBindingsManager;
|
||||
logger.info("Creating FoeiProcess: "+getName());
|
||||
}
|
||||
|
||||
// ========= FoeiProcess
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.FoeiProcess#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.FoeiProcess#getEventObjectContext()
|
||||
*/
|
||||
public Context getEventObjectContext() {
|
||||
return eventObjectContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.FoeiProcess#getObjectBindingsManager()
|
||||
*/
|
||||
public ObjectBindingsManager getObjectBindingsManager() {
|
||||
return objectBindingsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.FoeiProcess#destroy()
|
||||
*/
|
||||
public void destroy() {
|
||||
logger.info("Destroying FoeiProcess: "+getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.FoeiProcess#getFoeiContext()
|
||||
*/
|
||||
public FoeiContext getFoeiContext() {
|
||||
return foeiContext;
|
||||
}
|
||||
|
||||
// ================== EventPortExecutor
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.EventPortExecutor#executeEvent(com.idcanet.foei.event.EventPort, java.lang.Object)
|
||||
*/
|
||||
public void executeEvent(EventPort eventPort, Object eventObject) {
|
||||
getFoeiContext().getEventExecutorManager().executeEvent(eventPort,eventObject);
|
||||
}
|
||||
|
||||
// ============= ObjectContextManager
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.ObjectContextManager#addEventObject(com.idcanet.foei.event.EventObject)
|
||||
*/
|
||||
public void addEventObject(Object eventObject,String id) {
|
||||
try {
|
||||
getEventObjectContext().bind(id,eventObject);
|
||||
} catch (NameAlreadyBoundException nabe) {
|
||||
logger.log(Level.WARNING,"NameAlreadyBoundException: "+nabe.getMessage(),nabe);
|
||||
} catch (NamingException ne) {
|
||||
logger.log(Level.WARNING,"NamingException: "+ne.getMessage(),ne);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.ObjectContextManager#getEventObject(java.lang.String)
|
||||
*/
|
||||
public Object getEventObject(String id) {
|
||||
try {
|
||||
return getEventObjectContext().lookup(id);
|
||||
} catch (NamingException ne) {
|
||||
logger.log(Level.WARNING,"NamingException: "+ne.getMessage(),ne);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.ObjectContextManager#removeEventObject(com.idcanet.foei.event.EventObject)
|
||||
*/
|
||||
public void removeEventObject(String id) {
|
||||
try {
|
||||
getEventObjectContext().unbind(id);
|
||||
} catch (NameNotFoundException nnfe) {
|
||||
logger.log(Level.WARNING,"NamingNotFoundException: "+nnfe.getMessage(),nnfe);
|
||||
} catch (NamingException ne) {
|
||||
logger.log(Level.WARNING,"NamingException: "+ne.getMessage(),ne);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ============ ObjectBindingsManager
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.ObjectBindingsManager#addBinding(com.idcanet.foei.event.EventPort, com.idcanet.foei.event.EventPort)
|
||||
*/
|
||||
public void addBinding(EventPort outputPort, EventPort inputPort) {
|
||||
getObjectBindingsManager().addBinding(outputPort,inputPort);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.ObjectBindingsManager#getBindings(com.idcanet.foei.event.EventPort)
|
||||
*/
|
||||
public List<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);
|
||||
}
|
||||
}
|
125
src/com/idcanet/foei/core/impl/FoeiProcessManagerImpl.java
Normal file
125
src/com/idcanet/foei/core/impl/FoeiProcessManagerImpl.java
Normal file
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.core.impl;
|
||||
|
||||
import com.idcanet.foei.core.FoeiContext;
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.core.FoeiProcessManager;
|
||||
import com.idcanet.foei.core.ObjectBindingsManager;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.naming.Context;
|
||||
|
||||
/**
|
||||
* Defines the default FoeiProcessManager implementation
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 2, 2006
|
||||
*/
|
||||
public class FoeiProcessManagerImpl implements FoeiProcessManager {
|
||||
|
||||
/** Stores all foeiProcesses */
|
||||
private Map<String,FoeiProcess> foeiProcesses = null;
|
||||
/** The logger to log to. */
|
||||
private Logger logger = null;
|
||||
|
||||
/**
|
||||
* Creates an FoeiProcessManagerImpl
|
||||
*/
|
||||
public FoeiProcessManagerImpl() {
|
||||
logger = Logger.getLogger(FoeiProcessManagerImpl.class.getName());
|
||||
foeiProcesses = new HashMap<String,FoeiProcess>(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.FoeiProcessManager#createFoeiProcess(java.lang.String, FoeiContext)
|
||||
*/
|
||||
public FoeiProcess createFoeiProcess(String name,FoeiContext foeiContext) {
|
||||
if(name==null) {
|
||||
throw new NullPointerException("name may not be null.");
|
||||
}
|
||||
if(foeiContext==null) {
|
||||
throw new NullPointerException("foeiContext may not be null.");
|
||||
}
|
||||
try {
|
||||
Context c = foeiContext.getEventObjectContext().createSubcontext(name);
|
||||
ObjectBindingsManager objectBindingsManager = FoeiConfiguratorImpl.newObjectBindingsManager(foeiContext.getStartProperties());
|
||||
FoeiProcess fp = new FoeiProcessImpl(name,foeiContext,c,objectBindingsManager);
|
||||
synchronized (foeiProcesses) {
|
||||
foeiProcesses.put(fp.getName(),fp);
|
||||
}
|
||||
logger.finer("FoeiProcess created and added total processes: "+foeiProcesses.size());
|
||||
return fp;
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,"Error whiile creating FoeiProcess: "+e.getMessage(),e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.FoeiProcessManager#destroyFoeiProcess(java.lang.String)
|
||||
*/
|
||||
public void destroyFoeiProcess(String name) {
|
||||
FoeiProcess p = getFoeiProcess(name);
|
||||
if(p==null) {
|
||||
throw new NullPointerException("No FoeiProcess found with id: "+name);
|
||||
}
|
||||
p.destroy();
|
||||
synchronized (foeiProcesses) {
|
||||
foeiProcesses.remove(p.getName());
|
||||
}
|
||||
logger.finer("FoeiProcess destroyed total processes: "+foeiProcesses.size());
|
||||
try {
|
||||
p.getFoeiContext().getEventObjectContext().destroySubcontext(p.getName());
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,"Error while removing process context from foei context; "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.FoeiProcessManager#getFoeiProcess(java.lang.String)
|
||||
*/
|
||||
public FoeiProcess getFoeiProcess(String name) {
|
||||
if(name==null) {
|
||||
throw new NullPointerException("name may not be null.");
|
||||
}
|
||||
return foeiProcesses.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.FoeiProcessManager#getFoeiProcesses()
|
||||
*/
|
||||
public Collection<FoeiProcess> getFoeiProcesses() {
|
||||
return foeiProcesses.values();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.core.impl;
|
||||
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.core.FoeiProcessFactory;
|
||||
|
||||
/**
|
||||
* Wraps an Runnable object so it binds the FoeiProcess before running
|
||||
* and unbinds it also.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 3, 2006
|
||||
*/
|
||||
public class FoeiProcessRunnableWrapper implements Runnable {
|
||||
|
||||
/** The wrapped runnable object. */
|
||||
private Runnable runnable = null;
|
||||
/** The FoeiProcess for this Runnable. */
|
||||
private FoeiProcess foeiProcess = null;
|
||||
|
||||
/**
|
||||
* creates an FoeiProcessRunnableWrapper
|
||||
* @param runnable
|
||||
* @param foeiProcess
|
||||
*/
|
||||
public FoeiProcessRunnableWrapper(Runnable runnable,FoeiProcess foeiProcess) {
|
||||
if(runnable==null) {
|
||||
throw new NullPointerException("runnable may not be null.");
|
||||
}
|
||||
if(foeiProcess==null) {
|
||||
throw new NullPointerException("FoeiProcess may not be null.");
|
||||
}
|
||||
this.runnable=runnable;
|
||||
this.foeiProcess=foeiProcess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds and unbinds the FoeiProcess and call the runnalbe run method.
|
||||
*/
|
||||
public void run() {
|
||||
FoeiProcessFactory.bindFoeiProcess(foeiProcess);
|
||||
runnable.run();
|
||||
FoeiProcessFactory.unbindFoeiProcess();
|
||||
}
|
||||
}
|
179
src/com/idcanet/foei/core/impl/ObjectBindingsManagerImpl.java
Normal file
179
src/com/idcanet/foei/core/impl/ObjectBindingsManagerImpl.java
Normal file
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.core.impl;
|
||||
|
||||
import com.idcanet.foei.core.ObjectBindingsManager;
|
||||
import com.idcanet.foei.event.EventPort;
|
||||
import com.idcanet.foei.event.EventPortType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Defines the ObjectBindingsManager implamentation.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 20/04/2005
|
||||
*/
|
||||
public class ObjectBindingsManagerImpl implements ObjectBindingsManager
|
||||
{
|
||||
/** */
|
||||
private Map<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.");
|
||||
}
|
||||
List<EventPort> result = new ArrayList<EventPort>(0);
|
||||
List<EventPort> inputPorts = bindingsInput.get(eventPort);
|
||||
List<EventPort> outputPorts = bindingsOutput.get(eventPort);
|
||||
if(inputPorts!=null) {
|
||||
result.addAll(inputPorts);
|
||||
}
|
||||
if(outputPorts!=null) {
|
||||
result.addAll(outputPorts);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the dotty xml bindings
|
||||
*/
|
||||
public String getBindingsAsXML() {
|
||||
StringBuffer result = new StringBuffer();
|
||||
result.append("<?xml version=\"1.0\"?>\n");
|
||||
result.append("<bindings>\n");
|
||||
for(EventPort port:bindingsOutput.keySet()) {
|
||||
for(EventPort b:getBindings(port)) {
|
||||
result.append("<binding outputId=\""+port.getEventObject()+"\" outputPortName=\""+port.getName());
|
||||
result.append("\" inputId=\""+b.getEventObject()+"\" inputPortName=\""+b.getName()+"\" inputPortPassed=\""+b.getEventsPassed());
|
||||
result.append("\"/>\n");
|
||||
|
||||
}
|
||||
}
|
||||
result.append("</bindings>");
|
||||
return result.toString();
|
||||
}
|
||||
}
|
150
src/com/idcanet/foei/core/impl/X2OExecutorImpl.java
Normal file
150
src/com/idcanet/foei/core/impl/X2OExecutorImpl.java
Normal 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.core.impl;
|
||||
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.core.FoeiProcessFactory;
|
||||
import com.idcanet.foei.core.X2OExecutor;
|
||||
import com.idcanet.x4o.core.X4OParser;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* The default X2OExecutor implemention
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 24, 2006
|
||||
*
|
||||
*/
|
||||
public class X2OExecutorImpl implements X2OExecutor {
|
||||
|
||||
private String parseFileName = null;
|
||||
private InputStream parseInputStream = null;
|
||||
private String parseXml = null;
|
||||
private boolean debug = false;
|
||||
private boolean ready = false;
|
||||
private Logger logger = null;
|
||||
|
||||
/**
|
||||
* Constructs an X2OExecutorImpl
|
||||
*/
|
||||
public X2OExecutorImpl() {
|
||||
logger = Logger.getLogger(X2OExecutorImpl.class.getName());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
public void run() {
|
||||
try {
|
||||
|
||||
// config parser
|
||||
FoeiProcess foeiProcess = FoeiProcessFactory.getFoeiProcess();
|
||||
X4OParser parser = new X4OParser(FoeiConfiguratorImpl.getX2ORootTag(foeiProcess.getFoeiContext().getStartProperties()),"foei");
|
||||
parser.setDebug(debug);
|
||||
parser.getParsingContext().getProperties().putAll(foeiProcess.getFoeiContext().getStartProperties());
|
||||
|
||||
logger.info("Executing X2O Parsing.");
|
||||
|
||||
if(parseFileName!=null) {
|
||||
try {
|
||||
logger.finer("Parsing File: "+parseFileName);
|
||||
parser.parseFile(parseFileName);
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE,"Error while loading config file:"+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
if(parseInputStream!=null) {
|
||||
try {
|
||||
logger.finer("Parsing InputStream");
|
||||
parser.parse(parseInputStream);
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE,"Error while loading inputStream:"+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
if(parseXml!=null) {
|
||||
try {
|
||||
logger.finer("Parsing XML");
|
||||
parser.parseXml(parseXml);
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.SEVERE,"Error while loading xml:"+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
logger.log(Level.WARNING,"Error in X2O thread: "+t.getMessage(),t);
|
||||
} finally {
|
||||
ready = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.X2OExecutor#isReady()
|
||||
*/
|
||||
public boolean isReady() {
|
||||
return ready;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.X2OExecutor#getDebug()
|
||||
*/
|
||||
public boolean getDebug() {
|
||||
return debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.X2OExecutor#setDebug(boolean)
|
||||
*/
|
||||
public void setDebug(boolean debug) {
|
||||
this.debug=debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.X2OExecutor#setFileName(java.lang.String)
|
||||
*/
|
||||
public void setFileName(String fileName) {
|
||||
parseFileName=fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.X2OExecutor#setInputStream(java.io.InputStream)
|
||||
*/
|
||||
public void setInputStream(InputStream inputStream) {
|
||||
parseInputStream=inputStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.core.X2OExecutor#setXml(java.lang.String)
|
||||
*/
|
||||
public void setXml(String xml) {
|
||||
parseXml=xml;
|
||||
}
|
||||
}
|
58
src/com/idcanet/foei/core/impl/package.html
Normal file
58
src/com/idcanet/foei/core/impl/package.html
Normal 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>
|
94
src/com/idcanet/foei/core/x4o/BindAttributeHandler.java
Normal file
94
src/com/idcanet/foei/core/x4o/BindAttributeHandler.java
Normal file
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.core.x4o;
|
||||
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.core.FoeiProcessFactory;
|
||||
import com.idcanet.foei.event.EventInput;
|
||||
import com.idcanet.foei.event.EventOutput;
|
||||
import com.idcanet.foei.event.EventPort;
|
||||
import com.idcanet.x4o.eld.GlobalParameterHandler;
|
||||
import com.idcanet.x4o.element.Element;
|
||||
import com.idcanet.x4o.element.ElementException;
|
||||
|
||||
/**
|
||||
* Handlers the "bind" attribute
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 15, 2006
|
||||
*/
|
||||
public class BindAttributeHandler implements GlobalParameterHandler {
|
||||
|
||||
private String parameterName =null;
|
||||
|
||||
/**
|
||||
* @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doParameter(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
public void doParameter(Element element,String parameterValue) {
|
||||
String[] port = parameterValue.split(":");
|
||||
if(port.length!=2) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
EventInput in = (EventInput)element.getElementObject();
|
||||
if(in==null) {
|
||||
throw new ElementException("Could not find EventObject from inputID");
|
||||
}
|
||||
EventOutput out = (EventOutput)element.getParent().getElementObject();
|
||||
if(out==null) {
|
||||
throw new ElementException("Could not find EventObject from outputID");
|
||||
}
|
||||
EventPort inputEventPort = in.getInputPort(port[1]);
|
||||
EventPort outputEventPort = out.getOutputPort(port[0]);
|
||||
|
||||
FoeiProcess foei = FoeiProcessFactory.getFoeiProcess();
|
||||
|
||||
if(inputEventPort==null) {
|
||||
throw new ElementException("Could not find EventPort from inputPort");
|
||||
}
|
||||
if(outputEventPort==null) {
|
||||
throw new ElementException("Could not find EventPort from outputPort");
|
||||
}
|
||||
foei.addBinding(outputEventPort,inputEventPort);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#getParameterName()
|
||||
*/
|
||||
public String getParameterName() {
|
||||
return parameterName;
|
||||
}
|
||||
|
||||
public void setParameterName(String parameterName) {
|
||||
this.parameterName=parameterName;
|
||||
}
|
||||
}
|
76
src/com/idcanet/foei/core/x4o/EventStepBindRuleHandler.java
Normal file
76
src/com/idcanet/foei/core/x4o/EventStepBindRuleHandler.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.core.x4o;
|
||||
|
||||
import com.idcanet.foei.event.EventStep;
|
||||
import com.idcanet.foei.event.EventStepController;
|
||||
import com.idcanet.x4o.eld.BindingRuleHandler;
|
||||
import com.idcanet.x4o.element.Element;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 16, 2006
|
||||
*/
|
||||
public class EventStepBindRuleHandler implements BindingRuleHandler {
|
||||
|
||||
private Map<String, String> parameters = null;
|
||||
|
||||
/**
|
||||
* @see com.idca.foei.xml.x2o.eld.BindingRuleHandler#canBind(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public boolean canBind(Element element) {
|
||||
Object parent = element.getParent().getElementObject();
|
||||
Object child = element.getElementObject();
|
||||
if(!(parent instanceof EventStepController)) {
|
||||
return false;
|
||||
}
|
||||
if(!(child instanceof EventStep)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idca.foei.xml.x2o.eld.BindingRuleHandler#doBind(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void doBind(Element element) throws Exception {
|
||||
Object parent = element.getParent().getElementObject();
|
||||
Object child = element.getElementObject();
|
||||
((EventStepController)parent).addEventStep((EventStep)child);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idca.foei.xml.x2o.eld.BindingRuleHandler#setParameters(java.util.Map)
|
||||
*/
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters=parameters;
|
||||
}
|
||||
}
|
67
src/com/idcanet/foei/core/x4o/IdAttributeHandler.java
Normal file
67
src/com/idcanet/foei/core/x4o/IdAttributeHandler.java
Normal 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.x4o;
|
||||
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.core.FoeiProcessFactory;
|
||||
import com.idcanet.x4o.eld.GlobalParameterHandler;
|
||||
import com.idcanet.x4o.element.Element;
|
||||
|
||||
/**
|
||||
* Handles the id
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jul 8, 2006
|
||||
*/
|
||||
public class IdAttributeHandler implements GlobalParameterHandler {
|
||||
|
||||
private String parameterName =null;
|
||||
|
||||
/**
|
||||
* @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#doParameter(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
public void doParameter(Element element,String parameterValue) {
|
||||
// add to objext context
|
||||
if(element.getElementObject()==null | "".equals(parameterValue)) {
|
||||
parameterValue= "auto."+Integer.toHexString(element.getElementObject().hashCode());
|
||||
//logger.finest("Generated auto id: "+parameterValue);
|
||||
}
|
||||
FoeiProcess process = FoeiProcessFactory.getFoeiProcess();
|
||||
process.addEventObject(element.getElementObject(),parameterValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idca.foei.xml.x2o.eld.GlobalParameterHandler#getParameterName()
|
||||
*/
|
||||
public String getParameterName() {
|
||||
return parameterName;
|
||||
}
|
||||
|
||||
public void setParameterName(String parameterName) {
|
||||
this.parameterName=parameterName;
|
||||
}
|
||||
}
|
150
src/com/idcanet/foei/core/x4o/ObjectBindingElement.java
Normal file
150
src/com/idcanet/foei/core/x4o/ObjectBindingElement.java
Normal 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.core.x4o;
|
||||
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.core.FoeiProcessFactory;
|
||||
import com.idcanet.foei.event.EventInput;
|
||||
import com.idcanet.foei.event.EventOutput;
|
||||
import com.idcanet.foei.event.EventPort;
|
||||
import com.idcanet.x4o.element.AbstractElement;
|
||||
import com.idcanet.x4o.element.ElementException;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 2, 2006
|
||||
*/
|
||||
public class ObjectBindingElement extends AbstractElement {
|
||||
|
||||
/** The Object which is configed */
|
||||
//private Object parentObject = null;
|
||||
//private Object childObject = null;
|
||||
|
||||
private String outputID = null;
|
||||
private String outputPort = null;
|
||||
private String inputID = null;
|
||||
private String inputPort = null;
|
||||
|
||||
/**
|
||||
* Do the element
|
||||
*/
|
||||
public void doElementStart(Attributes attributes) throws ElementException {
|
||||
|
||||
outputID = attributes.getValue("outputID");
|
||||
outputPort = attributes.getValue("outputPort");
|
||||
inputID = attributes.getValue("inputID");
|
||||
inputPort = attributes.getValue("inputPort");
|
||||
|
||||
FoeiProcess foei = FoeiProcessFactory.getFoeiProcess();
|
||||
|
||||
Object in = foei.getEventObject(inputID);
|
||||
if(in==null) {
|
||||
throw new ElementException("Could not find EventObject from inputID");
|
||||
}
|
||||
Object out = foei.getEventObject(outputID);
|
||||
if(out==null) {
|
||||
throw new ElementException("Could not find EventObject from outputID");
|
||||
}
|
||||
EventPort inputEventPort = ((EventInput)in).getInputPort(inputPort);
|
||||
EventPort outputEventPort = ((EventOutput)out).getOutputPort(outputPort);
|
||||
if(inputEventPort==null) {
|
||||
throw new ElementException("Could not find EventPort from inputPort");
|
||||
}
|
||||
if(outputEventPort==null) {
|
||||
throw new ElementException("Could not find EventPort from outputPort");
|
||||
}
|
||||
foei.addBinding(outputEventPort,inputEventPort);
|
||||
|
||||
|
||||
/*
|
||||
if(outputID==null) {
|
||||
//outputID = foei.getObjectConfigurator().getParameter(parentObject,"id").toString();
|
||||
}
|
||||
if(outputPort==null) {
|
||||
if(parentObject instanceof EventOutput) {
|
||||
EventOutput eventOutput = (EventOutput)parentObject;
|
||||
if(eventOutput.getOutputPorts().size()>0) {
|
||||
EventPort port = (EventPort)eventOutput.getOutputPorts().get(0);
|
||||
outputPort = port.getName();
|
||||
} else {
|
||||
// no output ports
|
||||
throw new ElementException("parentObject(EventOutput) is no output ports defined");
|
||||
}
|
||||
} else {
|
||||
// np EventOutput ..
|
||||
throw new ElementException("parentObject: "+parentObject+" is not an EventOutput");
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// HACK routines
|
||||
/*
|
||||
public String getOutputID() {
|
||||
return outputID;
|
||||
}
|
||||
public String getOutputPort() {
|
||||
return outputPort;
|
||||
}
|
||||
*/
|
||||
|
||||
public void doElementEnd() {
|
||||
/*
|
||||
FoeiProcess foei = FoeiProcessFactory.getFoeiProcess();
|
||||
if(inputID!=null & inputPort!=null & outputID!=null & outputPort!=null) {
|
||||
// Add binding
|
||||
foei.addBinding()
|
||||
foeiInstance.getObjectBindingsManager().addBinding(outputID,outputPort,inputID,inputPort);
|
||||
} else {
|
||||
System.err.println("Coudn't addbinding: inID="+inputID+" inPort="+inputPort+" outID="+outputID+" outPort="+outputPort);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
//------------------ ElementObject
|
||||
|
||||
/**
|
||||
* Get the object this elements configs.
|
||||
* @return The object this Element controlles
|
||||
*/
|
||||
/*
|
||||
public Object getElementObject() {
|
||||
return parentObject;
|
||||
//return object;
|
||||
}
|
||||
|
||||
public void setElementObject(Object object) {
|
||||
// TODO: this is an quich hack see FoeiTagHandler
|
||||
//this.object=object;
|
||||
}
|
||||
*/
|
||||
}
|
88
src/com/idcanet/foei/core/x4o/SetParameterElement.java
Normal file
88
src/com/idcanet/foei/core/x4o/SetParameterElement.java
Normal 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.core.x4o;
|
||||
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import com.idcanet.x4o.element.AbstractElement;
|
||||
import com.idcanet.x4o.element.ElementException;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 2, 2006
|
||||
*/
|
||||
public class SetParameterElement extends AbstractElement {
|
||||
/** The Object which is configed */
|
||||
private Object object = null;
|
||||
|
||||
private Object eventObject = null;
|
||||
private String parameterName = null;
|
||||
private Object parameterValue = null;
|
||||
|
||||
public SetParameterElement() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the element
|
||||
*/
|
||||
public void doElementStart(Attributes attributes) throws ElementException
|
||||
{
|
||||
// the EventObject for the parent element is also this its elementObject.
|
||||
Object o = getParent().getElementObject();
|
||||
/*
|
||||
if(!(o instanceof EventObject)) {
|
||||
throw new ElementException("parent ElementObject is not EventObject");
|
||||
}
|
||||
eventObject = (EventObject)o;
|
||||
*/
|
||||
parameterName = attributes.getValue("name");
|
||||
parameterValue = attributes.getValue("value");
|
||||
}
|
||||
|
||||
public void doElementEnd()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------ ElementObject
|
||||
|
||||
/**
|
||||
* Get the object this elements configs.
|
||||
* @return The object this Element controlles
|
||||
*/
|
||||
public Object getElementObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
public void setElementObject(Object object) {
|
||||
this.object=object;
|
||||
}
|
||||
}
|
55
src/com/idcanet/foei/core/x4o/package.html
Normal file
55
src/com/idcanet/foei/core/x4o/package.html
Normal 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>
|
70
src/com/idcanet/foei/event/annotations/SetEventPort.java
Normal file
70
src/com/idcanet/foei/event/annotations/SetEventPort.java
Normal 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";
|
||||
}
|
49
src/com/idcanet/foei/event/annotations/SetEventPorts.java
Normal file
49
src/com/idcanet/foei/event/annotations/SetEventPorts.java
Normal 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();
|
||||
}
|
37
src/com/idcanet/foei/server/config/FoeiConfigContext.java
Normal file
37
src/com/idcanet/foei/server/config/FoeiConfigContext.java
Normal 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.server.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class FoeiConfigContext {
|
||||
|
||||
private String name = null;
|
||||
private Map properties = null;
|
||||
private Map processes = null;
|
||||
|
||||
}
|
70
src/com/idcanet/foei/server/config/FoeiConfigParser.java
Normal file
70
src/com/idcanet/foei/server/config/FoeiConfigParser.java
Normal 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.server.config;
|
||||
|
||||
import com.idca.foei.xml.AbstractXMLParser;
|
||||
import com.idca.foei.xml.XMLDebugTagHandler;
|
||||
import com.idca.foei.xml.XMLHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Parses the foei-config.xml file
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jun 23, 2006
|
||||
*/
|
||||
public class FoeiConfigParser extends AbstractXMLParser {
|
||||
|
||||
/**
|
||||
* Parsesn the input stream as a X2O document
|
||||
*/
|
||||
public void parse(InputStream inputStream) throws ParserConfigurationException,SAXException,IOException {
|
||||
XMLHandler handler = new XMLHandler();
|
||||
if(isDebug()) {
|
||||
handler.addXMLTagHandler(new XMLDebugTagHandler("DEBUG"));
|
||||
}
|
||||
/*
|
||||
X2OTagHandler xth = new X2OTagHandler(rootTag,parsingContext);
|
||||
xth.setDebug(debug);
|
||||
handler.addXMLTagHandler(xth);
|
||||
*/
|
||||
|
||||
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
SAXParser saxParser = factory.newSAXParser();
|
||||
saxParser.parse(inputStream,handler);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.server.config;
|
||||
|
||||
import com.idca.foei.xml.AbstractXMLTagHandler;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jun 23, 2006
|
||||
*/
|
||||
public class FoeiContextXMLTagHandler extends AbstractXMLTagHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public void startElement(String nameSpace,String tag,String qName,Attributes attributes) throws SAXException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String nameSpace,String tag,String qName) throws SAXException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AbstractXMLTagHandler#characters(String)
|
||||
*/
|
||||
@Override
|
||||
public void characters(String text) {/*
|
||||
if(this.text==null) {
|
||||
this.text=text;
|
||||
} else {
|
||||
this.text+=text;
|
||||
} */
|
||||
}
|
||||
}
|
69
src/com/idcanet/foei/server/config/package.html
Normal file
69
src/com/idcanet/foei/server/config/package.html
Normal file
|
@ -0,0 +1,69 @@
|
|||
<!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 some startup util classes for starting and config multipe Foei instances in a ServletContainer.<br/>
|
||||
|
||||
<h2>Package Specification</h2>
|
||||
|
||||
We can access an FoeiContext here in the FoeiContextManager.<br/>
|
||||
Use with care !!<br/>
|
||||
<br/>
|
||||
To be sure of your code use something like:<br/>
|
||||
<pre>
|
||||
FoeiContext foeiContext = FoeiContextManagerFactory.getFoeiContextManager().getFoeiContext("Test-Context");
|
||||
FoeiContextFactory.bindFoeiContext(foeiContext);
|
||||
// Do your stuff here.
|
||||
//....
|
||||
FoeiContextFactory.unbindFoeiContext();
|
||||
</pre>
|
||||
|
||||
<!--
|
||||
<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>
|
107
src/com/idcanet/foei/server/startup/FoeiStartupListener.java
Normal file
107
src/com/idcanet/foei/server/startup/FoeiStartupListener.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.server.startup;
|
||||
|
||||
import com.idcanet.foei.core.FoeiConfigurator;
|
||||
import com.idcanet.foei.core.FoeiContext;
|
||||
import com.idcanet.foei.server.FoeiContextManager;
|
||||
import com.idcanet.foei.server.FoeiContextManagerFactory;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
/**
|
||||
* Helps to startup Foei in a J2EE context.
|
||||
*
|
||||
* Its creates the FoeiContextManager and builds FoeiContext for us.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 20, 2006
|
||||
*/
|
||||
public class FoeiStartupListener implements ServletContextListener {
|
||||
|
||||
/** The logger to log to. */
|
||||
private Logger logger = null;
|
||||
|
||||
/** The key for in web.xml */
|
||||
static public final String FOEI_CONFIG_RESOURCES = "FOEI_CONFIG_RESOURCES";
|
||||
|
||||
/**
|
||||
* Starts Foei
|
||||
*/
|
||||
public void contextInitialized(ServletContextEvent event) {
|
||||
logger = Logger.getLogger(FoeiStartupListener.class.getName());
|
||||
|
||||
// Creates FoeiContextManager
|
||||
FoeiContextManager foeiContextManager = new FoeiContextManager();
|
||||
FoeiContextManagerFactory.setFoeiContextManager(foeiContextManager);
|
||||
|
||||
String resources = event.getServletContext().getInitParameter(FOEI_CONFIG_RESOURCES);
|
||||
if(resources==null) {
|
||||
logger.warning("No "+FOEI_CONFIG_RESOURCES+" defined in web.xml not starting foei.");
|
||||
return;
|
||||
}
|
||||
|
||||
String[] resource = resources.split(",");
|
||||
for(String className:resource) {
|
||||
try {
|
||||
InputStream foeiProperties = this.getClass().getResourceAsStream(className);
|
||||
if(foeiProperties==null) {
|
||||
logger.warning("Can't load: '"+className+"'");
|
||||
continue;
|
||||
}
|
||||
Properties properties = new Properties();
|
||||
properties.load(foeiProperties);
|
||||
foeiProperties.close();
|
||||
properties.put(FoeiConfigurator.ROOT_PATH,event.getServletContext().getRealPath("/"));
|
||||
foeiContextManager.createFoeiContext(properties);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,"Error while starting FoeiContext: "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop Foei
|
||||
*/
|
||||
public void contextDestroyed(ServletContextEvent event) {
|
||||
logger.info("Stopping Foei Contexts");
|
||||
try {
|
||||
FoeiContextManagerFactory.getFoeiContextManager().destroyAll();
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,"Error while shutdowning Foei: "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
69
src/com/idcanet/foei/server/startup/package.html
Normal file
69
src/com/idcanet/foei/server/startup/package.html
Normal file
|
@ -0,0 +1,69 @@
|
|||
<!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 some startup util classes for starting and config multipe Foei instances in a ServletContainer.<br/>
|
||||
|
||||
<h2>Package Specification</h2>
|
||||
|
||||
We can access an FoeiContext here in the FoeiContextManager.<br/>
|
||||
Use with care !!<br/>
|
||||
<br/>
|
||||
To be sure of your code use something like:<br/>
|
||||
<pre>
|
||||
FoeiContext foeiContext = FoeiContextManagerFactory.getFoeiContextManager().getFoeiContext("Test-Context");
|
||||
FoeiContextFactory.bindFoeiContext(foeiContext);
|
||||
// Do your stuff here.
|
||||
//....
|
||||
FoeiContextFactory.unbindFoeiContext();
|
||||
</pre>
|
||||
|
||||
<!--
|
||||
<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>
|
40
src/com/idcanet/foei/utils/beans/BeanProperty.java
Normal file
40
src/com/idcanet/foei/utils/beans/BeanProperty.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.utils.beans;
|
||||
|
||||
/**
|
||||
* Gets ans Set properties of an java bean
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 18, 2006
|
||||
*/
|
||||
public class BeanProperty {
|
||||
|
||||
|
||||
|
||||
}
|
174
src/com/idcanet/foei/utils/beans/BeanPropertyComparator.java
Normal file
174
src/com/idcanet/foei/utils/beans/BeanPropertyComparator.java
Normal file
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.utils.beans;
|
||||
|
||||
import java.lang.Comparable;
|
||||
import java.util.Comparator;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
|
||||
/**
|
||||
* Compares a property of a java bean.
|
||||
* The property should be Comparable.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 11, 2006
|
||||
*/
|
||||
public class BeanPropertyComparator<T> implements Comparator {
|
||||
|
||||
/** The propery of the bean to compare. */
|
||||
private String property = null;
|
||||
/** The logger to log to. */
|
||||
private Logger logger = null;
|
||||
/** The ascending */
|
||||
private boolean ascending = true;
|
||||
|
||||
/**
|
||||
* The constructor inits the logger.
|
||||
*/
|
||||
public BeanPropertyComparator() {
|
||||
logger = Logger.getLogger(BeanPropertyComparator.class.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an BeanPropertyComparator with an property
|
||||
* @param property
|
||||
*/
|
||||
public BeanPropertyComparator(String property) {
|
||||
this();
|
||||
setProperty(property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an BeanPropertyComparator with an property
|
||||
* @param property
|
||||
*/
|
||||
public BeanPropertyComparator(String property,boolean ascending) {
|
||||
this();
|
||||
setProperty(property);
|
||||
setAscending(ascending);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares 2 objects by the propery
|
||||
* @see Comparator#compare(T, T);
|
||||
* @param o1 Object 1
|
||||
* @param o2 Object 2
|
||||
* @return the differce between the objects.
|
||||
*/
|
||||
public int compare(Object o1,Object o2) throws ClassCastException {
|
||||
|
||||
Comparable c1 = getComparableProperty(o1);
|
||||
Comparable c2 = getComparableProperty(o2);
|
||||
|
||||
if(c1==null && c2==null) {
|
||||
return 0;
|
||||
}
|
||||
if(c1==null) {
|
||||
if(ascending) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if(c2==null) {
|
||||
if(ascending) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(ascending) {
|
||||
return c1.compareTo(c2);
|
||||
} else {
|
||||
return c2.compareTo(c1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Comparable property of the object.
|
||||
* @param object
|
||||
* @return
|
||||
* @throws ClassCastException
|
||||
*/
|
||||
private Comparable getComparableProperty(Object object) throws ClassCastException {
|
||||
|
||||
if(property==null) {
|
||||
throw new IllegalStateException("property is not set.");
|
||||
}
|
||||
Object result = null;
|
||||
try {
|
||||
result = BeanUtils.getProperty(object,property);
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,"property:"+property+" is not an property of object: "+object.getClass().getName(),e);
|
||||
}
|
||||
try {
|
||||
Comparable c = (Comparable)result;
|
||||
return c;
|
||||
} catch (ClassCastException e) {
|
||||
logger.log(Level.WARNING,"property:"+property+" is not Comparable",e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the property.
|
||||
*/
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param property The property to set.
|
||||
*/
|
||||
public void setProperty(String property) {
|
||||
if(property==null) {
|
||||
throw new NullPointerException("property may not be null");
|
||||
}
|
||||
this.property = property;
|
||||
logger.finest("property="+property);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the ascending.
|
||||
*/
|
||||
public boolean isAscending() {
|
||||
return ascending;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ascending The ascending to set.
|
||||
*/
|
||||
public void setAscending(boolean ascending) {
|
||||
this.ascending = ascending;
|
||||
logger.finest("ascending="+ascending);
|
||||
}
|
||||
}
|
||||
|
95
src/com/idcanet/foei/utils/beans/NumberComparator.java
Normal file
95
src/com/idcanet/foei/utils/beans/NumberComparator.java
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.utils.beans;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.Comparator;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 9, 2006
|
||||
*/
|
||||
public class NumberComparator implements Comparator {
|
||||
|
||||
private Locale locale = null;
|
||||
|
||||
/**
|
||||
* @return Returns the locale.
|
||||
*/
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param locale The locale to set.
|
||||
*/
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two String as number.
|
||||
* @param o1
|
||||
* @param o2
|
||||
* @return
|
||||
* @see Comparator#compare(T, T)
|
||||
*/
|
||||
public int compare(Object o1, Object o2) {
|
||||
Double d1 = getDoubleValue((String)o1,locale);
|
||||
Double d2 = getDoubleValue((String)o2,locale);
|
||||
return d1.compareTo(d2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an String to an Number wich is converted to a Double
|
||||
* @param test The String to parse.
|
||||
* @param locale The locale of the numberFormat.
|
||||
* @return An Double
|
||||
*/
|
||||
static public Double getDoubleValue(String text,Locale locale) {
|
||||
try {
|
||||
NumberFormat nf = NumberFormat.getInstance(locale);
|
||||
Number n = nf.parse(text);
|
||||
if(n instanceof Double) {
|
||||
return (Double)n;
|
||||
}
|
||||
if(n instanceof Integer) {
|
||||
return ((Integer)n).doubleValue();
|
||||
}
|
||||
if(n instanceof Long) {
|
||||
return ((Long)n).doubleValue();
|
||||
}
|
||||
} catch(ParseException pe) {
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
}
|
61
src/com/idcanet/foei/utils/beans/package.html
Normal file
61
src/com/idcanet/foei/utils/beans/package.html
Normal 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 some handy classes for working with java beans.<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>
|
56
src/com/idcanet/foei/utils/jdbc/ConnectionFactory.java
Normal file
56
src/com/idcanet/foei/utils/jdbc/ConnectionFactory.java
Normal 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.utils.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
/**
|
||||
* Java code can get a DB connections here.
|
||||
* Its retreived from the ConnectionProviderManager.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ConnectionFactory
|
||||
{
|
||||
/**
|
||||
* Returns a connection by its name
|
||||
* @param name The name of the connection
|
||||
* @return Returns the Connection.
|
||||
*/
|
||||
static public Connection getConnection(String name) {
|
||||
return getConnectionProviderManager().getConnection(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instance of the ConnectionProviderManager.
|
||||
* @return Returns the ConnectionProviderManager.
|
||||
*/
|
||||
static public ConnectionProviderManager getConnectionProviderManager() {
|
||||
return ConnectionProviderManager.getSharedInstance();
|
||||
}
|
||||
}
|
55
src/com/idcanet/foei/utils/jdbc/ConnectionProvider.java
Normal file
55
src/com/idcanet/foei/utils/jdbc/ConnectionProvider.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.utils.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
/**
|
||||
* The ConnectionProvider is an interface which
|
||||
* lets objects returns a Connection.
|
||||
*
|
||||
* We normally registrates an ConnectionProvider to the
|
||||
* ConnectionProviderManager so objects can use it.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 4, 2006
|
||||
*/
|
||||
public interface ConnectionProvider
|
||||
{
|
||||
/**
|
||||
* Gets the connection name for which this
|
||||
* ConnectionProvider handles connections.
|
||||
* @return Returns the connection name.
|
||||
*/
|
||||
public String getConnectionName();
|
||||
|
||||
/**
|
||||
* Gets an connection of this ConnectionProvider.
|
||||
* @return Returns an Connection
|
||||
*/
|
||||
public Connection getConnection();
|
||||
}
|
115
src/com/idcanet/foei/utils/jdbc/ConnectionProviderManager.java
Normal file
115
src/com/idcanet/foei/utils/jdbc/ConnectionProviderManager.java
Normal 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.utils.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Manages the different ConnectionProviders.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 4, 2006
|
||||
*/
|
||||
public class ConnectionProviderManager
|
||||
{
|
||||
/** The logger to log to */
|
||||
private Logger logger = null;
|
||||
/** The map with all connection providers */
|
||||
private Map<String,ConnectionProvider> connectionProviders = null;
|
||||
/** The ConnectionProviderManager instance */
|
||||
static private ConnectionProviderManager connectionProviderManager = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
connectionProviderManager = new ConnectionProviderManager();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error while creating ConnectionProviderManager",e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an private ConnectionProviderManager
|
||||
*
|
||||
*/
|
||||
private ConnectionProviderManager() {
|
||||
logger = Logger.getLogger(ConnectionProviderManager.class.getName());
|
||||
logger.fine("Creating an ConnectionProviderManager");
|
||||
connectionProviders = new HashMap<String,ConnectionProvider>(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the singleton object of the ConnectionProviderManager.
|
||||
* @return
|
||||
*/
|
||||
static public ConnectionProviderManager getSharedInstance() {
|
||||
return connectionProviderManager;
|
||||
}
|
||||
|
||||
// ============ END SINGLETON
|
||||
|
||||
/**
|
||||
* Gets an Connection by its connectionName
|
||||
* @param connectionName The connection name.
|
||||
* @return Returns the Connection
|
||||
*/
|
||||
public Connection getConnection(String connectionName) {
|
||||
return getConnectionProvider(connectionName).getConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an ConnectionProvider
|
||||
* @param connectionProvider The ConnectionProvider to add.
|
||||
*/
|
||||
public void addConnectionProvider(ConnectionProvider connectionProvider) {
|
||||
if(connectionProvider==null) {
|
||||
throw new NullPointerException("connectionProvider may not be null.");
|
||||
}
|
||||
logger.fine("Adding ConnnectionProvider for connection: "+connectionProvider.getConnectionName());
|
||||
connectionProviders.put(connectionProvider.getConnectionName(),connectionProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an ConnectionProvider by its connectionName
|
||||
* @param connectionName The connection name
|
||||
* @return Returns the ConnectionProvider for this connectionName.
|
||||
*/
|
||||
public ConnectionProvider getConnectionProvider(String connectionName) {
|
||||
return connectionProviders.get(connectionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all ConnectionProviders
|
||||
* @return Returns all ConnectionProviders.
|
||||
*/
|
||||
public Collection<ConnectionProvider> getConnectionProviders() {
|
||||
return connectionProviders.values();
|
||||
}
|
||||
}
|
163
src/com/idcanet/foei/utils/jdbc/JndiDataSourceProvider.java
Normal file
163
src/com/idcanet/foei/utils/jdbc/JndiDataSourceProvider.java
Normal file
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.utils.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* The JndiDataSourceProvider is an ConnectionProvider which gets its connection
|
||||
* from a jndi context.
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 4, 2006
|
||||
*/
|
||||
public class JndiDataSourceProvider implements ConnectionProvider
|
||||
{
|
||||
/** The context in which database datasources are found. */
|
||||
private static final String DATASOURCE_CONTEXT = "java:comp/env/jdbc/";
|
||||
/** The connectionName for this Provider */
|
||||
private String connectionName = null;
|
||||
/** The jndi context to search for the dataSource. */
|
||||
private String dataSourceContext = null;
|
||||
/** The logger to log to. */
|
||||
private Logger logger = null;
|
||||
|
||||
/**
|
||||
* Creates an JndiDataSourceProvider and inits the Logger
|
||||
*/
|
||||
public JndiDataSourceProvider() {
|
||||
logger = Logger.getLogger(JndiDataSourceProvider.class.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates JndiDataSourceProvider and sets its connectionName.
|
||||
* @param connectionName
|
||||
*/
|
||||
public JndiDataSourceProvider(String connectionName) {
|
||||
this();
|
||||
setConnectionName(connectionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an JndiDataSourceProvider and inits the Logger
|
||||
* @param connectionName The connection name which this provider handles
|
||||
* @param dataSourceContext The JNDI datasource prefix for getting the DataSource
|
||||
*/
|
||||
public JndiDataSourceProvider(String connectionName,String dataSourceContext) {
|
||||
this(connectionName);
|
||||
setDataSourceContext(dataSourceContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an DataSource out of the jndi context.
|
||||
* @param name The name of the datasource in the jndi context.
|
||||
* @return The datasource.
|
||||
*/
|
||||
static public DataSource getDataSource(String name) {
|
||||
|
||||
try {
|
||||
Context initialContext = new InitialContext();
|
||||
if(initialContext == null) {
|
||||
throw new RuntimeException("Init: Cannot get Initial Context");
|
||||
}
|
||||
DataSource datasource = (DataSource) initialContext.lookup(name);
|
||||
if(datasource == null) {
|
||||
throw new RuntimeException("Init: Cannot lookup datasource: '"+name+"'");
|
||||
}
|
||||
return datasource;
|
||||
} catch (NamingException ex) {
|
||||
throw new RuntimeException("Init: Cannot get connection " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
//========= ConnectionProvider
|
||||
|
||||
/**
|
||||
* Gets the connection name for which this
|
||||
* ConnectionProvider handles connections.
|
||||
* @return Returns the connection name.
|
||||
* @see ConnectionProvider#getConnectionName()
|
||||
*/
|
||||
public String getConnectionName() {
|
||||
return connectionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an connection of this ConnectionProvider.
|
||||
* @return Returns an Connection
|
||||
* @see ConnectionProvider#getConnection()
|
||||
*/
|
||||
public Connection getConnection() {
|
||||
try {
|
||||
if(dataSourceContext==null) {
|
||||
dataSourceContext=DATASOURCE_CONTEXT;
|
||||
}
|
||||
logger.finest("Trying retreiving DataSource of connectionName="+connectionName);
|
||||
return getDataSource(dataSourceContext+connectionName).getConnection();
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,"Error while getting DataSource",e);
|
||||
throw new NullPointerException("No datasource");
|
||||
}
|
||||
}
|
||||
|
||||
// ==== set/getter
|
||||
|
||||
/**
|
||||
* Sets the connectionName.
|
||||
* @param connectionName The connectionName to set.
|
||||
*/
|
||||
public void setConnectionName(String connectionName) {
|
||||
if(connectionName==null) {
|
||||
throw new NullPointerException("connectionName may not be null.");
|
||||
}
|
||||
logger.finest("setting connectionName="+connectionName);
|
||||
this.connectionName=connectionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the dataSourceContext.
|
||||
*/
|
||||
public String getDataSourceContext() {
|
||||
return dataSourceContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* When set to null(default) then
|
||||
* DATASOURCE_CONTEXT is used. ("java:comp/env/jdbc/")
|
||||
* @param dataSourceContext The dataSourceContext to set.
|
||||
*/
|
||||
public void setDataSourceContext(String dataSourceContext) {
|
||||
logger.finest("setting dataSourceContext="+dataSourceContext);
|
||||
this.dataSourceContext = dataSourceContext;
|
||||
}
|
||||
}
|
61
src/com/idcanet/foei/utils/jdbc/package.html
Normal file
61
src/com/idcanet/foei/utils/jdbc/package.html
Normal 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">
|
||||
An generic ConnectionProvider with default jndi support.<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>
|
70
src/com/idcanet/foei/utils/jndi/ContextListWriter.java
Normal file
70
src/com/idcanet/foei/utils/jndi/ContextListWriter.java
Normal 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.utils.jndi;
|
||||
|
||||
import javax.naming.Binding;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import java.io.PrintStream;
|
||||
|
||||
/**
|
||||
* A util recursive method which prints the jndi tree.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 18, 2006
|
||||
*/
|
||||
public class ContextListWriter
|
||||
{
|
||||
/**
|
||||
* writes an context tree to the printstream out.
|
||||
* @param out The printstream to which the text line are printed.
|
||||
* @param ctx The context to list.
|
||||
* @param indent The intext text for sub contexts.
|
||||
*/
|
||||
public static void writeContextTree(PrintStream out,Context ctx, String indent) {
|
||||
|
||||
if(out==null | ctx==null | indent==null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
NamingEnumeration list = ctx.listBindings("");
|
||||
while (list.hasMore()) {
|
||||
Binding item = (Binding)list.next();
|
||||
String className = item.getClassName();
|
||||
String name = item.getName();
|
||||
out.println(indent+" class: "+className+" name="+name);
|
||||
Object o = item.getObject();
|
||||
if (o instanceof javax.naming.Context) {
|
||||
writeContextTree(out,(Context)o,indent+indent);
|
||||
}
|
||||
}
|
||||
} catch (NamingException ne) {
|
||||
out.println("Nameing Exception: "+ne.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
669
src/com/idcanet/foei/utils/jndi/MemoryContext.java
Normal file
669
src/com/idcanet/foei/utils/jndi/MemoryContext.java
Normal file
|
@ -0,0 +1,669 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.utils.jndi;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import javax.naming.Binding;
|
||||
import javax.naming.CompositeName;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InvalidNameException;
|
||||
import javax.naming.Name;
|
||||
import javax.naming.NameAlreadyBoundException;
|
||||
import javax.naming.NameClassPair;
|
||||
import javax.naming.NameNotFoundException;
|
||||
import javax.naming.NameParser;
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.NotContextException;
|
||||
import javax.naming.OperationNotSupportedException;
|
||||
import javax.naming.spi.NamingManager;
|
||||
|
||||
|
||||
/**
|
||||
* A sample service provider that implements a hierarchical namespace in memory.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 18, 2006
|
||||
*/
|
||||
public class MemoryContext implements Context
|
||||
{
|
||||
protected Hashtable myEnv;
|
||||
protected Hashtable bindings = new Hashtable(11);
|
||||
protected final static NameParser myParser = new MemoryContextNameParser();
|
||||
protected MemoryContext parent = null;
|
||||
protected String myAtomicName = null;
|
||||
|
||||
/**
|
||||
* Creates an new FoeiContext without an everment
|
||||
* note:
|
||||
* This should be done via an Factrory
|
||||
* but then the server loader can not easaly load this class
|
||||
*/
|
||||
public MemoryContext()
|
||||
{
|
||||
//super()FoeiContext(null);
|
||||
}
|
||||
|
||||
MemoryContext(Hashtable inEnv)
|
||||
{
|
||||
myEnv = (inEnv != null)
|
||||
? (Hashtable)(inEnv.clone())
|
||||
: null;
|
||||
}
|
||||
|
||||
protected MemoryContext(MemoryContext parent, String name, Hashtable inEnv,Hashtable bindings)
|
||||
{
|
||||
this(inEnv);
|
||||
this.parent = parent;
|
||||
myAtomicName = name;
|
||||
this.bindings = (Hashtable)bindings.clone();
|
||||
}
|
||||
|
||||
protected Context createFoeiContext(MemoryContext parent, String name, Hashtable inEnv)
|
||||
{
|
||||
return new MemoryContext(parent, name, inEnv, new Hashtable(11));
|
||||
}
|
||||
|
||||
protected Context cloneCtx()
|
||||
{
|
||||
return new MemoryContext(parent, myAtomicName, myEnv, bindings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method for processing composite/compound name.
|
||||
* @param name The non-null composite or compound name to process.
|
||||
* @return The non-null string name in this namespace to be processed.
|
||||
*/
|
||||
protected Name getMyComponents(Name name) throws NamingException
|
||||
{
|
||||
if (name instanceof CompositeName)
|
||||
{
|
||||
if (name.size() > 1)
|
||||
{
|
||||
throw new InvalidNameException(name.toString()+" has more components than namespace can handle");
|
||||
}
|
||||
// Turn component that belongs to us into compound name
|
||||
return myParser.parse(name.get(0));
|
||||
}
|
||||
// Already parsed
|
||||
return name;
|
||||
}
|
||||
|
||||
public Object lookup(String name) throws NamingException
|
||||
{
|
||||
return lookup(new CompositeName(name));
|
||||
}
|
||||
|
||||
public Object lookup(Name name) throws NamingException
|
||||
{
|
||||
if (name.isEmpty())
|
||||
{
|
||||
return cloneCtx();
|
||||
}
|
||||
|
||||
// Extract components that belong to this namespace
|
||||
Name nm = getMyComponents(name);
|
||||
String atom = nm.get(0);
|
||||
Object inter = bindings.get(atom);
|
||||
|
||||
if (nm.size() == 1)
|
||||
{
|
||||
// Atomic name: Find object in internal data structure
|
||||
if (inter == null)
|
||||
{
|
||||
throw new NameNotFoundException(name + " not found");
|
||||
}
|
||||
|
||||
// Call getObjectInstance for using any object factories
|
||||
try
|
||||
{
|
||||
return NamingManager.getObjectInstance(inter,new CompositeName().add(atom),this, myEnv);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
NamingException ne = new NamingException("getObjectInstance failed");
|
||||
ne.setRootCause(e);
|
||||
throw ne;
|
||||
}
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// Intermediate name: Consume name in this context and continue
|
||||
if (!(inter instanceof Context))
|
||||
{
|
||||
throw new NotContextException(atom+" does not name a context");
|
||||
}
|
||||
return ((Context)inter).lookup(nm.getSuffix(1));
|
||||
// }
|
||||
}
|
||||
|
||||
public void bind(String name, Object obj) throws NamingException
|
||||
{
|
||||
bind(new CompositeName(name), obj);
|
||||
}
|
||||
|
||||
public void bind(Name name, Object obj) throws NamingException
|
||||
{
|
||||
if (name.isEmpty())
|
||||
{
|
||||
throw new InvalidNameException("Cannot bind empty name");
|
||||
}
|
||||
|
||||
Name nm = getMyComponents(name);
|
||||
String atom = nm.get(0);
|
||||
Object inter = bindings.get(atom);
|
||||
|
||||
if (nm.size() == 1)
|
||||
{
|
||||
// Atomic name: Find object in internal data structure
|
||||
if (inter != null)
|
||||
{
|
||||
throw new NameAlreadyBoundException("Use rebind to override");
|
||||
}
|
||||
|
||||
// Call getStateToBind for using any state factories
|
||||
obj = NamingManager.getStateToBind(obj,new CompositeName().add(atom),this, myEnv);
|
||||
|
||||
// Add object to internal data structure
|
||||
bindings.put(atom, obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Intermediate name: Consume name in this context and continue
|
||||
if(inter==null)
|
||||
{
|
||||
// auto create sub context.
|
||||
inter = createSubcontext(atom);
|
||||
}
|
||||
|
||||
if (!(inter instanceof Context))
|
||||
{
|
||||
throw new NotContextException(atom+" does not name a context");
|
||||
}
|
||||
((Context)inter).bind(nm.getSuffix(1), obj);
|
||||
}
|
||||
}
|
||||
|
||||
public void rebind(String name, Object obj) throws NamingException
|
||||
{
|
||||
rebind(new CompositeName(name), obj);
|
||||
}
|
||||
|
||||
public void rebind(Name name, Object obj) throws NamingException
|
||||
{
|
||||
if (name.isEmpty())
|
||||
{
|
||||
throw new InvalidNameException("Cannot bind empty name");
|
||||
}
|
||||
|
||||
// Extract components that belong to this namespace
|
||||
Name nm = getMyComponents(name);
|
||||
String atom = nm.get(0);
|
||||
|
||||
if (nm.size() == 1)
|
||||
{
|
||||
// Atomic name
|
||||
// Call getStateToBind for using any state factories
|
||||
obj = NamingManager.getStateToBind(obj,new CompositeName().add(atom),this, myEnv);
|
||||
|
||||
// Add object to internal data structure
|
||||
bindings.put(atom, obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Intermediate name: Consume name in this context and continue
|
||||
Object inter = bindings.get(atom);
|
||||
if(inter==null)
|
||||
{
|
||||
// auto create sub context.
|
||||
inter = createSubcontext(atom);
|
||||
}
|
||||
|
||||
if (!(inter instanceof Context))
|
||||
{
|
||||
throw new NotContextException(atom+" does not name a context");
|
||||
}
|
||||
((Context)inter).rebind(nm.getSuffix(1), obj);
|
||||
}
|
||||
}
|
||||
|
||||
public void unbind(String name) throws NamingException
|
||||
{
|
||||
unbind(new CompositeName(name));
|
||||
}
|
||||
|
||||
public void unbind(Name name) throws NamingException
|
||||
{
|
||||
if (name.isEmpty())
|
||||
{
|
||||
throw new InvalidNameException("Cannot unbind empty name");
|
||||
}
|
||||
|
||||
// Extract components that belong to this namespace
|
||||
Name nm = getMyComponents(name);
|
||||
String atom = nm.get(0);
|
||||
|
||||
// Remove object from internal data structure
|
||||
if (nm.size() == 1)
|
||||
{
|
||||
// Atomic name: Find object in internal data structure
|
||||
bindings.remove(atom);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Intermediate name: Consume name in this context and continue
|
||||
Object inter = bindings.get(atom);
|
||||
if (!(inter instanceof Context))
|
||||
{
|
||||
throw new NotContextException(atom+" does not name a context");
|
||||
}
|
||||
((Context)inter).unbind(nm.getSuffix(1));
|
||||
}
|
||||
}
|
||||
|
||||
public void rename(String oldName, String newName) throws NamingException
|
||||
{
|
||||
rename(new CompositeName(oldName), new CompositeName(newName));
|
||||
}
|
||||
|
||||
public void rename(Name oldname, Name newname) throws NamingException
|
||||
{
|
||||
if (oldname.isEmpty() || newname.isEmpty())
|
||||
{
|
||||
throw new InvalidNameException("Cannot rename empty name");
|
||||
}
|
||||
|
||||
Name oldnm = getMyComponents(oldname);
|
||||
Name newnm = getMyComponents(newname);
|
||||
|
||||
// Simplistic implementation: support only rename within same context
|
||||
if (oldnm.size() != newnm.size())
|
||||
{
|
||||
throw new OperationNotSupportedException("Do not support rename across different contexts");
|
||||
}
|
||||
|
||||
String oldatom = oldnm.get(0);
|
||||
String newatom = newnm.get(0);
|
||||
|
||||
if (oldnm.size() == 1)
|
||||
{
|
||||
if (bindings.get(newatom) != null)
|
||||
{
|
||||
throw new NameAlreadyBoundException(newname.toString()+" is already bound");
|
||||
}
|
||||
|
||||
// Check if old name is bound
|
||||
Object oldBinding = bindings.remove(oldatom);
|
||||
if (oldBinding == null)
|
||||
{
|
||||
throw new NameNotFoundException(oldname.toString() + " not bound");
|
||||
}
|
||||
bindings.put(newatom, oldBinding);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!oldatom.equals(newatom))
|
||||
{
|
||||
throw new OperationNotSupportedException("Do not support rename across different contexts");
|
||||
}
|
||||
|
||||
// Intermediate name: Consume name in this context and continue
|
||||
Object inter = bindings.get(oldatom);
|
||||
if (!(inter instanceof Context))
|
||||
{
|
||||
throw new NotContextException(oldatom+" does not name a context");
|
||||
}
|
||||
((Context)inter).rename(oldnm.getSuffix(1), newnm.getSuffix(1));
|
||||
}
|
||||
}
|
||||
|
||||
public NamingEnumeration list(String name) throws NamingException
|
||||
{
|
||||
return list(new CompositeName(name));
|
||||
}
|
||||
|
||||
public NamingEnumeration list(Name name) throws NamingException
|
||||
{
|
||||
if (name.isEmpty())
|
||||
{
|
||||
// listing this context
|
||||
return new ListOfNames(bindings.keys());
|
||||
}
|
||||
|
||||
// Perhaps 'name' names a context
|
||||
Object target = lookup(name);
|
||||
if (target instanceof Context)
|
||||
{
|
||||
return ((Context)target).list("");
|
||||
}
|
||||
throw new NotContextException(name + " cannot be listed");
|
||||
}
|
||||
|
||||
public NamingEnumeration listBindings(String name) throws NamingException
|
||||
{
|
||||
return listBindings(new CompositeName(name));
|
||||
}
|
||||
|
||||
public NamingEnumeration listBindings(Name name) throws NamingException
|
||||
{
|
||||
//System.err.println("FoeiContext list bindings is called "+this+" map size:"+bindings.size());
|
||||
|
||||
if (name.isEmpty()) {
|
||||
// listing this context
|
||||
return new ListOfBindings(bindings.keys());
|
||||
}
|
||||
|
||||
// Perhaps 'name' names a context
|
||||
Object target = lookup(name);
|
||||
if (target instanceof Context) {
|
||||
return ((Context)target).listBindings("");
|
||||
}
|
||||
throw new NotContextException(name + " cannot be listed");
|
||||
}
|
||||
|
||||
public void destroySubcontext(String name) throws NamingException {
|
||||
destroySubcontext(new CompositeName(name));
|
||||
}
|
||||
|
||||
public void destroySubcontext(Name name) throws NamingException
|
||||
{
|
||||
if (name.isEmpty())
|
||||
{
|
||||
throw new InvalidNameException("Cannot destroy context using empty name");
|
||||
}
|
||||
|
||||
// Simplistic implementation: not checking for nonempty context first
|
||||
// Use same implementation as unbind
|
||||
unbind(name);
|
||||
}
|
||||
|
||||
public Context createSubcontext(String name) throws NamingException
|
||||
{
|
||||
return createSubcontext(new CompositeName(name));
|
||||
}
|
||||
|
||||
public Context createSubcontext(Name name) throws NamingException
|
||||
{
|
||||
if (name.isEmpty())
|
||||
{
|
||||
throw new InvalidNameException("Cannot bind empty name");
|
||||
}
|
||||
|
||||
// Extract components that belong to this namespace
|
||||
Name nm = getMyComponents(name);
|
||||
String atom = nm.get(0);
|
||||
Object inter = bindings.get(atom);
|
||||
|
||||
if (nm.size() == 1)
|
||||
{
|
||||
// Atomic name: Find object in internal data structure
|
||||
if (inter != null)
|
||||
{
|
||||
throw new NameAlreadyBoundException("Use rebind to override");
|
||||
}
|
||||
|
||||
// Create child
|
||||
Context child = createFoeiContext(this, atom, myEnv);
|
||||
|
||||
// Add child to internal data structure
|
||||
bindings.put(atom, child);
|
||||
return child;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Intermediate name: Consume name in this context and continue
|
||||
if (!(inter instanceof Context))
|
||||
{
|
||||
throw new NotContextException(atom+" does not name a context");
|
||||
}
|
||||
return ((Context)inter).createSubcontext(nm.getSuffix(1));
|
||||
}
|
||||
}
|
||||
|
||||
public Object lookupLink(String name) throws NamingException
|
||||
{
|
||||
return lookupLink(new CompositeName(name));
|
||||
}
|
||||
|
||||
public Object lookupLink(Name name) throws NamingException
|
||||
{
|
||||
return lookup(name);
|
||||
}
|
||||
|
||||
public NameParser getNameParser(String name) throws NamingException
|
||||
{
|
||||
return getNameParser(new CompositeName(name));
|
||||
}
|
||||
|
||||
public NameParser getNameParser(Name name) throws NamingException
|
||||
{
|
||||
// Do lookup to verify name exists
|
||||
Object obj = lookup(name);
|
||||
if (obj instanceof Context)
|
||||
{
|
||||
((Context)obj).close();
|
||||
}
|
||||
return myParser;
|
||||
}
|
||||
|
||||
public String composeName(String name, String prefix) throws NamingException
|
||||
{
|
||||
Name result = composeName(new CompositeName(name),new CompositeName(prefix));
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public Name composeName(Name name, Name prefix) throws NamingException
|
||||
{
|
||||
Name result;
|
||||
|
||||
// Both are compound names, compose using compound name rules
|
||||
if (!(name instanceof CompositeName) && !(prefix instanceof CompositeName))
|
||||
{
|
||||
result = (Name)(prefix.clone());
|
||||
result.addAll(name);
|
||||
return new CompositeName().add(result.toString());
|
||||
}
|
||||
|
||||
// Simplistic implementation: do not support federation
|
||||
throw new OperationNotSupportedException("Do not support composing composite names");
|
||||
}
|
||||
|
||||
public Object addToEnvironment(String propName, Object propVal) throws NamingException
|
||||
{
|
||||
if (myEnv == null)
|
||||
{
|
||||
myEnv = new Hashtable(5, 0.75f);
|
||||
}
|
||||
return myEnv.put(propName, propVal);
|
||||
}
|
||||
|
||||
public Object removeFromEnvironment(String propName) throws NamingException
|
||||
{
|
||||
if (myEnv == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return myEnv.remove(propName);
|
||||
}
|
||||
|
||||
public Hashtable getEnvironment() throws NamingException
|
||||
{
|
||||
if (myEnv == null)
|
||||
{
|
||||
return new Hashtable(3, 0.75f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (Hashtable)myEnv.clone();
|
||||
}
|
||||
}
|
||||
|
||||
public String getNameInNamespace() throws NamingException
|
||||
{
|
||||
MemoryContext ancestor = parent;
|
||||
|
||||
// No ancestor
|
||||
if (ancestor == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
Name name = myParser.parse("");
|
||||
name.add(myAtomicName);
|
||||
|
||||
// Get parent's names
|
||||
while (ancestor != null && ancestor.myAtomicName != null)
|
||||
{
|
||||
name.add(0, ancestor.myAtomicName);
|
||||
ancestor = ancestor.parent;
|
||||
}
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
if (myAtomicName != null)
|
||||
{
|
||||
return myAtomicName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "ROOT CONTEXT";
|
||||
}
|
||||
}
|
||||
|
||||
public void close() throws NamingException
|
||||
{
|
||||
}
|
||||
|
||||
// Class for enumerating name/class pairs
|
||||
class ListOfNames implements NamingEnumeration {
|
||||
protected Enumeration names;
|
||||
|
||||
ListOfNames (Enumeration names) {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
public boolean hasMoreElements() {
|
||||
try {
|
||||
return hasMore();
|
||||
} catch (NamingException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasMore() throws NamingException {
|
||||
return names.hasMoreElements();
|
||||
}
|
||||
|
||||
public Object next() throws NamingException {
|
||||
String name = (String)names.nextElement();
|
||||
String className = bindings.get(name).getClass().getName();
|
||||
return new NameClassPair(name, className);
|
||||
}
|
||||
|
||||
public Object nextElement() {
|
||||
try {
|
||||
return next();
|
||||
} catch (NamingException e) {
|
||||
throw new NoSuchElementException(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
|
||||
// Class for enumerating bindings
|
||||
class ListOfBindings extends ListOfNames {
|
||||
|
||||
ListOfBindings(Enumeration names) {
|
||||
super(names);
|
||||
}
|
||||
|
||||
public Object next() throws NamingException {
|
||||
String name = (String)names.nextElement();
|
||||
Object obj = bindings.get(name);
|
||||
|
||||
try {
|
||||
obj = NamingManager.getObjectInstance(obj,
|
||||
new CompositeName().add(name), MemoryContext.this,
|
||||
MemoryContext.this.myEnv);
|
||||
} catch (Exception e) {
|
||||
NamingException ne = new NamingException(
|
||||
"getObjectInstance failed");
|
||||
ne.setRootCause(e);
|
||||
throw ne;
|
||||
}
|
||||
|
||||
return new Binding(name, obj);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
static FoeiContext testRoot;
|
||||
static {
|
||||
try {
|
||||
testRoot = new FoeiContext(null);
|
||||
|
||||
Context a = testRoot.createSubcontext("a");
|
||||
Context b = a.createSubcontext("b");
|
||||
Context c = b.createSubcontext("c");
|
||||
|
||||
testRoot.createSubcontext("x");
|
||||
testRoot.createSubcontext("y");
|
||||
} catch (NamingException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static Context getStaticNamespace(Hashtable env) {
|
||||
return testRoot;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
Context ctx = new FoeiContext(null);
|
||||
|
||||
Context a = ctx.createSubcontext("a");
|
||||
Context b = a.createSubcontext("b");
|
||||
Context c = b.createSubcontext("c");
|
||||
|
||||
System.out.println(c.getNameInNamespace());
|
||||
|
||||
System.out.println(ctx.lookup(""));
|
||||
System.out.println(ctx.lookup("a"));
|
||||
System.out.println(ctx.lookup("b.a"));
|
||||
System.out.println(a.lookup("c.b"));
|
||||
} catch (NamingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
61
src/com/idcanet/foei/utils/jndi/MemoryContextFactory.java
Normal file
61
src/com/idcanet/foei/utils/jndi/MemoryContextFactory.java
Normal 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.utils.jndi;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import javax.naming.spi.InitialContextFactory;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
|
||||
/**
|
||||
* Creates an new MemoryContext
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 18, 2006
|
||||
*
|
||||
*/
|
||||
public class MemoryContextFactory implements InitialContextFactory
|
||||
{
|
||||
/** Stores the jvm wide instance of the FoeiContext */
|
||||
static private Context context = null;
|
||||
|
||||
/**
|
||||
* Returns the FoeiContext
|
||||
* @param environment
|
||||
* @return
|
||||
* @throws NamingException
|
||||
*/
|
||||
public Context getInitialContext(Hashtable environment) throws NamingException {
|
||||
|
||||
if(context!=null) {
|
||||
return context;
|
||||
}
|
||||
context = new MemoryContext(environment);
|
||||
return context;
|
||||
}
|
||||
}
|
66
src/com/idcanet/foei/utils/jndi/MemoryContextNameParser.java
Normal file
66
src/com/idcanet/foei/utils/jndi/MemoryContextNameParser.java
Normal 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.utils.jndi;
|
||||
|
||||
import java.util.Properties;
|
||||
import javax.naming.NameParser;
|
||||
import javax.naming.Name;
|
||||
import javax.naming.CompoundName;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
/**
|
||||
* A jndi name parser
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 18, 2006
|
||||
*/
|
||||
class MemoryContextNameParser implements NameParser {
|
||||
|
||||
/** The syntax to use. */
|
||||
private static Properties syntax = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
syntax = new Properties();
|
||||
syntax.put("jndi.syntax.direction", "left_to_right");
|
||||
syntax.put("jndi.syntax.separator", ".");
|
||||
syntax.put("jndi.syntax.ignorecase", "false");
|
||||
syntax.put("jndi.syntax.escape", "\\");
|
||||
syntax.put("jndi.syntax.beginquote", "'");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error while creating FoeiNameParser",e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the String name into an Jndi name.
|
||||
* @see NameParser#parse(java.lang.String)
|
||||
*/
|
||||
public Name parse(String name) throws NamingException {
|
||||
return new CompoundName(name, syntax);
|
||||
}
|
||||
}
|
61
src/com/idcanet/foei/utils/jndi/package.html
Normal file
61
src/com/idcanet/foei/utils/jndi/package.html
Normal 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">
|
||||
Defines an MemoryContext for storing object in a jndi tree.<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>
|
13
tests/com/META-INF/foei-config.xml
Normal file
13
tests/com/META-INF/foei-config.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<foei-config>
|
||||
|
||||
<foeiContext name="test">
|
||||
<property name="" value=""/>
|
||||
|
||||
<foeiProcess name="start">
|
||||
<load type="file" name=""/>
|
||||
<load type="resource" name=""/>
|
||||
</foeiProcess>
|
||||
</foeiContext>
|
||||
|
||||
</foei-config>
|
26
tests/com/META-INF/foei.properties
Normal file
26
tests/com/META-INF/foei.properties
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
foei.context_name=TEST-0
|
||||
|
||||
foei.event_thread_listeners=tests.TestEventThreadListener
|
||||
|
||||
foei.event_executor_manager.pool_core_size=5
|
||||
foei.event_executor_manager.pool_max_size=10
|
||||
foei.event_executor_manager.pool_keep_alive=300
|
||||
|
||||
############
|
||||
## DEFAULTS ##
|
||||
############
|
||||
#
|
||||
#foei.context_name=<No-default-required-to-set>
|
||||
#foei.root_path=<No-default-required-to-set>
|
||||
#
|
||||
#foei.object_bindings_manager=com.idca.foei.core.impl.ObjectBindingsManagerImpl
|
||||
#foei.event_executor=com.idca.foei.core.impl.EventExecutorImpl
|
||||
#foei.event_executor_manager=com.idca.foei.core.impl.EventExecutorManagerImpl
|
||||
#foei.event_executor_manager.pool_core_size=3
|
||||
#foei.event_executor_manager.pool_max_size=5
|
||||
#foei.event_executor_manager.pool_keep_alive=180
|
||||
#foei.initial_object_context_factory=com.idca.foei.utils.jndi.MemoryContextFactory
|
||||
#foei.event_thread_listeners=<empty>
|
||||
#foei.x2o_root_tag=foei
|
||||
#foei.x2o_default_element_configurator=com.idca.foei.xml.x2o.DefaultX2OElementConfigurator
|
|
@ -1,3 +1,14 @@
|
|||
|
||||
|
||||
dfg
|
||||
package com.idcanet.foei.tests;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jul 27, 2006
|
||||
*/
|
||||
public class SimpleFoeiTests {
|
||||
}
|
22
tests/com/idcanet/foei/tests/TestEventThreadListener.java
Normal file
22
tests/com/idcanet/foei/tests/TestEventThreadListener.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
package com.idcanet.foei.tests;
|
||||
|
||||
import com.idcanet.foei.core.EventThreadListener;
|
||||
import com.idcanet.foei.core.FoeiContext;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jul 27, 2006
|
||||
*/
|
||||
public class TestEventThreadListener implements EventThreadListener {
|
||||
|
||||
public void startThread(FoeiContext foeiContext) {
|
||||
System.out.println("START: "+Thread.currentThread().getName()+" context: "+foeiContext.getName());
|
||||
}
|
||||
|
||||
public void stopThread(FoeiContext foeiContext) {
|
||||
System.out.println("STOP: "+Thread.currentThread().getName()+" context: "+foeiContext.getName());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue