simple split to multi module project
This commit is contained in:
parent
5c13908f8e
commit
2906c482d1
182 changed files with 396 additions and 589 deletions
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.server;
|
||||
|
||||
import com.idcanet.foei.core.FoeiConfigurator;
|
||||
import com.idcanet.foei.core.FoeiContext;
|
||||
import com.idcanet.foei.core.impl.FoeiConfiguratorImpl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Manages the different FoeiContext.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 6, 2006
|
||||
*/
|
||||
public class FoeiContextManager {
|
||||
|
||||
/** The logger to log to. */
|
||||
private Logger logger = null;
|
||||
/** All FoeiContext */
|
||||
private Map<String,FoeiContext> contexts = null;
|
||||
|
||||
/**
|
||||
* Inits the logger and the FoeiContext storage.
|
||||
*/
|
||||
public FoeiContextManager() {
|
||||
logger = Logger.getLogger(FoeiContextManager.class.getName());
|
||||
contexts = new HashMap<String,FoeiContext>(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an FoeiContext.
|
||||
* @param properties The properties of the FoeiContext.
|
||||
*/
|
||||
public void createFoeiContext(Map properties) {
|
||||
FoeiConfigurator config = null;
|
||||
try {
|
||||
config = (FoeiConfigurator) FoeiConfigurator.DEFAULT_FOEI_CONFIGURATOR.newInstance();
|
||||
logger.info("Building FoeiContext: "+FoeiConfiguratorImpl.getContextName(properties));
|
||||
FoeiContext context = config.buildFoeiContext(properties);
|
||||
addFoeiContext(context);
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING,"Error while starting FoeiContext: "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an FoeiContext
|
||||
* @param foeiContext The FoeiContext to add.
|
||||
*/
|
||||
public void addFoeiContext(FoeiContext foeiContext) {
|
||||
if(foeiContext==null) {
|
||||
throw new NullPointerException("FoeiContext may not be null.");
|
||||
}
|
||||
contexts.put(foeiContext.getName(),foeiContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* USE AS LESS AS POSIBLE, MOSTLY NOT !!<br/>
|
||||
*
|
||||
* Be aware that a lot of functions in Foei depent on the
|
||||
* thread locale being injected in the current thread.
|
||||
*
|
||||
* For sake of OO dividing layers its not recommened to do Foei Logic
|
||||
* in the request/event/etc thread.
|
||||
*
|
||||
* Gets an FoeiContext by its name.
|
||||
* @param name The name of the FoeiContext
|
||||
* @return Returns the FoeiContext or null if none was found by its name.
|
||||
*/
|
||||
public FoeiContext getFoeiContext(String name) {
|
||||
return contexts.get(name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destroys all FoeiContexts.
|
||||
*/
|
||||
public void destroyAll() {
|
||||
for(FoeiContext context:contexts.values()) {
|
||||
context.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright 2004-2006 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei.server;
|
||||
|
||||
/**
|
||||
* Provides the method to get the FoeiContextManager
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Feb 6, 2006
|
||||
*/
|
||||
public class FoeiContextManagerFactory {
|
||||
|
||||
/** */
|
||||
static private FoeiContextManager foeiContextManager = null;
|
||||
|
||||
/**
|
||||
* Gets the FoeiContextManager
|
||||
* @return Returns the FoeiContextManager
|
||||
*/
|
||||
static public FoeiContextManager getFoeiContextManager() {
|
||||
if(foeiContextManager==null) {
|
||||
throw new IllegalStateException("no FoeiContextManager has been set.");
|
||||
}
|
||||
return foeiContextManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an FoeiContextManager.<br/>
|
||||
* note:
|
||||
* May only be set once !.
|
||||
*
|
||||
* @param foeiContextManager
|
||||
*/
|
||||
static public void setFoeiContextManager(FoeiContextManager foeiContextManager) {
|
||||
if(foeiContextManager==null) {
|
||||
throw new NullPointerException("foeiContextManager may not be null.");
|
||||
}
|
||||
if(FoeiContextManagerFactory.foeiContextManager!=null) {
|
||||
throw new IllegalStateException("foeiContextManager may only be set once.");
|
||||
}
|
||||
FoeiContextManagerFactory.foeiContextManager=foeiContextManager;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
@ -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>
|
||||
|
|
@ -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">
|
||||
Foei server objects<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,103 @@
|
|||
/*
|
||||
* 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.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();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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>
|
||||
0
foei-server/src/main/resources/.empty
Normal file
0
foei-server/src/main/resources/.empty
Normal file
166
foei-server/src/test/java/com/idcanet/foei/SimpleFoeiTests.java
Normal file
166
foei-server/src/test/java/com/idcanet/foei/SimpleFoeiTests.java
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
/*
|
||||
* Copyright 2004-2008 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.idcanet.foei.components.lang.DummyOutputPort;
|
||||
import com.idcanet.foei.components.lang.Filter;
|
||||
import com.idcanet.foei.core.FoeiContext;
|
||||
import com.idcanet.foei.core.FoeiProcess;
|
||||
import com.idcanet.foei.event.AbstractEventInput;
|
||||
import com.idcanet.foei.event.EventPort;
|
||||
import com.idcanet.foei.event.IllegalEventPortNameException;
|
||||
import com.idcanet.foei.server.FoeiContextManager;
|
||||
import com.idcanet.foei.server.FoeiContextManagerFactory;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jul 27, 2006
|
||||
*/
|
||||
public class SimpleFoeiTests extends TestCase {
|
||||
|
||||
private static FoeiContext test0 = null;
|
||||
|
||||
private void start() throws Exception {
|
||||
if (test0!=null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Creates FoeiContextManager
|
||||
FoeiContextManager foeiContextManager = new FoeiContextManager();
|
||||
FoeiContextManagerFactory.setFoeiContextManager(foeiContextManager);
|
||||
|
||||
InputStream foeiProperties = this.getClass().getResourceAsStream("/META-INF/test-foei.properties");
|
||||
Properties properties = new Properties();
|
||||
properties.load(foeiProperties);
|
||||
foeiProperties.close();
|
||||
//properties.put(FoeiConfigurator.ROOT_PATH,"/tmp");
|
||||
foeiContextManager.createFoeiContext(properties);
|
||||
|
||||
test0 = foeiContextManager.getFoeiContext("TEST-0");
|
||||
}
|
||||
|
||||
public void testStartup() throws Exception {
|
||||
start();
|
||||
assertNotNull(test0);
|
||||
}
|
||||
|
||||
public void testFoeiProcessLife() throws Exception {
|
||||
start();
|
||||
FoeiProcess proc = test0.getFoeiProcessManager().createFoeiProcess("testProces",test0);
|
||||
assertNotNull(proc);
|
||||
test0.getFoeiProcessManager().destroyFoeiProcess("testProces");
|
||||
assertNull(test0.getFoeiProcessManager().getFoeiProcess("testProces"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void testSimpleSpeed() throws Exception {
|
||||
start();
|
||||
FoeiProcess proc = test0.getFoeiProcessManager().createFoeiProcess("testSpeed0",test0);
|
||||
assertNotNull(proc);
|
||||
|
||||
DummyOutputPort in = new DummyOutputPort();
|
||||
Filter f1 = new Filter();
|
||||
Filter f2 = new Filter();
|
||||
Filter f3 = new Filter();
|
||||
SpeedTestPort out = new SpeedTestPort();
|
||||
|
||||
//in.getOutputPort(EventPort.OUTPUT).setImmediate(true);
|
||||
|
||||
// saves 300ms on 100k records
|
||||
f1.getOutputPort(EventPort.PASS).setImmediate(true);
|
||||
f2.getOutputPort(EventPort.PASS).setImmediate(true);
|
||||
f3.getOutputPort(EventPort.PASS).setImmediate(true);
|
||||
|
||||
// has no effect !!
|
||||
//out.getInputPort(EventPort.INPUT).setImmediate(true);
|
||||
|
||||
proc.addBinding(in.getOutputPort(EventPort.OUTPUT), f1.getInputPort(EventPort.INPUT));
|
||||
proc.addBinding(f1.getOutputPort(EventPort.PASS), f2.getInputPort(EventPort.INPUT));
|
||||
proc.addBinding(f2.getOutputPort(EventPort.PASS), f3.getInputPort(EventPort.INPUT));
|
||||
proc.addBinding(f3.getOutputPort(EventPort.PASS), out.getInputPort(EventPort.INPUT));
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
for (int i=0;i<100000;i++) {
|
||||
SpeedModel m = new SpeedModel();
|
||||
|
||||
// IN FOEI it is;
|
||||
//proc.executeEvent(in.getOutputPort(EventPort.OUTPUT), m);
|
||||
|
||||
// running outside foei context thread use;
|
||||
proc.getFoeiContext().getEventExecutorManager().executeEvent(in.getOutputPort(EventPort.OUTPUT), m, proc);
|
||||
}
|
||||
proc.getFoeiContext().getEventExecutorManager().executeEvent(in.getOutputPort(EventPort.OUTPUT), new Date(), proc);
|
||||
long endTime = System.currentTimeMillis();
|
||||
System.out.println("Done sending in: "+(endTime-startTime)+" ms.");
|
||||
Thread.sleep(5000); // todo: create destory context on end of event que
|
||||
System.out.println("End speedtest");
|
||||
test0.getFoeiProcessManager().destroyFoeiProcess("testSpeed0");
|
||||
}
|
||||
|
||||
}
|
||||
class SpeedModel {
|
||||
Date dateCreated = new Date();
|
||||
Date dateDone = null;
|
||||
}
|
||||
class SpeedTestPort extends AbstractEventInput {
|
||||
|
||||
/** v1.0 */
|
||||
static final long serialVersionUID = 10l;
|
||||
Date startTime = new Date();
|
||||
|
||||
|
||||
/**
|
||||
* Creates the output port
|
||||
*/
|
||||
public SpeedTestPort() {
|
||||
addInputPort(EventPort.INPUT,Object.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.idcanet.foei.event.AbstractEventInput#doEvent(com.idcanet.foei.event.EventPort, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void doEvent(EventPort eventPort, Object object) throws IllegalEventPortNameException {
|
||||
if (object instanceof SpeedModel) {
|
||||
SpeedModel m = (SpeedModel)object;
|
||||
m.dateDone=new Date();
|
||||
return;
|
||||
}
|
||||
// other object == end of test
|
||||
long endTime = System.currentTimeMillis();
|
||||
System.out.println("End of test: "+(endTime-startTime.getTime())+" ms.");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 2004-2008 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package com.idcanet.foei;
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
13
foei-server/src/test/resources/META-INF/test-foei-config.xml
Normal file
13
foei-server/src/test/resources/META-INF/test-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
foei-server/src/test/resources/META-INF/test-foei.properties
Normal file
26
foei-server/src/test/resources/META-INF/test-foei.properties
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
foei.context_name=TEST-0
|
||||
|
||||
foei.event_thread_listeners=com.idcanet.foei.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
|
||||
Loading…
Add table
Add a link
Reference in a new issue