User: user57  
  Date: 01/07/06 18:01:45

  Modified:    src/main/org/jboss/jms/jndi JMSProviderAdapter.java
                        JMSProviderLoader.java
  Log:
   o added some logging to help debug a loader problem.
   o modified JMSProviderAdapter to extend from Serializable, since it is
     bound as one, perhaps it should be non-serializable?
  
  Revision  Changes    Path
  1.4       +18 -17    jboss/src/main/org/jboss/jms/jndi/JMSProviderAdapter.java
  
  Index: JMSProviderAdapter.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/jms/jndi/JMSProviderAdapter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JMSProviderAdapter.java   2001/06/22 22:41:21     1.3
  +++ JMSProviderAdapter.java   2001/07/07 01:01:45     1.4
  @@ -19,28 +19,29 @@
   
   import javax.naming.Context;
   import javax.naming.NamingException;
  +import java.io.Serializable;
   
   /**
    * JMSProviderAdapter.java
    *
  + * <p>Created: Wed Nov 29 14:15:07 2000
  + * 
  + * <p>6/22/01 - hchirino - The queue/topic jndi references are now configed via JMX
    *
  - * Created: Wed Nov 29 14:15:07 2000
  - * 6/22/01 - hchirino - The queue/topic jndi references are now configed via JMX
  - *
  - * @author 
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Hiram Chirino</a>
  - * @version
  + * @author  <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
  + * @version $Revision: 1.4 $
    */
  -
  -public interface JMSProviderAdapter {
  -     public Context getInitialContext() throws NamingException;
  -
  -     public void setName(String name);
  -     public String getName();
  -     public void setProviderUrl(String url);
  -     public String getProviderUrl();
  -     public String getQueueFactoryRef();
  -     public String getTopicFactoryRef();
  -     public void setQueueFactoryRef(String newQueueFactoryRef);
  -     public void setTopicFactoryRef(String newTopicFactoryRef);
  +public interface JMSProviderAdapter
  +   extends Serializable
  +{
  +   Context getInitialContext() throws NamingException;
  +   void setName(String name);
  +   String getName();
  +   void setProviderUrl(String url);
  +   String getProviderUrl();
  +   String getQueueFactoryRef();
  +   String getTopicFactoryRef();
  +   void setQueueFactoryRef(String newQueueFactoryRef);
  +   void setTopicFactoryRef(String newTopicFactoryRef);
   }
  
  
  
  1.5       +148 -111  jboss/src/main/org/jboss/jms/jndi/JMSProviderLoader.java
  
  Index: JMSProviderLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/jms/jndi/JMSProviderLoader.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JMSProviderLoader.java    2001/06/22 22:41:21     1.4
  +++ JMSProviderLoader.java    2001/07/07 01:01:45     1.5
  @@ -19,180 +19,217 @@
   
   import javax.management.ObjectName;
   import javax.management.MBeanServer;
  -
  +import javax.management.MalformedObjectNameException;
   import javax.naming.Context;
   import javax.naming.Name;
   import javax.naming.InitialContext;
   import javax.naming.NamingException;
   import javax.naming.NameNotFoundException;
   
  +import org.apache.log4j.Category;
  +
   import org.jboss.configuration.ConfigurationException;
   import org.jboss.util.ServiceMBeanSupport;
  -import org.jboss.logging.Logger;
   
   /**
  - * JMSProviderLoader.java
  + * A JMX service to load a JMSProviderAdapter and register it.
    *
  - * This is realy NOT a factory for pool's but simply a way of getting
  - * an object instantiated and bound in jndi
  - * Created: Wed Nov 29 14:07:07 2000
  - * 6/22/01 - hchirino - The queue/topic jndi references are now configed via JMX
  + * <p>Created: Wed Nov 29 14:07:07 2000
  + * 
  + * <p>6/22/01 - hchirino - The queue/topic jndi references are now configed via JMX
    *
  - * @author 
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Hiram Chirino</a>
  - * @version
  + * @author  <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
  + * @version $Revision: 1.5 $
    */
  -
   public class JMSProviderLoader 
      extends ServiceMBeanSupport
      implements JMSProviderLoaderMBean 
   {
  -   JMSProviderAdapter providerAdapter;
  -   
  -   String url;
  -   String providerName;
  -   String providerAdapterClass;
  -   String queueFactoryRef;
  -   String topicFactoryRef;
  +   /** Instance logger. */
  +   private final Category log = Category.getInstance(this.getClass());
  +
  +   /** The provider adapter which we are loading. */
  +   protected JMSProviderAdapter providerAdapter;
  +
  +   /** The provider url. */
  +   protected String url;
  +
  +   /** The provider name. */
  +   protected String providerName;
   
  +   /** The provider adapter classname. */
  +   protected String providerAdapterClass;
  +
  +   /** The queue factory jndi name. */
  +   protected String queueFactoryRef;
  +
  +   /** The topic factory jndi name. */   
  +   protected String topicFactoryRef;
  +
      public void setProviderName(String name)
      {
  -       this.providerName = name;
  +      this.providerName = name;
      }      
      
      public String getProviderName()
      {
  -       return providerName;
  +      return providerName;
      }      
      
      public void setProviderAdapterClass(String clazz)
      {
  -       providerAdapterClass = clazz;
  +      providerAdapterClass = clazz;
      }      
      
      public String getProviderAdapterClass()
      {
  -       return providerAdapterClass;
  +      return providerAdapterClass;
      }      
      
  -   public void setProviderUrl(String url)
  +   public void setProviderUrl(final String url)
      {
  -       this.url = url;
  +      this.url = url;
      }      
   
      public String getProviderUrl()
      {
  -       return url;
  -   }      
  +      return url;
  +   }
  +   
      public ObjectName getObjectName(MBeanServer parm1, ObjectName parm2) 
  -       throws javax.management.MalformedObjectNameException
  +      throws MalformedObjectNameException
      {
  -       return (parm2 == null) ? new ObjectName(OBJECT_NAME) : parm2;
  +      return (parm2 == null) ? new ObjectName(OBJECT_NAME) : parm2;
      }      
   
      public String getName()
      {
  -       return providerName;
  +      return providerName;
      }      
      
  -   public void initService() 
  -       throws Exception
  +   public void initService() throws Exception
      {
         // validate the configuration
         if (queueFactoryRef == null)
  -          throw new ConfigurationException
  -              ("missing required attribute: QueueFactoryRef");
  +         throw new ConfigurationException
  +            ("missing required attribute: QueueFactoryRef");
   
         if (topicFactoryRef == null)
  -          throw new ConfigurationException
  -              ("missing required attribute: TopicFactoryRef");
  +         throw new ConfigurationException
  +            ("missing required attribute: TopicFactoryRef");
          
  -       Class cls = Class.forName(providerAdapterClass);
  -       providerAdapter = (JMSProviderAdapter)cls.newInstance();
  -       providerAdapter.setName(providerName);
  -       providerAdapter.setProviderUrl(url);
  -       providerAdapter.setQueueFactoryRef(queueFactoryRef);
  -       providerAdapter.setTopicFactoryRef(topicFactoryRef);
  +      Class cls = Class.forName(providerAdapterClass);
  +      providerAdapter = (JMSProviderAdapter)cls.newInstance();
  +      providerAdapter.setName(providerName);
  +      providerAdapter.setProviderUrl(url);
  +      providerAdapter.setQueueFactoryRef(queueFactoryRef);
  +      providerAdapter.setTopicFactoryRef(topicFactoryRef);
      }            
      
  -   public void startService() 
  -       throws Exception
  +   public void startService() throws Exception
      {
  -       // Bind in JNDI
  -       bind(new InitialContext(), "java:/"+providerAdapter.getName(), 
providerAdapter);
  -
  -       log.log("JMS provider Adapter "+providerAdapter.getName()+" bound to 
java:/"+providerAdapter.getName());
  +      InitialContext context = new InitialContext();
  +      try {
  +         // Bind in JNDI
  +         String name = providerAdapter.getName();
  +         String jndiname = "java:/" + name;
  +         bind(context, jndiname, providerAdapter);
  +         log.info("bound adapter " + name + " to " + jndiname);
  +      }
  +      finally {
  +         context.close();
  +      }
      }      
   
      public void stopService()
      {
  -       // Unbind from JNDI
  -       try {
  -              String name = providerAdapter.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
  -       }
  +      InitialContext context = null;
  +      
  +      try {
  +         context = new InitialContext();
  +
  +         // Unbind from JNDI
  +         String name = providerAdapter.getName();
  +         String jndiname = "java:/" + name;
  +         context.unbind(jndiname);
  +         log.info("unbound adapter " + name + " from " + jndiname);
  +         
  +         //source.close();
  +         //log.log("XA Connection pool "+name+" shut down");
  +      }
  +      catch (Exception e) {
  +         log.warn("failed to unbind; ignoring", e);
  +      }
  +      finally {
  +         if (context != null) {
  +            try {
  +               context.close();
  +            }
  +            catch (NamingException ignore) {}
  +         }
  +      }
      }      
   
      // Private -------------------------------------------------------
  -   private void bind(Context ctx, String name, Object val) throws NamingException
  +   
  +   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);
  -   }      
  -
  -/**
  - * Insert the method's description here.
  - * Creation date: (6/22/2001 12:38:31 AM)
  - * @param newQueueFactoryRef java.lang.String
  - */
  -public void setQueueFactoryRef(java.lang.String newQueueFactoryRef) {
  -     queueFactoryRef = newQueueFactoryRef;
  -}
  -
  -/**
  - * Insert the method's description here.
  - * Creation date: (6/22/2001 12:38:31 AM)
  - * @param newTopicFactoryRef java.lang.String
  - */
  -public void setTopicFactoryRef(java.lang.String newTopicFactoryRef) {
  -     topicFactoryRef = newTopicFactoryRef;
  -}
  -
  -/**
  - * Insert the method's description here.
  - * Creation date: (6/22/2001 12:38:31 AM)
  - * @return java.lang.String
  - */
  -public java.lang.String getQueueFactoryRef() {
  -     return queueFactoryRef;
  -}
  -
  -/**
  - * Insert the method's description here.
  - * Creation date: (6/22/2001 12:38:31 AM)
  - * @return java.lang.String
  - */
  -public java.lang.String getTopicFactoryRef() {
  -     return topicFactoryRef;
  -}
  +      log.debug("attempting to bind " + val + " to " + name);
  +      
  +      // 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);
  +   }      
  +
  +   /**
  +    * Insert the method's description here.
  +    * Creation date: (6/22/2001 12:38:31 AM)
  +    * @param newQueueFactoryRef String
  +    */
  +   public void setQueueFactoryRef(final String newQueueFactoryRef) {
  +      queueFactoryRef = newQueueFactoryRef;
  +   }
  +
  +   /**
  +    * Insert the method's description here.
  +    * Creation date: (6/22/2001 12:38:31 AM)
  +    * @param newTopicFactoryRef String
  +    */
  +   public void setTopicFactoryRef(final String newTopicFactoryRef) {
  +      topicFactoryRef = newTopicFactoryRef;
  +   }
  +
  +   /**
  +    * Insert the method's description here.
  +    * Creation date: (6/22/2001 12:38:31 AM)
  +    * @return String
  +    */
  +   public String getQueueFactoryRef() {
  +      return queueFactoryRef;
  +   }
  +
  +   /**
  +    * Insert the method's description here.
  +    * Creation date: (6/22/2001 12:38:31 AM)
  +    * @return String
  +    */
  +   public String getTopicFactoryRef() {
  +      return topicFactoryRef;
  +   }
   }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to