User: oberg   
  Date: 00/11/07 04:20:07

  Modified:    src/main/org/jboss/jdbc XADataSourceLoader.java
  Log:
  Uses java: namespace to find TM and bind pools
  Removed default constructor (seemed like a very dangerous one)
  Name of MBean is now datasource name instead of generic one. Will help separate them 
in logs
  
  Revision  Changes    Path
  1.12      +12 -8     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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XADataSourceLoader.java   2000/10/05 01:36:33     1.11
  +++ XADataSourceLoader.java   2000/11/07 12:20:07     1.12
  @@ -29,7 +29,7 @@
    * 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.11 $
  + * @version $Revision: 1.12 $
    * @author Aaron Mulder ([EMAIL PROTECTED])
    */
   public class XADataSourceLoader extends ServiceMBeanSupport
  @@ -37,7 +37,10 @@
       private XAPoolDataSource source;
       private String url;
   
  +/*
  +// RO: This seems like a dangerous constructor, since the instance would be 
inconsistently init.-ed    
       public XADataSourceLoader() {}
  +*/
   
       public XADataSourceLoader(String poolName, String xaDataSourceClass) {
           source = new XAPoolDataSource();
  @@ -237,14 +240,15 @@
       }
   
       public ObjectName getObjectName(MBeanServer parm1, ObjectName parm2) throws 
javax.management.MalformedObjectNameException {
  -        return new ObjectName(OBJECT_NAME+",name="+source.getPoolName());
  +        return (parm2 == null) ? new 
ObjectName(OBJECT_NAME+",name="+source.getPoolName()) : parm2;
       }
   
       public String getName() {
  -        return "XADataSource";
  +        return source.getPoolName();
       }
   
       public void startService() throws Exception {
  +    
           initializePool();
       }
   
  @@ -252,7 +256,7 @@
           // Unbind from JNDI
           try {
               String name = source.getPoolName();
  -            new InitialContext().unbind(name);
  +            new InitialContext().unbind("java:/"+name);
               log.log("XA Connection pool "+name+" removed from JNDI");
               source.close();
               log.log("XA Connection pool "+name+" shut down");
  @@ -266,19 +270,19 @@
       private void initializePool() throws NamingException, SQLException {
           Context ctx = null;
           Object mgr = null;
  -        source.setTransactionManagerJNDIName("TransactionManager");
  +        source.setTransactionManagerJNDIName("java:/TransactionManager");
           try {
               ctx = new InitialContext();
  -            mgr = ctx.lookup("TransactionManager");
  +            mgr = ctx.lookup("java:/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(), source.getPoolName(), source);
  +        bind(new InitialContext(), "java:/"+source.getPoolName(), source);
   
  -        log.log("XA Connection pool "+source.getPoolName()+" bound to 
"+source.getPoolName());
  +        log.log("XA Connection pool "+source.getPoolName()+" bound to 
java:/"+source.getPoolName());
   
           // Test database
           source.getConnection().close();
  
  
  

Reply via email to