diff --git a/openesb-standalone-bootstrap/pom.xml b/openesb-standalone-bootstrap/pom.xml
index 488c080..ee40f97 100644
--- a/openesb-standalone-bootstrap/pom.xml
+++ b/openesb-standalone-bootstrap/pom.xml
@@ -23,7 +23,7 @@
net.openesb.standalone.startup.Bootstrap
- jbi.jar jbi-ext.jar jta-1_1-classes.zip
+ jbi.jar jbi-ext.jar
diff --git a/openesb-standalone-bootstrap/src/main/java/net/openesb/standalone/startup/Bootstrap.java b/openesb-standalone-bootstrap/src/main/java/net/openesb/standalone/startup/Bootstrap.java
index 1c8f643..3fa90b1 100644
--- a/openesb-standalone-bootstrap/src/main/java/net/openesb/standalone/startup/Bootstrap.java
+++ b/openesb-standalone-bootstrap/src/main/java/net/openesb/standalone/startup/Bootstrap.java
@@ -105,7 +105,7 @@ public class Bootstrap {
// quick sanity check on the install root
if (!openesbHomeDir.isDirectory()
|| !new File(openesbHomeDir, "lib/jbi_rt.jar").exists()) {
- throw new RuntimeException("Invalid JBI install root: "
+ throw new RuntimeException("Invalid OpenESB Home: "
+ openesbHomeDir.getAbsolutePath());
}
@@ -159,9 +159,9 @@ public class Bootstrap {
}
if (errMsg != null) {
- mLog.log(Level.SEVERE, "Failed to unload JBI framework: {0}", errMsg);
+ mLog.log(Level.SEVERE, "Failed to stop OpenESB Standalone Container: {0}", errMsg);
} else {
- mLog.log(Level.INFO, "JBI framework has been unloaded.");
+ mLog.log(Level.INFO, "OpenESB Standalone Container has has been stopped.");
}
}
diff --git a/openesb-standalone-container/pom.xml b/openesb-standalone-container/pom.xml
index ecb0c21..f04e09d 100644
--- a/openesb-standalone-container/pom.xml
+++ b/openesb-standalone-container/pom.xml
@@ -18,7 +18,7 @@
org.codehaus.mojo
jaxb2-maven-plugin
- 1.5
+ 1.6
xjc
@@ -49,6 +49,13 @@
+
+
+ net.open-esb
+ openesb-rest-api
+ ${openesb-rest-api.version}
+
+
com.atomikos
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/LocalStringKeys.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/LocalStringKeys.java
index d2096b2..176f075 100644
--- a/openesb-standalone-container/src/main/java/net/openesb/standalone/LocalStringKeys.java
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/LocalStringKeys.java
@@ -14,6 +14,18 @@ public interface LocalStringKeys {
*/
static final String CONTAINER_SHUTDOWN_ERROR =
"CONTAINER_SHUTDOWN_ERROR";
+ static final String CONTAINER_INIT_INSTANCE =
+ "CONTAINER_INIT_INSTANCE";
+ static final String CONTAINER_INIT_INSTANCE_DONE =
+ "CONTAINER_INIT_INSTANCE_DONE";
+ static final String CONTAINER_START_INSTANCE =
+ "CONTAINER_START_INSTANCE";
+ static final String CONTAINER_START_INSTANCE_DONE =
+ "CONTAINER_START_INSTANCE_DONE";
+ static final String CONTAINER_STOP_INSTANCE =
+ "CONTAINER_STOP_INSTANCE";
+ static final String CONTAINER_STOP_INSTANCE_DONE =
+ "CONTAINER_STOP_INSTANCE_DONE";
/**
* Connector server Messages.
*/
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/core/CoreModule.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/core/CoreModule.java
index 5feddb8..a61f96c 100644
--- a/openesb-standalone-container/src/main/java/net/openesb/standalone/core/CoreModule.java
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/core/CoreModule.java
@@ -19,9 +19,9 @@ public class CoreModule extends AbstractModule {
@Override
protected void configure() {
- bind(Settings.class).toProvider(YamlSettingsProvider.class).asEagerSingleton();
+ bind(Settings.class).toProvider(YamlSettingsProvider.class).in(Scopes.SINGLETON);
bind(TransactionManager.class).toProvider(TransactionManagerProvider.class).in(Scopes.SINGLETON);
- bind(SecurityProvider.class).to(SecurityProviderImpl.class).asEagerSingleton();
+ bind(SecurityProvider.class).to(SecurityProviderImpl.class).in(Scopes.SINGLETON);
bind(javax.management.remote.JMXAuthenticator.class).to(JMXAuthenticator.class).in(Scopes.SINGLETON);
}
}
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/framework/FrameworkModule.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/framework/FrameworkModule.java
index 9a638f1..416ebf5 100644
--- a/openesb-standalone-container/src/main/java/net/openesb/standalone/framework/FrameworkModule.java
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/framework/FrameworkModule.java
@@ -1,6 +1,7 @@
package net.openesb.standalone.framework;
import com.google.inject.AbstractModule;
+import com.google.inject.Scopes;
/**
*
@@ -13,6 +14,6 @@ public class FrameworkModule extends AbstractModule {
protected void configure() {
bind(com.sun.jbi.platform.PlatformContext.class)
.to(net.openesb.standalone.framework.PlatformContext.class)
- .asEagerSingleton();
+ .in(Scopes.SINGLETON);
}
}
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/framework/FrameworkService.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/framework/FrameworkService.java
index fc3217a..0af243d 100644
--- a/openesb-standalone-container/src/main/java/net/openesb/standalone/framework/FrameworkService.java
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/framework/FrameworkService.java
@@ -53,11 +53,14 @@ public class FrameworkService
platformContext.getInstallRoot());
// --------------------------------------------
- // TODO: removing this part asap
+ // TODO: removing this part asap and move into the HTTP server
+ // Please have a look to the Rest API module
System.setProperty("http.port",
settings.get("http.port", "4848"));
System.setProperty("http.enabled",
settings.get("http.enabled", "true"));
+ System.setProperty("http.binding",
+ settings.get("http.binding", "localhost"));
// --------------------------------------------
try {
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/framework/PlatformContext.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/framework/PlatformContext.java
index d041009..668bd8e 100644
--- a/openesb-standalone-container/src/main/java/net/openesb/standalone/framework/PlatformContext.java
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/framework/PlatformContext.java
@@ -18,7 +18,7 @@ import javax.transaction.TransactionManager;
import net.openesb.security.SecurityProvider;
import net.openesb.standalone.Constants;
import net.openesb.standalone.jmx.JMXService;
-import net.openesb.standalone.settings.Settings;
+import net.openesb.standalone.node.Node;
/**
* Implementation of PlatformContext for OpenESB Standalone.
@@ -28,22 +28,14 @@ import net.openesb.standalone.settings.Settings;
*/
public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
- private static final String INSTANCE_NAME = "instance.name";
-
- private final String mInstanceName;
-
@Inject private JMXService jmxConnector;
@Inject private SecurityProvider securityProvider;
@Inject private TransactionManager transactionManager;
@Inject private InitialContext namingContext;
+ @Inject private Node node;
+
private String mInstallRoot = System.getProperty(
Constants.OPENESB_HOME_PROP);
-
- @Inject
- public PlatformContext(Settings settings) {
- mInstanceName = settings.get(INSTANCE_NAME,
- Constants.DEFAULT_INSTANCE_NAME);
- }
/**
* Get the TransactionManager for this implementation. The instance returned
@@ -82,7 +74,7 @@ public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
*/
@Override
public String getAdminServerName() {
- return mInstanceName;
+ return node.name();
}
/**
@@ -103,7 +95,7 @@ public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
*/
@Override
public String getInstanceName() {
- return mInstanceName;
+ return node.name();
}
/**
@@ -113,7 +105,7 @@ public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
*/
@Override
public boolean isInstanceUp(String instanceName) {
- return mInstanceName.equals(instanceName);
+ return node.name().equals(instanceName);
}
/**
@@ -136,7 +128,7 @@ public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
*/
@Override
public String getTargetName() {
- return mInstanceName;
+ return node.name();
}
/**
@@ -159,7 +151,7 @@ public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
@Override
public Set getStandaloneServerNames() {
HashSet names = new HashSet();
- names.add(mInstanceName);
+ names.add(node.name());
return names;
}
@@ -201,7 +193,7 @@ public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
*/
@Override
public boolean isValidTarget(String targetName) {
- return mInstanceName.equals(targetName);
+ return node.name().equals(targetName);
}
/**
@@ -223,7 +215,7 @@ public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
*/
@Override
public boolean isStandaloneServer(String targetName) {
- return mInstanceName.equals(targetName);
+ return node.name().equals(targetName);
}
/**
@@ -275,7 +267,7 @@ public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
*/
@Override
public String getInstanceRoot() {
- return mInstallRoot + File.separator + mInstanceName;
+ return mInstallRoot + File.separator + node.name();
}
/**
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/http/HttpModule.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/http/HttpModule.java
new file mode 100644
index 0000000..d76eac3
--- /dev/null
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/http/HttpModule.java
@@ -0,0 +1,16 @@
+package net.openesb.standalone.http;
+
+import com.google.inject.AbstractModule;
+
+/**
+ *
+ * @author David BRASSELY (brasseld at gmail.com)
+ * @author OpenESB Community
+ */
+public class HttpModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+
+ }
+}
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/http/HttpService.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/http/HttpService.java
new file mode 100644
index 0000000..07f2647
--- /dev/null
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/http/HttpService.java
@@ -0,0 +1,99 @@
+package net.openesb.standalone.http;
+
+import com.sun.jbi.EnvironmentContext;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.inject.Inject;
+import net.openesb.rest.api.OpenESBApplication;
+import net.openesb.rest.extension.RestServiceLifecycle;
+import net.openesb.standalone.Lifecycle;
+import net.openesb.standalone.LifecycleException;
+import net.openesb.standalone.http.handlers.ConsoleHandler;
+import net.openesb.standalone.settings.Settings;
+import org.glassfish.grizzly.http.server.HttpHandler;
+import org.glassfish.grizzly.http.server.HttpServer;
+import org.glassfish.grizzly.http.server.NetworkListener;
+import org.glassfish.grizzly.http.server.ServerConfiguration;
+import org.glassfish.grizzly.threadpool.ThreadPoolConfig;
+import org.glassfish.jersey.server.ContainerFactory;
+
+/**
+ *
+ * @author David BRASSELY (brasseld at gmail.com)
+ * @author OpenESB Community
+ */
+public class HttpService implements Lifecycle {
+
+ private static final Logger LOG =
+ Logger.getLogger(HttpService.class.getPackage().getName());
+ private static final String HTTP_LISTENER_NAME = "openesb-http-server";
+ private static final String HTTP_PORT_PROPERTY = "http.port";
+ private static final String HTTP_ENABLED_PROPERTY = "http.enabled";
+ private static final String HTTP_BINDING_PROPERTY = "http.binding";
+ private static final int DEFAULT_HTTP_PORT = 4848;
+ private static final boolean DEFAULT_HTTP_ENABLED = true;
+ private static final String DEFAULT_HTTP_BINDING = "localhost";
+ private HttpServer httpServer = null;
+ @Inject
+ private Settings settings;
+
+ public void setEnvironmentContext(EnvironmentContext environmentContext) {
+ RestServiceLifecycle.environmentContext = environmentContext;
+ }
+
+ @Override
+ public void start() throws LifecycleException {
+ boolean enabled = settings.getAsBoolean(HTTP_ENABLED_PROPERTY, DEFAULT_HTTP_ENABLED);
+ if (enabled) {
+ httpServer = createHttpServer();
+
+ // Map the path to the processor.
+ final ServerConfiguration config = httpServer.getServerConfiguration();
+
+ ConsoleHandler consoleHandler = new ConsoleHandler();
+ config.addHttpHandler(consoleHandler.getHandler(), consoleHandler.path());
+
+ HttpHandler handler = ContainerFactory.createContainer(HttpHandler.class, new OpenESBApplication());
+ config.addHttpHandler(handler, "/api");
+
+ try {
+ httpServer.start();
+ } catch (IOException ex) {
+ LOG.log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+
+ @Override
+ public void stop() throws LifecycleException {
+ if (httpServer != null) {
+ httpServer.shutdownNow();
+ }
+ }
+
+ private HttpServer createHttpServer() {
+ int port = settings.getAsInt(HTTP_PORT_PROPERTY, DEFAULT_HTTP_PORT);
+ String binding = settings.get(HTTP_BINDING_PROPERTY, DEFAULT_HTTP_BINDING);
+
+ final HttpServer server = new HttpServer();
+ final NetworkListener listener = new NetworkListener(HTTP_LISTENER_NAME,
+ binding, port);
+
+ ThreadPoolConfig threadPoolConfig = ThreadPoolConfig
+ .defaultConfig()
+ .setCorePoolSize(5)
+ .setMaxPoolSize(5);
+
+ listener.getTransport().setWorkerThreadPoolConfig(threadPoolConfig);
+ /*
+ listener.setSecure(secure);
+ if (sslEngineConfigurator != null) {
+ listener.setSSLEngineConfig(sslEngineConfigurator);
+ }
+ */
+
+ server.addListener(listener);
+ return server;
+ }
+}
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/http/handlers/ConsoleHandler.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/http/handlers/ConsoleHandler.java
new file mode 100644
index 0000000..dc3c510
--- /dev/null
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/http/handlers/ConsoleHandler.java
@@ -0,0 +1,39 @@
+package net.openesb.standalone.http.handlers;
+
+import org.glassfish.grizzly.http.server.CLStaticHttpHandler;
+import org.glassfish.grizzly.http.server.HttpHandler;
+
+/**
+ *
+ * @author David BRASSELY (brasseld at gmail.com)
+ * @author OpenESB Community
+ */
+public class ConsoleHandler implements Handler {
+
+ private final static String DUMMY_CLASS = "net.openesb.console.DummyClass";
+
+ @Override
+ public HttpHandler getHandler() {
+ try {
+ Class> clazz = Class.forName(
+ DUMMY_CLASS, false,
+ ConsoleHandler.class.getClassLoader());
+
+ return new CLStaticHttpHandler(
+ clazz.getClassLoader(), "/public_html/");
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ /*
+ sLog.log(Level.WARNING,
+ "Unable to attache HTTP handler for the Web Console", ex);
+ */
+ }
+
+ return null;
+ }
+
+ @Override
+ public String path() {
+ return "/webui";
+ }
+}
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/http/handlers/Handler.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/http/handlers/Handler.java
new file mode 100644
index 0000000..363c167
--- /dev/null
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/http/handlers/Handler.java
@@ -0,0 +1,13 @@
+package net.openesb.standalone.http.handlers;
+
+/**
+ *
+ * @author David BRASSELY (brasseld at gmail.com)
+ * @author OpenESB Community
+ */
+public interface Handler {
+
+ T getHandler();
+
+ String path();
+}
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/naming/jndi/DataSourcePoolFactory.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/naming/jndi/DataSourcePoolFactory.java
index e45851d..441d4c0 100644
--- a/openesb-standalone-container/src/main/java/net/openesb/standalone/naming/jndi/DataSourcePoolFactory.java
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/naming/jndi/DataSourcePoolFactory.java
@@ -2,7 +2,7 @@ package net.openesb.standalone.naming.jndi;
import javax.sql.DataSource;
import javax.sql.XADataSource;
-import net.openesb.standalone.naming.jaxb.DataSourcePoolPropertiesComplexType;
+import net.openesb.standalone.naming.jaxb.DataSourcePoolProperties;
/**
*
@@ -11,7 +11,7 @@ import net.openesb.standalone.naming.jaxb.DataSourcePoolPropertiesComplexType;
*/
public interface DataSourcePoolFactory {
- public DataSource getDataSource (DataSourcePoolPropertiesComplexType dSPProperties) ;
- public XADataSource getXADataSource (DataSourcePoolPropertiesComplexType dSPProperties) ;
+ public DataSource getDataSource (DataSourcePoolProperties dSPProperties) ;
+ public XADataSource getXADataSource (DataSourcePoolProperties dSPProperties) ;
}
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/naming/jndi/impl/InitialContexFactoryImpl.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/naming/jndi/impl/InitialContexFactoryImpl.java
index c1447bb..3f0094b 100644
--- a/openesb-standalone-container/src/main/java/net/openesb/standalone/naming/jndi/impl/InitialContexFactoryImpl.java
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/naming/jndi/impl/InitialContexFactoryImpl.java
@@ -8,7 +8,6 @@ import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.inject.Inject;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -21,9 +20,8 @@ import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import net.openesb.standalone.LocalStringKeys;
-import net.openesb.standalone.naming.jaxb.DataSourcePoolPropertiesComplexType;
-import net.openesb.standalone.naming.jaxb.JdbcResourceComplexType;
-import net.openesb.standalone.naming.jaxb.OeContextComplexType;
+import net.openesb.standalone.naming.jaxb.DataSourcePoolProperties;
+import net.openesb.standalone.naming.jaxb.JDBCResource;
import net.openesb.standalone.naming.jndi.DataSourcePoolFactory;
import net.openesb.standalone.naming.jndi.tomcat.TomcatDataSourcePoolFactory;
import net.openesb.standalone.utils.I18NBundle;
@@ -38,9 +36,9 @@ public class InitialContexFactoryImpl implements InitialContextFactory {
private static final Logger LOG = Logger.getLogger(InitialContexFactoryImpl.class.getName());
public static final String DATASOURCE_TYPE = "Datasource";
public static final String XADATASOURCE_TYPE = "XADatasource";
- private final Map mDSPMap = new HashMap();
+ private final Map mDSPMap = new HashMap();
- @Inject
+// @Inject
private DataSourcePoolFactory mDSPFactory = new TomcatDataSourcePoolFactory();
@@ -72,11 +70,11 @@ public class InitialContexFactoryImpl implements InitialContextFactory {
/* Read the context from the URL */
@SuppressWarnings("UnusedAssignment")
- JAXBElement root = null;
+ JAXBElement root = null;
try {
JAXBContext jc = JAXBContext.newInstance("net.openesb.standalone.naming.jaxb");
Unmarshaller unmarshaller = jc.createUnmarshaller();
- root = (JAXBElement) unmarshaller.unmarshal(new URL(urlValue));
+ root = (JAXBElement) unmarshaller.unmarshal(new URL(urlValue));
} catch (MalformedURLException ex) {
LOG.log(Level.SEVERE, I18NBundle.getBundle().getMessage(
LocalStringKeys.NAMING_CONTEXT_CONTEXT_URL_INVALID, urlValue));
@@ -95,33 +93,33 @@ public class InitialContexFactoryImpl implements InitialContextFactory {
}
// This must be made with the xml file has an element root
- OeContextComplexType oeContext = root.getValue();
+ net.openesb.standalone.naming.jaxb.Context oeContext = root.getValue();
/* OeContext contains the complete context */
/* I create a map with the datasourcePool Name as key and datasourcePool as Value
* This will be useful to instanciate the db connector later.
*/
- List dataSourcePoolList = oeContext.getDataSourcePoolProperties();
+ List dataSourcePoolList = oeContext.getDataSourcePoolProperties();
int listSize = dataSourcePoolList.size();
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage("number.dataSourcePoolProperties.found",
listSize));
//Loop on dataSourcePoolList iterator
- for (DataSourcePoolPropertiesComplexType dspComplexType : dataSourcePoolList) {
+ for (DataSourcePoolProperties dspComplexType : dataSourcePoolList) {
mDSPMap.put(dspComplexType.getDbConnectorName(), dspComplexType);
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage("datasourcepoolproperties.found.in.context",
dspComplexType.getDbConnectorName()));
}
// Now Let's read JdbcResource
- List jdbcResourceList = oeContext.getJdbcResources();
+ List jdbcResourceList = oeContext.getJdbcResources();
listSize = jdbcResourceList.size();
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage("number.jdbcResource.declaration.found",
listSize));
//Loop on JDBCResourceList iterator
- for (JdbcResourceComplexType jdbcResource : jdbcResourceList) {
+ for (JDBCResource jdbcResource : jdbcResourceList) {
/* For each jcbc resource I want to associate a dbConnector.
* DBConnector provide a connectionPool or a XAConnectionPool
* I instanciate the dbConnetor in a lazy mode (when needed)
@@ -164,7 +162,7 @@ public class InitialContexFactoryImpl implements InitialContextFactory {
}
// Retrieve DataSourcePoolPropertie
- DataSourcePoolPropertiesComplexType dspProperties = mDSPMap.get(dbConnectorName);
+ DataSourcePoolProperties dspProperties = mDSPMap.get(dbConnectorName);
// Check if Datasourse or XA Datasource
if (dspProperties.getResourceType().equals(InitialContexFactoryImpl.DATASOURCE_TYPE)) {
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage("datasource.in.process", jndiName));
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/naming/jndi/tomcat/TomcatDataSourcePoolFactory.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/naming/jndi/tomcat/TomcatDataSourcePoolFactory.java
index 37c0932..1089354 100644
--- a/openesb-standalone-container/src/main/java/net/openesb/standalone/naming/jndi/tomcat/TomcatDataSourcePoolFactory.java
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/naming/jndi/tomcat/TomcatDataSourcePoolFactory.java
@@ -15,13 +15,12 @@ import javax.management.ObjectName;
import javax.sql.DataSource;
import javax.sql.XADataSource;
import javax.xml.bind.JAXBElement;
-import net.openesb.standalone.naming.jaxb.DataSourcePoolPropertiesComplexType;
-import net.openesb.standalone.naming.jaxb.DataSourcePropertiesComplexType;
-import net.openesb.standalone.naming.jaxb.PoolPropertiesComplexType;
-import net.openesb.standalone.naming.jaxb.PropertyComplexType;
+import net.openesb.standalone.naming.jaxb.DataSourcePoolProperties;
+import net.openesb.standalone.naming.jaxb.DataSourceProperties;
+import net.openesb.standalone.naming.jaxb.PoolProperties;
+import net.openesb.standalone.naming.jaxb.Property;
import net.openesb.standalone.naming.jndi.DataSourcePoolFactory;
import net.openesb.standalone.utils.I18NBundle;
-import org.apache.tomcat.jdbc.pool.PoolProperties;
/**
*
@@ -42,8 +41,8 @@ public class TomcatDataSourcePoolFactory implements DataSourcePoolFactory {
* Then we create an Apache datasource with the pool as parameter
*/
@Override
- public DataSource getDataSource(DataSourcePoolPropertiesComplexType dspProperties) {
- PoolProperties poolProperties = this.createNativeDataSource(dspProperties);
+ public DataSource getDataSource(DataSourcePoolProperties dspProperties) {
+ org.apache.tomcat.jdbc.pool.PoolProperties poolProperties = this.createNativeDataSource(dspProperties);
org.apache.tomcat.jdbc.pool.DataSource ds = new org.apache.tomcat.jdbc.pool.DataSource(poolProperties);
ds.setName(dspProperties.getDbConnectorName());
registerMBean(ds);
@@ -52,8 +51,8 @@ public class TomcatDataSourcePoolFactory implements DataSourcePoolFactory {
}
@Override
- public XADataSource getXADataSource(DataSourcePoolPropertiesComplexType dspProperties) {
- PoolProperties poolProperties = this.createNativeDataSource(dspProperties);
+ public XADataSource getXADataSource(DataSourcePoolProperties dspProperties) {
+ org.apache.tomcat.jdbc.pool.PoolProperties poolProperties = this.createNativeDataSource(dspProperties);
org.apache.tomcat.jdbc.pool.XADataSource ds = new org.apache.tomcat.jdbc.pool.XADataSource(poolProperties);
ds.setName(dspProperties.getDbConnectorName());
registerMBean(ds);
@@ -75,9 +74,9 @@ public class TomcatDataSourcePoolFactory implements DataSourcePoolFactory {
}
}
- private PoolProperties createNativeDataSource(DataSourcePoolPropertiesComplexType dspProperties) {
+ private org.apache.tomcat.jdbc.pool.PoolProperties createNativeDataSource(DataSourcePoolProperties dspProperties) {
/* get the properties for the native Datasource. it is not created yet*/
- DataSourcePropertiesComplexType dataSourceProperties = dspProperties.getDataSourceProperties();
+ DataSourceProperties dataSourceProperties = dspProperties.getDataSourceProperties();
Map datasourceMap = this.listToMap(dataSourceProperties.getProperty());
/* Get datasource name from OE Context. Native DS is create dynamically
@@ -186,10 +185,12 @@ public class TomcatDataSourcePoolFactory implements DataSourcePoolFactory {
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage(
"start.pool.configuration"));
- PoolPropertiesComplexType contextPoolProperties = dspProperties.getPoolProperties();
+ PoolProperties contextPoolProperties = dspProperties.getPoolProperties();
Map poolMap = this.listToMap(contextPoolProperties.getProperty());
// Create pool configuration
- org.apache.tomcat.jdbc.pool.PoolProperties poolProperties = new PoolProperties();
+ org.apache.tomcat.jdbc.pool.PoolProperties poolProperties =
+ new org.apache.tomcat.jdbc.pool.PoolProperties();
+
Class poolPropertiesClass = poolProperties.getClass();
Map poolPropertiesFields = this.getAllFields(poolPropertiesClass);
/* Use java reflexion to set up pool configurationwith context properties
@@ -254,14 +255,14 @@ public class TomcatDataSourcePoolFactory implements DataSourcePoolFactory {
return poolProperties;
}
- /* List to Map is an internal methode used to convert a List to a Map.
+ /* List to Map is an internal methode used to convert a List to a Map.
* Map will be use to set the DataSource and the Pool
*/
- private Map listToMap(List inputList) {
+ private Map listToMap(List inputList) {
Map outputMap = new HashMap();
- Iterator it = inputList.iterator();
+ Iterator it = inputList.iterator();
while (it.hasNext()) {
- PropertyComplexType prop = it.next();
+ Property prop = it.next();
List> nameAndValueAndDescription = prop.getNameAndValueAndDescription();
Iterator> it2 = nameAndValueAndDescription.iterator();
String key = null, value = null;
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/node/Node.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/node/Node.java
index 7b98085..c8854a3 100644
--- a/openesb-standalone-container/src/main/java/net/openesb/standalone/node/Node.java
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/node/Node.java
@@ -17,4 +17,9 @@ public interface Node {
*/
void stop();
+ /**
+ * Returns the node name.
+ * @return The node name.
+ */
+ String name();
}
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/node/internal/InstanceNode.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/node/internal/InstanceNode.java
index 79fb3d5..c307227 100644
--- a/openesb-standalone-container/src/main/java/net/openesb/standalone/node/internal/InstanceNode.java
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/node/internal/InstanceNode.java
@@ -2,17 +2,24 @@ package net.openesb.standalone.node.internal;
import com.google.inject.Injector;
import com.sun.jbi.platform.PlatformContext;
+import java.util.logging.Level;
import java.util.logging.Logger;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.StandardMBean;
+import net.openesb.standalone.Constants;
+import net.openesb.standalone.LocalStringKeys;
import net.openesb.standalone.core.CoreModule;
import net.openesb.standalone.framework.FrameworkModule;
import net.openesb.standalone.framework.FrameworkService;
+import net.openesb.standalone.http.HttpModule;
+import net.openesb.standalone.http.HttpService;
import net.openesb.standalone.inject.ModulesBuilder;
import net.openesb.standalone.jmx.JMXService;
import net.openesb.standalone.naming.NamingModule;
import net.openesb.standalone.node.Node;
+import net.openesb.standalone.settings.Settings;
+import net.openesb.standalone.utils.I18NBundle;
/**
*
@@ -24,36 +31,60 @@ public class InstanceNode implements Node {
private static final Logger LOG =
Logger.getLogger(InstanceNode.class.getPackage().getName());
+ private static final String INSTANCE_NAME = "instance.name";
+
+ private final String nodeName;
+
private final Injector injector;
private JMXService jmxService;
private FrameworkService frameworkService;
+ private HttpService httpService;
public InstanceNode () {
- LOG.info("Initializing new instance...");
+ if(LOG.isLoggable(Level.INFO)) {
+ LOG.log(Level.INFO, I18NBundle.getBundle().getMessage(
+ LocalStringKeys.CONTAINER_INIT_INSTANCE));
+ }
ModulesBuilder modules = new ModulesBuilder();
modules.add(new CoreModule());
modules.add(new FrameworkModule());
modules.add(new NamingModule());
+ modules.add(new HttpModule());
modules.add(new NodeModule(this));
injector = modules.createInjector();
- LOG.info("Instance initialized");
+ jmxService = injector.getInstance(JMXService.class);
+ frameworkService = injector.getInstance(FrameworkService.class);
+ httpService = injector.getInstance(HttpService.class);
+
+ nodeName = injector.getInstance(Settings.class).get(INSTANCE_NAME,
+ Constants.DEFAULT_INSTANCE_NAME);
+
+ if(LOG.isLoggable(Level.INFO)) {
+ LOG.log(Level.INFO, I18NBundle.getBundle().getMessage(
+ LocalStringKeys.CONTAINER_INIT_INSTANCE_DONE), nodeName);
+ }
}
@Override
public void start() {
- LOG.info("Instance is starting ...");
+ if(LOG.isLoggable(Level.INFO)) {
+ LOG.log(Level.INFO, I18NBundle.getBundle().getMessage(
+ LocalStringKeys.CONTAINER_START_INSTANCE), nodeName);
+ }
+
+ long startTime = System.currentTimeMillis(); // Get the start Time
- jmxService = injector.getInstance(JMXService.class);
jmxService.start();
-
- frameworkService = injector.getInstance(FrameworkService.class);
frameworkService.start();
+ httpService.setEnvironmentContext(frameworkService.getEnvironment());
+ httpService.start();
+
PlatformContext platformContext = injector.getInstance(PlatformContext.class);
try {
@@ -79,16 +110,34 @@ public class InstanceNode implements Node {
e.printStackTrace();
}
- LOG.info("Instance started");
+ long endTime = System.currentTimeMillis(); // Get the end Time
+
+ if(LOG.isLoggable(Level.INFO)) {
+ LOG.log(Level.INFO, I18NBundle.getBundle().getMessage(
+ LocalStringKeys.CONTAINER_START_INSTANCE_DONE),
+ new Object []{nodeName, (endTime-startTime)});
+ }
}
@Override
public void stop() {
- LOG.info("Instance is stopping ...");
+ if(LOG.isLoggable(Level.INFO)) {
+ LOG.log(Level.INFO, I18NBundle.getBundle().getMessage(
+ LocalStringKeys.CONTAINER_STOP_INSTANCE), nodeName);
+ }
+ httpService.stop();
frameworkService.stop();
jmxService.stop();
- LOG.info("Instance stopped");
+ if(LOG.isLoggable(Level.INFO)) {
+ LOG.log(Level.INFO, I18NBundle.getBundle().getMessage(
+ LocalStringKeys.CONTAINER_STOP_INSTANCE_DONE), nodeName);
+ }
+ }
+
+ @Override
+ public String name() {
+ return this.nodeName;
}
}
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/startup/Container.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/startup/Container.java
index d7a60f5..bc50626 100644
--- a/openesb-standalone-container/src/main/java/net/openesb/standalone/startup/Container.java
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/startup/Container.java
@@ -1,10 +1,10 @@
package net.openesb.standalone.startup;
-import java.lang.reflect.Method;
import java.util.logging.LogManager;
import net.openesb.standalone.Lifecycle;
import net.openesb.standalone.node.Node;
import net.openesb.standalone.node.NodeBuilder;
+import net.openesb.standalone.utils.ReflectionUtils;
/**
*
@@ -25,7 +25,6 @@ public class Container implements Lifecycle {
public void start() {
node.start();
- System.out.println("CONTAINER STARTED");
// Register shutdown hook
shutdownHook = new ContainerShutdownHook();
Runtime.getRuntime().addShutdownHook(shutdownHook);
@@ -38,40 +37,13 @@ public class Container implements Lifecycle {
public void stop() {
node.stop();
- // This is a fix when shutdown an instance by using a shutdown hook.
+ // This is a fix when we are trying to shutdown an instance by using
+ // a shutdown hook.
try {
- invoke(LogManager.getLogManager(), "reset0");
+ ReflectionUtils.invoke(
+ LogManager.getLogManager(), "reset0");
} catch (Throwable t) {
}
-
- System.out.println("CONTAINER STOPPED");
- }
-
- /**
- * 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();
- }
}
private class ContainerShutdownHook extends Thread {
diff --git a/openesb-standalone-container/src/main/java/net/openesb/standalone/utils/ReflectionUtils.java b/openesb-standalone-container/src/main/java/net/openesb/standalone/utils/ReflectionUtils.java
new file mode 100644
index 0000000..81e8d06
--- /dev/null
+++ b/openesb-standalone-container/src/main/java/net/openesb/standalone/utils/ReflectionUtils.java
@@ -0,0 +1,38 @@
+package net.openesb.standalone.utils;
+
+import java.lang.reflect.Method;
+
+/**
+ *
+ * @author David BRASSELY (brasseld at gmail.com)
+ * @author OpenESB Community
+ */
+public final class ReflectionUtils {
+
+ /**
+ * 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
+ */
+ public static 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();
+ }
+ }
+}
diff --git a/openesb-standalone-container/src/main/resources/net/openesb/standalone/Bundle.properties b/openesb-standalone-container/src/main/resources/net/openesb/standalone/Bundle.properties
index 8e02f5d..5da73bb 100644
--- a/openesb-standalone-container/src/main/resources/net/openesb/standalone/Bundle.properties
+++ b/openesb-standalone-container/src/main/resources/net/openesb/standalone/Bundle.properties
@@ -4,7 +4,13 @@
# OpenESB Standalone : Container messages (10xx)
# ============================================================================
#
-CONTAINER_SHUTDOWN_ERROR = OESE-1000: Error during framework shutdown: {0}.
+CONTAINER_SHUTDOWN_ERROR = OESE-1000: Error during framework shutdown: {0}.
+CONTAINER_INIT_INSTANCE = OESE-1001: Initializing a new instance...
+CONTAINER_INIT_INSTANCE_DONE = OESE-1002: Instance {0} initialized.
+CONTAINER_START_INSTANCE = OESE-1003: Instance {0} is now starting...
+CONTAINER_START_INSTANCE_DONE = OESE-1004: Instance {0} started in {1} ms.
+CONTAINER_STOP_INSTANCE = OESE-1005: Instance {0} is stopping...
+CONTAINER_STOP_INSTANCE_DONE = OESE-1006: Instance {0} stopped.
#
# ============================================================================
@@ -15,7 +21,7 @@ CONNECTOR_CREATE_REGISTRY_FAILURE = OESE-1100: Create RMI registry failure.
CONNECTOR_START_CONNECTOR_FAILURE = OESE-1101: Start connector failure: {0}.
CONNECTOR_START_CONNECTOR_STARTED = OESE-1102: JMX connector server started at: {0}
CONNECTOR_SERVER_INVALID_PORT = OESE-1103: Invalid JMX Connector port. Use the default one {0}.
-CONNECTOR_SERVER_CONNECTOR_STOPPED = OESE-1104: JMX connector server stopped.
+CONNECTOR_SERVER_CONNECTOR_STOPPED = OESE-1104: JMX connector stopped.
#
# ============================================================================
diff --git a/openesb-standalone-container/src/main/xjb/bindings.xjb b/openesb-standalone-container/src/main/xjb/bindings.xjb
new file mode 100644
index 0000000..2849361
--- /dev/null
+++ b/openesb-standalone-container/src/main/xjb/bindings.xjb
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/openesb-standalone-packaging/src/main/resources/config/openesb.yaml b/openesb-standalone-packaging/src/main/resources/config/openesb.yaml
index 431a731..b343e56 100644
--- a/openesb-standalone-packaging/src/main/resources/config/openesb.yaml
+++ b/openesb-standalone-packaging/src/main/resources/config/openesb.yaml
@@ -11,13 +11,14 @@
##################################### HTTP ########################################
# Set a custom port to listen for HTTP traffic:
-#
# http.port: 4848
# Disable HTTP completely:
-#
# http.enabled: false
+# HTTP Binding
+# http.binding: localhost
+
##################################### JNDI ########################################
# Specify the context file to used for JNDI
# jndi.context: ${openesb.home}/config/context.xml
diff --git a/pom.xml b/pom.xml
index 8fe220a..821408f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,6 +38,7 @@
4.11
1.7.6
3.0
+ 1.11