Include HTTP server in standalone container.
Rest API HTTP server is now based on the HTTP server from standalone and does not remain as a core extensionmaster
parent
23d49add6c
commit
e4c5fe274f
|
@ -23,7 +23,7 @@
|
||||||
<archive>
|
<archive>
|
||||||
<manifestEntries>
|
<manifestEntries>
|
||||||
<Main-Class>net.openesb.standalone.startup.Bootstrap</Main-Class>
|
<Main-Class>net.openesb.standalone.startup.Bootstrap</Main-Class>
|
||||||
<Class-Path>jbi.jar jbi-ext.jar jta-1_1-classes.zip</Class-Path>
|
<Class-Path>jbi.jar jbi-ext.jar</Class-Path>
|
||||||
</manifestEntries>
|
</manifestEntries>
|
||||||
</archive>
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class Bootstrap {
|
||||||
// quick sanity check on the install root
|
// quick sanity check on the install root
|
||||||
if (!openesbHomeDir.isDirectory()
|
if (!openesbHomeDir.isDirectory()
|
||||||
|| !new File(openesbHomeDir, "lib/jbi_rt.jar").exists()) {
|
|| !new File(openesbHomeDir, "lib/jbi_rt.jar").exists()) {
|
||||||
throw new RuntimeException("Invalid JBI install root: "
|
throw new RuntimeException("Invalid OpenESB Home: "
|
||||||
+ openesbHomeDir.getAbsolutePath());
|
+ openesbHomeDir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,9 +159,9 @@ public class Bootstrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errMsg != null) {
|
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 {
|
} else {
|
||||||
mLog.log(Level.INFO, "JBI framework has been unloaded.");
|
mLog.log(Level.INFO, "OpenESB Standalone Container has has been stopped.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>jaxb2-maven-plugin</artifactId>
|
<artifactId>jaxb2-maven-plugin</artifactId>
|
||||||
<version>1.5</version>
|
<version>1.6</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>xjc</id>
|
<id>xjc</id>
|
||||||
|
@ -49,6 +49,13 @@
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- OpenESB Rest API-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.open-esb</groupId>
|
||||||
|
<artifactId>openesb-rest-api</artifactId>
|
||||||
|
<version>${openesb-rest-api.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Transaction management -->
|
<!-- Transaction management -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.atomikos</groupId>
|
<groupId>com.atomikos</groupId>
|
||||||
|
|
|
@ -14,6 +14,18 @@ public interface LocalStringKeys {
|
||||||
*/
|
*/
|
||||||
static final String CONTAINER_SHUTDOWN_ERROR =
|
static final String CONTAINER_SHUTDOWN_ERROR =
|
||||||
"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.
|
* Connector server Messages.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,9 +19,9 @@ public class CoreModule extends AbstractModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
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(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);
|
bind(javax.management.remote.JMXAuthenticator.class).to(JMXAuthenticator.class).in(Scopes.SINGLETON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.openesb.standalone.framework;
|
package net.openesb.standalone.framework;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.google.inject.Scopes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -13,6 +14,6 @@ public class FrameworkModule extends AbstractModule {
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(com.sun.jbi.platform.PlatformContext.class)
|
bind(com.sun.jbi.platform.PlatformContext.class)
|
||||||
.to(net.openesb.standalone.framework.PlatformContext.class)
|
.to(net.openesb.standalone.framework.PlatformContext.class)
|
||||||
.asEagerSingleton();
|
.in(Scopes.SINGLETON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,11 +53,14 @@ public class FrameworkService
|
||||||
platformContext.getInstallRoot());
|
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",
|
System.setProperty("http.port",
|
||||||
settings.get("http.port", "4848"));
|
settings.get("http.port", "4848"));
|
||||||
System.setProperty("http.enabled",
|
System.setProperty("http.enabled",
|
||||||
settings.get("http.enabled", "true"));
|
settings.get("http.enabled", "true"));
|
||||||
|
System.setProperty("http.binding",
|
||||||
|
settings.get("http.binding", "localhost"));
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import javax.transaction.TransactionManager;
|
||||||
import net.openesb.security.SecurityProvider;
|
import net.openesb.security.SecurityProvider;
|
||||||
import net.openesb.standalone.Constants;
|
import net.openesb.standalone.Constants;
|
||||||
import net.openesb.standalone.jmx.JMXService;
|
import net.openesb.standalone.jmx.JMXService;
|
||||||
import net.openesb.standalone.settings.Settings;
|
import net.openesb.standalone.node.Node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of PlatformContext for OpenESB Standalone.
|
* 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 {
|
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 JMXService jmxConnector;
|
||||||
@Inject private SecurityProvider securityProvider;
|
@Inject private SecurityProvider securityProvider;
|
||||||
@Inject private TransactionManager transactionManager;
|
@Inject private TransactionManager transactionManager;
|
||||||
@Inject private InitialContext namingContext;
|
@Inject private InitialContext namingContext;
|
||||||
|
@Inject private Node node;
|
||||||
|
|
||||||
private String mInstallRoot = System.getProperty(
|
private String mInstallRoot = System.getProperty(
|
||||||
Constants.OPENESB_HOME_PROP);
|
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
|
* Get the TransactionManager for this implementation. The instance returned
|
||||||
|
@ -82,7 +74,7 @@ public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getAdminServerName() {
|
public String getAdminServerName() {
|
||||||
return mInstanceName;
|
return node.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,7 +95,7 @@ public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getInstanceName() {
|
public String getInstanceName() {
|
||||||
return mInstanceName;
|
return node.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,7 +105,7 @@ public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isInstanceUp(String instanceName) {
|
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
|
@Override
|
||||||
public String getTargetName() {
|
public String getTargetName() {
|
||||||
return mInstanceName;
|
return node.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,7 +151,7 @@ public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getStandaloneServerNames() {
|
public Set<String> getStandaloneServerNames() {
|
||||||
HashSet<String> names = new HashSet<String>();
|
HashSet<String> names = new HashSet<String>();
|
||||||
names.add(mInstanceName);
|
names.add(node.name());
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +193,7 @@ public class PlatformContext implements com.sun.jbi.platform.PlatformContext {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isValidTarget(String targetName) {
|
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
|
@Override
|
||||||
public boolean isStandaloneServer(String targetName) {
|
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
|
@Override
|
||||||
public String getInstanceRoot() {
|
public String getInstanceRoot() {
|
||||||
return mInstallRoot + File.separator + mInstanceName;
|
return mInstallRoot + File.separator + node.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<HttpHandler> {
|
||||||
|
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package net.openesb.standalone.http.handlers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author David BRASSELY (brasseld at gmail.com)
|
||||||
|
* @author OpenESB Community
|
||||||
|
*/
|
||||||
|
public interface Handler<T> {
|
||||||
|
|
||||||
|
T getHandler();
|
||||||
|
|
||||||
|
String path();
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package net.openesb.standalone.naming.jndi;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import javax.sql.XADataSource;
|
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 interface DataSourcePoolFactory {
|
||||||
|
|
||||||
public DataSource getDataSource (DataSourcePoolPropertiesComplexType dSPProperties) ;
|
public DataSource getDataSource (DataSourcePoolProperties dSPProperties) ;
|
||||||
public XADataSource getXADataSource (DataSourcePoolPropertiesComplexType dSPProperties) ;
|
public XADataSource getXADataSource (DataSourcePoolProperties dSPProperties) ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.naming.Context;
|
import javax.naming.Context;
|
||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
import javax.naming.NamingException;
|
import javax.naming.NamingException;
|
||||||
|
@ -21,9 +20,8 @@ import javax.xml.bind.JAXBElement;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import javax.xml.bind.Unmarshaller;
|
import javax.xml.bind.Unmarshaller;
|
||||||
import net.openesb.standalone.LocalStringKeys;
|
import net.openesb.standalone.LocalStringKeys;
|
||||||
import net.openesb.standalone.naming.jaxb.DataSourcePoolPropertiesComplexType;
|
import net.openesb.standalone.naming.jaxb.DataSourcePoolProperties;
|
||||||
import net.openesb.standalone.naming.jaxb.JdbcResourceComplexType;
|
import net.openesb.standalone.naming.jaxb.JDBCResource;
|
||||||
import net.openesb.standalone.naming.jaxb.OeContextComplexType;
|
|
||||||
import net.openesb.standalone.naming.jndi.DataSourcePoolFactory;
|
import net.openesb.standalone.naming.jndi.DataSourcePoolFactory;
|
||||||
import net.openesb.standalone.naming.jndi.tomcat.TomcatDataSourcePoolFactory;
|
import net.openesb.standalone.naming.jndi.tomcat.TomcatDataSourcePoolFactory;
|
||||||
import net.openesb.standalone.utils.I18NBundle;
|
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());
|
private static final Logger LOG = Logger.getLogger(InitialContexFactoryImpl.class.getName());
|
||||||
public static final String DATASOURCE_TYPE = "Datasource";
|
public static final String DATASOURCE_TYPE = "Datasource";
|
||||||
public static final String XADATASOURCE_TYPE = "XADatasource";
|
public static final String XADATASOURCE_TYPE = "XADatasource";
|
||||||
private final Map<String, DataSourcePoolPropertiesComplexType> mDSPMap = new HashMap<String, DataSourcePoolPropertiesComplexType>();
|
private final Map<String, DataSourcePoolProperties> mDSPMap = new HashMap<String, DataSourcePoolProperties>();
|
||||||
|
|
||||||
@Inject
|
// @Inject
|
||||||
private DataSourcePoolFactory mDSPFactory = new TomcatDataSourcePoolFactory();
|
private DataSourcePoolFactory mDSPFactory = new TomcatDataSourcePoolFactory();
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,11 +70,11 @@ public class InitialContexFactoryImpl implements InitialContextFactory {
|
||||||
|
|
||||||
/* Read the context from the URL */
|
/* Read the context from the URL */
|
||||||
@SuppressWarnings("UnusedAssignment")
|
@SuppressWarnings("UnusedAssignment")
|
||||||
JAXBElement<OeContextComplexType> root = null;
|
JAXBElement<net.openesb.standalone.naming.jaxb.Context> root = null;
|
||||||
try {
|
try {
|
||||||
JAXBContext jc = JAXBContext.newInstance("net.openesb.standalone.naming.jaxb");
|
JAXBContext jc = JAXBContext.newInstance("net.openesb.standalone.naming.jaxb");
|
||||||
Unmarshaller unmarshaller = jc.createUnmarshaller();
|
Unmarshaller unmarshaller = jc.createUnmarshaller();
|
||||||
root = (JAXBElement<OeContextComplexType>) unmarshaller.unmarshal(new URL(urlValue));
|
root = (JAXBElement<net.openesb.standalone.naming.jaxb.Context>) unmarshaller.unmarshal(new URL(urlValue));
|
||||||
} catch (MalformedURLException ex) {
|
} catch (MalformedURLException ex) {
|
||||||
LOG.log(Level.SEVERE, I18NBundle.getBundle().getMessage(
|
LOG.log(Level.SEVERE, I18NBundle.getBundle().getMessage(
|
||||||
LocalStringKeys.NAMING_CONTEXT_CONTEXT_URL_INVALID, urlValue));
|
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
|
// 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 */
|
/* OeContext contains the complete context */
|
||||||
/* I create a map with the datasourcePool Name as key and datasourcePool as Value
|
/* I create a map with the datasourcePool Name as key and datasourcePool as Value
|
||||||
* This will be useful to instanciate the db connector later.
|
* This will be useful to instanciate the db connector later.
|
||||||
*/
|
*/
|
||||||
List<DataSourcePoolPropertiesComplexType> dataSourcePoolList = oeContext.getDataSourcePoolProperties();
|
List<DataSourcePoolProperties> dataSourcePoolList = oeContext.getDataSourcePoolProperties();
|
||||||
int listSize = dataSourcePoolList.size();
|
int listSize = dataSourcePoolList.size();
|
||||||
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage("number.dataSourcePoolProperties.found",
|
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage("number.dataSourcePoolProperties.found",
|
||||||
listSize));
|
listSize));
|
||||||
|
|
||||||
//Loop on dataSourcePoolList iterator
|
//Loop on dataSourcePoolList iterator
|
||||||
for (DataSourcePoolPropertiesComplexType dspComplexType : dataSourcePoolList) {
|
for (DataSourcePoolProperties dspComplexType : dataSourcePoolList) {
|
||||||
mDSPMap.put(dspComplexType.getDbConnectorName(), dspComplexType);
|
mDSPMap.put(dspComplexType.getDbConnectorName(), dspComplexType);
|
||||||
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage("datasourcepoolproperties.found.in.context",
|
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage("datasourcepoolproperties.found.in.context",
|
||||||
dspComplexType.getDbConnectorName()));
|
dspComplexType.getDbConnectorName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now Let's read JdbcResource
|
// Now Let's read JdbcResource
|
||||||
List<JdbcResourceComplexType> jdbcResourceList = oeContext.getJdbcResources();
|
List<JDBCResource> jdbcResourceList = oeContext.getJdbcResources();
|
||||||
listSize = jdbcResourceList.size();
|
listSize = jdbcResourceList.size();
|
||||||
|
|
||||||
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage("number.jdbcResource.declaration.found",
|
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage("number.jdbcResource.declaration.found",
|
||||||
listSize));
|
listSize));
|
||||||
|
|
||||||
//Loop on JDBCResourceList iterator
|
//Loop on JDBCResourceList iterator
|
||||||
for (JdbcResourceComplexType jdbcResource : jdbcResourceList) {
|
for (JDBCResource jdbcResource : jdbcResourceList) {
|
||||||
/* For each jcbc resource I want to associate a dbConnector.
|
/* For each jcbc resource I want to associate a dbConnector.
|
||||||
* DBConnector provide a connectionPool or a XAConnectionPool
|
* DBConnector provide a connectionPool or a XAConnectionPool
|
||||||
* I instanciate the dbConnetor in a lazy mode (when needed)
|
* I instanciate the dbConnetor in a lazy mode (when needed)
|
||||||
|
@ -164,7 +162,7 @@ public class InitialContexFactoryImpl implements InitialContextFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve DataSourcePoolPropertie
|
// Retrieve DataSourcePoolPropertie
|
||||||
DataSourcePoolPropertiesComplexType dspProperties = mDSPMap.get(dbConnectorName);
|
DataSourcePoolProperties dspProperties = mDSPMap.get(dbConnectorName);
|
||||||
// Check if Datasourse or XA Datasource
|
// Check if Datasourse or XA Datasource
|
||||||
if (dspProperties.getResourceType().equals(InitialContexFactoryImpl.DATASOURCE_TYPE)) {
|
if (dspProperties.getResourceType().equals(InitialContexFactoryImpl.DATASOURCE_TYPE)) {
|
||||||
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage("datasource.in.process", jndiName));
|
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage("datasource.in.process", jndiName));
|
||||||
|
|
|
@ -15,13 +15,12 @@ import javax.management.ObjectName;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import javax.sql.XADataSource;
|
import javax.sql.XADataSource;
|
||||||
import javax.xml.bind.JAXBElement;
|
import javax.xml.bind.JAXBElement;
|
||||||
import net.openesb.standalone.naming.jaxb.DataSourcePoolPropertiesComplexType;
|
import net.openesb.standalone.naming.jaxb.DataSourcePoolProperties;
|
||||||
import net.openesb.standalone.naming.jaxb.DataSourcePropertiesComplexType;
|
import net.openesb.standalone.naming.jaxb.DataSourceProperties;
|
||||||
import net.openesb.standalone.naming.jaxb.PoolPropertiesComplexType;
|
import net.openesb.standalone.naming.jaxb.PoolProperties;
|
||||||
import net.openesb.standalone.naming.jaxb.PropertyComplexType;
|
import net.openesb.standalone.naming.jaxb.Property;
|
||||||
import net.openesb.standalone.naming.jndi.DataSourcePoolFactory;
|
import net.openesb.standalone.naming.jndi.DataSourcePoolFactory;
|
||||||
import net.openesb.standalone.utils.I18NBundle;
|
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
|
* Then we create an Apache datasource with the pool as parameter
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public DataSource getDataSource(DataSourcePoolPropertiesComplexType dspProperties) {
|
public DataSource getDataSource(DataSourcePoolProperties dspProperties) {
|
||||||
PoolProperties poolProperties = this.createNativeDataSource(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);
|
org.apache.tomcat.jdbc.pool.DataSource ds = new org.apache.tomcat.jdbc.pool.DataSource(poolProperties);
|
||||||
ds.setName(dspProperties.getDbConnectorName());
|
ds.setName(dspProperties.getDbConnectorName());
|
||||||
registerMBean(ds);
|
registerMBean(ds);
|
||||||
|
@ -52,8 +51,8 @@ public class TomcatDataSourcePoolFactory implements DataSourcePoolFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XADataSource getXADataSource(DataSourcePoolPropertiesComplexType dspProperties) {
|
public XADataSource getXADataSource(DataSourcePoolProperties dspProperties) {
|
||||||
PoolProperties poolProperties = this.createNativeDataSource(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);
|
org.apache.tomcat.jdbc.pool.XADataSource ds = new org.apache.tomcat.jdbc.pool.XADataSource(poolProperties);
|
||||||
ds.setName(dspProperties.getDbConnectorName());
|
ds.setName(dspProperties.getDbConnectorName());
|
||||||
registerMBean(ds);
|
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*/
|
/* get the properties for the native Datasource. it is not created yet*/
|
||||||
DataSourcePropertiesComplexType dataSourceProperties = dspProperties.getDataSourceProperties();
|
DataSourceProperties dataSourceProperties = dspProperties.getDataSourceProperties();
|
||||||
Map<String, String> datasourceMap = this.listToMap(dataSourceProperties.getProperty());
|
Map<String, String> datasourceMap = this.listToMap(dataSourceProperties.getProperty());
|
||||||
|
|
||||||
/* Get datasource name from OE Context. Native DS is create dynamically
|
/* 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(
|
LOG.log(Level.FINE, I18NBundle.getBundle().getMessage(
|
||||||
"start.pool.configuration"));
|
"start.pool.configuration"));
|
||||||
|
|
||||||
PoolPropertiesComplexType contextPoolProperties = dspProperties.getPoolProperties();
|
PoolProperties contextPoolProperties = dspProperties.getPoolProperties();
|
||||||
Map<String, String> poolMap = this.listToMap(contextPoolProperties.getProperty());
|
Map<String, String> poolMap = this.listToMap(contextPoolProperties.getProperty());
|
||||||
// Create pool configuration
|
// 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();
|
Class poolPropertiesClass = poolProperties.getClass();
|
||||||
Map<String, Field> poolPropertiesFields = this.getAllFields(poolPropertiesClass);
|
Map<String, Field> poolPropertiesFields = this.getAllFields(poolPropertiesClass);
|
||||||
/* Use java reflexion to set up pool configurationwith context properties
|
/* Use java reflexion to set up pool configurationwith context properties
|
||||||
|
@ -254,14 +255,14 @@ public class TomcatDataSourcePoolFactory implements DataSourcePoolFactory {
|
||||||
return poolProperties;
|
return poolProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* List to Map is an internal methode used to convert a List<PropertyComplexType> to a Map.
|
/* List to Map is an internal methode used to convert a List<Property> to a Map.
|
||||||
* Map will be use to set the DataSource and the Pool
|
* Map will be use to set the DataSource and the Pool
|
||||||
*/
|
*/
|
||||||
private Map<String, String> listToMap(List<PropertyComplexType> inputList) {
|
private Map<String, String> listToMap(List<Property> inputList) {
|
||||||
Map<String, String> outputMap = new HashMap<String, String>();
|
Map<String, String> outputMap = new HashMap<String, String>();
|
||||||
Iterator<PropertyComplexType> it = inputList.iterator();
|
Iterator<Property> it = inputList.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
PropertyComplexType prop = it.next();
|
Property prop = it.next();
|
||||||
List<JAXBElement<String>> nameAndValueAndDescription = prop.getNameAndValueAndDescription();
|
List<JAXBElement<String>> nameAndValueAndDescription = prop.getNameAndValueAndDescription();
|
||||||
Iterator<JAXBElement<String>> it2 = nameAndValueAndDescription.iterator();
|
Iterator<JAXBElement<String>> it2 = nameAndValueAndDescription.iterator();
|
||||||
String key = null, value = null;
|
String key = null, value = null;
|
||||||
|
|
|
@ -17,4 +17,9 @@ public interface Node {
|
||||||
*/
|
*/
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the node name.
|
||||||
|
* @return The node name.
|
||||||
|
*/
|
||||||
|
String name();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,24 @@ package net.openesb.standalone.node.internal;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.sun.jbi.platform.PlatformContext;
|
import com.sun.jbi.platform.PlatformContext;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.management.MBeanServer;
|
import javax.management.MBeanServer;
|
||||||
import javax.management.ObjectName;
|
import javax.management.ObjectName;
|
||||||
import javax.management.StandardMBean;
|
import javax.management.StandardMBean;
|
||||||
|
import net.openesb.standalone.Constants;
|
||||||
|
import net.openesb.standalone.LocalStringKeys;
|
||||||
import net.openesb.standalone.core.CoreModule;
|
import net.openesb.standalone.core.CoreModule;
|
||||||
import net.openesb.standalone.framework.FrameworkModule;
|
import net.openesb.standalone.framework.FrameworkModule;
|
||||||
import net.openesb.standalone.framework.FrameworkService;
|
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.inject.ModulesBuilder;
|
||||||
import net.openesb.standalone.jmx.JMXService;
|
import net.openesb.standalone.jmx.JMXService;
|
||||||
import net.openesb.standalone.naming.NamingModule;
|
import net.openesb.standalone.naming.NamingModule;
|
||||||
import net.openesb.standalone.node.Node;
|
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 =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(InstanceNode.class.getPackage().getName());
|
Logger.getLogger(InstanceNode.class.getPackage().getName());
|
||||||
|
|
||||||
|
private static final String INSTANCE_NAME = "instance.name";
|
||||||
|
|
||||||
|
private final String nodeName;
|
||||||
|
|
||||||
private final Injector injector;
|
private final Injector injector;
|
||||||
|
|
||||||
private JMXService jmxService;
|
private JMXService jmxService;
|
||||||
private FrameworkService frameworkService;
|
private FrameworkService frameworkService;
|
||||||
|
private HttpService httpService;
|
||||||
|
|
||||||
public InstanceNode () {
|
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();
|
ModulesBuilder modules = new ModulesBuilder();
|
||||||
|
|
||||||
modules.add(new CoreModule());
|
modules.add(new CoreModule());
|
||||||
modules.add(new FrameworkModule());
|
modules.add(new FrameworkModule());
|
||||||
modules.add(new NamingModule());
|
modules.add(new NamingModule());
|
||||||
|
modules.add(new HttpModule());
|
||||||
modules.add(new NodeModule(this));
|
modules.add(new NodeModule(this));
|
||||||
|
|
||||||
injector = modules.createInjector();
|
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
|
@Override
|
||||||
public void start() {
|
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();
|
jmxService.start();
|
||||||
|
|
||||||
frameworkService = injector.getInstance(FrameworkService.class);
|
|
||||||
frameworkService.start();
|
frameworkService.start();
|
||||||
|
|
||||||
|
httpService.setEnvironmentContext(frameworkService.getEnvironment());
|
||||||
|
httpService.start();
|
||||||
|
|
||||||
PlatformContext platformContext = injector.getInstance(PlatformContext.class);
|
PlatformContext platformContext = injector.getInstance(PlatformContext.class);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -79,16 +110,34 @@ public class InstanceNode implements Node {
|
||||||
e.printStackTrace();
|
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
|
@Override
|
||||||
public void stop() {
|
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();
|
frameworkService.stop();
|
||||||
jmxService.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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package net.openesb.standalone.startup;
|
package net.openesb.standalone.startup;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.logging.LogManager;
|
import java.util.logging.LogManager;
|
||||||
import net.openesb.standalone.Lifecycle;
|
import net.openesb.standalone.Lifecycle;
|
||||||
import net.openesb.standalone.node.Node;
|
import net.openesb.standalone.node.Node;
|
||||||
import net.openesb.standalone.node.NodeBuilder;
|
import net.openesb.standalone.node.NodeBuilder;
|
||||||
|
import net.openesb.standalone.utils.ReflectionUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -25,7 +25,6 @@ public class Container implements Lifecycle {
|
||||||
public void start() {
|
public void start() {
|
||||||
node.start();
|
node.start();
|
||||||
|
|
||||||
System.out.println("CONTAINER STARTED");
|
|
||||||
// Register shutdown hook
|
// Register shutdown hook
|
||||||
shutdownHook = new ContainerShutdownHook();
|
shutdownHook = new ContainerShutdownHook();
|
||||||
Runtime.getRuntime().addShutdownHook(shutdownHook);
|
Runtime.getRuntime().addShutdownHook(shutdownHook);
|
||||||
|
@ -38,40 +37,13 @@ public class Container implements Lifecycle {
|
||||||
public void stop() {
|
public void stop() {
|
||||||
node.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 {
|
try {
|
||||||
invoke(LogManager.getLogManager(), "reset0");
|
ReflectionUtils.invoke(
|
||||||
|
LogManager.getLogManager(), "reset0");
|
||||||
} catch (Throwable t) {
|
} 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 {
|
private class ContainerShutdownHook extends Thread {
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,13 @@
|
||||||
# OpenESB Standalone : Container messages (10xx)
|
# 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_FAILURE = OESE-1101: Start connector failure: {0}.
|
||||||
CONNECTOR_START_CONNECTOR_STARTED = OESE-1102: JMX connector server started at: {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_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.
|
||||||
|
|
||||||
#
|
#
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
|
||||||
|
<jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
|
||||||
|
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||||
|
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
||||||
|
xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance">
|
||||||
|
<jaxb:bindings schemaLocation="../xsd/OEContext.xsd" node="/xs:schema">
|
||||||
|
|
||||||
|
<jaxb:bindings node="//xs:complexType[@name='pool-propertiesComplexType']">
|
||||||
|
<jaxb:class name="PoolProperties" />
|
||||||
|
</jaxb:bindings>
|
||||||
|
|
||||||
|
<jaxb:bindings node="//xs:complexType[@name='propertyComplexType']">
|
||||||
|
<jaxb:class name="Property" />
|
||||||
|
</jaxb:bindings>
|
||||||
|
|
||||||
|
<jaxb:bindings node="//xs:complexType[@name='dataSource-pool-propertiesComplexType']">
|
||||||
|
<jaxb:class name="DataSourcePoolProperties" />
|
||||||
|
</jaxb:bindings>
|
||||||
|
|
||||||
|
<jaxb:bindings node="//xs:complexType[@name='dataSource-propertiesComplexType']">
|
||||||
|
<jaxb:class name="DataSourceProperties" />
|
||||||
|
</jaxb:bindings>
|
||||||
|
|
||||||
|
<jaxb:bindings node="//xs:complexType[@name='oeContextComplexType']">
|
||||||
|
<jaxb:class name="Context" />
|
||||||
|
</jaxb:bindings>
|
||||||
|
|
||||||
|
<jaxb:bindings node="//xs:complexType[@name='jdbc-resourceComplexType']">
|
||||||
|
<jaxb:class name="JDBCResource" />
|
||||||
|
</jaxb:bindings>
|
||||||
|
|
||||||
|
</jaxb:bindings>
|
||||||
|
</jaxb:bindings>
|
|
@ -11,13 +11,14 @@
|
||||||
|
|
||||||
##################################### HTTP ########################################
|
##################################### HTTP ########################################
|
||||||
# Set a custom port to listen for HTTP traffic:
|
# Set a custom port to listen for HTTP traffic:
|
||||||
#
|
|
||||||
# http.port: 4848
|
# http.port: 4848
|
||||||
|
|
||||||
# Disable HTTP completely:
|
# Disable HTTP completely:
|
||||||
#
|
|
||||||
# http.enabled: false
|
# http.enabled: false
|
||||||
|
|
||||||
|
# HTTP Binding
|
||||||
|
# http.binding: localhost
|
||||||
|
|
||||||
##################################### JNDI ########################################
|
##################################### JNDI ########################################
|
||||||
# Specify the context file to used for JNDI
|
# Specify the context file to used for JNDI
|
||||||
# jndi.context: ${openesb.home}/config/context.xml
|
# jndi.context: ${openesb.home}/config/context.xml
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -38,6 +38,7 @@
|
||||||
<junit.version>4.11</junit.version>
|
<junit.version>4.11</junit.version>
|
||||||
<slf4j.version>1.7.6</slf4j.version>
|
<slf4j.version>1.7.6</slf4j.version>
|
||||||
<guice.version>3.0</guice.version>
|
<guice.version>3.0</guice.version>
|
||||||
|
<jansi.version>1.11</jansi.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
Loading…
Reference in New Issue