User: simone  
  Date: 01/01/26 05:57:04

  Modified:    src/main/org/jboss/ejb/plugins AbstractInstanceCache.java
  Log:
  JMS Connections are now acquired only if user want to do JMS monitoring.
  Thanks to Craig Day ([EMAIL PROTECTED]) for this patch.
  
  Revision  Changes    Path
  1.5       +31 -20    jboss/src/main/org/jboss/ejb/plugins/AbstractInstanceCache.java
  
  Index: AbstractInstanceCache.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/AbstractInstanceCache.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractInstanceCache.java        2001/01/23 17:12:09     1.4
  +++ AbstractInstanceCache.java        2001/01/26 13:57:04     1.5
  @@ -56,7 +56,7 @@
    * </ul>
    *
    * @author Simone Bordet ([EMAIL PROTECTED])
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public abstract class AbstractInstanceCache
        implements InstanceCache, XmlLoadable, Monitorable, MetricsConstants
  @@ -323,17 +323,20 @@
                ClassLoader cl = getContainer().getClassLoader();
                m_passivator = new PassivatorQueue(threadName, cl);
   
  -             // Setup JMS for cache monitoring
  -             Context namingContext = new InitialContext();
  -             Object factoryRef = namingContext.lookup("TopicConnectionFactory");
  -             TopicConnectionFactory factory = 
(TopicConnectionFactory)PortableRemoteObject.narrow(factoryRef, 
TopicConnectionFactory.class);
  -
  -             m_jmsConnection = factory.createTopicConnection();
  -
  -             Object topicRef = namingContext.lookup("topic/metrics");
  -             m_jmsTopic = (Topic)PortableRemoteObject.narrow(topicRef, Topic.class);
  -             m_jmsSession = m_jmsConnection.createTopicSession(false, 
Session.DUPS_OK_ACKNOWLEDGE);
  -             m_jmsPublisher = m_jmsSession.createPublisher(m_jmsTopic);
  +             if (isJMSMonitoringEnabled())
  +             {
  +                     // Setup JMS for cache monitoring
  +                     Context namingContext = new InitialContext();
  +                     Object factoryRef = 
namingContext.lookup("TopicConnectionFactory");
  +                     TopicConnectionFactory factory = 
(TopicConnectionFactory)PortableRemoteObject.narrow(factoryRef, 
TopicConnectionFactory.class);
  +
  +                     m_jmsConnection = factory.createTopicConnection();
  +
  +                     Object topicRef = namingContext.lookup("topic/metrics");
  +                     m_jmsTopic = (Topic)PortableRemoteObject.narrow(topicRef, 
Topic.class);
  +                     m_jmsSession = m_jmsConnection.createTopicSession(false, 
Session.DUPS_OK_ACKNOWLEDGE);
  +                     m_jmsPublisher = m_jmsSession.createPublisher(m_jmsTopic);
  +             }
        }
        /* From Service interface*/
        public void start() throws Exception
  @@ -341,7 +344,10 @@
                getCache().start();
                m_passivator.start();
   
  -             m_jmsConnection.start();
  +             if (isJMSMonitoringEnabled())
  +             {
  +                     m_jmsConnection.start();
  +             }
        }
        /* From Service interface*/
        public void stop()
  @@ -353,22 +359,27 @@
                }
                m_passivator.stop();
   
  -             try
  +             if (isJMSMonitoringEnabled())
                {
  -                     m_jmsConnection.stop();
  +                     try
  +                     {
  +                             m_jmsConnection.stop();
  +                     }
  +                     catch (JMSException ignored) {}
                }
  -             catch (JMSException ignored) {}
        }
        /* From Service interface*/
        public void destroy()
        {
                getCache().destroy();
  -
  -             try
  +             if (isJMSMonitoringEnabled())
                {
  -                     m_jmsConnection.close();
  +                     try
  +                     {
  +                             m_jmsConnection.close();
  +                     }
  +                     catch (JMSException ignored) {}
                }
  -             catch (JMSException ignored) {}
        }
   
        // Y overrides ---------------------------------------------------
  
  
  

Reply via email to