Standalone container : big refactor

master
David BRASSELY 2014-03-03 17:06:03 +01:00
parent 3b218dcec2
commit dce6c0306a
38 changed files with 2028 additions and 32 deletions

View File

@ -8,24 +8,35 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>openesb-standalone-framework</artifactId>
<artifactId>openesb-standalone-container</artifactId>
<name>OpenESB - Standalone - Framework</name>
<description>OpenESB runtime in standalone mode - Framework</description>
<name>OpenESB - Standalone - Container</name>
<description>OpenESB runtime in standalone mode - Container</description>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaFiles>OEContext.xsd</schemaFiles>
<schemaDirectory>${project.basedir}/src/main/resources/net/openesb/standalone/naming/utils</schemaDirectory>
<packageName>net.openesb.standalone.naming.jaxb</packageName>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Internal dependencies -->
<dependency>
<groupId>net.open-esb.runtime.standalone</groupId>
<artifactId>openesb-standalone-naming</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.open-esb.runtime.standalone</groupId>
<artifactId>openesb-standalone-security</artifactId>
<version>${project.version}</version>
</dependency>
<!-- OpenESB Core dependencies -->
<dependency>
<groupId>net.open-esb</groupId>
@ -45,6 +56,13 @@
<version>${atomikos.version}</version>
</dependency>
<!-- Security support -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>${shiro.version}</version>
</dependency>
<!-- Cluster support
<dependency>
<groupId>org.jgroups</groupId>
@ -60,6 +78,19 @@
<version>${snakeyaml.version}</version>
</dependency>
<!-- JNDI support -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>${tomcat.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>${tomcat.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

@ -0,0 +1,17 @@
package net.openesb.standalone.naming.jndi;
import javax.sql.DataSource;
import javax.sql.XADataSource;
import net.openesb.standalone.naming.jaxb.DataSourcePoolPropertiesComplexType;
/**
*
* @author Paul PEREZ (paul.perez at pymma.com)
* @author OpenESB Community
*/
public interface DataSourcePoolFactory {
public DataSource getDataSource (DataSourcePoolPropertiesComplexType dSPProperties) ;
public XADataSource getXADataSource (DataSourcePoolPropertiesComplexType dSPProperties) ;
}

View File

@ -0,0 +1,221 @@
package net.openesb.standalone.naming.jndi.impl;
import net.openesb.standalone.naming.jndi.tomcat.TomcatDataSourcePoolFactory;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.naming.spi.InitialContextFactory;
import javax.sql.DataSource;
import javax.sql.XADataSource;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
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.jndi.DataSourcePoolFactory;
import net.openesb.standalone.naming.utils.I18NBundle;
/**
*
* @author Paul PEREZ (paul.perez at pymma.com)
* @author OpenESB Community
*/
public class InitialContexFactoryImpl implements InitialContextFactory {
public static final String DATASOURCE_TYPE = "Datasource";
public static final String XADATASOURCE_TYPE = "XADatasource";
private static final Logger sLogger = Logger.getLogger("net.openesb.standalone.naming");
private final Map<String, DataSourcePoolPropertiesComplexType> mDSPMap = new HashMap<String, DataSourcePoolPropertiesComplexType>();
private final DataSourcePoolFactory mDSPFactory = new TomcatDataSourcePoolFactory();
private final String mClassName = "InitialContexFactoryImpl";
private final ResourceBundle mResourceBundle;
private String mMessage;
// Constructor
public InitialContexFactoryImpl() {
I18NBundle nBundle = new I18NBundle("net.openesb.standalone.naming.utils");
mResourceBundle = nBundle.getBundle();
}
/* Regarding the exception management, If the context file if not correct,
* I choosed to return an initial context in any case even empty. So if input data
is not correct, I log this information but catch the exception in order to return
an initial context. Another policy would be to stop at any exception. I did not choose
it. Naming exception will be thrown only if I cannot create the initial context */
/* The initial context I use is the one found in Tomcat 7 */
@Override
public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException {
Map<String, DataSource> datasourceMap = new HashMap<String, DataSource>();
String methodName = "getInitialContext";
/*Context initialisation Just set the system properties and use the class InitialContext*/
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming");
Context initialContext = new InitialContext();
mMessage = mResourceBundle.getString("context.created");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage);
/* Second step read the XML file URL where context configuration is described
* The URL can be file:// http:// ...
* The XML File URL must be in environement hashmap and read the key URL must be equal to
* CONTEXT_URL*/
String urlValue = null;
if (environment.containsKey(Context.PROVIDER_URL)) {
urlValue = (String) environment.get(Context.PROVIDER_URL);
mMessage = mResourceBundle.getString("context.url.read");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage, new Object[]{urlValue});
} else {
mMessage = mResourceBundle.getString("context.url.not.provided") + " " + mResourceBundle.getString("context.url.not.provided.ID");
sLogger.logp(Level.SEVERE, mClassName, methodName, mMessage);
}
/* Read the context from the URL */
@SuppressWarnings("UnusedAssignment") JAXBElement<OeContextComplexType> root = null;
try {
JAXBContext jc = JAXBContext.newInstance("net.openesb.standalone.naming.jaxb");
Unmarshaller unmarshaller = jc.createUnmarshaller();
root = (JAXBElement<OeContextComplexType>) unmarshaller.unmarshal(new URL(urlValue));
} catch (MalformedURLException ex) {
mMessage = mResourceBundle.getString("url.context.name.malformed") ;
sLogger.logp(Level.SEVERE, mClassName, methodName, mMessage, new Object[] {urlValue});
mMessage = mResourceBundle.getString("catch.exception");
sLogger.logp(Level.SEVERE, mClassName, methodName, mMessage, ex);
return initialContext ;
} catch (JAXBException ex) {
mMessage = mResourceBundle.getString("jaxb.unmarshalling.failed");
sLogger.logp(Level.SEVERE, mClassName, methodName, mMessage, new Object[] {urlValue});
mMessage = mResourceBundle.getString("catch.exception");
sLogger.logp(Level.SEVERE, mClassName, methodName, mMessage, ex);
return initialContext ;
}
// This must be made with the xml file has an element root
// Log level Fine Unmarshalling ok
OeContextComplexType oeContext = root.getValue();
mMessage = mResourceBundle.getString("context.binding.ok");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage);
/* 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<DataSourcePoolPropertiesComplexType> dataSourcePoolList = oeContext.getDataSourcePoolProperties();
int listSize = dataSourcePoolList.size();
mMessage = mResourceBundle.getString("number.dataSourcePoolProperties.found");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage, new Object[]{listSize});
//Loop on dataSourcePoolList iterator
for (DataSourcePoolPropertiesComplexType dspComplexType : dataSourcePoolList) {
mDSPMap.put(dspComplexType.getDbConnectorName(), dspComplexType);
mMessage = mResourceBundle.getString("datasourcepoolproperties.found.in.context");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage, new Object[]{dspComplexType.getDbConnectorName()});
}
// Now Let's read JdbcResource
List<JdbcResourceComplexType> jdbcResourceList = oeContext.getJdbcResources();
listSize = jdbcResourceList.size();
mMessage = mResourceBundle.getString("number.jdbcResource.declaration.found");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage, new Object[]{listSize});
//Loop on JDBCResourceList iterator
for (JdbcResourceComplexType 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)
* Once instanciated dbConnector are put in a map for reusing purpose
* ex: when two JNDI names target the same dbConnector
*/
// Get JNDI Name
String jndiName = jdbcResource.getJndiName();
mMessage = jndiName + " " + mResourceBundle.getString("in.process");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage);
/* Check if this JNDI name is already in the context. In that case the
* second instance is not taken into account
*/
try {
initialContext.lookup(jndiName);
mMessage = mResourceBundle.getString("jndi.value.already.defined");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage, new Object[]{jndiName});
continue;
} catch (NamingException ex) {
// Nothing else to do. Having an exception is the normal process
}
/* Create datasource or XA Datasource thanks to the underlying dbConnector
* DBConnector refeence is in the DataSourcePoolProperties. DBConnector are instanciated
* dynamically and must be present in the classpath
* */
String dbConnectorName = jdbcResource.getDbConnectorName();
/* check if the datasource has been created already for a previous
* JNDI Name. In that case we reuse it.
*/
if (datasourceMap.containsKey(dbConnectorName)) {
if (datasourceMap.get(dbConnectorName) instanceof XADataSource) {
initialContext.rebind(jndiName, (XADataSource) datasourceMap.get(dbConnectorName));
} else {
initialContext.rebind(jndiName, datasourceMap.get(dbConnectorName));
}
continue;
}
// Retrieve DataSourcePoolPropertie
DataSourcePoolPropertiesComplexType dspProperties = mDSPMap.get(dbConnectorName);
// Check if Datasourse or XA Datasource
if (dspProperties.getResourceType().equals(InitialContexFactoryImpl.DATASOURCE_TYPE)) {
mMessage = mResourceBundle.getString("datasource.in.process");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage, new Object[]{jndiName});
DataSource dataSource = mDSPFactory.getDataSource(dspProperties);
/* Check if datasource is not null then put in the context since exception are catch */
if (null != dataSource) {
datasourceMap.put(dbConnectorName, dataSource);
try {
initialContext.rebind(jndiName, dataSource);
} catch (NamingException ex) {
initialContext.bind(jndiName, dataSource);
}
mMessage = mResourceBundle.getString("datasource.processed.bind.success");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage, new Object[]{jndiName});
}
} else if (dspProperties.getResourceType()
.equals(InitialContexFactoryImpl.XADATASOURCE_TYPE)) {
mMessage = mResourceBundle.getString("xadatasource.in.process");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage, new Object[]{jndiName});
XADataSource xaDataSource = mDSPFactory.getXADataSource(dspProperties);
if (null != xaDataSource) {
/* Store the XAdatasource in a map for reusing purpose see above */
datasourceMap.put(dbConnectorName, (DataSource) xaDataSource);
initialContext.rebind(jndiName, xaDataSource);
mMessage = mResourceBundle.getString("xadatasource.processed.bind.success");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage, new Object[]{jndiName});
}
} else {
mMessage = mResourceBundle.getString("bad.resource.type");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage, new Object[]{dspProperties.getResourceType(), dspProperties.getDatabaseName()});
}
}
/* the context contains the binding and the datasource or xaDatasource links
* Return the context
*/
return initialContext;
}
}

View File

@ -0,0 +1,311 @@
package net.openesb.standalone.naming.jndi.tomcat;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.management.MBeanServer;
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.jndi.DataSourcePoolFactory;
import net.openesb.standalone.naming.utils.I18NBundle;
import org.apache.tomcat.jdbc.pool.PoolProperties;
/**
*
* @author Paul PEREZ (paul.perez at pymma.com)
* @author OpenESB Community
*/
public class TomcatDataSourcePoolFactory implements DataSourcePoolFactory {
private final ResourceBundle mResourceBundle;
private String mMessage;
private final String mClassName = "DataSourcePoolFactoryimpl";
private static final Logger sLogger = Logger.getLogger("net.openesb.standalone.naming");
public TomcatDataSourcePoolFactory() {
I18NBundle nBundle = new I18NBundle("net.openesb.standalone.naming.utils");
mResourceBundle = nBundle.getBundle();
}
@Override
/* GetDatasource method is used to create dynamically and set up a pooled datasource. Information and parameters
* are provided by dspProperties. The first part of the method create dynamically a native datasource.
* Introspection is used to set up datasource properties. We setup just the properties declared in
* context.xml (or else).
* Using the same way, the second part setup Apache pool. Important: Pool Datasource property is
* set up with the native datasource, so there is no need for setting up other pool properties
* related to the connection.
* Then we create an Apache datasource with the pool as parameter
*/
public DataSource getDataSource(DataSourcePoolPropertiesComplexType dspProperties) {
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);
return ds;
}
@Override
public XADataSource getXADataSource(DataSourcePoolPropertiesComplexType dspProperties) {
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);
return ds;
}
private void registerMBean(org.apache.tomcat.jdbc.pool.DataSource ds) {
try {
ds.createPool();
ds.setJmxEnabled(true);
MBeanServer mBeanServer = java.lang.management.ManagementFactory.getPlatformMBeanServer();
String mBeanName = "net.open-esb.standalone:type=DataSources,name=" + ds.getName();
mBeanServer.registerMBean(ds.getPool().getJmxPool(), new ObjectName(mBeanName));
} catch (Exception e) {
e.printStackTrace();
}
}
private PoolProperties createNativeDataSource(DataSourcePoolPropertiesComplexType dspProperties) {
String methodName = "createNativeDataSource";
/* get the properties for the native Datasource. it is not created yet*/
DataSourcePropertiesComplexType dataSourceProperties = dspProperties.getDataSourceProperties();
Map<String, String> datasourceMap = this.listToMap(dataSourceProperties.getProperty());
/* Get datasource name from OE Context. Native DS is create dynamically
* so the class must be present in the classpath. DS Instance not created yet
*/
String dsName = dspProperties.getDatasourceClassname();
mMessage = mResourceBundle.getString("start.instanciate.datasource");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage, new Object[]{dsName});
Class<?> dsClass;
try {
dsClass = Class.forName(dsName);
} catch (ClassNotFoundException ex) {
mMessage = mResourceBundle.getString("datasource.class.not.found");
sLogger.logp(Level.SEVERE, mClassName, methodName, mMessage, new Object[]{dsName});
mMessage = mResourceBundle.getString("catch.exception");
sLogger.logp(Level.SEVERE, mClassName, methodName, mMessage, ex);
/* An exception don't stop JNDI context process so we return a null Datasource. */
return null;
}
/*Return Fields declared in a class and its ancesters */
Map<String, Field> dsFields = this.getAllFields(dsClass);
/*Create datasource instance. This is the instance that will be set with reflexion and returned
* to the caller
*/
Object nativeDS;
try {
nativeDS = dsClass.newInstance();
} catch (InstantiationException ex) {
mMessage = mResourceBundle.getString("impossible.instanciate.datasource");
sLogger.logp(Level.SEVERE, mClassName, methodName, mMessage, new Object[]{dsName});
mMessage = mResourceBundle.getString("catch.exception");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, ex);
return null;
} catch (IllegalAccessException ex) {
mMessage = mResourceBundle.getString("catch.exception");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, ex);
return null;
}
/* Use java reflexion to set up Native Datasource declared in the context */
Set<String> dspSet = datasourceMap.keySet();
Iterator<String> keys = dspSet.iterator();
while (keys.hasNext()) {
String fieldName = keys.next();
Field field = dsFields.get(fieldName);
if (null == field) {
mMessage = mResourceBundle.getString("invalid.field.name");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, new Object[]{fieldName, dsName});
} else {
if (!field.isAccessible()) {
field.setAccessible(true);
}
String fieldValue = datasourceMap.get(fieldName);
try {
if (field.getType().equals(byte.class)) {
field.set(nativeDS, Byte.parseByte(fieldValue));
} else if (field.getType().equals(boolean.class)) {
field.set(nativeDS, Boolean.parseBoolean(fieldValue));
} else if (field.getType().equals(char.class)) {
field.set(nativeDS, fieldValue.charAt(0));
} else if (field.getType().equals(short.class)) {
field.set(nativeDS, Short.parseShort(fieldValue));
} else if (field.getType().equals(int.class)) {
field.set(nativeDS, Integer.parseInt(fieldValue));
} else if (field.getType().equals(long.class)) {
field.set(nativeDS, Long.parseLong(fieldValue));
} else if (field.getType().equals(float.class)) {
field.set(nativeDS, Float.parseFloat(fieldValue));
} else if (field.getType().equals(double.class)) {
field.set(nativeDS, Double.parseDouble(fieldValue));
} else if (field.getType().equals(String.class)) {
field.set(nativeDS, fieldValue);
} else {
mMessage = mResourceBundle.getString("field.not.set");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, new Object[]{fieldName});
mMessage = mResourceBundle.getString("field.type.not.process");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, new Object[]{fieldName, dsName, field.getType()});
}
} catch (IllegalArgumentException ex) {
mMessage = mResourceBundle.getString("field.not.set");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, new Object[]{fieldName});
mMessage = mResourceBundle.getString("catch.exception");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, ex);
} catch (IllegalAccessException ex) {
mMessage = mResourceBundle.getString("field.not.set");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, new Object[]{fieldName});
mMessage = mResourceBundle.getString("catch.exception");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, ex);
}
}
}
/* Datasouce fields are set with data proterties found in the context
* Now let's set the pool with the pool proterties found in the context
* get the properties for the pool */
mMessage = mResourceBundle.getString("native.datasource.set.succesfully");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage, new Object[]{dsName});
/**
* ** Set up Pool
*/
mMessage = mResourceBundle.getString("start.pool.configuration");
sLogger.logp(Level.FINE, mClassName, methodName, mMessage);
PoolPropertiesComplexType contextPoolProperties = dspProperties.getPoolProperties();
Map<String, String> poolMap = this.listToMap(contextPoolProperties.getProperty());
// Create pool configuration
org.apache.tomcat.jdbc.pool.PoolProperties poolProperties = new PoolProperties();
Class poolPropertiesClass = poolProperties.getClass();
Map<String, Field> poolPropertiesFields = this.getAllFields(poolPropertiesClass);
/* Use java reflexion to set up pool configurationwith context properties
*/
Set<String> poolPropertiesSet = poolMap.keySet();
keys = poolPropertiesSet.iterator();
while (keys.hasNext()) {
String fieldName = keys.next();
Field field = poolPropertiesFields.get(fieldName);
if (null == field) {
mMessage = mResourceBundle.getString("invalid.field.name");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, new Object[]{fieldName, poolPropertiesClass});
} else {
if (!field.isAccessible()) {
field.setAccessible(true);
}
String fieldValue = poolMap.get(fieldName);
try {
if (field.getType().equals(byte.class)) {
field.set(poolProperties, Byte.parseByte(fieldValue));
} else if (field.getType().equals(boolean.class)) {
field.set(poolProperties, Boolean.parseBoolean(fieldValue));
} else if (field.getType().equals(char.class)) {
field.set(poolProperties, fieldValue.charAt(0));
} else if (field.getType().equals(short.class)) {
field.set(poolProperties, Short.parseShort(fieldValue));
} else if (field.getType().equals(int.class)) {
field.set(poolProperties, Integer.parseInt(fieldValue));
} else if (field.getType().equals(long.class)) {
field.set(poolProperties, Long.parseLong(fieldValue));
} else if (field.getType().equals(float.class)) {
field.set(poolProperties, Float.parseFloat(fieldValue));
} else if (field.getType().equals(double.class)) {
field.set(poolProperties, Double.parseDouble(fieldValue));
} else if (field.getType().equals(String.class)) {
field.set(poolProperties, fieldValue);
} else {
mMessage = mResourceBundle.getString("field.not.set");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, new Object[]{fieldName});
mMessage = mResourceBundle.getString("field.type.not.process");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, new Object[]{fieldName, poolPropertiesClass, field.getType()});
}
} catch (IllegalArgumentException ex) {
mMessage = mResourceBundle.getString("field.not.set");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, new Object[]{fieldName});
mMessage = mResourceBundle.getString("catch.exception");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, ex);
} catch (IllegalAccessException ex) {
mMessage = mResourceBundle.getString("field.not.set");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, new Object[]{fieldName});
mMessage = mResourceBundle.getString("catch.exception");
sLogger.logp(Level.INFO, mClassName, methodName, mMessage, ex);
}
}
}
// set the pool and get a Poolled Datasource
poolProperties.setDataSource(nativeDS);
poolProperties.setJmxEnabled(true);
return poolProperties;
}
/* List to Map is an internal methode used to convert a List<PropertyComplexType> to a Map.
* Map will be use to set the DataSource and the Pool
*/
private Map<String, String> listToMap(List<PropertyComplexType> inputList) {
Map<String, String> outputMap = new HashMap<String, String>();
Iterator<PropertyComplexType> it = inputList.iterator();
while (it.hasNext()) {
PropertyComplexType prop = it.next();
List<JAXBElement<String>> nameAndValueAndDescription = prop.getNameAndValueAndDescription();
Iterator<JAXBElement<String>> it2 = nameAndValueAndDescription.iterator();
String key = null, value = null;
while (it2.hasNext()) {
JAXBElement<String> element = it2.next();
String localpart = element.getName().getLocalPart();
if ("name".equals(localpart)) {
key = element.getValue();
} else if ("value".equals(localpart)) {
value = element.getValue();
}
// Put the key valu in the Map
outputMap.put(key, value);
}
}
return outputMap;
}
/* getAll field is used to get all the fields declared in a class + its ancesters
* getDeclaredField just returns the field declared at the class level and not
* at the ancester levels. The retured map contains key-values pairs with Field name and Field object
*/
private Map<String, Field> getAllFields(Class<?> type) {
List<Field> listFields = new ArrayList<Field>();
for (Class<?> c = type; c
!= Object.class; c = c.getSuperclass()) {
listFields.addAll(Arrays.asList(c.getDeclaredFields()));
}
Map<String, Field> mapFields = new HashMap<String, Field>();
Iterator<Field> fieldIterator = listFields.iterator();
while (fieldIterator.hasNext()) {
Field field = fieldIterator.next();
String fieldName = field.getName();
mapFields.put(fieldName, field);
}
return mapFields;
}
}

View File

@ -0,0 +1,79 @@
package net.openesb.standalone.naming.test;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Hashtable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.NamingException;
import net.openesb.standalone.naming.jndi.impl.InitialContexFactoryImpl;
import javax.naming.spi.InitialContextFactory;
import javax.sql.DataSource;
/**
*
* @author Paul PEREZ (paul.perez at pymma.com)
* @author OpenESB Community
*/
public class TestConnection01 {
public static void main(String[] args) throws Exception{
InitialContextFactory factory = new InitialContexFactoryImpl();
Hashtable environment = new Hashtable();
environment.put(Context.PROVIDER_URL, "file:///G:/projects/jndi-standalone/jndi-standalone/src/main/resources/net/openesb/standalone/naming/utils/OEContextSample.xml");
Context context = null;
try {
context = factory.getInitialContext(environment);
} catch (NamingException ex) {
Logger.getLogger(TestConnection01.class.getName()).log(Level.SEVERE, null, ex);
System.out.println("Get initial context Error");
System.exit(1);
}
DataSource dsMySQL = null;
try {
dsMySQL = (DataSource) context.lookup("MySQLServer01");
} catch (NamingException ex) {
Logger.getLogger(TestConnection01.class.getName()).log(Level.SEVERE, null, ex);
System.out.println("Look up Error");
System.exit(1);
}
Connection connectionMySQL = null;
try {
connectionMySQL = dsMySQL.getConnection();
PreparedStatement sta2 = connectionMySQL.prepareStatement("SELECT * FROM test.test");
ResultSet rs = sta2.executeQuery();
rs.next();
String name = rs.getString("NAME");
System.out.println(name);
} catch (SQLException ex) {
Logger.getLogger(TestConnection01.class.getName()).log(Level.SEVERE, null, ex);
System.out.println("Look up Error");
System.exit(1);
}
// Derby test
DataSource dsDerby = (DataSource)context.lookup("Derby01");
Connection connectionDerby = dsDerby.getConnection();
PreparedStatement staDerby = connectionDerby.prepareStatement("select * from APP.CUSTOMER where CUSTOMER_ID=1");
ResultSet rsDerby = staDerby.executeQuery();
rsDerby.next();
String customerID = rsDerby.getString("NAME");
System.out.println(customerID);
//PostGresql test
DataSource dsPostgres = (DataSource)context.lookup("Postgres01");
Connection connectionPG = dsPostgres.getConnection();
PreparedStatement staPG = connectionPG.prepareStatement("SELECT * FROM public.distributors");
ResultSet rsPG = staPG.executeQuery();
rsPG.next();
String customerName = rsPG.getString(2);
System.out.println(customerName);
}
}

View File

@ -0,0 +1,28 @@
context.created=Empty JNDI Context has been created
context.url.not.provided.ID=NAMING-0001
context.url.not.provided=The URL context context is not provided.
context.url.read=The URL for the context has been retrieved and its value is {0}
url.context.name.malformed.ID=NAMING-0002
url.context.name.malformed=The URL {0} provided for the context is malformed
jaxb.unmarshalling.failed=UNMarshalling failed with the provided URL {0}
context.binding.ok=context binding is successful and the data have been unmarshaled
number.dataSourcePoolProperties.found={0} DataSourcePool properties have been found in the context
datasourcepoolproperties.found.in.context=DatasourcePoolProperties {0} has been found in the context
number.jdbcResource.declaration.found={0} JDBC Resources have defined in the context
in.process=in process
datasource.created.succesfully=A datasource has been created successfully for the JNDI Name {0}
jndi.value.already.defined=The JNDI value {0} has been declare more than once. Just the first declaration is taken into account
datasource.in.process=Creation Datasource for {0} in process
datasource.processed.bind.success=Datasource for {0} has been processed and bind with success
xadatasource.in.process=Creation XADatasource for {0} in process
xadatasource.processed.bind.success=XADatasource for {0} has been processed and bind with success
bad.resource.type=The resource type {0} defined in the datasourcePoolProperties {1} is not supported
start.instanciate.datasource=Start datasource {0} instanciation
datasource.class.not.found=Datasource class {0} is not found, please check OpenESB classpath
impossible.instanciate.datasource=Impossible to instanciate the datasource {0}
catch.exception=The following exception has been catch
invalid.field.name=Field name "{0}" does not exist in the class {1} please check class and ancestor content and context properties.
field.type.not.process= The field {0} in the class {1} is a not supported type {2}. Just set filed with primitive and String type.
field.not.set=The field {0} has not been set.
native.datasource.set.succesfully=Native datasource {0} has been set successfully
start.pool.configuration= Start pool configuration

View File

@ -0,0 +1,184 @@
package net.openesb.standalone.naming.utils;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* This class reads the i18n strings from locale specific bundle from the
* Bundle[locale].properties or bundle[locale].properties file in a specified
* package. This class has methods for formating the messages.
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
public class I18NBundle {
private final Logger sLogger = Logger.getLogger("net.openesb.standalone.naming");
/**
* package name
*/
private String mBundlePackageName = null;
/**
* resource bundle
*/
private ResourceBundle mBundle = null;
/**
* constructor
*
* @param packageName packe name ( e.g. com.sun.mypackage ) in which to look
* for Bundle.properties file
*/
public I18NBundle(String packageName) {
this.mBundlePackageName = packageName;
this.mBundle = null;
}
/**
* loads the bundle
*
* @param bundleName bundle name
* @param packageName packe name ( e.g. com.sun.mypackage ) in which to look
* for Bundle.properties file
*/
private void loadBundle(String packageName, String bundleName) {
String bundleBaseName = packageName + "." + bundleName;
ResourceBundle resBundle = null;
try {
resBundle = ResourceBundle.getBundle(bundleBaseName);
} catch (MissingResourceException ex) {
// Try with locale independent defaultBundle
try {
resBundle = ResourceBundle.getBundle(bundleBaseName, new Locale(""));
} catch (Exception anyEx) {
sLogger.log(Level.FINE, anyEx.getMessage());
}
}
if (resBundle != null) {
this.mBundle = resBundle;
}
}
/**
* gets the loaded resource bundle
*
* @return resource bundle
*/
public ResourceBundle getBundle() {
// lazzy init
if (this.mBundle == null) {
loadBundle(this.mBundlePackageName, "Bundle");
// try to load the bundle with lower case first letter
if (this.mBundle == null) {
loadBundle(this.mBundlePackageName, "bundle");
}
}
return this.mBundle;
}
/**
* gets the i18n message
*
* @param aI18NMsg String.
* @param aArgs Object[]
* @return formated i18n string.
*/
public static String getFormattedMessage(
String aI18NMsg, Object[] aArgs) {
String formattedI18NMsg = aI18NMsg;
try {
MessageFormat mf = new MessageFormat(aI18NMsg);
formattedI18NMsg = mf.format(aArgs);
} catch (Exception ex) {
}
return formattedI18NMsg;
}
/**
* gets the i18n message
*
* @param aI18NKey i18n key
* @param anArgsArray array of arguments for the formatted string
* @return formatted i18n string
*/
public String getMessage(String aI18NKey, Object[] anArgsArray) {
String i18nMessage = getBundle().getString(aI18NKey);
if (anArgsArray != null) {
return getFormattedMessage(i18nMessage, anArgsArray);
} else {
return i18nMessage;
}
}
/**
* gets the i18n message
*
* @param aI18NKey i18n key
* @return i18n string
*/
public String getMessage(String aI18NKey) {
return getMessage(aI18NKey, null);
}
/**
* gets the i18n message
*
* @param aI18NKey i18n key
* @param arg1 argrument object to message
* @return i18n string
*/
public String getMessage(String aI18NKey, Object arg1) {
Object[] args = {arg1};
return getMessage(aI18NKey, args);
}
/**
* gets the i18n message
*
* @param aI18NKey i18n key
* @param arg1 argrument object to message
* @param arg2 argrument object to message
* @return i18n string
*/
public String getMessage(String aI18NKey, Object arg1, Object arg2) {
Object[] args = {arg1, arg2};
return getMessage(aI18NKey, args);
}
/**
* gets the i18n message
*
* @param aI18NKey i18n key
* @param arg1 argrument object to message
* @param arg2 argrument object to message
* @param arg3 argrument object to message
* @return i18n string
*/
public String getMessage(String aI18NKey, Object arg1, Object arg2, Object arg3) {
Object[] args = {arg1, arg2, arg3};
return getMessage(aI18NKey, args);
}
/**
* main
*
* @param args string array.
*/
public static void main(String[] args) {
Locale l = new Locale("");
System.out.println("Locale : " + l);
System.out.println("Default Locale : " + Locale.getDefault());
I18NBundle bundle = new I18NBundle("net.openesb.standalone.naming.utils");
bundle.loadBundle("net.openesb.standalone.naming.utils","toto");
System.out.println(
bundle.getMessage("jbi.ui.ant.jmx.msg.jmxmp.connected", new String[]{"xyz"}));
}
}

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Document : OEContext.xml
Created on : 24 January 2014, 10:22
Author : polperez
Description:
Purpose of the document follows.
-->
<ns0:context xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:ns0='http://org.open-esb/standalone/OEContext'
xsi:schemaLocation='http://org.open-esb/standalone/OEContext OEContext.xsd'>
<ns0:dataSource-pool-properties>
<ns0:dbConnector-name>Derby Connector</ns0:dbConnector-name>
<ns0:datasource-classname>org.apache.derby.jdbc.ClientDataSource40</ns0:datasource-classname>
<ns0:resource-type>Datasource</ns0:resource-type>
<ns0:database-name>DERBY</ns0:database-name>
<ns0:database-vendor>OpenESB Community</ns0:database-vendor>
<ns0:database-version>10.7.1.1</ns0:database-version>
<ns0:dbconnector-description>DBConnector for Derby</ns0:dbconnector-description>
<ns0:dataSource-properties>
<ns0:property>
<ns0:name>user</ns0:name>
<ns0:value>app</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>password</ns0:name>
<ns0:value>app</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>serverName</ns0:name>
<ns0:value>localhost</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>portNumber</ns0:name>
<ns0:value>1527</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>databaseName</ns0:name>
<ns0:value>sample</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:dataSource-properties>
<ns0:pool-properties>
<ns0:property>
<ns0:name>initialSize</ns0:name>
<ns0:value>11</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxActive</ns0:name>
<ns0:value>20</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxIdle</ns0:name>
<ns0:value>10</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>minIdle</ns0:name>
<ns0:value>10</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:pool-properties>
</ns0:dataSource-pool-properties>
<ns0:jdbc-resources>
<ns0:dbConnector-name>Derby Connector</ns0:dbConnector-name>
<ns0:jndi-name>Derby01</ns0:jndi-name>
<ns0:description>Datasource connection to Derby</ns0:description>
</ns0:jdbc-resources>
</ns0:context>

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://org.open-esb/standalone/OEContext"
xmlns:tns="http://org.open-esb/standalone/OEContext"
elementFormDefault="qualified">
<xsd:complexType name="pool-propertiesComplexType">
<xsd:sequence>
<xsd:element name="property" type="tns:propertyComplexType" minOccurs="0" maxOccurs="unbounded"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="propertyComplexType">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element name="name" type="xsd:string"></xsd:element>
<xsd:element name="value" type="xsd:string"></xsd:element>
<xsd:element name="description" type="xsd:string" minOccurs="0"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="dataSource-pool-propertiesComplexType">
<xsd:sequence>
<xsd:element name="dbConnector-name" type="xsd:string"></xsd:element>
<xsd:element name="datasource-classname" type="xsd:string"></xsd:element>
<xsd:element name="resource-type">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Datasource">
<xsd:annotation>
<xsd:documentation>Datasource</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="XADatasource">
<xsd:annotation>
<xsd:documentation>XADatasource</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="database-name" type="xsd:string"></xsd:element>
<xsd:element name="database-vendor" type="xsd:string"></xsd:element>
<xsd:element name="database-version" type="xsd:string"></xsd:element>
<xsd:element name="dbconnector-description" type="xsd:string" minOccurs="0"></xsd:element>
<xsd:element name="dataSource-properties" type="tns:dataSource-propertiesComplexType" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="pool-properties" type="tns:pool-propertiesComplexType"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="dataSource-propertiesComplexType">
<xsd:sequence>
<xsd:element name="property" type="tns:propertyComplexType" maxOccurs="unbounded" minOccurs="0"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="oeContextComplexType">
<xsd:sequence>
<xsd:element name="dataSource-pool-properties" type="tns:dataSource-pool-propertiesComplexType" minOccurs="0" maxOccurs="unbounded"></xsd:element>
<xsd:element name="jdbc-resources" type="tns:jdbc-resourceComplexType" maxOccurs="unbounded" minOccurs="0"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="context" type="tns:oeContextComplexType"></xsd:element>
<xsd:complexType name="jdbc-resourceComplexType">
<xsd:sequence>
<xsd:element name="dbConnector-name" type="xsd:string"></xsd:element>
<xsd:element name="jndi-name" type="xsd:string"></xsd:element>
<xsd:element name="description" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

View File

@ -0,0 +1,208 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Document : OEContext.xml
Created on : 25 December 2013, 10:05
Author : polperez
Description:
Purpose of the document follows.
-->
<ns0:context xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:ns0='http://org.open-esb/standalone/OEContext'
xsi:schemaLocation='http://org.open-esb/standalone/OEContext OEContext.xsd'>
<ns0:dataSource-pool-properties>
<ns0:dbConnector-name>MYSQL Connector</ns0:dbConnector-name>
<ns0:datasource-classname>com.mysql.jdbc.jdbc2.optional.MysqlDataSource</ns0:datasource-classname>
<ns0:resource-type>Datasource</ns0:resource-type>
<ns0:database-name>MYSQL</ns0:database-name>
<ns0:database-vendor>Oracle</ns0:database-vendor>
<ns0:database-version>5.6</ns0:database-version>
<ns0:dbconnector-description>DBConnector for MySQL</ns0:dbconnector-description>
<ns0:dataSource-properties>
<ns0:property>
<ns0:name>user</ns0:name>
<ns0:value>root</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>password</ns0:name>
<ns0:value>password</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>hostName</ns0:name>
<ns0:value>localhost</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>port</ns0:name>
<ns0:value>3306</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>databaseName</ns0:name>
<ns0:value>test</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:dataSource-properties>
<ns0:pool-properties>
<ns0:property>
<ns0:name>initialSize</ns0:name>
<ns0:value>11</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxActive</ns0:name>
<ns0:value>20</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxIdle</ns0:name>
<ns0:value>11</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>minIdle</ns0:name>
<ns0:value>10</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:pool-properties>
</ns0:dataSource-pool-properties>
<ns0:dataSource-pool-properties>
<ns0:dbConnector-name>Derby Connector</ns0:dbConnector-name>
<ns0:datasource-classname>org.apache.derby.jdbc.ClientDataSource40</ns0:datasource-classname>
<ns0:resource-type>Datasource</ns0:resource-type>
<ns0:database-name>DERBY</ns0:database-name>
<ns0:database-vendor>OpenESB Community</ns0:database-vendor>
<ns0:database-version>10.7.1.1</ns0:database-version>
<ns0:dbconnector-description>DBConnector for Derby</ns0:dbconnector-description>
<ns0:dataSource-properties>
<ns0:property>
<ns0:name>user</ns0:name>
<ns0:value>app</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>password</ns0:name>
<ns0:value>app</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>serverName</ns0:name>
<ns0:value>localhost</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>portNumber</ns0:name>
<ns0:value>1527</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>databaseName</ns0:name>
<ns0:value>sample</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:dataSource-properties>
<ns0:pool-properties>
<ns0:property>
<ns0:name>initialSize</ns0:name>
<ns0:value>11</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxActive</ns0:name>
<ns0:value>20</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxIdle</ns0:name>
<ns0:value>10</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>minIdle</ns0:name>
<ns0:value>10</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:pool-properties>
</ns0:dataSource-pool-properties>
<ns0:dataSource-pool-properties>
<ns0:dbConnector-name>Postgres Connector</ns0:dbConnector-name>
<ns0:datasource-classname>org.postgresql.ds.PGSimpleDataSource</ns0:datasource-classname>
<ns0:resource-type>Datasource</ns0:resource-type>
<ns0:database-name>POSTGRESQL</ns0:database-name>
<ns0:database-vendor>Postgres</ns0:database-vendor>
<ns0:database-version>9.1-90</ns0:database-version>
<ns0:dbconnector-description>DBConnector for postgres</ns0:dbconnector-description>
<ns0:dataSource-properties>
<ns0:property>
<ns0:name>user</ns0:name>
<ns0:value>postgres</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>password</ns0:name>
<ns0:value>password</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>serverName</ns0:name>
<ns0:value>localhost</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>portNumber</ns0:name>
<ns0:value>5432</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>databaseName</ns0:name>
<ns0:value>postgres</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:dataSource-properties>
<ns0:pool-properties>
<ns0:property>
<ns0:name>initialSize</ns0:name>
<ns0:value>11</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxActive</ns0:name>
<ns0:value>20</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxIdle</ns0:name>
<ns0:value>10</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>minIdle</ns0:name>
<ns0:value>10</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:pool-properties>
</ns0:dataSource-pool-properties>
<ns0:jdbc-resources>
<ns0:dbConnector-name>MYSQL Connector</ns0:dbConnector-name>
<ns0:jndi-name>MySQLServer01</ns0:jndi-name>
<ns0:description>Datasource connection to MySQ</ns0:description>
</ns0:jdbc-resources>
<ns0:jdbc-resources>
<ns0:dbConnector-name>Derby Connector</ns0:dbConnector-name>
<ns0:jndi-name>Derby01</ns0:jndi-name>
<ns0:description>Datasource connection to Derby</ns0:description>
</ns0:jdbc-resources>
<ns0:jdbc-resources>
<ns0:dbConnector-name>Postgres Connector</ns0:dbConnector-name>
<ns0:jndi-name>Postgres01</ns0:jndi-name>
<ns0:description>Datasource connection to Postgres</ns0:description>
</ns0:jdbc-resources>
</ns0:context>

View File

@ -0,0 +1,82 @@
package net.openesb.standalone.security;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.security.auth.Subject;
import net.openesb.security.AuthenticationException;
import net.openesb.security.AuthenticationToken;
import net.openesb.security.SecurityProvider;
import net.openesb.standalone.security.realm.Realm;
import net.openesb.standalone.security.realm.RealmBuilder;
import net.openesb.standalone.security.realm.shiro.ShiroAuthenticator;
/**
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
public class SecurityProviderImpl implements SecurityProvider {
private final Logger mLog =
Logger.getLogger(this.getClass().getPackage().getName());
private final static String MANAGEMENT_REALM = "admin";
private final Map<String, Realm> realms = new HashMap<String, Realm>();
private final ShiroAuthenticator authenticator = new ShiroAuthenticator();
public SecurityProviderImpl(Map<String, Map<String, String>> realmsConfiguration) {
this.init(realmsConfiguration);
}
private void init(Map<String, Map<String, String>> realmsConfiguration) {
if (realmsConfiguration != null) {
mLog.log(Level.INFO, "Loading security realms from configuration.");
for(Map.Entry<String, Map<String, String>> realmConfig : realmsConfiguration.entrySet()) {
if (! realms.containsKey(realmConfig.getKey())) {
Realm realm = RealmBuilder.
realmBuilder().
build(realmConfig.getKey(), realmConfig.getValue());
authenticator.loadRealm(realm);
realms.put(realmConfig.getKey(), realm);
if (realm.getName().equals(MANAGEMENT_REALM)) {
mLog.log(Level.INFO, "Management Realm ({0}) has been correctly configured.",
realmConfig.getKey());
} else {
mLog.log(Level.INFO, "Realm {0} has been correctly configured.",
realmConfig.getKey());
}
} else {
mLog.log(Level.INFO, "Realm {0} is already defined, skipping...",
realmConfig.getKey());
}
}
} else {
mLog.log(Level.WARNING, "No realm defined. Please have a look to "
+ " the configuration !");
}
}
@Override
public Collection<String> getRealms() {
return Collections.unmodifiableSet(
realms.keySet());
}
@Override
public Subject login(String realmName, AuthenticationToken authenticationToken) throws AuthenticationException {
return authenticator.authenticate(realmName, authenticationToken);
}
@Override
public Subject login(AuthenticationToken authenticationToken) throws AuthenticationException {
return login(MANAGEMENT_REALM, authenticationToken);
}
}

View File

@ -0,0 +1,42 @@
package net.openesb.standalone.security.auth.login;
import javax.management.remote.JMXAuthenticator;
import javax.security.auth.Subject;
import net.openesb.security.AuthenticationException;
import net.openesb.security.AuthenticationToken;
import net.openesb.security.SecurityProvider;
/**
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
public class JMXauthenticator implements JMXAuthenticator {
private final SecurityProvider securityProvider;
public JMXauthenticator(final SecurityProvider securityProvider) {
this.securityProvider = securityProvider;
}
@Override
public Subject authenticate(Object credentialsObj) {
final String [] credentials = (String []) credentialsObj;
try {
return securityProvider.login(new AuthenticationToken() {
@Override
public Object getPrincipal() {
return credentials[0];
}
@Override
public Object getCredentials() {
return credentials[1];
}
});
} catch (AuthenticationException ae) {
throw new SecurityException(ae.getMessage());
}
}
}

View File

@ -0,0 +1,26 @@
package net.openesb.standalone.security.realm;
/**
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
public abstract class AbstractRealm implements Realm {
private String realmName;
protected AbstractRealm() {
}
protected AbstractRealm(String realmName) {
this.realmName = realmName;
}
public String getName() {
return realmName;
}
public void setName(String realmName) {
this.realmName = realmName;
}
}

View File

@ -0,0 +1,11 @@
package net.openesb.standalone.security.realm;
/**
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
public interface Realm {
String getName();
}

View File

@ -0,0 +1,33 @@
package net.openesb.standalone.security.realm;
import java.util.Map;
import java.util.ServiceLoader;
/**
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
public final class RealmBuilder {
private final static String REALM_TYPE = "type";
public static RealmBuilder realmBuilder() {
return new RealmBuilder();
}
public Realm build(String realmName, Map<String, String> properties) {
ServiceLoader<RealmHandler> handlers = ServiceLoader.load(RealmHandler.class);
for(RealmHandler handler : handlers) {
String type = properties.get(REALM_TYPE);
if (handler.canHandle(type)) {
Realm realm = handler.create(realmName, properties);
return realm;
}
}
throw new IllegalStateException("Unable to create realm " + realmName +
" : no handler found !");
}
}

View File

@ -0,0 +1,15 @@
package net.openesb.standalone.security.realm;
import java.util.Map;
/**
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
public interface RealmHandler<T extends Realm> {
boolean canHandle(String type);
T create(String realmName, Map<String, String> properties);
}

View File

@ -0,0 +1,55 @@
package net.openesb.standalone.security.realm.impl;
import java.util.Map;
import net.openesb.standalone.security.realm.Realm;
import net.openesb.standalone.security.realm.RealmHandler;
/**
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
public abstract class AbstractRealmHandler<T extends Realm> implements RealmHandler<T> {
@Override
public T create(String realmName, Map<String, String> properties) {
return instantiate(realmName, properties);
}
abstract T instantiate(String realmName, Map<String, String> properties);
/**
* System property replacement in the given string.
*
* @param str The original string
* @return the modified string
*/
protected String replace(String str) {
String result = str;
int pos_start = str.indexOf("${");
if (pos_start >= 0) {
StringBuilder builder = new StringBuilder();
int pos_end = -1;
while (pos_start >= 0) {
builder.append(str, pos_end + 1, pos_start);
pos_end = str.indexOf('}', pos_start + 2);
if (pos_end < 0) {
pos_end = pos_start - 1;
break;
}
String propName = str.substring(pos_start + 2, pos_end);
String replacement = propName.length() > 0 ? System
.getProperty(propName) : null;
if (replacement != null) {
builder.append(replacement);
} else {
builder.append(str, pos_start, pos_end + 1);
}
pos_start = str.indexOf("${", pos_end + 1);
}
builder.append(str, pos_end + 1, str.length());
result = builder.toString();
}
return result;
}
}

View File

@ -0,0 +1,48 @@
package net.openesb.standalone.security.realm.impl;
import net.openesb.standalone.security.realm.AbstractRealm;
/**
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
public class PropertiesRealm extends AbstractRealm {
private String path;
private boolean reload = false;
/**
* Unit: seconds
*/
private int reloadInterval;
public PropertiesRealm(String realmName) {
super(realmName);
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public boolean isReload() {
return reload;
}
public void setReload(boolean reload) {
this.reload = reload;
}
public int getReloadInterval() {
return reloadInterval;
}
public void setReloadInterval(int reloadInterval) {
this.reloadInterval = reloadInterval;
}
}

View File

@ -0,0 +1,61 @@
package net.openesb.standalone.security.realm.impl;
import java.io.File;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
public class PropertiesRealmHandler extends AbstractRealmHandler<PropertiesRealm> {
private final Logger mLog =
Logger.getLogger(this.getClass().getPackage().getName());
private final static String PROPERTIES_REALM = "properties";
private final static String PROPERTY_PATH = "file";
private final static String PROPERTY_RELOAD_ENABLE = "reload";
private final static String PROPERTY_RELOAD_INTERVAL = "interval";
@Override
public boolean canHandle(String type) {
return PROPERTIES_REALM.equalsIgnoreCase(type);
}
@Override
public PropertiesRealm instantiate(String realmName, Map<String, String> properties) {
String file = properties.get(PROPERTY_PATH);
file = replace(file);
mLog.log(Level.INFO, "Creating properties realm using file: {0}", file);
File propertyFile = new File(file);
if (! propertyFile.exists()) {
mLog.log(Level.SEVERE, "Properties realm, invalid path: {0}",
propertyFile.getAbsolutePath());
throw new IllegalStateException("Properties realm, invalid path: " +
propertyFile.getAbsolutePath());
}
boolean reload = Boolean.parseBoolean(properties.get(PROPERTY_RELOAD_ENABLE));
PropertiesRealm propertiesRealm = new PropertiesRealm(realmName);
propertiesRealm.setPath(propertyFile.getAbsolutePath());
if (reload) {
String sInterval = properties.get(PROPERTY_RELOAD_INTERVAL);
try {
int interval = Integer.parseInt(sInterval);
propertiesRealm.setReloadInterval(interval);
} catch (NumberFormatException nfe) {
}
}
return propertiesRealm;
}
}

View File

@ -0,0 +1,35 @@
package net.openesb.standalone.security.realm.shiro;
import net.openesb.standalone.security.realm.Realm;
import org.apache.shiro.realm.text.PropertiesRealm;
/**
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
public class PropertiesRealmConverter implements
RealmConverter<net.openesb.standalone.security.realm.impl.PropertiesRealm, PropertiesRealm> {
@Override
public PropertiesRealm convert(net.openesb.standalone.security.realm.impl.PropertiesRealm realm) {
PropertiesRealm cRealm = new PropertiesRealm();
cRealm.setResourcePath(realm.getPath());
if (realm.isReload()) {
cRealm.setReloadIntervalSeconds(realm.getReloadInterval());
}
// Initialize the realm
cRealm.onInit();
return cRealm;
}
@Override
public boolean canHandle(Class<? extends Realm> realm) {
return realm.equals(net.openesb.standalone.security.realm.impl.PropertiesRealm.class);
}
}

View File

@ -0,0 +1,15 @@
package net.openesb.standalone.security.realm.shiro;
import net.openesb.standalone.security.realm.Realm;
/**
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
public interface RealmConverter<T extends Realm, S extends org.apache.shiro.realm.Realm> {
S convert(T realm);
boolean canHandle(Class<? extends Realm> realm);
}

View File

@ -0,0 +1,59 @@
package net.openesb.standalone.security.realm.shiro;
import java.util.HashMap;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.logging.Logger;
import javax.security.auth.Subject;
import net.openesb.security.AuthenticationException;
import net.openesb.security.AuthenticationToken;
import net.openesb.standalone.security.realm.Realm;
import net.openesb.standalone.security.realm.RealmHandler;
import net.openesb.standalone.security.realm.impl.PropertiesRealm;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.mgt.DefaultSecurityManager;
/**
*
* @author David BRASSELY (brasseld at gmail.com)
* @author OpenESB Community
*/
public class ShiroAuthenticator {
private final Logger mLog =
Logger.getLogger(this.getClass().getPackage().getName());
private final Map <String, org.apache.shiro.mgt.SecurityManager> securityManagers =
new HashMap<String, org.apache.shiro.mgt.SecurityManager>();
public void loadRealm(Realm realm) {
ServiceLoader<RealmConverter> converters = ServiceLoader.load(RealmConverter.class);
for (RealmConverter converter : converters) {
if (converter.canHandle(realm.getClass())) {
org.apache.shiro.realm.Realm sRealm = converter.convert((PropertiesRealm)realm);
DefaultSecurityManager manager = new DefaultSecurityManager(sRealm);
securityManagers.put(realm.getName(), manager);
}
}
}
public Subject authenticate(String realmName, AuthenticationToken authenticationToken)
throws AuthenticationException {
org.apache.shiro.mgt.SecurityManager securityManager = securityManagers.get(realmName);
org.apache.shiro.subject.Subject currentUser =
new org.apache.shiro.subject.Subject.Builder(securityManager).buildSubject();
UsernamePasswordToken token = new UsernamePasswordToken(
(String) authenticationToken.getPrincipal(),
(char []) authenticationToken.getCredentials());
try {
currentUser.login(token);
Subject subject = new Subject();
return subject;
} catch (org.apache.shiro.authc.AuthenticationException ae) {
throw new AuthenticationException(ae.getMessage());
}
}
}

View File

@ -0,0 +1 @@
net.openesb.standalone.security.realm.impl.PropertiesRealmHandler

View File

@ -0,0 +1 @@
net.openesb.standalone.security.realm.shiro.PropertiesRealmConverter

View File

@ -0,0 +1,28 @@
context.created=Empty JNDI Context has been created
context.url.not.provided.ID=NAMING-0001
context.url.not.provided=The URL context context is not provided.
context.url.read=The URL for the context has been retrieved and its value is {0}
url.context.name.malformed.ID=NAMING-0002
url.context.name.malformed=The URL {0} provided for the context is malformed
jaxb.unmarshalling.failed=Unmarshalling failed with the provided URL {0}
context.binding.ok=context binding is successful and the data have been unmarshaled
number.dataSourcePoolProperties.found={0} DataSourcePool properties have been found in the context
datasourcepoolproperties.found.in.context=DatasourcePoolProperties {0} has been found in the context
number.jdbcResource.declaration.found={0} JDBC Resources have defined in the context
in.process=in process
datasource.created.succesfully=A datasource has been created successfully for the JNDI Name {0}
jndi.value.already.defined=The JNDI value {0} has been declare more than once. Just the first declaration is taken into account
datasource.in.process=Creation Datasource for {0} in process
datasource.processed.bind.success=Datasource for {0} has been processed and bind with success
xadatasource.in.process=Creation XADatasource for {0} in process
xadatasource.processed.bind.success=XADatasource for {0} has been processed and bind with success
bad.resource.type=The resource type {0} defined in the datasourcePoolProperties {1} is not supported
start.instanciate.datasource=Start datasource {0} instanciation
datasource.class.not.found=Datasource class {0} is not found, please check OpenESB classpath
impossible.instanciate.datasource=Impossible to instanciate the datasource {0}
catch.exception=The following exception has been catch
invalid.field.name=Field name "{0}" does not exist in the class {1} please check class and ancestor content and context properties.
field.type.not.process= The field {0} in the class {1} is a not supported type {2}. Just set filed with primitive and String type.
field.not.set=The field {0} has not been set.
native.datasource.set.succesfully=Native datasource {0} has been set successfully
start.pool.configuration= Start pool configuration

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://org.open-esb/standalone/OEContext"
xmlns:tns="http://org.open-esb/standalone/OEContext"
elementFormDefault="qualified">
<xsd:complexType name="pool-propertiesComplexType">
<xsd:sequence>
<xsd:element name="property" type="tns:propertyComplexType" minOccurs="0" maxOccurs="unbounded"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="propertyComplexType">
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element name="name" type="xsd:string"></xsd:element>
<xsd:element name="value" type="xsd:string"></xsd:element>
<xsd:element name="description" type="xsd:string" minOccurs="0"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="dataSource-pool-propertiesComplexType">
<xsd:sequence>
<xsd:element name="dbConnector-name" type="xsd:string"></xsd:element>
<xsd:element name="datasource-classname" type="xsd:string"></xsd:element>
<xsd:element name="resource-type">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Datasource">
<xsd:annotation>
<xsd:documentation>Datasource</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="XADatasource">
<xsd:annotation>
<xsd:documentation>XADatasource</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="database-name" type="xsd:string"></xsd:element>
<xsd:element name="database-vendor" type="xsd:string"></xsd:element>
<xsd:element name="database-version" type="xsd:string"></xsd:element>
<xsd:element name="dbconnector-description" type="xsd:string" minOccurs="0"></xsd:element>
<xsd:element name="dataSource-properties" type="tns:dataSource-propertiesComplexType" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="pool-properties" type="tns:pool-propertiesComplexType"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="dataSource-propertiesComplexType">
<xsd:sequence>
<xsd:element name="property" type="tns:propertyComplexType" maxOccurs="unbounded" minOccurs="0"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="oeContextComplexType">
<xsd:sequence>
<xsd:element name="dataSource-pool-properties" type="tns:dataSource-pool-propertiesComplexType" minOccurs="0" maxOccurs="unbounded"></xsd:element>
<xsd:element name="jdbc-resources" type="tns:jdbc-resourceComplexType" maxOccurs="unbounded" minOccurs="0"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="context" type="tns:oeContextComplexType"></xsd:element>
<xsd:complexType name="jdbc-resourceComplexType">
<xsd:sequence>
<xsd:element name="dbConnector-name" type="xsd:string"></xsd:element>
<xsd:element name="jndi-name" type="xsd:string"></xsd:element>
<xsd:element name="description" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

View File

@ -0,0 +1,208 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Document : OEContext.xml
Created on : 25 December 2013, 10:05
Author : polperez
Description:
Purpose of the document follows.
-->
<ns0:context xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:ns0='http://org.open-esb/standalone/OEContext'
xsi:schemaLocation='http://org.open-esb/standalone/OEContext OEContext.xsd'>
<ns0:dataSource-pool-properties>
<ns0:dbConnector-name>MYSQL Connector</ns0:dbConnector-name>
<ns0:datasource-classname>com.mysql.jdbc.jdbc2.optional.MysqlDataSource</ns0:datasource-classname>
<ns0:resource-type>Datasource</ns0:resource-type>
<ns0:database-name>MYSQL</ns0:database-name>
<ns0:database-vendor>Oracle</ns0:database-vendor>
<ns0:database-version>5.6</ns0:database-version>
<ns0:dbconnector-description>DBConnector for MySQL</ns0:dbconnector-description>
<ns0:dataSource-properties>
<ns0:property>
<ns0:name>user</ns0:name>
<ns0:value>root</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>password</ns0:name>
<ns0:value>password</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>hostName</ns0:name>
<ns0:value>localhost</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>port</ns0:name>
<ns0:value>3306</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>databaseName</ns0:name>
<ns0:value>test</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:dataSource-properties>
<ns0:pool-properties>
<ns0:property>
<ns0:name>initialSize</ns0:name>
<ns0:value>11</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxActive</ns0:name>
<ns0:value>20</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxIdle</ns0:name>
<ns0:value>11</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>minIdle</ns0:name>
<ns0:value>10</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:pool-properties>
</ns0:dataSource-pool-properties>
<ns0:dataSource-pool-properties>
<ns0:dbConnector-name>Derby Connector</ns0:dbConnector-name>
<ns0:datasource-classname>org.apache.derby.jdbc.ClientDataSource40</ns0:datasource-classname>
<ns0:resource-type>Datasource</ns0:resource-type>
<ns0:database-name>DERBY</ns0:database-name>
<ns0:database-vendor>OpenESB Community</ns0:database-vendor>
<ns0:database-version>10.7.1.1</ns0:database-version>
<ns0:dbconnector-description>DBConnector for Derby</ns0:dbconnector-description>
<ns0:dataSource-properties>
<ns0:property>
<ns0:name>user</ns0:name>
<ns0:value>app</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>password</ns0:name>
<ns0:value>app</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>serverName</ns0:name>
<ns0:value>localhost</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>portNumber</ns0:name>
<ns0:value>1527</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>databaseName</ns0:name>
<ns0:value>sample</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:dataSource-properties>
<ns0:pool-properties>
<ns0:property>
<ns0:name>initialSize</ns0:name>
<ns0:value>11</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxActive</ns0:name>
<ns0:value>20</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxIdle</ns0:name>
<ns0:value>10</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>minIdle</ns0:name>
<ns0:value>10</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:pool-properties>
</ns0:dataSource-pool-properties>
<ns0:dataSource-pool-properties>
<ns0:dbConnector-name>Postgres Connector</ns0:dbConnector-name>
<ns0:datasource-classname>org.postgresql.ds.PGSimpleDataSource</ns0:datasource-classname>
<ns0:resource-type>Datasource</ns0:resource-type>
<ns0:database-name>POSTGRESQL</ns0:database-name>
<ns0:database-vendor>Postgres</ns0:database-vendor>
<ns0:database-version>9.1-90</ns0:database-version>
<ns0:dbconnector-description>DBConnector for postgres</ns0:dbconnector-description>
<ns0:dataSource-properties>
<ns0:property>
<ns0:name>user</ns0:name>
<ns0:value>postgres</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>password</ns0:name>
<ns0:value>password</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>serverName</ns0:name>
<ns0:value>localhost</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>portNumber</ns0:name>
<ns0:value>5432</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>databaseName</ns0:name>
<ns0:value>postgres</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:dataSource-properties>
<ns0:pool-properties>
<ns0:property>
<ns0:name>initialSize</ns0:name>
<ns0:value>11</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxActive</ns0:name>
<ns0:value>20</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>maxIdle</ns0:name>
<ns0:value>10</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
<ns0:property>
<ns0:name>minIdle</ns0:name>
<ns0:value>10</ns0:value>
<ns0:description></ns0:description>
</ns0:property>
</ns0:pool-properties>
</ns0:dataSource-pool-properties>
<ns0:jdbc-resources>
<ns0:dbConnector-name>MYSQL Connector</ns0:dbConnector-name>
<ns0:jndi-name>MySQLServer01</ns0:jndi-name>
<ns0:description>Datasource connection to MySQ</ns0:description>
</ns0:jdbc-resources>
<ns0:jdbc-resources>
<ns0:dbConnector-name>Derby Connector</ns0:dbConnector-name>
<ns0:jndi-name>Derby01</ns0:jndi-name>
<ns0:description>Datasource connection to Derby</ns0:description>
</ns0:jdbc-resources>
<ns0:jdbc-resources>
<ns0:dbConnector-name>Postgres Connector</ns0:dbConnector-name>
<ns0:jndi-name>Postgres01</ns0:jndi-name>
<ns0:description>Datasource connection to Postgres</ns0:description>
</ns0:jdbc-resources>
</ns0:context>

View File

@ -49,17 +49,7 @@
</dependency>
<dependency>
<groupId>net.open-esb.runtime.standalone</groupId>
<artifactId>openesb-standalone-framework</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.open-esb.runtime.standalone</groupId>
<artifactId>openesb-standalone-naming</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.open-esb.runtime.standalone</groupId>
<artifactId>openesb-standalone-security</artifactId>
<artifactId>openesb-standalone-container</artifactId>
<version>${project.version}</version>
</dependency>

View File

@ -108,10 +108,8 @@
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>net.open-esb.runtime.standalone:openesb-standalone-framework</include>
<include>net.open-esb.runtime.standalone:openesb-standalone-bootstrap</include>
<include>net.open-esb.runtime.standalone:openesb-standalone-naming</include>
<include>net.open-esb.runtime.standalone:openesb-standalone-security</include>
<include>net.open-esb.runtime.standalone:openesb-standalone-container</include>
</includes>
<binaries>
<includeDependencies>false</includeDependencies>

View File

@ -17,11 +17,9 @@
<description>OpenESB runtime in standalone mode</description>
<modules>
<module>openesb-standalone-framework</module>
<module>openesb-standalone-container</module>
<module>openesb-standalone-bootstrap</module>
<module>openesb-standalone-naming</module>
<module>openesb-standalone-packaging</module>
<module>openesb-standalone-security</module>
</modules>
<properties>