[jboss-svn-commits] JBL Code SVN: r22461 - labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Sep 6 03:25:10 EDT 2008


Author: tfennelly
Date: 2008-09-06 03:25:09 -0400 (Sat, 06 Sep 2008)
New Revision: 22461

Modified:
   labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageHandler.java
   labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageListener.java
   labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/MessageSender.java
Log:
Sorting out some if the checkstyle issues

Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageHandler.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageHandler.java	2008-09-06 05:15:59 UTC (rev 22460)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageHandler.java	2008-09-06 07:25:09 UTC (rev 22461)
@@ -59,7 +59,13 @@
      */
     private Destination destination = null;
 
-    public AbstractMessageHandler(final Properties jndiProperties, final String destinationName)
+    /**
+     * Public vonstructor.
+     *
+     * @param destinationName The JMS destination name.
+     * @param jndiProperties  The JNDI properties for connecting to the JMS destination.
+     */
+    public AbstractMessageHandler(final String destinationName, final Properties jndiProperties)
     {
         logger = Logger.getLogger(getClass());
         this.jndiProperties = jndiProperties;
@@ -101,7 +107,7 @@
      *
      * @throws JMSException Failed to connect.
      */
-    protected void connect() throws JMSException
+    public final void connect() throws JMSException
     {
         ConnectionFactory connectionFactory;
 
@@ -159,9 +165,87 @@
         {
             conn.setExceptionListener(new DefaultExceptionListener());
         }
+
+        // And perform the handler specific connection ops...
+        handlerConnect();
     }
 
     /**
+     * Close out the handler and all it's resources.
+     */
+    public final void close()
+    {
+        try
+        {
+            // And perform the handler specific close ops...
+            handlerClose();
+        } catch (Throwable e)
+        {
+            logger.debug("Handler '" + getClass().getName() + "' close method threw unexpected exception while closing JMS destination '" + destinationName + "'.", e);
+            // Handler close failures should be taken care of by the handler impl.  Continue closing...
+        }
+
+        try
+        {
+            if (conn != null)
+            {
+                conn.stop();
+                logger.debug("Stopping JMS Connection for connected handler '" + getClass().getName() + "' on JMS destination '" + destinationName + "'.");
+            }
+        } catch (Throwable e)
+        {
+            logger.error("Failed to stop JMS connection.", e);
+            conn = null;
+        }
+        try
+        {
+            if (session != null)
+            {
+                session.close();
+                logger.debug("Closing JMS Session for connected handler '" + getClass().getName() + "' on JMS destination '" + destinationName + "'.");
+            }
+        } catch (Throwable e)
+        {
+            logger.error("Failed to close JMS session.", e);
+        } finally
+        {
+            session = null;
+        }
+        try
+        {
+            if (conn != null)
+            {
+                conn.close();
+                logger.debug("Closing JMS Connection for connected handler '" + getClass().getName() + "' on JMS destination '" + destinationName + "'.");
+            }
+        } catch (Throwable e)
+        {
+            logger.error("Failed to close JMS connection.", e);
+        } finally
+        {
+            conn = null;
+        }
+        destination = null;
+        logger.debug("JMS handler '" + getClass().getName() + "' on JMS destination '" + destinationName + "' is now closed.");
+    }
+
+    /**
+     * Handler connect.
+     * <p/>
+     * Implement handler specific connect operations.
+     *
+     * @throws JMSException Failed to connect.
+     */
+    protected abstract void handlerConnect() throws JMSException;
+
+    /**
+     * Handler close.
+     * <p/>
+     * Implement handler specific close operations.
+     */
+    protected abstract void handlerClose();
+
+    /**
      * Get the JMS Connection factory.
      *
      * @return Connection Factory.
@@ -226,55 +310,6 @@
     }
 
     /**
-     * Close out the handler and all it's resources.
-     */
-    public void close()
-    {
-        try
-        {
-            if (conn != null)
-            {
-                conn.stop();
-                logger.debug("Stopping JMS Connection for connected handler '" + getClass().getName() + "' on JMS destination '" + destinationName + "'.");
-            }
-        } catch (Throwable e)
-        {
-            logger.error("Failed to stop JMS connection.", e);
-            conn = null;
-        }
-        try
-        {
-            if (session != null)
-            {
-                session.close();
-                logger.debug("Closing JMS Session for connected handler '" + getClass().getName() + "' on JMS destination '" + destinationName + "'.");
-            }
-        } catch (Throwable e)
-        {
-            logger.error("Failed to close JMS session.", e);
-        } finally
-        {
-            session = null;
-        }
-        try
-        {
-            if (conn != null)
-            {
-                conn.close();
-                logger.debug("Closing JMS Connection for connected handler '" + getClass().getName() + "' on JMS destination '" + destinationName + "'.");
-            }
-        } catch (Throwable e)
-        {
-            logger.error("Failed to close JMS connection.", e);
-        } finally
-        {
-            conn = null;
-        }
-        destination = null;
-        logger.debug("JMS handler '" + getClass().getName() + "' on JMS destination '" + destinationName + "' is now closed.");
-    }
-
-    /**
      * The Default JMS Exception Listener.
      *
      * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
@@ -342,6 +377,7 @@
 
     /**
      * Is the handler connected.
+     *
      * @return True if the connector is connected, otherwise false.
      */
     public abstract boolean isConnected();

Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageListener.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageListener.java	2008-09-06 05:15:59 UTC (rev 22460)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageListener.java	2008-09-06 07:25:09 UTC (rev 22461)
@@ -52,7 +52,7 @@
      */
     protected AbstractMessageListener(final String destinationName, final Properties jndiProperties)
     {
-        super(jndiProperties, destinationName);
+        super(destinationName, jndiProperties);
         logger = Logger.getLogger(getClass());
     }
 
@@ -61,7 +61,7 @@
      *
      * @throws JMSException Failed to connect.
      */
-    public final void connect() throws JMSException
+    protected final void handlerConnect() throws JMSException
     {
         try
         {
@@ -95,7 +95,7 @@
     /**
      * Close out the listener and all it's resources.
      */
-    public void close()
+    protected final void handlerClose()
     {
         try
         {
@@ -123,7 +123,7 @@
      * Is the handler connected.
      * @return True if the connector is connected, otherwise false.
      */
-    public boolean isConnected()
+    public final boolean isConnected()
     {
         return (messageConsumer != null);
     }

Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/MessageSender.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/MessageSender.java	2008-09-06 05:15:59 UTC (rev 22460)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/MessageSender.java	2008-09-06 07:25:09 UTC (rev 22461)
@@ -52,7 +52,7 @@
      */
     protected MessageSender(final String destinationName, final Properties jndiProperties)
     {
-        super(jndiProperties, destinationName);
+        super(destinationName, jndiProperties);
         logger = Logger.getLogger(getClass());
     }
 
@@ -61,7 +61,7 @@
      *
      * @throws JMSException Failed to connect.
      */
-    public final void connect() throws JMSException
+    protected final void handlerConnect() throws JMSException
     {
         try
         {
@@ -110,7 +110,7 @@
     /**
      * Close out the sender and all it's resources.
      */
-    public final void close()
+    protected final void handlerClose()
     {
         try
         {




More information about the jboss-svn-commits mailing list