Initial commit for OpenESB standalone

master
David BRASSELY 2013-06-20 17:06:00 +02:00
commit ff40dd1a58
10 changed files with 1456 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
!.gitignore
target/

View File

@ -0,0 +1,42 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.open-esb</groupId>
<artifactId>openesb-standalone</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>openesb-standalone-bootstrap</artifactId>
<name>OpenESB - Standalone - Bootstrap</name>
<description>OpenESB runtime in standalone mode - Bootstrap</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestEntries>
<Main-Class>net.openesb.standalone.bootstrap.StandaloneBoostrapper</Main-Class>
<Class-Path>jbi.jar jbi-ext.jar jta-1_1-classes.zip</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.open-esb</groupId>
<artifactId>openesb-standalone-framework</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,388 @@
/*
* BEGIN_HEADER - DO NOT EDIT
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
* If applicable add the following below this CDDL HEADER,
* with the fields enclosed by brackets "[]" replaced with
* your own identifying information: Portions Copyright
* [year] [name of copyright owner]
*/
/*
* @(#)JSEJBIBootstrap.java
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package net.openesb.standalone.bootstrap;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
public class StandaloneBoostrapper
implements Runnable
{
/** JSR208 interfaces. */
private static final String JBI_JAR_NAME = "jbi.jar";
/** JBI runtime interfaces exposed to components. */
private static final String JBI_EXT_JAR_NAME = "jbi-ext.jar";
/** Name of the top-level class of the JBI runtime framework. */
private static final String JBI_FRAMEWORK_CLASS_NAME =
"net.openesb.standalone.framework.JSEJBIFramework";
/** Runtime life cycle commands. */
private static final String START = "start";
private static final String STOP = "stop";
/** Environment property used to override install root location. */
private static final String INSTALL_ROOT = "install.root";
/** Environment property used for instance name. */
public static final String INSTANCE_NAME = "instance.name";
/** Environment property used for JMX connector port setting. */
private static final String CONNECTOR_PORT = "connector.port";
/** Default connector port. */
private static final String DEFAULT_CONNECTOR_PORT = "8699";
/** Default instance name. */
private static final String DEFAULT_INSTANCE_NAME = "server";
/** List of jars that should not be included in the runtime classloader. */
private List<String> mBlacklistJars = new ArrayList<String>();
/** ClassLoader used for JBI runtime classes. These classes are not
* part of the component classloader hierarchy.
*/
private ClassLoader mFrameworkClassLoader;
/** ClassLoader for clases in lib/ext that become part of the component
* classloader hierarchy.
*/
private ClassLoader mExtensionClassLoader;
/** JBI installation directory. */
private File mJbiInstallDir;
/** JBI Framework implementation */
private Object mJbiFramework;
/** Environment properties */
private Properties mEnvironment;
private Logger mLog =
Logger.getLogger(this.getClass().getPackage().getName());
/** Runs the JBI framework in stand-alone mode under Java SE. System
* properties defined at the command-line with '-D' are passed into the
* framework as environment properties.
* @param args not used at this time
* @throws Exception framework failed to initialize
*/
public static void main(String[] args)
{
StandaloneBoostrapper jbiBootstrap = new StandaloneBoostrapper(System.getProperties());
try
{
jbiBootstrap.createJBIFramework();
// Are we starting or stopping? Default to start.
if (args != null && args.length > 0 && STOP.equalsIgnoreCase(args[0]))
{
jbiBootstrap.unloadJBIFramework();
}
else
{
jbiBootstrap.loadJBIFramework();
}
}
catch (Exception ex)
{
System.err.println(ex.getMessage());
}
}
/** Create a new JSEJBIBootstrap instance with the specified environment.
* @param env environment properties
*/
public StandaloneBoostrapper(Properties env)
{
mEnvironment = env;
// setup blacklist jars
mBlacklistJars.add(JBI_JAR_NAME);
mBlacklistJars.add(JBI_EXT_JAR_NAME);
// If connector port is not specified, set a 'smart' value
if (mEnvironment.getProperty(CONNECTOR_PORT) == null)
{
mEnvironment.setProperty(CONNECTOR_PORT, DEFAULT_CONNECTOR_PORT);
}
// If install root is not set, default to current working directory
String installPath = mEnvironment.getProperty(INSTALL_ROOT);
if (installPath == null)
{
File installDir = new File(System.getProperty("user.dir"));
// account for javaw launch from a double-click on the jar
if (installDir.getName().equals("lib"))
{
installDir = installDir.getParentFile();
}
installPath = installDir.getAbsolutePath();
}
mJbiInstallDir = new File(installPath);
// quick sanity check on the install root
if (!mJbiInstallDir.isDirectory() ||
!new File(mJbiInstallDir, "lib/jbi_rt.jar").exists())
{
throw new RuntimeException("Invalid JBI install root: " +
mJbiInstallDir.getAbsolutePath());
}
// pass this information along to the core framework
mEnvironment.setProperty(INSTALL_ROOT, mJbiInstallDir.getAbsolutePath());
}
/** Shutdown hook to allow the JBI framework to exit gracefully in the
* event of an abrupt shutdown (e.g. ^C).
*/
public void run()
{
try
{
// Using System.out because the loggers appear to be gone at this point
System.out.println("Unloading JBI framework in response to VM termination.");
invoke(mJbiFramework, "unload");
System.out.println("JBI framework shutdown complete.");
}
catch (Throwable t)
{
mLog.log(Level.SEVERE, "Failed to unload JBI framework: {0}", t.toString());
}
}
/** Loads the JBI framework using the Java SE platform wrapper. If the
* framework loads successfully, this method adds a shutdown hook to
* allow for civilized clean-up when the VM terminates.
*/
void loadJBIFramework()
{
try
{
invoke(mJbiFramework, "load");
//Add a shutdown hook to call unload when the VM exits
Runtime.getRuntime().addShutdownHook(new Thread(this));
}
catch (Throwable t)
{
mLog.log(Level.SEVERE, "Failed to load JBI framework: {0}", t.toString());
}
}
/** Unloads the JBI framework using the Java SE platform wrapper. This is
* always a remote call, since the framework has (presumably) been loaded
* previously by another process.
*/
void unloadJBIFramework()
{
String errMsg = null;
JMXServiceURL serviceURL;
int jmxConnectorPort;
try
{
// Which port is the connector server running on?
jmxConnectorPort = Integer.parseInt(mEnvironment.getProperty(
CONNECTOR_PORT, DEFAULT_CONNECTOR_PORT));
serviceURL = (JMXServiceURL)invoke(mJbiFramework, "getServiceURL",
new Integer(jmxConnectorPort));
JMXConnector jmxConn = JMXConnectorFactory.connect(serviceURL);
MBeanServerConnection mbsConn = jmxConn.getMBeanServerConnection();
ObjectName fwMBeanName = new ObjectName("com.sun.jbi.jse", "instance",
mEnvironment.getProperty(INSTANCE_NAME, DEFAULT_INSTANCE_NAME));
mbsConn.invoke(fwMBeanName, "unload", new Object[0], new String[0]);
}
catch (NumberFormatException nfEx)
{
mLog.log(Level.SEVERE, "Invalid JMX connector port value. {0}", nfEx.getMessage());
}
catch (javax.management.MBeanException mbEx)
{
errMsg = mbEx.getTargetException().toString();
}
catch (Throwable t)
{
errMsg = t.toString();
}
if (errMsg != null)
{
mLog.log(Level.SEVERE, "Failed to unload JBI framework: {0}", errMsg);
}
else
{
mLog.log(Level.INFO, "JBI framework has been unloaded.");
}
}
/** Creates the JBI framework using the appropriate classloading structure.
*/
private void createJBIFramework()
throws Exception
{
Class fwClass;
Constructor fwCtor;
try
{
createExtensionClassLoader();
createFrameworkClassLoader();
// Set the thread context classloader to the extension classloader
Thread.currentThread().setContextClassLoader(mExtensionClassLoader);
fwClass = mFrameworkClassLoader.loadClass(JBI_FRAMEWORK_CLASS_NAME);
fwCtor = fwClass.getDeclaredConstructor(Properties.class);
mJbiFramework = fwCtor.newInstance(mEnvironment);
}
catch (Exception ex)
{
throw new Exception("Failed to create JBI framework: " + ex.getMessage());
}
}
/** Creates a separate runtime classloader to avoid namespace pollution
* between the component classloading hierarchy and the JBI implementation.
* At present, this method is greedy and includes any file in the lib/
* directory in the runtime classpath.
*/
private void createFrameworkClassLoader()
{
ArrayList<URL> cpList = new ArrayList<URL>();
URL[] cpURLs = new URL[0];
File libDir = new File(mJbiInstallDir, "lib");
// Everything in the lib directory goes into the classpath
for (File lib : libDir.listFiles())
{
try
{
if (mBlacklistJars.contains(lib.getName()))
{
// skip blacklisted jars
continue;
}
cpList.add(lib.toURI().toURL());
}
catch (java.net.MalformedURLException urlEx)
{
mLog.log(Level.WARNING, "Bad library URL: {0}", urlEx.getMessage());
}
}
cpURLs = cpList.toArray(cpURLs);
mFrameworkClassLoader = new URLClassLoader(
cpURLs, mExtensionClassLoader);
}
/** Creates a separate extension classloader for the component classloading
* chain. All jars added in the lib/ext directory are automatically added
* to this classloader's classpath.
*/
private void createExtensionClassLoader()
{
ArrayList<URL> cpList = new ArrayList<URL>();
URL[] cpURLs = new URL[0];
File libDir = new File(mJbiInstallDir, "lib/ext");
if (libDir.exists() || libDir.isDirectory())
{
try
{
// Add the top-level ext directory
cpList.add(libDir.toURI().toURL());
// Everything in the lib/ext directory goes into the classpath
for (File lib : libDir.listFiles())
{
cpList.add(lib.toURI().toURL());
}
}
catch (java.net.MalformedURLException urlEx)
{
mLog.log(Level.WARNING, "Bad library URL: {0}", urlEx.getMessage());
}
}
cpURLs = cpList.toArray(cpURLs);
mExtensionClassLoader = new URLClassLoader(
cpURLs, getClass().getClassLoader());
}
/** Utility method to invoke a method using reflection. This is kind of
* a sloppy implementation, since we don't account for overloaded methods.
* @param obj contains the method to be invoked
* @param method name of the method to be invoked
* @param params parameters, if any
* @return returned object, if any
*/
private Object invoke(Object obj, String method, Object... params)
throws Throwable
{
Object result = null;
try
{
for (Method m : obj.getClass().getDeclaredMethods())
{
if (m.getName().equals(method))
{
result = m.invoke(obj, params);
break;
}
}
return result;
}
catch (java.lang.reflect.InvocationTargetException itEx)
{
throw itEx.getTargetException();
}
}
}

View File

@ -0,0 +1,27 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.open-esb</groupId>
<artifactId>openesb-standalone</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>openesb-standalone-framework</artifactId>
<name>OpenESB - Standalone - Framework</name>
<description>OpenESB runtime in standalone mode - Framework</description>
<dependencies>
<dependency>
<groupId>open-esb</groupId>
<artifactId>framework-core</artifactId>
</dependency>
<dependency>
<groupId>com.atomikos</groupId>
<artifactId>transactions-jta</artifactId>
<version>${atomikos.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,228 @@
/*
* BEGIN_HEADER - DO NOT EDIT
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
* If applicable add the following below this CDDL HEADER,
* with the fields enclosed by brackets "[]" replaced with
* your own identifying information: Portions Copyright
* [year] [name of copyright owner]
*/
/*
* @(#)JSEJBIFramework.java
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package net.openesb.standalone.framework;
import com.sun.jndi.rmi.registry.RegistryContextFactory;
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
import java.util.HashMap;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
/**
* JBI framework wrapper for Java SE platform.
* <br><br>
* A JSEJBIFramework instance cannot be loaded multiple times in the same
* VM. If multiple instances of the framework are required in a VM,
* instantiate multiple instances of JSEJBIFramework and load each one
* independently. There is no limit on the number of uniquely named
* JSEJBIFramework instances in the same VM. A specific JSEJBIFramework instance
* can be loaded and unloaded multiple times in a VM.
*
* @author Sun Microsystems, Inc.
*/
public class JSEJBIFramework
extends com.sun.jbi.framework.JBIFramework
implements JSEJBIFrameworkMBean
{
public static final String INSTALL_ROOT = "install.root";
public static final String INSTANCE_NAME = "instance.name";
public static final String CONNECTOR_PORT = "connector.port";
/** Configuration defaults. */
private static final String DEFAULT_INSTALL_ROOT =
System.getProperty("user.dir");
private static final String DEFAULT_INSTANCE_NAME =
"server";
private JSEPlatformContext mPlatformContext;
private boolean mLoaded;
private Properties mEnvironment;
private JMXConnectorServer mJMXServer;
private Registry mRegistry;
private Logger mLog =
Logger.getLogger(this.getClass().getPackage().getName());
/** Creates a new instance of the JBI framework.
*/
public JSEJBIFramework(Properties environment)
{
super();
mEnvironment = environment;
mPlatformContext = new JSEPlatformContext(
mEnvironment.getProperty(INSTANCE_NAME, DEFAULT_INSTANCE_NAME),
mEnvironment.getProperty(INSTALL_ROOT, DEFAULT_INSTALL_ROOT));
}
/** Load the JBI framework with the specified environment. When this method
* retuns, all public interfaces and system services have completely
* initialized. If a connector port is specified in the environment
* properties, a remote JMX connector server is created.
* @throws Exception failed to load JBI framework
*/
public synchronized void load()
throws Exception
{
if (mLoaded)
{
throw new IllegalStateException("JBI framework already loaded!");
}
// Register a management MBean for this framework instance
ObjectName fwMBeanName = new ObjectName("com.sun.jbi.jse",
"instance", mPlatformContext.getInstanceName());
MBeanServer mbs = mPlatformContext.getMBeanServer();
if (mbs.isRegistered(fwMBeanName))
{
if (mbs.getAttribute(fwMBeanName, "Loaded").equals(Boolean.TRUE))
{
// Framework already loaded from a separate thread/process
throw new IllegalStateException("JBI framework instance " +
mPlatformContext.getInstanceName() + " has already been loaded");
}
else
{
// MBean should not be registered - try to clean up
mbs.unregisterMBean(fwMBeanName);
}
}
mbs.registerMBean(this, fwMBeanName);
// Setup the remote JMX connector server
String portStr = mEnvironment.getProperty(CONNECTOR_PORT);
if (portStr != null)
{
try
{
int port = Integer.parseInt(portStr);
createJMXConnectorServer(port);
}
catch (NumberFormatException nfEx)
{
mLog.log(Level.WARNING, "Invalid connector server port: {0}. Remote JMX connector will not be created.", portStr);
}
}
// For stand-alone JBI, JBI_HOME = platform install root
mEnvironment.setProperty("com.sun.jbi.home",
mPlatformContext.getInstallRoot());
init(mPlatformContext, mEnvironment);
startup(mPlatformContext.getNamingContext(), "");
prepare();
ready(true);
// JBI framework has been loaded
mLoaded = true;
}
/** Queries the state of the JBI Framework.
* @return true if the JBI framework is loaded, false otherwise.
*/
public boolean isLoaded()
{
return mLoaded;
}
/** Unloads the JBI framework. When this method retuns, all
* public interfaces, system services, and JMX connector (if configured)
* have been destroyed.
* @throws javax.jbi.JBIException failed to unload JBI framework
*/
public synchronized void unload()
throws Exception
{
if (!mLoaded)
{
return;
}
shutdown();
terminate();
try
{
mJMXServer.stop();
UnicastRemoteObject.unexportObject(mRegistry, true);
}
catch (Exception ex)
{
mLog.log(Level.SEVERE, "Error during framework shutdown: {0}", ex.toString());
}
mLoaded = false;
}
public JMXServiceURL getServiceURL(int port)
throws java.net.MalformedURLException
{
return new JMXServiceURL(
"service:jmx:rmi:///jndi/rmi://localhost:" + port + "/jmxrmi");
}
/** Creates a JMX connector server at the specified port.
* @param port port for the JMX connector server.
*/
private void createJMXConnectorServer(int port)
{
HashMap<String, String> map = new HashMap<String, String>();
map.put("java.naming.factory.initial",
RegistryContextFactory.class.getName());
try
{
// Create the service URL
JMXServiceURL serviceURL = getServiceURL(port);
// Create an RMI registry instance to hold the JMX connector server
mRegistry = LocateRegistry.createRegistry(port);
// Create and start the connector server
mJMXServer = JMXConnectorServerFactory.newJMXConnectorServer(
serviceURL, map, mPlatformContext.getMBeanServer());
mJMXServer.start();
mLog.log(Level.INFO, "remote JMX connector available at {0}", mJMXServer.getAddress());
}
catch (Exception ex)
{
mLog.log(Level.SEVERE, "Failed to create remote JMX connector: {0}", ex.toString());
}
}
}

View File

@ -0,0 +1,57 @@
/*
* BEGIN_HEADER - DO NOT EDIT
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
* If applicable add the following below this CDDL HEADER,
* with the fields enclosed by brackets "[]" replaced with
* your own identifying information: Portions Copyright
* [year] [name of copyright owner]
*/
/*
* @(#)JSEJBIFrameworkMBean.java
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package net.openesb.standalone.framework;
/**
* Management interface for Java SE JBI framework.
*
* @author Sun Microsystems, Inc.
*/
public interface JSEJBIFrameworkMBean
{
/** Queries the state of the JBI Framework.
* @return true if the JBI framework is loaded, false otherwise.
*/
boolean isLoaded();
/** Load the JBI framework with the specified environment. When this method
* retuns, all public interfaces and system services have completely
* initialized. If a connector port is specified in the environment
* properties, a remote JMX connector server is created.
* @throws Exception failed to load JBI framework
*/
void load() throws Exception;
/** Unloads the JBI framework. When this method retuns, all
* public interfaces, system services, and JMX connector (if configured)
* have been destroyed.
* @throws javax.jbi.JBIException failed to unload JBI framework
*/
void unload() throws Exception;
}

View File

@ -0,0 +1,387 @@
/*
* BEGIN_HEADER - DO NOT EDIT
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
* If applicable add the following below this CDDL HEADER,
* with the fields enclosed by brackets "[]" replaced with
* your own identifying information: Portions Copyright
* [year] [name of copyright owner]
*/
/*
* @(#)JSEPlatformContext.java
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package net.openesb.standalone.framework;
import com.sun.jbi.JBIProvider;
import com.sun.jbi.platform.PlatformEventListener;
import com.sun.jbi.security.KeyStoreUtil;
import java.io.File;
import java.util.Set;
import java.util.HashSet;
import java.util.logging.Logger;
import java.util.logging.Level;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServer;
import javax.naming.InitialContext;
/**
* Implementation of PlatformContext for Java SE.
* @author Sun Microsystems Inc.
*/
public class JSEPlatformContext implements com.sun.jbi.platform.PlatformContext
{
private String mInstanceName;
private String mInstanceRoot;
private String mInstallRoot;
private InitialContext mNamingContext;
private Logger mLog = Logger.getLogger(getClass().getPackage().getName());
public JSEPlatformContext(String instanceName, String installRoot)
{
mInstanceName = instanceName;
mInstallRoot = installRoot;
mInstanceRoot = installRoot + File.separator + instanceName;
try
{
mNamingContext = new InitialContext();
}
catch (javax.naming.NamingException nmEx)
{
mLog.warning(nmEx.toString());
}
}
/**
* Get the TransactionManager for this implementation. The instance
* returned is an implementation of the standard JTS interface. If none
* is available, returns <CODE>null</CODE>.
* @return a <CODE>TransactionManager</CODE> instance.
* @throws Exception if a <CODE>TransactionManager</CODE> cannot be obtained.
*/
public javax.transaction.TransactionManager getTransactionManager()
throws Exception
{
return new com.atomikos.icatch.jta.UserTransactionManager();
}
/**
* Get the MBean server connection for a particular instance.
* @return the <CODE>MBeanServerConnection</CODE> for the specified instance.
*/
public MBeanServerConnection getMBeanServerConnection(String instanceName)
throws Exception
{
return java.lang.management.ManagementFactory.getPlatformMBeanServer();
}
/**
* Get the instance name of the platform's administration server. If the
* platform does not provide a separate administration server, then this
* method returns the name of the local instance.
* @return instance name of the administration server
*/
public String getAdminServerName()
{
return mInstanceName;
}
/**
* Determine whether this instance is the administration server instance.
* @return <CODE>true</CODE> if this instance is the administration server,
* <CODE>false</CODE> if not.
*/
public boolean isAdminServer()
{
return true;
}
/**
* Get the name of this instance.
* @return the name of this server instance.
*/
public String getInstanceName()
{
return mInstanceName;
}
/**
* Determine if the specified instance is up.
* @return true if the instance is up and running, false otherwise
*/
public boolean isInstanceUp(String instanceName)
{
return mInstanceName.equals(instanceName);
}
/**
* Determine whether multiple servers are permitted within this AS
* installation.
* @return true if multiple servers are permitted.
*/
public boolean supportsMultipleServers()
{
return false;
}
/**
* Get the Target Name. If the instance is not a clustered instance then
* the target name is the instance name. If the instance is part of a
* cluster then the target name is the cluster name.
*
* @return the target name.
*/
public String getTargetName()
{
return mInstanceName;
}
/**
* Get the Target Name for a specified instance. If the instance is not
* clustered the instance name is returned. This operation is invoked by
* the JBI instance MBeans only.
*
* @return the target name.
*/
public String getTargetName(String instanceName)
{
return instanceName;
}
/**
* Get a set of the names of all the standalone servers in the domain.
* @return a set of names of standalone servers in the domain.
*/
public Set<String> getStandaloneServerNames()
{
HashSet<String> names = new HashSet<String>();
names.add(mInstanceName);
return names;
}
/**
* Get a set of the names of all the clustered servers in the domain.
* @return a set of names of clustered servers in the domain.
*/
public Set<String> getClusteredServerNames()
{
return new HashSet<String>();
}
/**
* Get a set of the names of all the clusters in the domain.
* @return a set of names of clusters in the domain.
*/
public Set<String> getClusterNames()
{
return new HashSet<String>();
}
/**
* Get a set of the names of all the servers in the specified cluster.
* @return a set of names of servers in the cluster.
*/
public Set<String> getServersInCluster(String clusterName)
{
return new HashSet<String>();
}
/**
* Determine whether a target is a valid server or cluster name.
* @return <CODE>true</CODE> if <CODE>targetName</CODE> is a valid
* standalone server name or cluster name, <CODE>false</CODE> if not.
*/
public boolean isValidTarget(String targetName)
{
return mInstanceName.equals(targetName);
}
/**
* Determine whether a target is a cluster.
* @return <CODE>true</CODE> if <CODE>targetName</CODE> is a cluster,
* <CODE>false</CODE> if not.
*/
public boolean isCluster(String targetName)
{
return false;
}
/**
* Determine whether a target is a standalone server.
* @return <CODE>true</CODE> if <CODE>targetName</CODE> is a standalone
* server, <CODE>false</CODE> if not.
*/
public boolean isStandaloneServer(String targetName)
{
return mInstanceName.equals(targetName);
}
/**
* Determine whether the target is a clustered server.
* @return <CODE>true</CODE> if <CODE>targetName</CODE> is a clustered
* server, <CODE>false</CODE> if not.
*/
public boolean isClusteredServer(String targetName)
{
return false;
}
/**
* Determine whether or not an instance is clustered.
* @return <CODE>true</CODE> if the instance is clustered,
* <CODE>false</CODE> if not.
*/
public boolean isInstanceClustered(String instanceName)
{
return false;
}
/**
* Get a string representation of the DAS JMX RMI connector port.
* @return the JMX RMI connector port as a <CODE>String</CODE>.
*/
public String getJmxRmiPort()
{
return null;
}
/**
* Provides access to the platform's MBean server.
* @return platform MBean server.
*/
public MBeanServer getMBeanServer()
{
return java.lang.management.ManagementFactory.getPlatformMBeanServer();
}
/**
* Get the full path to the platform's instance root directory.
* @return platform instance root
*/
public String getInstanceRoot()
{
return mInstanceRoot;
}
/**
* Get the full path to the platform's instaall root directory.
* @return platform install root
*/
public String getInstallRoot()
{
return mInstallRoot;
}
/**
* Returns the provider type for this platform.
* @return enum value corresponding to this platform implementation.
*/
public JBIProvider getProvider()
{
return JBIProvider.JSE;
}
/**
* Returns the KeyStoreUtil for Java SE. Currently unsupported
*
* @return a KeyStoreUtil
* @exception UnsupportedOperationException
*/
public KeyStoreUtil getKeyStoreUtil() {
return null;
}
/**
* Retrieves the naming context that should be used to locate platform
* resources (e.g. TransactionManager).
* @return naming context
*/
public InitialContext getNamingContext()
{
return mNamingContext;
}
/**
* Get the JBI system class loader for this implementation.
* This is the JBI common classloader and is the parent of the JBI runtime
* classloader that loaded this class.
*
* @return the <CODE>ClassLoader</CODE> that is the "system" class loader
* from a JBI runtime perspective.
* @throws SecurityException if access to the class loader is denied.
*/
public ClassLoader getSystemClassLoader()
throws SecurityException
{
return this.getClass().getClassLoader().getParent();
}
/**
* Register a listener for platform events.
* @param listener listener implementation
*/
public void addListener(PlatformEventListener listener)
{
// NOP
}
/**
* Remove a listener for platform events.
* @param listener listener implementation
*/
public void removeListener(PlatformEventListener listener)
{
// NOP
}
/**
* Get the "com.sun.jbi" log level for a target.
*
* @param target - target name
* @return the default platform log level
*/
public java.util.logging.Level getJbiLogLevel(String target)
{
Level jbiLoggerLevel =
Logger.getLogger(JBI_LOGGER_NAME).getLevel();
if ( jbiLoggerLevel == null )
{
// -- If the level is not set return INFO
jbiLoggerLevel = Level.INFO;
}
return jbiLoggerLevel;
}
/**
* Set the "com.sun.jbi" log level for a target.
*
* @param target = target name
* @param level the default platform log level
*/
public void setJbiLogLevel(String target, java.util.logging.Level level)
{
Logger.getLogger(JBI_LOGGER_NAME).setLevel(level);
}
}

View File

@ -0,0 +1,206 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.open-esb</groupId>
<artifactId>openesb-standalone</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>openesb-standalone-packaging</artifactId>
<packaging>pom</packaging>
<name>OpenESB - Standalone - Packaging</name>
<description>OpenESB runtime in standalone mode - Packaging</description>
<build>
<finalName>openesb-standalone-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<stripVersion>true</stripVersion>
<artifactItems>
<artifactItem>
<groupId>open-esb</groupId>
<artifactId>core-top</artifactId>
<version>${openesb.version}</version>
<classifier>distribution</classifier>
<type>zip</type>
<outputDirectory>${stagingDir}</outputDirectory>
<destFileName>openesb-core-distribution.zip</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>${project.artifactId}-fetch-openesb-standalone</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<stripVersion>true</stripVersion>
<artifactItems>
<artifactItem>
<groupId>net.open-esb</groupId>
<artifactId>openesb-standalone-framework</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${stagingDir}</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>net.open-esb</groupId>
<artifactId>openesb-standalone-bootstrap</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${stagingDir}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>${project.artifactId}-fetch-openesb-standalone-ext</id>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.atomikos</groupId>
<artifactId>transactions-jta</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${stagingDir}/ext</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>${project.artifactId}-unzip-openesb-core</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<unzip src="${stagingDir}/openesb-core-distribution.zip" dest="${project.build.outputDirectory}"/>
</target>
</configuration>
</execution>
<execution>
<id>${project.artifactId}-copy-standalone-libraries</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy todir="${project.build.outputDirectory}/lib">
<fileset dir="${stagingDir}">
<include name="*.jar"/>
</fileset>
</copy>
</target>
</configuration>
</execution>
<execution>
<id>${project.artifactId}-copy-standalone-ext-libraries</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy todir="${project.build.outputDirectory}/lib/ext">
<fileset dir="${stagingDir}/ext">
<include name="*.jar"/>
</fileset>
</copy>
</target>
</configuration>
</execution>
<execution>
<id>${project.artifactId}-copy-standalone-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy todir="${project.build.outputDirectory}">
<fileset dir="${basedir}/src/main/resources">
<include name="**/*"/>
</fileset>
</copy>
</target>
</configuration>
</execution>
<execution>
<id>${project.artifactId}-zip</id>
<phase>verify</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<mkdir dir="${project.build.directory}/logs"/>
<delete file="${project.build.directory}/${project.build.finalName}.zip" />
<zip destfile="${project.build.directory}/${project.build.finalName}.zip"
basedir="${project.build.outputDirectory}"
/>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Framework and dependencies -->
<dependency>
<groupId>net.open-esb</groupId>
<artifactId>openesb-standalone-bootstrap</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.open-esb</groupId>
<artifactId>openesb-standalone-framework</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.atomikos</groupId>
<artifactId>transactions-jta</artifactId>
<version>${atomikos.version}</version>
</dependency>
</dependencies>
<properties>
<stagingDir>${project.build.directory}/staging</stagingDir>
</properties>
</project>

View File

@ -0,0 +1,57 @@
# Properties file which configures the operation of the JDK
# logging facility.
# The system will look for this config file, first using
# a System property specified at startup:
#
# >java -Djava.util.logging.config.file=myLoggingConfigFilePath
#
# If this property is not specified, then the config file is
# retrieved from its default location at:
#
# JDK_HOME/jre/lib/logging.properties
# Global logging properties.
# ------------------------------------------
# The set of handlers to be loaded upon startup.
# Comma-separated list of class names.
# (? LogManager docs say no comma here, but JDK example has comma.)
handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
# Default global logging level.
# Loggers and Handlers may override this level
.level=SEVERE
# Handlers
# -----------------------------------------
# --- ConsoleHandler ---
# Override of global logging level
java.util.logging.ConsoleHandler.level=FINE
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
# --- FileHandler ---
# Override of global logging level
java.util.logging.FileHandler.level=FINE
# Naming style for the output file:
java.util.logging.FileHandler.pattern=logs/openesb%u.log
# Limiting size of output file in bytes:
java.util.logging.FileHandler.limit=50000
# Number of output files to cycle through, by appending an
# integer to the base file name:
java.util.logging.FileHandler.count=1
# Style of output (Simple or XML):
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
# Loggers
# ------------------------------------------
# Loggers are usually attached to packages.
# Here, the level for each package is specified.
# The global level is used by default, so levels
# specified here simply act as an override.
com.sun.jbi.level=FINE
com.sun.jbi.framework.level=FINE

61
pom.xml Normal file
View File

@ -0,0 +1,61 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.open-esb</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>net.open-esb</groupId>
<artifactId>openesb-standalone</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>OpenESB - Standalone</name>
<description>OpenESB runtime in standalone mode</description>
<modules>
<module>openesb-standalone-framework</module>
<module>openesb-standalone-bootstrap</module>
<module>openesb-standalone-packaging</module>
</modules>
<properties>
<openesb.version>2.4.0-SNAPSHOT</openesb.version>
<atomikos.version>3.8.0</atomikos.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencyManagement>
<dependencies>
<!-- OpenESB Core -->
<dependency>
<groupId>open-esb</groupId>
<artifactId>framework-core</artifactId>
<version>${openesb.version}</version>
<exclusions>
<exclusion>
<groupId>jbiplatform</groupId>
<artifactId>jbi_compileconf</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
</project>