User: olegnitz
Date: 01/04/19 16:37:30
Modified: castorjdo/src/main/org/jboss/jdo/castor CastorJDOImpl.java
CastorJDOImplMBean.java
Log:
CastorJDO configuraton moved from jboss.conf to jboss.jcml
Build scripts updated to work with for Ant 1.3 and Castor 0.9.2
Revision Changes Path
1.10 +69 -43
contrib/castorjdo/src/main/org/jboss/jdo/castor/CastorJDOImpl.java
Index: CastorJDOImpl.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/castorjdo/src/main/org/jboss/jdo/castor/CastorJDOImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- CastorJDOImpl.java 2001/02/08 00:22:34 1.9
+++ CastorJDOImpl.java 2001/04/19 23:37:30 1.10
@@ -50,7 +50,7 @@
* Castor JDO support
*
* @author Oleg Nitz ([EMAIL PROTECTED])
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
public class CastorJDOImpl extends ServiceMBeanSupport
implements DataObjects, ObjectFactory, Referenceable, Serializable,
@@ -58,56 +58,23 @@
private String _jndiName;
+ private String _dbConf;
+
private JDO _jdo = new JDO();
private String _dataSourceName;
- private static HashMap instances = new HashMap();
+ private static HashMap _instances = new HashMap();
private transient PrintWriter writer;
/**
- * Do JDO classes should be loader by the same class loader
- * as Castor classes?
+ * Do JDO classes should be loader by the global class loader
+ * (the same class loader as Castor classes)?
*/
- private boolean _sameClassLoader;
+ private boolean _commonClassPath;
public CastorJDOImpl() {
- // Instance being used as ObjectFactory
- }
-
- public CastorJDOImpl(String dbConf, String jndiName, Integer lockTimeout,
Boolean logging)
- throws Exception {
- this(dbConf, jndiName, lockTimeout, logging, Boolean.FALSE);
- }
-
- public CastorJDOImpl(String dbConf, String jndiName, Integer lockTimeout,
- Boolean logging, Boolean sameClassLoader) throws Exception
{
- org.exolab.castor.jdo.conf.Database database;
- Unmarshaller unm;
- int pos;
- int timeout = 0;
-
- _jndiName = jndiName;
- _jdo.setTransactionManager("java:/TransactionManager");
- _jdo.setConfiguration(dbConf);
- unm = new Unmarshaller(org.exolab.castor.jdo.conf.Database.class);
- database = (org.exolab.castor.jdo.conf.Database) unm.unmarshal(new
InputSource(dbConf));
- _jdo.setDatabaseName(database.getName());
- if (database.getJndi() != null) {
- _dataSourceName = database.getJndi().getName();
- }
- if (lockTimeout != null) {
- timeout = lockTimeout.intValue();
- }
- if (timeout > 0) {
- _jdo.setLockTimeout(timeout);
- }
- if (logging != null && logging.booleanValue()) {
- _jdo.setLogInterceptor(this);
- }
- instances.put(jndiName, this);
- _sameClassLoader = sameClassLoader.booleanValue();
}
public ObjectName getObjectName(MBeanServer server, ObjectName name)
@@ -119,10 +86,24 @@
return "CastorJDO";
}
- public void initService() throws Exception {
+ public void startService() throws Exception {
+ org.exolab.castor.jdo.conf.Database database;
+ Unmarshaller unm;
+ int pos;
+
// Bind in JNDI
bind(new InitialContext(), "java:/" + _jndiName, this);
log.debug("DataObjects factory for " + _dataSourceName + " bound to " +
_jndiName);
+
+ _jdo.setTransactionManager("java:/TransactionManager");
+ _jdo.setConfiguration(_dbConf);
+ unm = new Unmarshaller(org.exolab.castor.jdo.conf.Database.class);
+ database = (org.exolab.castor.jdo.conf.Database) unm.unmarshal(new
InputSource(_dbConf));
+ _jdo.setDatabaseName(database.getName());
+ if (database.getJndi() != null) {
+ _dataSourceName = database.getJndi().getName();
+ }
+ _instances.put(_jndiName, this);
}
public void stopService() {
@@ -132,11 +113,56 @@
} catch (NamingException e) {
}
}
+
+
+ // CastorJDOImplMBean implementation ---------------------------
+
+ public void setJndiName(String jndiName) {
+ _jndiName = jndiName;
+ }
+
+ public String getJndiName() {
+ return _jndiName;
+ }
+
+ public void setConfiguration(String dbConf) {
+ _dbConf = dbConf;
+ }
+
+ public String getConfiguration() {
+ return _dbConf;
+ }
+
+ public void setLockTimeout(int lockTimeout) {
+ _jdo.setLockTimeout(lockTimeout);
+ }
+
+ public int getLockTimeout() {
+ return _jdo.getLockTimeout();
+ }
+
+ public void setLoggingEnabled(boolean loggingEnabled) {
+ _jdo.setLogInterceptor(loggingEnabled ? this : null);
+ }
+
+ public boolean getLoggingEnabled() {
+ return (_jdo.getLogInterceptor() != null);
+ }
+ public void setCommonClassPath(boolean commonClassPath) {
+ _commonClassPath = commonClassPath;
+ }
+
+ public boolean getCommonClassPath() {
+ return _commonClassPath;
+ }
+
// DataObjects implementation ----------------------------------
public Database getDatabase()
throws DatabaseNotFoundException, PersistenceException {
- if (!_sameClassLoader) {
+ if (_commonClassPath) {
+ _jdo.setClassLoader(null);
+ } else {
_jdo.setClassLoader(Thread.currentThread().getContextClassLoader());
}
return _jdo.getDatabase();
@@ -163,7 +189,7 @@
Context nameCtx,
Hashtable environment)
throws Exception {
- return instances.get(name.toString());
+ return _instances.get(name.toString());
}
// Private -------------------------------------------------------
1.3 +21 -1
contrib/castorjdo/src/main/org/jboss/jdo/castor/CastorJDOImplMBean.java
Index: CastorJDOImplMBean.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/castorjdo/src/main/org/jboss/jdo/castor/CastorJDOImplMBean.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CastorJDOImplMBean.java 2001/01/04 09:52:12 1.2
+++ CastorJDOImplMBean.java 2001/04/19 23:37:30 1.3
@@ -11,10 +11,30 @@
* Castor JDO support
*
* @author Oleg Nitz ([EMAIL PROTECTED])
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public interface CastorJDOImplMBean
extends org.jboss.util.ServiceMBean
{
public static final String OBJECT_NAME = ":service=CastorJDO";
+
+ public void setJndiName(String jndiName);
+
+ public String getJndiName();
+
+ public void setConfiguration(String dbConf);
+
+ public String getConfiguration();
+
+ public void setLockTimeout(int lockTimeout);
+
+ public int getLockTimeout();
+
+ public void setLoggingEnabled(boolean loggingEnabled);
+
+ public boolean getLoggingEnabled();
+
+ public void setCommonClassPath(boolean commonClassPath);
+
+ public boolean getCommonClassPath();
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development