ESBCOMP-89 Check if the MBean for datasource creation under GFv2 exists
parent
c3c7ebbe2f
commit
eab57bbd5a
|
@ -43,18 +43,22 @@ import javax.naming.InitialContext;
|
||||||
import com.sun.jbi.engine.bpel.core.bpel.connection.ConnectionConfiguration;
|
import com.sun.jbi.engine.bpel.core.bpel.connection.ConnectionConfiguration;
|
||||||
import com.sun.jbi.engine.bpel.core.bpel.exception.BPELConfigurationException;
|
import com.sun.jbi.engine.bpel.core.bpel.exception.BPELConfigurationException;
|
||||||
import com.sun.jbi.engine.bpel.util.I18n;
|
import com.sun.jbi.engine.bpel.util.I18n;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.management.MalformedObjectNameException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implemetation of the BPEL engine com.sun.jbi.engine.bpel.core.bpel.connection.ConnectionConfiguration
|
* Implemetation of the BPEL engine
|
||||||
* interface. This Appserver context in which the BPEL engine resides, has the knowledge to create, configure
|
* com.sun.jbi.engine.bpel.core.bpel.connection.ConnectionConfiguration
|
||||||
* and maintain the connection pools and jdbc resources.
|
* interface. This Appserver context in which the BPEL engine resides, has the
|
||||||
* This class can be extended to implement all the connection requirements like schema creation, etc that
|
* knowledge to create, configure and maintain the connection pools and jdbc
|
||||||
* the BPEL engine needs.
|
* resources. This class can be extended to implement all the connection
|
||||||
|
* requirements like schema creation, etc that the BPEL engine needs.
|
||||||
*
|
*
|
||||||
* Currently this class is used as an user friendly utility to programmatically create connection pools and
|
* Currently this class is used as an user friendly utility to programmatically
|
||||||
* resources for the the Derby DB. This is done so that a user wanting to try out the product does not have
|
* create connection pools and resources for the the Derby DB. This is done so
|
||||||
* to worry about these connection configurations.
|
* that a user wanting to try out the product does not have to worry about these
|
||||||
* This could be extended to all other DB that are supported with proper design.
|
* connection configurations. This could be extended to all other DB that are
|
||||||
|
* supported with proper design.
|
||||||
*
|
*
|
||||||
* @author Sun Microsystems.
|
* @author Sun Microsystems.
|
||||||
*
|
*
|
||||||
|
@ -70,7 +74,6 @@ public class ConnectionConfigurationImpl implements ConnectionConfiguration {
|
||||||
private static final String PASSWORD = "pass2";
|
private static final String PASSWORD = "pass2";
|
||||||
private static final String SERVER_NAME = "localhost"; //default is taken as the localhost where Derby DB is running
|
private static final String SERVER_NAME = "localhost"; //default is taken as the localhost where Derby DB is running
|
||||||
private static final String PORT_NUM = "1527"; // Derby DB port number (taken as the default.
|
private static final String PORT_NUM = "1527"; // Derby DB port number (taken as the default.
|
||||||
|
|
||||||
private ComponentContext mComponentContext;
|
private ComponentContext mComponentContext;
|
||||||
private Properties mProperties;
|
private Properties mProperties;
|
||||||
|
|
||||||
|
@ -83,7 +86,20 @@ public class ConnectionConfigurationImpl implements ConnectionConfiguration {
|
||||||
* @see com.sun.jbi.engine.bpel.core.bpel.connection.ConnectionConfiguration#createConnections()
|
* @see com.sun.jbi.engine.bpel.core.bpel.connection.ConnectionConfiguration#createConnections()
|
||||||
*/
|
*/
|
||||||
public void createConnectionsPools() {
|
public void createConnectionsPools() {
|
||||||
|
boolean mBeanAvailable = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
MBeanServer mBeanServer = mComponentContext.getMBeanServer();
|
||||||
|
|
||||||
|
Set<ObjectName> objectNames = mBeanServer.queryNames(
|
||||||
|
new ObjectName(RESOURCES_MBEAN_OBJ_NAME), null);
|
||||||
|
|
||||||
|
mBeanAvailable = !objectNames.isEmpty();
|
||||||
|
} catch (MalformedObjectNameException ex) {
|
||||||
|
// Nothing to do here... we are not running under Glassfish v2
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mBeanAvailable) {
|
||||||
try {
|
try {
|
||||||
String nonXaJndiResName = mProperties.getProperty(DatabaseNonXAJNDIName);
|
String nonXaJndiResName = mProperties.getProperty(DatabaseNonXAJNDIName);
|
||||||
String xaJndiResName = mProperties.getProperty(DatabaseXAJNDIName);
|
String xaJndiResName = mProperties.getProperty(DatabaseXAJNDIName);
|
||||||
|
@ -104,6 +120,7 @@ public class ConnectionConfigurationImpl implements ConnectionConfiguration {
|
||||||
throw new BPELConfigurationException(message);
|
throw new BPELConfigurationException(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see com.sun.jbi.engine.bpel.core.bpel.connection.ConnectionConfiguration#getNamingContext()
|
* @see com.sun.jbi.engine.bpel.core.bpel.connection.ConnectionConfiguration#getNamingContext()
|
||||||
|
@ -112,17 +129,18 @@ public class ConnectionConfigurationImpl implements ConnectionConfiguration {
|
||||||
return mComponentContext.getNamingContext();
|
return mComponentContext.getNamingContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method creates a connection pool and a jdbc resource pointing to that pool
|
* This method creates a connection pool and a jdbc resource pointing to
|
||||||
* if the pool is not already created.
|
* that pool if the pool is not already created. Use non public, non
|
||||||
* Use non public, non published apis to lookup and create the pools and resources.
|
* published apis to lookup and create the pools and resources. Hence it is
|
||||||
* Hence it is liable to change as and when the api's change.
|
* liable to change as and when the api's change.
|
||||||
*
|
*
|
||||||
* @param connPoolName, String value for the connection pool name.
|
* @param connPoolName, String value for the connection pool name.
|
||||||
* @param jndiResName, String value for the Jdbc jndi resource name.
|
* @param jndiResName, String value for the Jdbc jndi resource name.
|
||||||
* @param dataSrcClassName, String value of the actual datasource class name.
|
* @param dataSrcClassName, String value of the actual datasource class
|
||||||
* @param resourceType, String value of the resource type. ex: javax.sql.DataSource
|
* name.
|
||||||
|
* @param resourceType, String value of the resource type. ex:
|
||||||
|
* javax.sql.DataSource
|
||||||
* @param isXA, boolean value indicating if this is a XA connection
|
* @param isXA, boolean value indicating if this is a XA connection
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@ -143,8 +161,8 @@ public class ConnectionConfigurationImpl implements ConnectionConfiguration {
|
||||||
try {
|
try {
|
||||||
retRes = mBeanServer.invoke(configObjName,
|
retRes = mBeanServer.invoke(configObjName,
|
||||||
"getJdbcResourceByJndiName",
|
"getJdbcResourceByJndiName",
|
||||||
new Object[] { jndiResName },
|
new Object[]{jndiResName},
|
||||||
new String[] { String.class.getName() });
|
new String[]{String.class.getName()});
|
||||||
|
|
||||||
} catch (Exception resourceExec) {
|
} catch (Exception resourceExec) {
|
||||||
// if the JDBC Resource is not present then the above call throws an exception
|
// if the JDBC Resource is not present then the above call throws an exception
|
||||||
|
@ -165,8 +183,8 @@ public class ConnectionConfigurationImpl implements ConnectionConfiguration {
|
||||||
try {
|
try {
|
||||||
retPool = mBeanServer.invoke(configObjName,
|
retPool = mBeanServer.invoke(configObjName,
|
||||||
"getJdbcConnectionPoolByName",
|
"getJdbcConnectionPoolByName",
|
||||||
new Object[] { connPoolName },
|
new Object[]{connPoolName},
|
||||||
new String[] { String.class.getName() });
|
new String[]{String.class.getName()});
|
||||||
|
|
||||||
} catch (Exception poolExec) {
|
} catch (Exception poolExec) {
|
||||||
// if the connPoolName is not there the above call throws an exception
|
// if the connPoolName is not there the above call throws an exception
|
||||||
|
@ -229,10 +247,10 @@ public class ConnectionConfigurationImpl implements ConnectionConfiguration {
|
||||||
|
|
||||||
// create the connection pool
|
// create the connection pool
|
||||||
mBeanServer.invoke(configObjName, "createJdbcConnectionPool",
|
mBeanServer.invoke(configObjName, "createJdbcConnectionPool",
|
||||||
new Object[] { attrList, props, "domain" }, new String[] {
|
new Object[]{attrList, props, "domain"}, new String[]{
|
||||||
javax.management.AttributeList.class.getName(),
|
javax.management.AttributeList.class.getName(),
|
||||||
java.util.Properties.class.getName(),
|
java.util.Properties.class.getName(),
|
||||||
String.class.getName() });
|
String.class.getName()});
|
||||||
} else {
|
} else {
|
||||||
// the connection pool exits, log it.
|
// the connection pool exits, log it.
|
||||||
if (LOGGER.isLoggable(Level.FINE)) {
|
if (LOGGER.isLoggable(Level.FINE)) {
|
||||||
|
@ -251,10 +269,10 @@ public class ConnectionConfigurationImpl implements ConnectionConfiguration {
|
||||||
// create the JNDI JDBC resource
|
// create the JNDI JDBC resource
|
||||||
mBeanServer.invoke(configObjName,
|
mBeanServer.invoke(configObjName,
|
||||||
"createJdbcResource",
|
"createJdbcResource",
|
||||||
new Object[] { attrList2, new Properties(), "server" },
|
new Object[]{attrList2, new Properties(), "server"},
|
||||||
new String[] { javax.management.AttributeList.class.getName(),
|
new String[]{javax.management.AttributeList.class.getName(),
|
||||||
java.util.Properties.class.getName(),
|
java.util.Properties.class.getName(),
|
||||||
String.class.getName() });
|
String.class.getName()});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue