User: mulder
Date: 00/06/19 20:22:05
Modified: src/main/org/jboss/jdbc XADataSourceLoader.java
XADataSourceLoaderMBean.java
Log:
Update Minerva XA MBeans to use new configuration architecture.
Make build script copy JCML configuration file.
Add "long" variables to configuration architecture.
This still won't work unless you're lucky due to dependency on
TransactionManager being loaded beforehand.
Revision Changes Path
1.3 +154 -36 jboss/src/main/org/jboss/jdbc/XADataSourceLoader.java
Index: XADataSourceLoader.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/jdbc/XADataSourceLoader.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XADataSourceLoader.java 2000/06/07 23:09:07 1.2
+++ XADataSourceLoader.java 2000/06/20 03:22:04 1.3
@@ -22,69 +22,175 @@
* pool generates connections that are registered with the current Transaction
* and support two-phase commit. The constructors are called by the JMX engine
* based on your MLET tags.
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
* @author Aaron Mulder ([EMAIL PROTECTED])
*/
public class XADataSourceLoader extends ServiceMBeanSupport
implements XADataSourceLoaderMBean {
private XAPoolDataSource source;
- public XADataSourceLoader() {
- }
- public XADataSourceLoader(String poolName, String xaDataSourceClass, String
url, String username, String password, String properties, Integer minSize, Integer
maxSize) {
- this(poolName, xaDataSourceClass, url, username, password, properties,
minSize, maxSize, "");
- }
- public XADataSourceLoader(String poolName, String xaDataSourceClass, String
url, String username, String password, String properties, Integer minSize, Integer
maxSize, String poolParameters) {
+ public XADataSourceLoader() {}
+
+ public XADataSourceLoader(String poolName, String xaDataSourceClass) {
source = new XAPoolDataSource();
source.setPoolName(poolName);
-
- Context ctx = null;
- Object mgr = null;
- try {
- ctx = new InitialContext();
- mgr = ctx.lookup("TransactionManager");
-// log.log("XADataSourceLoader found Tx manager "+mgr);
- } catch(NamingException e) {
- throw new IllegalStateException("There is no TransactionManager in
JNDI!");
- }
-
XADataSource vendorSource = null;
try {
Class cls = Class.forName(xaDataSourceClass);
vendorSource = (XADataSource)cls.newInstance();
+ PrintWriter writer = new LogWriter(log);
+ vendorSource.setLogWriter(writer);
+ source.setLogWriter(writer);
+ } catch(Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("Unable to initialize XA database pool
'"+poolName+"': "+e);
+ }
+ source.setDataSource(vendorSource);
+ }
+
+ public void setURL(String url) {
+ XADataSource vendorSource = (XADataSource)source.getDataSource();
+ try {
+ Class cls = vendorSource.getClass();
if(url != null && url.length() > 0) {
Method setURL = cls.getMethod("setURL", new Class[]{String.class});
setURL.invoke(vendorSource, new Object[]{url});
}
+ } catch(Exception e) {
+ throw new IllegalArgumentException("Unable to set url to '"+url+"' for
pool "+source.getPoolName()+": "+e);
+ }
+ }
+
+ public String getURL() {
+ XADataSource vendorSource = (XADataSource)source.getDataSource();
+ try {
+ Class cls = vendorSource.getClass();
+ Method getURL = cls.getMethod("getURL", new Class[0]);
+ return (String) getURL.invoke(vendorSource, new Object[0]);
+ } catch(Exception e) {
+ return "";
+ }
+ }
+
+ public void setProperties(String properties) {
+ XADataSource vendorSource = (XADataSource)source.getDataSource();
+ try {
+ Class cls = vendorSource.getClass();
if(properties != null && properties.length() > 0) {
Properties props = parseProperties(properties);
Method setProperties = cls.getMethod("setProperties", new
Class[]{Properties.class});
setProperties.invoke(vendorSource, new Object[]{props});
}
} catch(Exception e) {
- e.printStackTrace();
+ throw new IllegalArgumentException("Unable to set proprties to
'"+properties+"' for pool "+source.getPoolName()+": "+e);
}
- source.setDataSource(vendorSource);
- if(username != null && username.length() > 0)
- source.setJDBCUser(username);
+ }
+
+ public String getProperties() {
+ return "";
+ }
+
+ public void setJDBCUser(String userName) {
+ if(userName != null && userName.length() > 0)
+ source.setJDBCUser(userName);
+ }
+
+ public String getJDBCUser() {
+ String user = source.getJDBCUser();
+ return user;
+ }
+
+ public void setPassword(String password) {
if(password != null && password.length() > 0)
source.setJDBCPassword(password);
- source.setMinSize(minSize.intValue());
- source.setMaxSize(maxSize.intValue());
- source.setTransactionManagerJNDIName("TransactionManager");
- setAdditionalProperties(parseProperties(poolParameters));
- try {
- PrintWriter writer = new LogWriter(log);
- vendorSource.setLogWriter(writer);
- source.setLogWriter(writer);
- } catch(java.sql.SQLException e) {
- e.printStackTrace();
- }
- source.initialize();
}
+ public String getPassword() {
+ return source.getJDBCPassword();
+ }
+
+ public void setMinSize(int minSize) {
+ source.setMinSize(minSize);
+ }
+
+ public int getMinSize() {
+ return source.getMinSize();
+ }
+
+ public void setMaxSize(int maxSize) {
+ source.setMaxSize(maxSize);
+ }
+
+ public int getMaxSize() {
+ return source.getMaxSize();
+ }
+
+ public void setBlocking(boolean blocking) {
+ source.setBlocking(blocking);
+ }
+
+ public boolean isBlocking() {
+ return source.isBlocking();
+ }
+
+ public void setGCEnabled(boolean gcEnabled) {
+ source.setGCEnabled(gcEnabled);
+ }
+
+ public boolean isGCEnabled() {
+ return source.isGCEnabled();
+ }
+
+ public void setGCInterval(long interval) {
+ source.setGCInterval(interval);
+ }
+
+ public long getGCInterval() {
+ return source.getGCInterval();
+ }
+
+ public void setGCMinIdleTime(long idleMillis) {
+ source.setGCMinIdleTime(idleMillis);
+ }
+
+ public long getGCMinIdleTime() {
+ return source.getGCMinIdleTime();
+ }
+
+ public void setShrinkingEnabled(boolean enabled) {
+ source.setShrinkingEnabled(enabled);
+ }
+
+ public boolean isShrinkingEnabled() {
+ return source.isShrinkingEnabled();
+ }
+
+ public void setShrinkMinIdleTime(long idleMillis) {
+ source.setShrinkMinIdleTime(idleMillis);
+ }
+
+ public long getShrinkMinIdleTime() {
+ return source.getShrinkMinIdleTime();
+ }
+
+ public void setShrinkPercent(float percent) {
+ source.setShrinkPercent(percent);
+ }
+
+ public float getShrinkPercent() {
+ return source.getShrinkPercent();
+ }
+
+ public void setTimestampUsed(boolean timestamp) {
+ source.setTimestampUsed(timestamp);
+ }
+
+ public boolean isTimestampUsed() {
+ return source.isTimestampUsed();
+ }
+
public ObjectName getObjectName(MBeanServer parm1, ObjectName parm2) throws
javax.management.MalformedObjectNameException {
- return new ObjectName(OBJECT_NAME+",name="+source.getJNDIName());
+ return new ObjectName(OBJECT_NAME+",name="+source.getPoolName());
}
public String getName() {
@@ -92,6 +198,17 @@
}
public void startService() throws Exception {
+ Context ctx = null;
+ Object mgr = null;
+ source.setTransactionManagerJNDIName("TransactionManager");
+ try {
+ ctx = new InitialContext();
+ mgr = ctx.lookup("TransactionManager");
+ } catch(NamingException e) {
+ throw new IllegalStateException("Cannot start XA Connection Pool; there
is no TransactionManager in JNDI!");
+ }
+ source.initialize();
+
// Bind in JNDI
bind(new InitialContext(), "xa."+source.getPoolName(), source);
@@ -151,7 +268,7 @@
}
props.setProperty(property.substring(0, pos), property.substring(pos+1));
}
-
+/*
private void setAdditionalProperties(Properties props) {
Iterator it = props.keySet().iterator();
while(it.hasNext()) {
@@ -191,4 +308,5 @@
if(source.equals(Byte.TYPE)) return Byte.class;
return null;
}
+*/
}
1.2 +28 -0 jboss/src/main/org/jboss/jdbc/XADataSourceLoaderMBean.java
Index: XADataSourceLoaderMBean.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/jdbc/XADataSourceLoaderMBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XADataSourceLoaderMBean.java 2000/06/02 13:48:38 1.1
+++ XADataSourceLoaderMBean.java 2000/06/20 03:22:04 1.2
@@ -13,4 +13,32 @@
public static final String OBJECT_NAME = ":service=XADataSource";
// Public --------------------------------------------------------
+ public void setURL(String url);
+ public String getURL();
+ public void setJDBCUser(String userName);
+ public String getJDBCUser();
+ public void setPassword(String password);
+ public String getPassword();
+ public void setProperties(String properties);
+ public String getProperties();
+ public void setMinSize(int minSize);
+ public int getMinSize();
+ public void setMaxSize(int maxSize);
+ public int getMaxSize();
+ public void setBlocking(boolean blocking);
+ public boolean isBlocking();
+ public void setGCEnabled(boolean gcEnabled);
+ public boolean isGCEnabled();
+ public void setGCInterval(long interval);
+ public long getGCInterval();
+ public void setGCMinIdleTime(long idleMillis);
+ public long getGCMinIdleTime();
+ public void setShrinkingEnabled(boolean enabled);
+ public boolean isShrinkingEnabled();
+ public void setShrinkMinIdleTime(long idleMillis);
+ public long getShrinkMinIdleTime();
+ public void setShrinkPercent(float percent);
+ public float getShrinkPercent();
+ public void setTimestampUsed(boolean timestamp);
+ public boolean isTimestampUsed();
}