diff --git a/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/jndi/impl/DataSourcePoolFactoryimpl.java b/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/jndi/impl/DataSourcePoolFactoryimpl.java index 08b70be..3530f78 100644 --- a/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/jndi/impl/DataSourcePoolFactoryimpl.java +++ b/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/jndi/impl/DataSourcePoolFactoryimpl.java @@ -28,8 +28,7 @@ import org.apache.tomcat.jdbc.pool.PoolProperties; * @author OpenESB Community */ public class DataSourcePoolFactoryimpl implements DataSourcePoolFactory { - - + private final ResourceBundle mResourceBundle; private String mMessage; private final String mClassName = "DataSourcePoolFactoryimpl"; @@ -39,7 +38,7 @@ public class DataSourcePoolFactoryimpl implements DataSourcePoolFactory { 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. @@ -221,16 +220,16 @@ public class DataSourcePoolFactoryimpl implements DataSourcePoolFactory { sLogger.logp(Level.INFO, mClassName, methodName, mMessage, ex); } } - // set the pool and get a Poolled Datasource - poolProperties.setDataSource(nativeDS); - outputDataSource = new org.apache.tomcat.jdbc.pool.DataSource(poolProperties); } - return outputDataSource; + // set the pool and get a Poolled Datasource + poolProperties.setDataSource(nativeDS); + outputDataSource = new org.apache.tomcat.jdbc.pool.DataSource(poolProperties); + return outputDataSource; } @Override public XADataSource getXADataSource(DataSourcePoolPropertiesComplexType dspProperties) { - return (XADataSource) this.getDataSource(dspProperties); + return (XADataSource) this.getDataSource(dspProperties); } /* List to Map is an internal methode used to convert a List to a Map. @@ -278,5 +277,5 @@ public class DataSourcePoolFactoryimpl implements DataSourcePoolFactory { mapFields.put(fieldName, field); } return mapFields; - } + } } diff --git a/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/jndi/impl/InitialContexFactoryImpl.java b/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/jndi/impl/InitialContexFactoryImpl.java index f7faa3a..fd2a8ed 100644 --- a/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/jndi/impl/InitialContexFactoryImpl.java +++ b/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/jndi/impl/InitialContexFactoryImpl.java @@ -58,9 +58,9 @@ public class InitialContexFactoryImpl implements InitialContextFactory { public Context getInitialContext(Hashtable environment) throws NamingException { Map datasourceMap = new HashMap(); String methodName = "getInitialContext"; - // /* Contect 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 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); @@ -183,7 +183,11 @@ public class InitialContexFactoryImpl implements InitialContextFactory { /* Check if datasource is not null then put in the context since exception are catch */ if (null != dataSource) { datasourceMap.put(dbConnectorName, dataSource); - initialContext.rebind(jndiName, 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}); } diff --git a/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/utils/Bundle.properties b/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/utils/Bundle.properties new file mode 100644 index 0000000..a6df13a --- /dev/null +++ b/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/utils/Bundle.properties @@ -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 \ No newline at end of file diff --git a/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/utils/OEContext.xml b/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/utils/OEContext.xml new file mode 100644 index 0000000..a1486a0 --- /dev/null +++ b/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/utils/OEContext.xml @@ -0,0 +1,79 @@ + + + + + + + Derby Connector + org.apache.derby.jdbc.ClientDataSource40 + Datasource + DERBY + OpenESB Community + 10.7.1.1 + DBConnector for Derby + + + user + app + + + + password + app + + + + serverName + localhost + + + + portNumber + 1527 + + + + databaseName + sample + + + + + + initialSize + 11 + + + + maxActive + 20 + + + + maxIdle + 10 + + + + minIdle + 10 + + + + + + + Derby Connector + Derby01 + Datasource connection to Derby + + + diff --git a/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/utils/OEContext.xsd b/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/utils/OEContext.xsd new file mode 100644 index 0000000..3bcd09b --- /dev/null +++ b/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/utils/OEContext.xsd @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Datasource + + + + + XADatasource + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/utils/OEContextSample.xml b/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/utils/OEContextSample.xml new file mode 100644 index 0000000..b2a29c1 --- /dev/null +++ b/openesb-standalone-naming/src/main/java/net/openesb/standalone/naming/utils/OEContextSample.xml @@ -0,0 +1,208 @@ + + + + + + + MYSQL Connector + com.mysql.jdbc.jdbc2.optional.MysqlDataSource + Datasource + MYSQL + Oracle + 5.6 + DBConnector for MySQL + + + user + root + + + + password + password + + + + hostName + localhost + + + + port + 3306 + + + + databaseName + test + + + + + + initialSize + 11 + + + + maxActive + 20 + + + + maxIdle + 11 + + + + minIdle + 10 + + + + + + + Derby Connector + org.apache.derby.jdbc.ClientDataSource40 + Datasource + DERBY + OpenESB Community + 10.7.1.1 + DBConnector for Derby + + + user + app + + + + password + app + + + + serverName + localhost + + + + portNumber + 1527 + + + + databaseName + sample + + + + + + initialSize + 11 + + + + maxActive + 20 + + + + maxIdle + 10 + + + + minIdle + 10 + + + + + + + Postgres Connector + org.postgresql.ds.PGSimpleDataSource + Datasource + POSTGRESQL + Postgres + 9.1-90 + DBConnector for postgres + + + user + postgres + + + + password + password + + + + serverName + localhost + + + + portNumber + 5432 + + + + databaseName + postgres + + + + + + initialSize + 11 + + + + maxActive + 20 + + + + maxIdle + 10 + + + + minIdle + 10 + + + + + + + MYSQL Connector + MySQLServer01 + Datasource connection to MySQ + + + + Derby Connector + Derby01 + Datasource connection to Derby + + + + Postgres Connector + Postgres01 + Datasource connection to Postgres + +