User: oberg   
  Date: 00/12/07 08:19:29

  Modified:    src/main/org/jboss/jms/asf ServerSessionPoolLoader.java
                        ServerSessionPoolLoaderMBean.java
  Log:
  Fixed JMS MBeans to work with new configuration scheme
  Formatting of source
  
  Revision  Changes    Path
  1.2       +102 -84   jboss/src/main/org/jboss/jms/asf/ServerSessionPoolLoader.java
  
  Index: ServerSessionPoolLoader.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/jms/asf/ServerSessionPoolLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServerSessionPoolLoader.java      2000/12/06 12:52:35     1.1
  +++ ServerSessionPoolLoader.java      2000/12/07 16:19:29     1.2
  @@ -39,88 +39,106 @@
    * @version
    */
   
  -public class ServerSessionPoolLoader extends ServiceMBeanSupport
  -        implements ServerSessionPoolLoaderMBean{
  -    private ServerSessionPoolFactory poolFactory;
  -    public ServerSessionPoolLoader(String name, String poolFactoryClass) {
  -        try {
  -            Class cls = Class.forName(poolFactoryClass);
  -            poolFactory = (ServerSessionPoolFactory)cls.newInstance();
  -        } catch(Exception e) {
  -            Logger.exception(e);
  -            throw new RuntimeException("Unable to initialize 
ServerSessionPoolFactory '"+name+"': "+e);
  -        }
  -     poolFactory.setName(name);
  -     
  -     
  -    }
  -     public ObjectName getObjectName(MBeanServer parm1, ObjectName parm2) throws 
javax.management.MalformedObjectNameException {
  -        return (parm2 == null) ? new 
ObjectName(OBJECT_NAME+",name="+poolFactory.getName()) : parm2;
  -    }
  -
  -    public String getName() {
  -        return poolFactory.getName();
  -    }
  -    public void startService() throws Exception {
  -    
  -        initializeAdapter();
  -    }
  -
  -    public void stopService() {
  -        // Unbind from JNDI
  -        try {
  -            String name = poolFactory.getName();
  -            new InitialContext().unbind("java:/"+name);
  -            log.log("JMA Provider Adapter "+name+" removed from JNDI");
  -            //source.close();
  -            //log.log("XA Connection pool "+name+" shut down");
  -        } catch (NamingException e) {
  -            // Ignore
  -        }
  -    }
  -
  -     // Private -------------------------------------------------------
  -
  -    private void initializeAdapter() throws NamingException {
  -        Context ctx = null;
  -        Object mgr = null;
  -
  -     /*
  -        source.setTransactionManagerJNDIName("java:/TransactionManager");
  -        try {
  -            ctx = new InitialContext();
  -            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(), "java:/"+poolFactory.getName(),poolFactory);
  -
  -        log.log("JMS provider Adapter "+poolFactory.getName()+" bound to 
java:/"+poolFactory.getName());
  -
  -   
  -    }
  -
  -    private void bind(Context ctx, String name, Object val) throws NamingException {
  -        // Bind val to name in ctx, and make sure that all intermediate contexts 
exist
  -        Name n = ctx.getNameParser("").parse(name);
  -        while (n.size() > 1) {
  -            String ctxName = n.get(0);
  -            try {
  -                ctx = (Context)ctx.lookup(ctxName);
  -            } catch (NameNotFoundException e) {
  -                ctx = ctx.createSubcontext(ctxName);
  -            }
  -            n = n.getSuffix(1);
  -        }
  -
  -        ctx.bind(n.get(0), val);
  -    }
  -    public static void main(String[] args) {
  -     
  -    }
  -    
  +public class ServerSessionPoolLoader 
  +   extends ServiceMBeanSupport
  +   implements ServerSessionPoolLoaderMBean
  +{
  +   private ServerSessionPoolFactory poolFactory;
  +   private String name;
  +   private String poolFactoryClass;
  +   
  +   public void setPoolName(String name)
  +   {
  +      this.name = name;
  +   }
  +   
  +   public String getPoolName()
  +   {
  +      return name;
  +   }
  +   
  +   public void setPoolFactoryClass(String clazz)
  +   {
  +      this.poolFactoryClass = clazz;
  +   }
  +   
  +   public String getPoolFactoryClass()
  +   {
  +      return poolFactoryClass;
  +   }
  +   
  +   public ObjectName getObjectName(MBeanServer parm1, ObjectName parm2) 
  +      throws javax.management.MalformedObjectNameException
  +   {
  +      return (parm2 == null) ? new ObjectName(OBJECT_NAME) : parm2;
  +   }
  +
  +   public String getName()
  +   {
  +      return name;
  +   }
  +   
  +   public void initService()
  +      throws Exception
  +   {
  +      Class cls = Class.forName(poolFactoryClass);
  +      poolFactory = (ServerSessionPoolFactory)cls.newInstance();
  +      poolFactory.setName(name);
  +   }
  +   
  +   public void startService() 
  +      throws Exception
  +   {
  +      Context ctx = null;
  +      Object mgr = null;
  +
  +      // Bind in JNDI
  +      bind(new InitialContext(), "java:/"+poolFactory.getName(),poolFactory);
  +
  +      log.log("JMS provider Adapter "+poolFactory.getName()+" bound to 
java:/"+poolFactory.getName());
  +   }
  +
  +   public void stopService()
  +   {
  +      // Unbind from JNDI
  +      try 
  +      {
  +         String name = poolFactory.getName();
  +         new InitialContext().unbind("java:/"+name);
  +         log.log("JMA Provider Adapter "+name+" removed from JNDI");
  +         //source.close();
  +         //log.log("XA Connection pool "+name+" shut down");
  +      } catch (NamingException e)
  +      {
  +         // Ignore
  +      }
  +   }
  +
  +   // Private -------------------------------------------------------
  +
  +   private void bind(Context ctx, String name, Object val) throws NamingException
  +   {
  +      // Bind val to name in ctx, and make sure that all intermediate contexts exist
  +      Name n = ctx.getNameParser("").parse(name);
  +      while (n.size() > 1)
  +      {
  +         String ctxName = n.get(0);
  +         try
  +         {
  +            ctx = (Context)ctx.lookup(ctxName);
  +         } catch (NameNotFoundException e)
  +         {
  +            ctx = ctx.createSubcontext(ctxName);
  +         }
  +         n = n.getSuffix(1);
  +      }
  +
  +      ctx.bind(n.get(0), val);
  +   }
  +   
  +   public static void main(String[] args)
  +   {
  +
  +   }
  +
   } // ServerSessionPoolLoader
  
  
  
  1.2       +13 -3     
jboss/src/main/org/jboss/jms/asf/ServerSessionPoolLoaderMBean.java
  
  Index: ServerSessionPoolLoaderMBean.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/jms/asf/ServerSessionPoolLoaderMBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServerSessionPoolLoaderMBean.java 2000/12/06 12:52:35     1.1
  +++ ServerSessionPoolLoaderMBean.java 2000/12/07 16:19:29     1.2
  @@ -28,6 +28,16 @@
    * @version
    */
   
  -public interface ServerSessionPoolLoaderMBean extends ServiceMBean {
  -    public static final String OBJECT_NAME = ":service=ServerSessionPoolMBean";
  -} // ServerSessionPoolLoaderMBean
  +public interface ServerSessionPoolLoaderMBean 
  +   extends ServiceMBean 
  +{
  +   public static final String OBJECT_NAME = ":service=ServerSessionPoolMBean";
  +
  +   public void setPoolName(String name);
  +   
  +   public String getPoolName();
  +   
  +   public void setPoolFactoryClass(String clazz);
  +   
  +   public String getPoolFactoryClass();
  +}
  
  
  

Reply via email to