You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2007/08/12 07:27:34 UTC

svn commit: r565003 [14/17] - in /activemq/trunk: activemq-fileserver/src/main/java/org/apache/activemq/util/ activemq-fileserver/src/test/java/org/apache/activemq/util/ activemq-jaas/src/main/java/org/apache/activemq/jaas/ activemq-jaas/src/test/java/...

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/DestinationFacade.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/DestinationFacade.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/DestinationFacade.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/DestinationFacade.java Sat Aug 11 22:27:21 2007
@@ -16,22 +16,19 @@
  */
 package org.apache.activemq.web;
 
+import javax.servlet.http.HttpServletRequest;
+
 import org.apache.activemq.broker.jmx.BrokerViewMBean;
 import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
 import org.springframework.web.servlet.ModelAndView;
 
-import javax.servlet.http.HttpServletRequest;
-
 /**
- *
  * @version $Revision$
  */
-public class DestinationFacade  {
+public class DestinationFacade {
 
-    private String JMSDestination;
-    private String JMSDestinationType;
+    private String jmsDestination;
+    private String jmsDestinationType;
     private BrokerFacade brokerFacade;
 
     public DestinationFacade(BrokerFacade brokerFacade) {
@@ -39,18 +36,16 @@
     }
 
     public String toString() {
-        return super.toString() + "[destination:" + JMSDestination + "; type=" + JMSDestinationType + "]";
+        return super.toString() + "[destination:" + jmsDestination + "; type=" + jmsDestinationType + "]";
     }
 
-
     // Operations
     // -------------------------------------------------------------------------
     public void removeDestination() throws Exception {
         getValidDestination();
         if (isQueue()) {
             getBrokerAdmin().removeQueue(getJMSDestination());
-        }
-        else {
+        } else {
             getBrokerAdmin().removeTopic(getJMSDestination());
         }
     }
@@ -58,12 +53,11 @@
     public void addDestination() throws Exception {
         if (isQueue()) {
             getBrokerAdmin().addQueue(getValidDestination());
-        }
-        else {
+        } else {
             getBrokerAdmin().addTopic(getValidDestination());
         }
     }
-    
+
     // Properties
     // -------------------------------------------------------------------------
     public BrokerViewMBean getBrokerAdmin() throws Exception {
@@ -75,26 +69,26 @@
     }
 
     public boolean isQueue() {
-        if (JMSDestinationType != null && JMSDestinationType.equalsIgnoreCase("topic")) {
+        if (jmsDestinationType != null && jmsDestinationType.equalsIgnoreCase("topic")) {
             return false;
         }
         return true;
     }
 
     public String getJMSDestination() {
-        return JMSDestination;
+        return jmsDestination;
     }
 
     public void setJMSDestination(String destination) {
-        this.JMSDestination = destination;
+        this.jmsDestination = destination;
     }
 
     public String getJMSDestinationType() {
-        return JMSDestinationType;
+        return jmsDestinationType;
     }
 
     public void setJMSDestinationType(String type) {
-        this.JMSDestinationType = type;
+        this.jmsDestinationType = type;
     }
 
     protected ActiveMQDestination createDestination() {
@@ -103,19 +97,17 @@
     }
 
     protected String getValidDestination() {
-        if (JMSDestination == null) {
+        if (jmsDestination == null) {
             throw new IllegalArgumentException("No JMSDestination parameter specified");
         }
-        return JMSDestination;
+        return jmsDestination;
     }
 
-
     protected ModelAndView redirectToRequest(HttpServletRequest request) {
         String view = "redirect:" + request.getRequestURI();
-//        System.out.println("Redirecting to: " + view);
+        // System.out.println("Redirecting to: " + view);
         return new ModelAndView(view);
     }
-
 
     protected ModelAndView redirectToBrowseView() {
         return new ModelAndView("redirect:" + (isQueue() ? "queues.jsp" : "topics.jsp"));

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/LocalBrokerFacade.java Sat Aug 11 22:27:21 2007
@@ -16,32 +16,21 @@
  */
 package org.apache.activemq.web;
 
+import java.util.Iterator;
+import java.util.Set;
+
 import org.apache.activemq.broker.Broker;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.jmx.BrokerView;
 import org.apache.activemq.broker.jmx.BrokerViewMBean;
-import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean;
 import org.apache.activemq.broker.jmx.ManagedRegionBroker;
 import org.apache.activemq.broker.jmx.ManagementContext;
-import org.apache.activemq.broker.jmx.TopicViewMBean;
 import org.apache.activemq.broker.region.Queue;
 import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.ObjectName;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
 
 /**
  * An implementation of {@link BrokerFacade} which uses a local in JVM broker
- *
+ * 
  * @version $Revision$
  */
 public class LocalBrokerFacade extends BrokerFacadeSupport {
@@ -78,7 +67,7 @@
 
     public void purgeQueue(ActiveMQDestination destination) throws Exception {
         Set destinations = getManagedBroker().getQueueRegion().getDestinations(destination);
-        for (Iterator i=destinations.iterator(); i.hasNext();) {
+        for (Iterator i = destinations.iterator(); i.hasNext();) {
             Queue regionQueue = (Queue)i.next();
             regionQueue.purge();
         }

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/MessageQuery.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/MessageQuery.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/MessageQuery.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/MessageQuery.java Sat Aug 11 22:27:21 2007
@@ -16,14 +16,15 @@
  */
 package org.apache.activemq.web;
 
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
 import javax.jms.JMSException;
 import javax.jms.MapMessage;
 import javax.jms.Message;
 import javax.jms.ObjectMessage;
 import javax.jms.TextMessage;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
 
 /**
  * Allow the user to browse a message on a queue by its ID
@@ -82,8 +83,8 @@
         return null;
     }
 
-    public Map getPropertiesMap() throws JMSException {
-        Map answer = new HashMap();
+    public Map<String, Object> getPropertiesMap() throws JMSException {
+        Map<String, Object> answer = new HashMap<String, Object>();
         Message aMessage = getMessage();
         Enumeration iter = aMessage.getPropertyNames();
         while (iter.hasMoreElements()) {
@@ -96,8 +97,8 @@
         return answer;
     }
 
-    protected Map createMapBody(MapMessage mapMessage) throws JMSException {
-        Map answer = new HashMap();
+    protected Map<String, Object> createMapBody(MapMessage mapMessage) throws JMSException {
+        Map<String, Object> answer = new HashMap<String, Object>();
         Enumeration iter = mapMessage.getMapNames();
         while (iter.hasMoreElements()) {
             String name = (String) iter.nextElement();

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/QueueBrowseQuery.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/QueueBrowseQuery.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/QueueBrowseQuery.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/QueueBrowseQuery.java Sat Aug 11 22:27:21 2007
@@ -16,12 +16,12 @@
  */
 package org.apache.activemq.web;
 
-import org.springframework.beans.factory.DisposableBean;
-
 import javax.jms.JMSException;
 import javax.jms.Queue;
 import javax.jms.QueueBrowser;
 import javax.jms.Session;
+
+import org.springframework.beans.factory.DisposableBean;
 
 /**
  * 

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java Sat Aug 11 22:27:21 2007
@@ -16,12 +16,12 @@
  */
 package org.apache.activemq.web;
 
-import org.apache.activemq.broker.jmx.BrokerViewMBean;
-import org.apache.activemq.broker.jmx.ManagementContext;
-import org.apache.activemq.broker.jmx.QueueViewMBean;
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
 
 import javax.management.MBeanServerConnection;
 import javax.management.MBeanServerInvocationHandler;
@@ -30,21 +30,24 @@
 import javax.management.remote.JMXConnector;
 import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
+
+import org.apache.activemq.broker.jmx.BrokerViewMBean;
+import org.apache.activemq.broker.jmx.ManagementContext;
+import org.apache.activemq.broker.jmx.QueueViewMBean;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * A {@link BrokerFacade} which uses a JMX-Connection to communicate with a
  * broker
- *
+ * 
  * @version $Revision: 1.1 $
  */
 public class RemoteJMXBrokerFacade extends BrokerFacadeSupport {
-    private static final transient Log log = LogFactory.getLog(RemoteJMXBrokerFacade.class);
+    
+    private static final transient Log LOG = LogFactory.getLog(RemoteJMXBrokerFacade.class);
+    
     private String jmxUrl;
     private String jmxRole;
     private String jmxPassword;
@@ -81,9 +84,8 @@
         if (brokers.size() == 0) {
             throw new IOException("No broker could be found in the JMX.");
         }
-        ObjectName name = (ObjectName) brokers.iterator().next();
-        BrokerViewMBean mbean = (BrokerViewMBean) MBeanServerInvocationHandler
-                .newProxyInstance(connection, name, BrokerViewMBean.class, true);
+        ObjectName name = (ObjectName)brokers.iterator().next();
+        BrokerViewMBean mbean = (BrokerViewMBean)MBeanServerInvocationHandler.newProxyInstance(connection, name, BrokerViewMBean.class, true);
         return mbean;
     }
 
@@ -96,7 +98,7 @@
         synchronized (this) {
             closeConnection();
 
-            log.debug("Creating a new JMX-Connection to the broker");
+            LOG.debug("Creating a new JMX-Connection to the broker");
             this.connector = createConnection();
             return this.connector.getMBeanServerConnection();
         }
@@ -108,69 +110,61 @@
         }
 
         try {
-            MBeanServerConnection connection = connector
-                    .getMBeanServerConnection();
+            MBeanServerConnection connection = connector.getMBeanServerConnection();
             int brokerCount = findBrokers(connection).size();
             return brokerCount > 0;
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             return false;
         }
     }
 
     protected JMXConnector createConnection() {
         String[] urls = this.jmxUrl.split(",");
-	HashMap env = new HashMap();
-	env.put("jmx.remote.credentials",
-		new String[] {this.jmxRole, this.jmxPassword});
+        HashMap env = new HashMap();
+        env.put("jmx.remote.credentials", new String[] {
+            this.jmxRole, this.jmxPassword
+        });
 
         if (urls == null || urls.length == 0) {
-            urls = new String[]{this.jmxUrl};
+            urls = new String[] {
+                this.jmxUrl
+            };
         }
 
         Exception exception = null;
         for (int i = 0; i < urls.length; i++) {
             try {
-                JMXConnector connector = JMXConnectorFactory
-                        .connect(new JMXServiceURL(urls[i]), env);
+                JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(urls[i]), env);
                 connector.connect();
-                MBeanServerConnection connection = connector
-                        .getMBeanServerConnection();
+                MBeanServerConnection connection = connector.getMBeanServerConnection();
 
                 Set brokers = findBrokers(connection);
                 if (brokers.size() > 0) {
-                    log
-                            .info("Connected via JMX to the broker at "
-                                    + urls[i]);
+                    LOG.info("Connected via JMX to the broker at " + urls[i]);
                     return connector;
                 }
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 // Keep the exception for later
                 exception = e;
             }
         }
         if (exception != null) {
             if (exception instanceof RuntimeException) {
-                throw (RuntimeException) exception;
-            }
-            else {
+                throw (RuntimeException)exception;
+            } else {
                 throw new RuntimeException(exception);
             }
         }
-        throw new IllegalStateException(
-                "No broker is found at any of the urls " + this.jmxUrl);
+        throw new IllegalStateException("No broker is found at any of the urls " + this.jmxUrl);
     }
 
     protected synchronized void closeConnection() {
         if (connector != null) {
             try {
-                log.debug("Closing a connection to a broker ("
-                        + connector.getConnectionId() + ")");
+                LOG.debug("Closing a connection to a broker (" + connector.getConnectionId() + ")");
 
                 connector.close();
-            }
-            catch (IOException e) {
+            } catch (IOException e) {
                 // Ignore the exception, since it most likly won't matter
                 // anymore
             }
@@ -180,21 +174,18 @@
     /**
      * Finds all ActiveMQ-Brokers registered on a certain JMX-Server or, if a
      * JMX-BrokerName has been set, the broker with that name.
-     *
+     * 
      * @param connection not <code>null</code>
      * @return Set with ObjectName-elements
      * @throws IOException
      * @throws MalformedObjectNameException
      */
-    protected Set findBrokers(MBeanServerConnection connection)
-            throws IOException, MalformedObjectNameException {
+    protected Set findBrokers(MBeanServerConnection connection) throws IOException, MalformedObjectNameException {
         ObjectName name;
         if (this.brokerName == null) {
             name = new ObjectName("org.apache.activemq:Type=Broker,*");
-        }
-        else {
-            name = new ObjectName("org.apache.activemq:BrokerName="
-                    + this.brokerName + ",Type=Broker");
+        } else {
+            name = new ObjectName("org.apache.activemq:BrokerName=" + this.brokerName + ",Type=Broker");
         }
 
         Set brokers = connection.queryNames(name, null);
@@ -214,8 +205,7 @@
         MBeanServerConnection connection;
         try {
             connection = getConnection();
-        }
-        catch (IOException e) {
+        } catch (IOException e) {
             throw new RuntimeException(e);
         }
 
@@ -223,14 +213,13 @@
         if (connection != null) {
             for (int i = 0; i < names.length; i++) {
                 ObjectName name = names[i];
-                Object value = MBeanServerInvocationHandler.newProxyInstance(
-                        connection, name, type, true);
+                Object value = MBeanServerInvocationHandler.newProxyInstance(connection, name, type, true);
                 if (value != null) {
                     answer.add(value);
                 }
             }
         }
-		return answer;
-	}
+        return answer;
+    }
 
 }

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/SessionPool.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/SessionPool.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/SessionPool.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/SessionPool.java Sat Aug 11 22:27:21 2007
@@ -30,71 +30,72 @@
  */
 public class SessionPool {
 
-	private ConnectionFactory connectionFactory;
-	private Connection connection;
-	private LinkedList sessions = new LinkedList();
-
-	public Connection getConnection() throws JMSException {
-		if (checkConnection())
-			return connection;
-
-		synchronized (this) {
-			connection = getConnectionFactory().createConnection();
-			connection.start();
-			return connection;
-		}
-	}
-
-	private boolean checkConnection() {
-		if (connection == null)
-			return false;
-
-		try {
-			connection.getMetaData();
-			return true;
-		} catch (JMSException e) {
-			return false;
-		}
-	}
-
-	public void setConnection(Connection connection) {
-		this.connection = connection;
-	}
-
-	public ConnectionFactory getConnectionFactory() {
-		if (connectionFactory == null) {
-			throw new IllegalStateException(
-					"No ConnectionFactory has been set for the session pool");
-		}
-		return connectionFactory;
-	}
-
-	public void setConnectionFactory(ConnectionFactory connectionFactory) {
-		this.connectionFactory = connectionFactory;
-	}
-
-	public Session borrowSession() throws JMSException {
-		Session answer = null;
-		synchronized (sessions) {
-			if (sessions.isEmpty()) {
-				answer = createSession();
-			} else {
-				answer = (Session) sessions.removeLast();
-			}
-		}
-		return answer;
-	}
-
-	public void returnSession(Session session) {
-		if (session != null) {
-			synchronized (sessions) {
-				sessions.add(session);
-			}
-		}
-	}
-
-	protected Session createSession() throws JMSException {
-		return getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
-	}
+    private ConnectionFactory connectionFactory;
+    private Connection connection;
+    private LinkedList<Session> sessions = new LinkedList<Session>();
+
+    public Connection getConnection() throws JMSException {
+        if (checkConnection()) {
+            return connection;
+        }
+
+        synchronized (this) {
+            connection = getConnectionFactory().createConnection();
+            connection.start();
+            return connection;
+        }
+    }
+
+    private boolean checkConnection() {
+        if (connection == null) {
+            return false;
+        }
+
+        try {
+            connection.getMetaData();
+            return true;
+        } catch (JMSException e) {
+            return false;
+        }
+    }
+
+    public void setConnection(Connection connection) {
+        this.connection = connection;
+    }
+
+    public ConnectionFactory getConnectionFactory() {
+        if (connectionFactory == null) {
+            throw new IllegalStateException("No ConnectionFactory has been set for the session pool");
+        }
+        return connectionFactory;
+    }
+
+    public void setConnectionFactory(ConnectionFactory connectionFactory) {
+        this.connectionFactory = connectionFactory;
+    }
+
+    public Session borrowSession() throws JMSException {
+        Session answer = null;
+        synchronized (sessions) {
+            if (sessions.isEmpty()) {
+                answer = createSession();
+            } else {
+                answer = sessions.removeLast();
+            }
+        }
+        return answer;
+    }
+
+    public void returnSession(Session session) {
+        if (session != null) {
+            synchronized (sessions) {
+                sessions.add(session);
+            }
+        }
+    }
+
+    protected Session createSession() throws JMSException {
+        return getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
+    }
 
 }

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/SingletonBrokerFacade.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/SingletonBrokerFacade.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/SingletonBrokerFacade.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/SingletonBrokerFacade.java Sat Aug 11 22:27:21 2007
@@ -16,8 +16,8 @@
  */
 package org.apache.activemq.web;
 
-import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.BrokerRegistry;
+import org.apache.activemq.broker.BrokerService;
 
 /**
  * A facade for the broker in the same JVM and ClassLoader
@@ -32,8 +32,7 @@
     protected static BrokerService findSingletonBroker() {
         BrokerService broker = BrokerRegistry.getInstance().findFirst();
         if (broker == null) {
-            throw new IllegalArgumentException("No BrokerService is registered with the BrokerRegistry." +
-                    " Are you sure there is a configured broker in the same ClassLoader?");
+            throw new IllegalArgumentException("No BrokerService is registered with the BrokerRegistry. Are you sure there is a configured broker in the same ClassLoader?");
         }
         return broker;
     }

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/WebConsoleStarter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/WebConsoleStarter.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/WebConsoleStarter.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/WebConsoleStarter.java Sat Aug 11 22:27:21 2007
@@ -21,11 +21,11 @@
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.context.support.WebApplicationContextUtils;
 import org.springframework.web.context.support.XmlWebApplicationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * Starts the WebConsole.
@@ -33,50 +33,49 @@
  * @version $Revision: 1.1 $
  */
 public class WebConsoleStarter implements ServletContextListener {
-    private static final transient Log log = LogFactory.getLog(WebConsoleStarter.class);
+    
+    private static final Log LOG = LogFactory.getLog(WebConsoleStarter.class);
 
     public void contextInitialized(ServletContextEvent event) {
-		log.debug("Initializing ActiveMQ WebConsole...");
-		
-		ServletContext servletContext = event.getServletContext();
-		WebApplicationContext context = createWebapplicationContext(servletContext);
-		
-		initializeWebClient(servletContext, context);
-		
-		log.info("ActiveMQ WebConsole initialized.");
-	}
-
-	private WebApplicationContext createWebapplicationContext(ServletContext servletContext) {
-		String webconsoleType = System.getProperty("webconsole.type", "embedded");
-		String configuration = "/WEB-INF/webconsole-" + webconsoleType + ".xml";
-		
-		XmlWebApplicationContext context = new XmlWebApplicationContext();
-		context.setServletContext(servletContext);
-		context.setConfigLocations(new String[] { configuration });
-		context.refresh();
-		context.start();
-		
-		servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);
-
-		return context;
-	}
-
-	private void initializeWebClient(ServletContext servletContext, WebApplicationContext context) {
-		ConnectionFactory connectionFactory = (ConnectionFactory) context
-				.getBean("connectionFactory");
-		servletContext.setAttribute(WebClient.connectionFactoryAttribute,
-				connectionFactory);
-	}
-	
-	public void contextDestroyed(ServletContextEvent event) {
-		XmlWebApplicationContext context = (XmlWebApplicationContext) WebApplicationContextUtils
-				.getWebApplicationContext(event.getServletContext());
-		if (context != null)
-		{
-			context.stop();
-			context.destroy();
-		}
-		// do nothing, since the context is destoyed anyway
-	}
+        LOG.debug("Initializing ActiveMQ WebConsole...");
+
+        ServletContext servletContext = event.getServletContext();
+        WebApplicationContext context = createWebapplicationContext(servletContext);
+
+        initializeWebClient(servletContext, context);
+
+        LOG.info("ActiveMQ WebConsole initialized.");
+    }
+
+    private WebApplicationContext createWebapplicationContext(ServletContext servletContext) {
+        String webconsoleType = System.getProperty("webconsole.type", "embedded");
+        String configuration = "/WEB-INF/webconsole-" + webconsoleType + ".xml";
+
+        XmlWebApplicationContext context = new XmlWebApplicationContext();
+        context.setServletContext(servletContext);
+        context.setConfigLocations(new String[] {
+            configuration
+        });
+        context.refresh();
+        context.start();
+
+        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context);
+
+        return context;
+    }
+
+    private void initializeWebClient(ServletContext servletContext, WebApplicationContext context) {
+        ConnectionFactory connectionFactory = (ConnectionFactory)context.getBean("connectionFactory");
+        servletContext.setAttribute(WebClient.CONNECTION_FACTORY_ATTRIBUTE, connectionFactory);
+    }
+
+    public void contextDestroyed(ServletContextEvent event) {
+        XmlWebApplicationContext context = (XmlWebApplicationContext)WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
+        if (context != null) {
+            context.stop();
+            context.destroy();
+        }
+        // do nothing, since the context is destoyed anyway
+    }
 
 }

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CreateDestination.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CreateDestination.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CreateDestination.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CreateDestination.java Sat Aug 11 22:27:21 2007
@@ -16,13 +16,13 @@
  */
 package org.apache.activemq.web.controller;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.activemq.web.BrokerFacade;
 import org.apache.activemq.web.DestinationFacade;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
 /**
  * 

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CreateSubscriber.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CreateSubscriber.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CreateSubscriber.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/CreateSubscriber.java Sat Aug 11 22:27:21 2007
@@ -16,13 +16,13 @@
  */
 package org.apache.activemq.web.controller;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.activemq.web.BrokerFacade;
 import org.apache.activemq.web.DurableSubscriberFacade;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
 /**
  * 

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteDestination.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteDestination.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteDestination.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteDestination.java Sat Aug 11 22:27:21 2007
@@ -16,13 +16,13 @@
  */
 package org.apache.activemq.web.controller;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.activemq.web.BrokerFacade;
 import org.apache.activemq.web.DestinationFacade;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
 /**
  * 

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteMessage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteMessage.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteMessage.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteMessage.java Sat Aug 11 22:27:21 2007
@@ -16,15 +16,15 @@
  */
 package org.apache.activemq.web.controller;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.activemq.broker.jmx.QueueViewMBean;
 import org.apache.activemq.web.BrokerFacade;
 import org.apache.activemq.web.DestinationFacade;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 /**
  * @version $Revision$
  */
@@ -41,8 +41,7 @@
             if (queueView != null) {
                 System.out.println("#### removing message: " + messageId);
                 queueView.removeMessage(messageId);
-            }
-            else {
+            } else {
                 System.out.println("#### NO QUEUE!");
             }
         }

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteSubscriber.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteSubscriber.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteSubscriber.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/DeleteSubscriber.java Sat Aug 11 22:27:21 2007
@@ -16,13 +16,13 @@
  */
 package org.apache.activemq.web.controller;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.activemq.web.BrokerFacade;
 import org.apache.activemq.web.DurableSubscriberFacade;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
 /**
  *

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/PurgeDestination.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/PurgeDestination.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/PurgeDestination.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/PurgeDestination.java Sat Aug 11 22:27:21 2007
@@ -16,16 +16,15 @@
  */
 package org.apache.activemq.web.controller;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.activemq.web.BrokerFacade;
 import org.apache.activemq.web.DestinationFacade;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 /**
- *
  * @version $Revision$
  */
 public class PurgeDestination extends DestinationFacade implements Controller {
@@ -42,10 +41,8 @@
     public void purgeDestination() throws Exception {
         if (isQueue()) {
             getBrokerFacade().purgeQueue(createDestination());
-        }
-        else {
+        } else {
             throw new UnsupportedOperationException("Purge supported for queues only. Receieved JMSDestinationType=" + getJMSDestinationType());
         }
     }
 }
-

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/SendMessage.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/SendMessage.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/SendMessage.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/controller/SendMessage.java Sat Aug 11 22:27:21 2007
@@ -16,6 +16,14 @@
  */
 package org.apache.activemq.web.controller;
 
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.web.BrokerFacade;
 import org.apache.activemq.web.DestinationFacade;
@@ -23,13 +31,6 @@
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.Controller;
 
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.Iterator;
-import java.util.Map;
-
 /**
  * Sends a message
  * 
@@ -37,15 +38,15 @@
  */
 public class SendMessage extends DestinationFacade implements Controller {
 
-    private String JMSText;
-    private boolean JMSPersistent;
-    private int JMSPriority;
-    private int JMSTimeToLive = -1;
-    private String JMSCorrelationID;
-    private String JMSReplyTo;
-    private String JMSType;
-    private int JMSMessageCount = 1;
-    private String JMSMessageCountHeader = "JMSXMessageNumber";
+    private String jmsText;
+    private boolean jmsPersistent;
+    private int jmsPriority;
+    private int jmsTimeToLive = -1;
+    private String jmsCorrelationID;
+    private String jmsReplyTo;
+    private String jmsType;
+    private int jmsMessageCount = 1;
+    private String jmsMessageCountHeader = "JMSXMessageNumber";
     private boolean redirectToBrowse;
 
     public SendMessage(BrokerFacade brokerFacade) {
@@ -66,17 +67,17 @@
     }
 
     protected void sendMessages(HttpServletRequest request, WebClient client, ActiveMQDestination dest) throws JMSException {
-        if (JMSMessageCount <= 1) {
-            JMSMessageCount = 1;
+        if (jmsMessageCount <= 1) {
+            jmsMessageCount = 1;
         }
-        for (int i = 0; i < JMSMessageCount; i++) {
+        for (int i = 0; i < jmsMessageCount; i++) {
             Message message = createMessage(client, request);
             appendHeaders(message, request);
-            if (JMSMessageCount > 1) {
-                message.setIntProperty(JMSMessageCountHeader, i + 1);
+            if (jmsMessageCount > 1) {
+                message.setIntProperty(jmsMessageCountHeader, i + 1);
             }
 
-            client.send(dest, message, JMSPersistent, JMSPriority, JMSTimeToLive);
+            client.send(dest, message, jmsPersistent, jmsPriority, jmsTimeToLive);
         }
     }
 
@@ -84,108 +85,107 @@
     // -------------------------------------------------------------------------
 
     public String getJMSCorrelationID() {
-        return JMSCorrelationID;
+        return jmsCorrelationID;
     }
 
     public void setJMSCorrelationID(String correlationID) {
-        JMSCorrelationID = correlationID;
+        jmsCorrelationID = correlationID;
     }
 
     public String getJMSReplyTo() {
-        return JMSReplyTo;
+        return jmsReplyTo;
     }
 
     public void setJMSReplyTo(String replyTo) {
-        JMSReplyTo = replyTo;
+        jmsReplyTo = replyTo;
     }
 
     public String getJMSType() {
-        return JMSType;
+        return jmsType;
     }
 
     public void setJMSType(String type) {
-        JMSType = type;
+        jmsType = type;
     }
 
     public boolean isJMSPersistent() {
-        return JMSPersistent;
+        return jmsPersistent;
     }
 
     public void setJMSPersistent(boolean persistent) {
-        this.JMSPersistent = persistent;
+        this.jmsPersistent = persistent;
     }
 
     public int getJMSPriority() {
-        return JMSPriority;
+        return jmsPriority;
     }
 
     public void setJMSPriority(int priority) {
-        this.JMSPriority = priority;
+        this.jmsPriority = priority;
     }
 
     public String getJMSText() {
-        return JMSText;
+        return jmsText;
     }
 
     public void setJMSText(String text) {
-        this.JMSText = text;
+        this.jmsText = text;
     }
 
     public int getJMSTimeToLive() {
-        return JMSTimeToLive;
+        return jmsTimeToLive;
     }
 
     public void setJMSTimeToLive(int timeToLive) {
-        this.JMSTimeToLive = timeToLive;
+        this.jmsTimeToLive = timeToLive;
     }
 
     public int getJMSMessageCount() {
-        return JMSMessageCount;
+        return jmsMessageCount;
     }
 
     public void setJMSMessageCount(int copies) {
-        JMSMessageCount = copies;
+        jmsMessageCount = copies;
     }
 
     public String getJMSMessageCountHeader() {
-        return JMSMessageCountHeader;
+        return jmsMessageCountHeader;
     }
 
     public void setJMSMessageCountHeader(String messageCountHeader) {
-        JMSMessageCountHeader = messageCountHeader;
+        jmsMessageCountHeader = messageCountHeader;
     }
 
     // Implementation methods
     // -------------------------------------------------------------------------
     protected Message createMessage(WebClient client, HttpServletRequest request) throws JMSException {
-        if (JMSText != null) {
-            return client.getSession().createTextMessage(JMSText);
+        if (jmsText != null) {
+            return client.getSession().createTextMessage(jmsText);
         }
         // TODO create Bytes message from request body...
         return client.getSession().createMessage();
     }
 
     protected void appendHeaders(Message message, HttpServletRequest request) throws JMSException {
-        message.setJMSCorrelationID(JMSCorrelationID);
-        if (JMSReplyTo != null && JMSReplyTo.trim().length() > 0) {
-            message.setJMSReplyTo(ActiveMQDestination.createDestination(JMSReplyTo, ActiveMQDestination.QUEUE_TYPE));
+        message.setJMSCorrelationID(jmsCorrelationID);
+        if (jmsReplyTo != null && jmsReplyTo.trim().length() > 0) {
+            message.setJMSReplyTo(ActiveMQDestination.createDestination(jmsReplyTo, ActiveMQDestination.QUEUE_TYPE));
         }
-        message.setJMSType(JMSType);
+        message.setJMSType(jmsType);
 
         // now lets add all of the parameters
         Map map = request.getParameterMap();
         if (map != null) {
             for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
-                Map.Entry entry = (Map.Entry) iter.next();
-                String name = (String) entry.getKey();
+                Map.Entry entry = (Map.Entry)iter.next();
+                String name = (String)entry.getKey();
                 Object value = entry.getValue();
                 if (isValidPropertyName(name)) {
                     if (value instanceof String[]) {
-                        String[] array = (String[]) value;
+                        String[] array = (String[])value;
                         if (array.length > 0) {
                             value = array[0];
-                        }
-                        else {
+                        } else {
                             value = null;
                         }
                     }
@@ -193,8 +193,7 @@
                         String text = value.toString().trim();
                         if (text.length() == 0) {
                             value = null;
-                        }
-                        else {
+                        } else {
                             value = text;
                         }
                     }

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java Sat Aug 11 22:27:21 2007
@@ -16,9 +16,11 @@
  */
 package org.apache.activemq.web.filter;
 
-import org.springframework.web.bind.ServletRequestDataBinder;
-import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.context.support.WebApplicationContextUtils;
+import java.io.IOException;
+import java.util.AbstractMap;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
 
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
@@ -27,11 +29,10 @@
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
-import java.io.IOException;
-import java.util.AbstractMap;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
+
+import org.springframework.web.bind.ServletRequestDataBinder;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
 
 /**
  * Exposes Spring ApplicationContexts to JSP EL and other view technologies.

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/handler/BindingBeanNameUrlHandlerMapping.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/handler/BindingBeanNameUrlHandlerMapping.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/handler/BindingBeanNameUrlHandlerMapping.java (original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/handler/BindingBeanNameUrlHandlerMapping.java Sat Aug 11 22:27:21 2007
@@ -16,33 +16,32 @@
  */
 package org.apache.activemq.web.handler;
 
+import javax.servlet.http.HttpServletRequest;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.web.bind.ServletRequestDataBinder;
 import org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping;
 
-import javax.servlet.http.HttpServletRequest;
-
 /**
- * 
  * @version $Revision$
  */
 public class BindingBeanNameUrlHandlerMapping extends BeanNameUrlHandlerMapping {
-    private static final transient Log log = LogFactory.getLog(BindingBeanNameUrlHandlerMapping.class);
+    private static final transient Log LOG = LogFactory.getLog(BindingBeanNameUrlHandlerMapping.class);
 
     protected Object getHandlerInternal(HttpServletRequest request) throws Exception {
         Object object = super.getHandlerInternal(request);
 
         if (object instanceof String) {
-            String handlerName = (String) object;
+            String handlerName = (String)object;
             object = getApplicationContext().getBean(handlerName);
         }
 
         ServletRequestDataBinder binder = new ServletRequestDataBinder(object, "request");
         binder.bind(request);
         binder.setIgnoreUnknownFields(true);
-        if (log.isDebugEnabled()) {
-            log.debug("Bound POJO is now: " + object);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Bound POJO is now: " + object);
         }
         return object;
     }

Modified: activemq/trunk/activemq-web-console/src/test/java/org/apache/activemq/web/tool/Main.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/test/java/org/apache/activemq/web/tool/Main.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web-console/src/test/java/org/apache/activemq/web/tool/Main.java (original)
+++ activemq/trunk/activemq-web-console/src/test/java/org/apache/activemq/web/tool/Main.java Sat Aug 11 22:27:21 2007
@@ -23,22 +23,25 @@
 import org.mortbay.jetty.nio.SelectChannelConnector;
 import org.mortbay.jetty.webapp.WebAppContext;
 
-
 /**
- * A simple bootstrap class for starting Jetty in your IDE using the local web application.
+ * A simple bootstrap class for starting Jetty in your IDE using the local web
+ * application.
  * 
  * @version $Revision$
  */
-public class Main {
-    
+public final class Main {
+
     public static final int PORT = 8080;
 
     public static final String WEBAPP_DIR = "src/main/webapp";
 
     public static final String WEBAPP_CTX = "/";
 
+    private Main() {
+    }
+
     public static void main(String[] args) throws Exception {
-        // now lets start the web server        
+        // now lets start the web server
         int port = PORT;
         if (args.length > 0) {
             String text = args[0];
@@ -50,14 +53,18 @@
         connector.setPort(port);
         connector.setServer(server);
         WebAppContext context = new WebAppContext();
-        
+
         context.setResourceBase(WEBAPP_DIR);
         context.setContextPath(WEBAPP_CTX);
         context.setServer(server);
-        server.setHandlers(new Handler[]{context});
-        server.setConnectors(new Connector[]{connector});
+        server.setHandlers(new Handler[] {
+            context
+        });
+        server.setConnectors(new Connector[] {
+            connector
+        });
         server.start();
-        
+
         System.out.println();
         System.out.println("==============================================================================");
         System.out.println("Started the ActiveMQ Console: point your web browser at http://localhost:" + port + "/");

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/AjaxServlet.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/AjaxServlet.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/AjaxServlet.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/AjaxServlet.java Sat Aug 11 22:27:21 2007
@@ -25,79 +25,75 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-
 /* ------------------------------------------------------------ */
-/** AjaxServlet.
- * The AjaxServlet extends the {@link MessageListenerServlet} with the capability to 
- * server the <code>amq.js</code> script and associated scripts from resources 
- * within the activemq-web jar.  The amq.js script is the client side companion to
- * the MessageListenerServlet and supports sending messages and long polling for 
- * receiving messages (Also called Comet style Ajax).
- * 
+/**
+ * AjaxServlet. The AjaxServlet extends the {@link MessageListenerServlet} with
+ * the capability to server the <code>amq.js</code> script and associated
+ * scripts from resources within the activemq-web jar. The amq.js script is the
+ * client side companion to the MessageListenerServlet and supports sending
+ * messages and long polling for receiving messages (Also called Comet style
+ * Ajax).
  */
 public class AjaxServlet extends MessageListenerServlet {
 
-    private Map jsCache = new HashMap();
-    private long jsLastModified = 1000*(System.currentTimeMillis()/1000);
-
+    private Map<String, byte[]> jsCache = new HashMap<String, byte[]>();
+    private long jsLastModified = 1000 * (System.currentTimeMillis() / 1000);
 
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        if (request.getPathInfo()!=null && request.getPathInfo().endsWith(".js"))
-            doJavaScript(request,response);
-        else 
+        if (request.getPathInfo() != null && request.getPathInfo().endsWith(".js")) {
+            doJavaScript(request, response);
+        } else {
             super.doGet(request, response);
+        }
     }
-    
-    protected void doJavaScript(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException {
-        
+
+    protected void doJavaScript(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+
         // Look for a local resource first.
-        String js = request.getServletPath()+request.getPathInfo();
+        String js = request.getServletPath() + request.getPathInfo();
         URL url = getServletContext().getResource(js);
-        if (url!=null)
-        {
-            getServletContext().getNamedDispatcher("default").forward(request,response);
+        if (url != null) {
+            getServletContext().getNamedDispatcher("default").forward(request, response);
             return;
         }
-        
+
         // Serve from the classpath resources
-        String resource="org/apache/activemq/web"+request.getPathInfo();
-        synchronized(jsCache){
-            
-            byte[] data = (byte[])jsCache.get(resource);
-            if (data==null) {
+        String resource = "org/apache/activemq/web" + request.getPathInfo();
+        synchronized (jsCache) {
+
+            byte[] data = jsCache.get(resource);
+            if (data == null) {
                 InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
-                if (in!=null)
-                {
+                if (in != null) {
                     ByteArrayOutputStream out = new ByteArrayOutputStream();
-                    byte[] buf=new byte[4096];
-                    int len=in.read(buf);
-                    while (len>=0) {
+                    byte[] buf = new byte[4096];
+                    int len = in.read(buf);
+                    while (len >= 0) {
                         out.write(buf, 0, len);
-                        len=in.read(buf);
+                        len = in.read(buf);
                     }
                     in.close();
                     out.close();
-                    data=out.toByteArray();
+                    data = out.toByteArray();
                     jsCache.put(resource, data);
                 }
             }
-            
-            if (data!=null){
-                
-                long if_modified = request.getDateHeader("If-Modified-Since");
-                
-                if (if_modified == jsLastModified) {
+
+            if (data != null) {
+
+                long ifModified = request.getDateHeader("If-Modified-Since");
+
+                if (ifModified == jsLastModified) {
                     response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
-                }
-                else  {
+                } else {
                     response.setContentType("application/x-javascript");
                     response.setContentLength(data.length);
-                    response.setDateHeader("Last-Modified",jsLastModified);
+                    response.setDateHeader("Last-Modified", jsLastModified);
                     response.getOutputStream().write(data);
                 }
-            }
-            else
+            } else {
                 response.sendError(HttpServletResponse.SC_NOT_FOUND);
+            }
         }
     }
 }

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java Sat Aug 11 22:27:21 2007
@@ -49,30 +49,29 @@
  * destination and whether it is a topic or queue via configuration details on
  * the servlet or as request parameters. <p/> For reading messages you can
  * specify a readTimeout parameter to determine how long the servlet should
- * block for.
- * 
- * The servlet can be configured with the following init parameters:<dl>
- * <dt>defaultReadTimeout</dt><dd>The default time in ms to wait for messages. 
- * May be overridden by a request using the 'timeout' parameter</dd>
- * <dt>maximumReadTimeout</dt><dd>The maximum value a request may specify for the 'timeout' parameter</dd>
- * <dt>maximumMessages</dt><dd>maximum messages to send per response</dd>
- * <dt></dt><dd></dd>
+ * block for. The servlet can be configured with the following init parameters:
+ * <dl>
+ * <dt>defaultReadTimeout</dt>
+ * <dd>The default time in ms to wait for messages. May be overridden by a
+ * request using the 'timeout' parameter</dd>
+ * <dt>maximumReadTimeout</dt>
+ * <dd>The maximum value a request may specify for the 'timeout' parameter</dd>
+ * <dt>maximumMessages</dt>
+ * <dd>maximum messages to send per response</dd>
+ * <dt></dt>
+ * <dd></dd>
  * </dl>
- *  
  * 
  * @version $Revision: 1.1.1.1 $
  */
 public class MessageListenerServlet extends MessageServletSupport {
-    private static final Log log = LogFactory.getLog(MessageListenerServlet.class);
+    private static final Log LOG = LogFactory.getLog(MessageListenerServlet.class);
 
     private String readTimeoutParameter = "timeout";
-
     private long defaultReadTimeout = -1;
-
     private long maximumReadTimeout = 25000;
-
     private int maximumMessages = 100;
-    
+
     public void init() throws ServletException {
         ServletConfig servletConfig = getServletConfig();
         String name = servletConfig.getInitParameter("defaultReadTimeout");
@@ -85,21 +84,23 @@
         }
         name = servletConfig.getInitParameter("maximumMessages");
         if (name != null) {
-            maximumMessages = (int) asLong(name);
+            maximumMessages = (int)asLong(name);
         }
     }
 
     /**
-     * Sends a message to a destination or manage subscriptions.
-     * 
-     * If the the content type of the POST is <code>application/x-www-form-urlencoded</code>, then the form parameters 
-     * "destination", "message" and "type" are used to pass a message or a subscription.  If multiple messages
-     * or subscriptions are passed in a single post, then additional parameters are shortened to "dN", "mN" and "tN"
-     * where N is an index starting from 1. The type is either "send", "listen" or "unlisten".  For send types,
-     * the message is the text of the TextMessage, otherwise it is the ID to be used for the subscription.
-     * 
-     * If the content type is not <code>application/x-www-form-urlencoded</code>, then the body of the post is
-     * sent as the message to a destination that is derived from a query parameter, the URL or the default destination.
+     * Sends a message to a destination or manage subscriptions. If the the
+     * content type of the POST is
+     * <code>application/x-www-form-urlencoded</code>, then the form
+     * parameters "destination", "message" and "type" are used to pass a message
+     * or a subscription. If multiple messages or subscriptions are passed in a
+     * single post, then additional parameters are shortened to "dN", "mN" and
+     * "tN" where N is an index starting from 1. The type is either "send",
+     * "listen" or "unlisten". For send types, the message is the text of the
+     * TextMessage, otherwise it is the ID to be used for the subscription. If
+     * the content type is not <code>application/x-www-form-urlencoded</code>,
+     * then the body of the post is sent as the message to a destination that is
+     * derived from a query parameter, the URL or the default destination.
      * 
      * @param request
      * @param response
@@ -107,134 +108,122 @@
      * @throws IOException
      */
     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        
+
         // lets turn the HTTP post into a JMS Message
-        
+
         WebClient client = WebClient.getWebClient(request);
-        String message_ids="";
-        
+        String messageIds = "";
+
         synchronized (client) {
-            
-            if (log.isDebugEnabled()) {
-                log.debug("POST client="+client+" session="+request.getSession().getId()+" info="+request.getPathInfo()+" contentType="+request.getContentType());
-            // dump(request.getParameterMap());
-            }
-            
-            int messages=0;
-            
+
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("POST client=" + client + " session=" + request.getSession().getId() + " info=" + request.getPathInfo() + " contentType=" + request.getContentType());
+                // dump(request.getParameterMap());
+            }
+
+            int messages = 0;
+
             // loop until no more messages
-            while (true)
-            {
-                // Get the message parameters.   Multiple messages are encoded with more compact parameter names.
-                String destination_name = request.getParameter(messages==0?"destination":("d"+messages));
-                
-                if(destination_name == null)
-                	destination_name = request.getHeader("destination");
-                
-                String message = request.getParameter(messages==0?"message":("m"+messages));
-                String type = request.getParameter(messages==0?"type":("t"+messages));
-                
-                if (destination_name==null || message==null || type==null)
+            while (true) {
+                // Get the message parameters. Multiple messages are encoded
+                // with more compact parameter names.
+                String destinationName = request.getParameter(messages == 0 ? "destination" : ("d" + messages));
+
+                if (destinationName == null) {
+                    destinationName = request.getHeader("destination");
+                }
+
+                String message = request.getParameter(messages == 0 ? "message" : ("m" + messages));
+                String type = request.getParameter(messages == 0 ? "type" : ("t" + messages));
+
+                if (destinationName == null || message == null || type == null) {
                     break;
-                
+                }
+
                 try {
-                    Destination destination=getDestination(client,request,destination_name);
-                    
-                    if (log.isDebugEnabled()) {
-                        log.debug(messages+" destination="+destination_name+" message="+message+" type="+type);
-                        log.debug(destination+" is a "+destination.getClass().getName());
+                    Destination destination = getDestination(client, request, destinationName);
+
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug(messages + " destination=" + destinationName + " message=" + message + " type=" + type);
+                        LOG.debug(destination + " is a " + destination.getClass().getName());
                     }
-                    
+
                     messages++;
-                    
-                    if ("listen".equals(type))
-                    {
+
+                    if ("listen".equals(type)) {
                         Listener listener = getListener(request);
-                        Map consumerIdMap = getConsumerIdMap(request);
-                        Map consumerDestinationMap = getConsumerDestinationNameMap(request);
-                        client.closeConsumer(destination); // drop any existing consumer.
-                        MessageAvailableConsumer consumer = (MessageAvailableConsumer) client.getConsumer(destination);
-                        
+                        Map<MessageAvailableConsumer, String> consumerIdMap = getConsumerIdMap(request);
+                        Map<MessageAvailableConsumer, String> consumerDestinationMap = getConsumerDestinationNameMap(request);
+                        client.closeConsumer(destination); // drop any existing
+                        // consumer.
+                        MessageAvailableConsumer consumer = (MessageAvailableConsumer)client.getConsumer(destination);
+
                         consumer.setAvailableListener(listener);
                         consumerIdMap.put(consumer, message);
-                        consumerDestinationMap.put(consumer, destination_name);
-                        if (log.isDebugEnabled()) {
-                            log.debug("Subscribed: "+consumer+" to "+destination+" id="+message);
+                        consumerDestinationMap.put(consumer, destinationName);
+                        if (LOG.isDebugEnabled()) {
+                            LOG.debug("Subscribed: " + consumer + " to " + destination + " id=" + message);
                         }
-                    }
-                    else if ("unlisten".equals(type))
-                    {
-                        Map consumerIdMap = getConsumerIdMap(request);
+                    } else if ("unlisten".equals(type)) {
+                        Map<MessageAvailableConsumer, String> consumerIdMap = getConsumerIdMap(request);
                         Map consumerDestinationMap = getConsumerDestinationNameMap(request);
-                        MessageAvailableConsumer consumer = (MessageAvailableConsumer) client.getConsumer(destination);
-                        
+                        MessageAvailableConsumer consumer = (MessageAvailableConsumer)client.getConsumer(destination);
+
                         consumer.setAvailableListener(null);
                         consumerIdMap.remove(consumer);
                         consumerDestinationMap.remove(consumer);
                         client.closeConsumer(destination);
-                        if (log.isDebugEnabled()) {
-                            log.debug("Unsubscribed: "+consumer);
+                        if (LOG.isDebugEnabled()) {
+                            LOG.debug("Unsubscribed: " + consumer);
                         }
-                    }
-                    else if ("send".equals(type))
-                    {
+                    } else if ("send".equals(type)) {
                         TextMessage text = client.getSession().createTextMessage(message);
                         appendParametersToMessage(request, text);
 
                         client.send(destination, text);
-                        message_ids+=text.getJMSMessageID()+"\n";
-                        if (log.isDebugEnabled()) {
-                            log.debug("Sent "+message+" to "+destination);
+                        messageIds += text.getJMSMessageID() + "\n";
+                        if (LOG.isDebugEnabled()) {
+                            LOG.debug("Sent " + message + " to " + destination);
                         }
+                    } else {
+                        LOG.warn("unknown type " + type);
                     }
-                    else
-                        log.warn("unknown type "+type);
-                    
-                } 
-                catch (JMSException e) {
-                    log.warn("jms", e);
+
+                } catch (JMSException e) {
+                    LOG.warn("jms", e);
                 }
             }
         }
-            
-        if ("true".equals(request.getParameter("poll")))
-        {
-            try
-            {
+
+        if ("true".equals(request.getParameter("poll"))) {
+            try {
                 // TODO return message IDs
-                doMessages(client,request,response);
-            }
-            catch (JMSException e) 
-            {
+                doMessages(client, request, response);
+            } catch (JMSException e) {
                 throw new ServletException("JMS problem: " + e, e);
             }
-        }
-        else 
-        {
+        } else {
             // handle simple POST of a message
-            if (request.getContentLength()!=0 && 
-               (request.getContentType()==null || !request.getContentType().toLowerCase().startsWith("application/x-www-form-urlencoded")))
-            {
+            if (request.getContentLength() != 0 && (request.getContentType() == null || !request.getContentType().toLowerCase().startsWith("application/x-www-form-urlencoded"))) {
                 try {
-                    Destination destination=getDestination(client, request);
+                    Destination destination = getDestination(client, request);
                     String body = getPostedMessageBody(request);
-                    TextMessage message = client.getSession().createTextMessage(body );
+                    TextMessage message = client.getSession().createTextMessage(body);
                     appendParametersToMessage(request, message);
 
                     client.send(destination, message);
-                    if (log.isDebugEnabled()) {
-                        log.debug("Sent to destination: " + destination + " body: " + body);
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Sent to destination: " + destination + " body: " + body);
                     }
-                    message_ids+=message.getJMSMessageID()+"\n";
-                }
-                catch (JMSException e) {
+                    messageIds += message.getJMSMessageID() + "\n";
+                } catch (JMSException e) {
                     throw new ServletException(e);
                 }
             }
-            
+
             response.setContentType("text/plain");
             response.setHeader("Cache-Control", "no-cache");
-            response.getWriter().print(message_ids);
+            response.getWriter().print(messageIds);
         }
     }
 
@@ -245,23 +234,20 @@
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         try {
             WebClient client = WebClient.getWebClient(request);
-            if (log.isDebugEnabled()) {
-                log.debug("GET client="+client+" session="+request.getSession().getId()+" uri="+request.getRequestURI()+" query="+request.getQueryString());
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("GET client=" + client + " session=" + request.getSession().getId() + " uri=" + request.getRequestURI() + " query=" + request.getQueryString());
             }
-            
+
             doMessages(client, request, response);
-        }
-        catch (JMSException e) {
+        } catch (JMSException e) {
             throw new ServletException("JMS problem: " + e, e);
         }
     }
 
-
     /**
      * Reads a message from a destination up to some specific timeout period
      * 
-     * @param client
-     *            The webclient
+     * @param client The webclient
      * @param request
      * @param response
      * @throws ServletException
@@ -273,14 +259,15 @@
         // This is a poll for any messages
 
         long timeout = getReadTimeout(request);
-        if (log.isDebugEnabled()) {
-            log.debug("doMessage timeout="+timeout);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("doMessage timeout=" + timeout);
         }
-        
+
         Continuation continuation = ContinuationSupport.getContinuation(request, client);
         Listener listener = getListener(request);
-        if (listener!=null && continuation!=null && !continuation.isPending())
+        if (listener != null && continuation != null && !continuation.isPending()) {
             listener.access();
+        }
 
         Message message = null;
         synchronized (client) {
@@ -290,14 +277,15 @@
 
             // Look for a message that is ready to go
             for (int i = 0; message == null && i < consumers.size(); i++) {
-                consumer = (MessageAvailableConsumer) consumers.get(i);
-                if (consumer.getAvailableListener() == null)
+                consumer = (MessageAvailableConsumer)consumers.get(i);
+                if (consumer.getAvailableListener() == null) {
                     continue;
+                }
 
                 // Look for any available messages
                 message = consumer.receiveNoWait();
-                if (log.isDebugEnabled()) {
-                    log.debug("received "+message+" from "+consumer);
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("received " + message + " from " + consumer);
                 }
             }
 
@@ -321,20 +309,21 @@
             StringWriter swriter = new StringWriter();
             PrintWriter writer = new PrintWriter(swriter);
 
-            Map consumerIdMap = getConsumerIdMap(request);
+            Map<MessageAvailableConsumer, String> consumerIdMap = getConsumerIdMap(request);
             Map<MessageAvailableConsumer, String> consumerDestinationNameMap = getConsumerDestinationNameMap(request);
             response.setStatus(HttpServletResponse.SC_OK);
             writer.println("<ajax-response>");
 
             // Send any message we already have
             if (message != null) {
-                String id = (String) consumerIdMap.get(consumer);
+                String id = consumerIdMap.get(consumer);
                 String destinationName = consumerDestinationNameMap.get(consumer);
                 writer.print("<response id='");
                 writer.print(id);
                 writer.print("'");
-                if(destinationName != null)
-                	writer.print(" destination='" + destinationName + "' ");
+                if (destinationName != null) {
+                    writer.print(" destination='" + destinationName + "' ");
+                }
                 writer.print(">");
                 writeMessageResponse(writer, message);
                 writer.println("</response>");
@@ -343,9 +332,10 @@
 
             // Send the rest of the messages
             for (int i = 0; i < consumers.size() && messages < maximumMessages; i++) {
-                consumer = (MessageAvailableConsumer) consumers.get(i);
-                if (consumer.getAvailableListener() == null)
+                consumer = (MessageAvailableConsumer)consumers.get(i);
+                if (consumer.getAvailableListener() == null) {
                     continue;
+                }
 
                 // Look for any available messages
                 while (messages < maximumMessages) {
@@ -354,22 +344,24 @@
                         break;
                     }
                     messages++;
-                    String id = (String) consumerIdMap.get(consumer);
+                    String id = consumerIdMap.get(consumer);
                     String destinationName = consumerDestinationNameMap.get(consumer);
                     writer.print("<response id='");
                     writer.print(id);
                     writer.print("'");
-                    if(destinationName != null)
-                    	writer.print(" destination='" + destinationName + "' ");
-                    writer.print(">");                    
+                    if (destinationName != null) {
+                        writer.print(" destination='" + destinationName + "' ");
+                    }
+                    writer.print(">");
                     writeMessageResponse(writer, message);
                     writer.println("</response>");
                 }
             }
 
             // Add poll message
-            // writer.println("<response type='object' id='amqPoll'><ok/></response>");
-            
+            // writer.println("<response type='object'
+            // id='amqPoll'><ok/></response>");
+
             writer.print("</ajax-response>");
 
             writer.flush();
@@ -382,14 +374,14 @@
 
     protected void writeMessageResponse(PrintWriter writer, Message message) throws JMSException, IOException {
         if (message instanceof TextMessage) {
-            TextMessage textMsg = (TextMessage) message;
+            TextMessage textMsg = (TextMessage)message;
             String txt = textMsg.getText();
             if (txt.startsWith("<?")) {
                 txt = txt.substring(txt.indexOf("?>") + 2);
             }
             writer.print(txt);
         } else if (message instanceof ObjectMessage) {
-            ObjectMessage objectMsg = (ObjectMessage) message;
+            ObjectMessage objectMsg = (ObjectMessage)message;
             Object object = objectMsg.getObject();
             writer.print(object.toString());
         }
@@ -397,7 +389,7 @@
 
     protected Listener getListener(HttpServletRequest request) {
         HttpSession session = request.getSession();
-        Listener listener = (Listener) session.getAttribute("mls.listener");
+        Listener listener = (Listener)session.getAttribute("mls.listener");
         if (listener == null) {
             listener = new Listener(WebClient.getWebClient(request));
             session.setAttribute("mls.listener", listener);
@@ -405,26 +397,26 @@
         return listener;
     }
 
-    protected Map getConsumerIdMap(HttpServletRequest request) {
+    protected Map<MessageAvailableConsumer, String> getConsumerIdMap(HttpServletRequest request) {
         HttpSession session = request.getSession(true);
-        Map map = (Map) session.getAttribute("mls.consumerIdMap");
+        Map<MessageAvailableConsumer, String> map = (Map<MessageAvailableConsumer, String>)session.getAttribute("mls.consumerIdMap");
         if (map == null) {
-            map = new HashMap();
+            map = new HashMap<MessageAvailableConsumer, String>();
             session.setAttribute("mls.consumerIdMap", map);
         }
         return map;
     }
 
     protected Map<MessageAvailableConsumer, String> getConsumerDestinationNameMap(HttpServletRequest request) {
-    	HttpSession session = request.getSession(true);
-    	Map map = (Map) session.getAttribute("mls.consumerDestinationNameMap");
-      if (map == null) {
-        map = new HashMap<MessageAvailableConsumer, String>();
-        session.setAttribute("mls.consumerDestinationNameMap", map);
-      }
-      return map;
+        HttpSession session = request.getSession(true);
+        Map<MessageAvailableConsumer, String> map = (Map<MessageAvailableConsumer, String>)session.getAttribute("mls.consumerDestinationNameMap");
+        if (map == null) {
+            map = new HashMap<MessageAvailableConsumer, String>();
+            session.setAttribute("mls.consumerDestinationNameMap", map);
+        }
+        return map;
     }
-    
+
     protected boolean isRicoAjax(HttpServletRequest request) {
         String rico = request.getParameter("rico");
         return rico != null && rico.equals("true");
@@ -459,23 +451,21 @@
             this.client = client;
         }
 
-        public void access()
-        {
-            lastAccess=System.currentTimeMillis();
+        public void access() {
+            lastAccess = System.currentTimeMillis();
         }
-        
-        synchronized public void setContinuation(Continuation continuation) {
+
+        public synchronized void setContinuation(Continuation continuation) {
             this.continuation = continuation;
         }
 
-        synchronized public void onMessageAvailable(MessageConsumer consumer) {
-            if (log.isDebugEnabled()) {
-                log.debug("message for "+consumer+"continuation="+continuation);
+        public synchronized void onMessageAvailable(MessageConsumer consumer) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("message for " + consumer + "continuation=" + continuation);
             }
-            if (continuation != null)
+            if (continuation != null) {
                 continuation.resume();
-            else if (System.currentTimeMillis()-lastAccess>2*maximumReadTimeout)
-            {
+            } else if (System.currentTimeMillis() - lastAccess > 2 * maximumReadTimeout) {
                 new Thread() {
                     public void run() {
                         client.closeConsumers();