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 [15/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/src/main/java/org/apache/activemq/web/MessageServlet.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java Sat Aug 11 22:27:21 2007
@@ -51,7 +51,7 @@
  * @version $Revision: 1.1.1.1 $
  */
 public class MessageServlet extends MessageServletSupport {
-    private static final Log log = LogFactory.getLog(MessageServlet.class);
+    private static final Log LOG = LogFactory.getLog(MessageServlet.class);
 
     private String readTimeoutParameter = "readTimeout";
     private long defaultReadTimeout = -1;
@@ -86,13 +86,14 @@
 
             // lets create the destination from the URI?
             Destination destination = getDestination(client, request);
-            if (destination==null)
+            if (destination == null) {
                 throw new NoDestinationSuppliedException();
+            }
 
-            if (log.isDebugEnabled()) {
-                log.debug("Sending message to: " + destination + " with text: " + text);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Sending message to: " + destination + " with text: " + text);
             }
-            
+
             TextMessage message = client.getSession().createTextMessage(text);
             appendParametersToMessage(request, message);
             boolean persistent = isSendPersistent(request);
@@ -103,8 +104,7 @@
             // lets return a unique URI for reliable messaging
             response.setHeader("messageID", message.getJMSMessageID());
             response.setStatus(HttpServletResponse.SC_OK);
-        }
-        catch (JMSException e) {
+        } catch (JMSException e) {
             throw new ServletException("Could not post JMS message: " + e, e);
         }
     }
@@ -139,25 +139,27 @@
         try {
             WebClient client = WebClient.getWebClient(request);
             Destination destination = getDestination(client, request);
-            if (destination==null)
+            if (destination == null) {
                 throw new NoDestinationSuppliedException();
+            }
             long timeout = getReadTimeout(request);
             boolean ajax = isRicoAjax(request);
-            if (!ajax)
+            if (!ajax) {
                 maxMessages = 1;
+            }
 
-            if (log.isDebugEnabled()) {
-                log.debug("Receiving message(s) from: " + destination + " with timeout: " + timeout);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Receiving message(s) from: " + destination + " with timeout: " + timeout);
             }
 
-            MessageAvailableConsumer consumer = (MessageAvailableConsumer) client.getConsumer(destination);
+            MessageAvailableConsumer consumer = (MessageAvailableConsumer)client.getConsumer(destination);
             Continuation continuation = null;
             Listener listener = null;
             Message message = null;
 
             synchronized (consumer) {
                 // Fetch the listeners
-                listener = (Listener) consumer.getAvailableListener();
+                listener = (Listener)consumer.getAvailableListener();
                 if (listener == null) {
                     listener = new Listener(consumer);
                     consumer.setAvailableListener(listener);
@@ -179,27 +181,29 @@
                 }
 
                 // Try again now
-                if (message == null)
+                if (message == null) {
                     message = consumer.receiveNoWait();
+                }
 
                 // write a responds
                 response.setContentType("text/xml");
                 PrintWriter writer = response.getWriter();
 
-                if (ajax)
+                if (ajax) {
                     writer.println("<ajax-response>");
+                }
 
                 // handle any message(s)
                 if (message == null) {
                     // No messages so OK response of for ajax else no content.
                     response.setStatus(ajax ? HttpServletResponse.SC_OK : HttpServletResponse.SC_NO_CONTENT);
-                }
-                else {
+                } else {
                     // We have at least one message so set up the response
                     response.setStatus(HttpServletResponse.SC_OK);
                     String type = getContentType(request);
-                    if (type != null)
+                    if (type != null) {
                         response.setContentType(type);
+                    }
 
                     // send a response for each available message (up to max
                     // messages)
@@ -209,15 +213,16 @@
                             writer.print("<response type='object' id='");
                             writer.print(request.getParameter("id"));
                             writer.println("'>");
-                        }
-                        else
+                        } else {
                             // only ever 1 message for non ajax!
                             setResponseHeaders(response, message);
+                        }
 
                         writeMessageResponse(writer, message);
 
-                        if (ajax)
+                        if (ajax) {
                             writer.println("</response>");
+                        }
 
                         // look for next message
                         message = consumer.receiveNoWait();
@@ -230,13 +235,11 @@
                     writer.println("</ajax-response>");
                 }
             }
-        }
-        catch (JMSException e) {
+        } catch (JMSException e) {
             throw new ServletException("Could not post JMS message: " + e, e);
-        }
-        finally {
-            if (log.isDebugEnabled()) {
-                log.debug("Received " + messages + " message(s)");
+        } finally {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Received " + messages + " message(s)");
             }
         }
     }
@@ -249,8 +252,7 @@
      * @throws ServletException
      * @throws IOException
      */
-    protected void doMessagesWithoutContinuation(HttpServletRequest request, HttpServletResponse response,
-            int maxMessages) throws ServletException, IOException {
+    protected void doMessagesWithoutContinuation(HttpServletRequest request, HttpServletResponse response, int maxMessages) throws ServletException, IOException {
 
         int messages = 0;
         try {
@@ -258,24 +260,23 @@
             Destination destination = getDestination(client, request);
             long timeout = getReadTimeout(request);
             boolean ajax = isRicoAjax(request);
-            if (!ajax)
+            if (!ajax) {
                 maxMessages = 1;
-
-            if (log.isDebugEnabled()) {
-                log.debug("Receiving message(s) from: " + destination + " with timeout: " + timeout);
+            }
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Receiving message(s) from: " + destination + " with timeout: " + timeout);
             }
 
-            MessageAvailableConsumer consumer = (MessageAvailableConsumer) client.getConsumer(destination);
-            Continuation continuation = null;
-            Listener listener = null;
+            MessageAvailableConsumer consumer = (MessageAvailableConsumer)client.getConsumer(destination);
             Message message = null;
 
             // write a responds
             response.setContentType("text/xml");
             PrintWriter writer = response.getWriter();
 
-            if (ajax)
+            if (ajax) {
                 writer.println("<ajax-response>");
+            }
 
             // Only one client thread at a time should poll for messages.
             if (client.getSemaphore().tryAcquire()) {
@@ -293,8 +294,9 @@
                         // response
                         response.setStatus(HttpServletResponse.SC_OK);
                         String type = getContentType(request);
-                        if (type != null)
+                        if (type != null) {
                             response.setContentType(type);
+                        }
 
                         // send a response for each available message (up to
                         // max
@@ -305,14 +307,16 @@
                                 writer.print("<response type='object' id='");
                                 writer.print(request.getParameter("id"));
                                 writer.println("'>");
-                            } else
+                            } else {
                                 // only ever 1 message for non ajax!
                                 setResponseHeaders(response, message);
+                            }
 
                             writeMessageResponse(writer, message);
 
-                            if (ajax)
+                            if (ajax) {
                                 writer.println("</response>");
+                            }
 
                             // look for next message
                             message = consumer.receiveNoWait();
@@ -335,23 +339,22 @@
         } catch (JMSException e) {
             throw new ServletException("Could not post JMS message: " + e, e);
         } finally {
-            if (log.isDebugEnabled()) {
-                log.debug("Received " + messages + " message(s)");
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Received " + messages + " message(s)");
             }
         }
     }
 
     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;
+        } else if (message instanceof ObjectMessage) {
+            ObjectMessage objectMsg = (ObjectMessage)message;
             Object object = objectMsg.getObject();
             writer.print(object.toString());
         }
@@ -420,8 +423,9 @@
             assert this.consumer == consumer;
 
             synchronized (this.consumer) {
-                if (continuation != null)
+                if (continuation != null) {
                     continuation.resume();
+                }
                 continuation = null;
             }
         }

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java Sat Aug 11 22:27:21 2007
@@ -17,11 +17,11 @@
 
 package org.apache.activemq.web;
 
-import org.apache.activemq.command.ActiveMQDestination;
-import org.apache.activemq.command.ActiveMQQueue;
-import org.apache.activemq.command.ActiveMQTopic;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
 
 import javax.jms.Destination;
 import javax.jms.JMSException;
@@ -30,28 +30,34 @@
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
+
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
- * A useful base class for any JMS related servlet;
- * there are various ways to map JMS operations to web requests
- * so we put most of the common behaviour in a reusable base class.
- *
- * This servlet can be configured with the following init paramters <dl>
- * <dt>topic</dt><dd>Set to 'true' if the servle should default to using topics rather than channels</dd>
- * <dt>destination</dt><dd>The default destination to use if one is not specifiied</dd>
- * <dt></dt><dd></dd>
+ * A useful base class for any JMS related servlet; there are various ways to
+ * map JMS operations to web requests so we put most of the common behaviour in
+ * a reusable base class. This servlet can be configured with the following init
+ * paramters
+ * <dl>
+ * <dt>topic</dt>
+ * <dd>Set to 'true' if the servle should default to using topics rather than
+ * channels</dd>
+ * <dt>destination</dt>
+ * <dd>The default destination to use if one is not specifiied</dd>
+ * <dt></dt>
+ * <dd></dd>
  * </dl>
+ * 
  * @version $Revision: 1.1.1.1 $
  */
 public abstract class MessageServletSupport extends HttpServlet {
 
-    private static final transient Log log = LogFactory.getLog(MessageServletSupport.class);
-    
+    private static final transient Log LOG = LogFactory.getLog(MessageServletSupport.class);
+
     private boolean defaultTopicFlag = true;
     private Destination defaultDestination;
     private String destinationParameter = "destination";
@@ -59,28 +65,27 @@
     private String bodyParameter = "body";
     private boolean defaultMessagePersistent = true;
     private int defaultMessagePriority = 5;
-    private long defaultMessageTimeToLive = 0;
+    private long defaultMessageTimeToLive;
     private String destinationOptions;
 
     public void init(ServletConfig servletConfig) throws ServletException {
         super.init(servletConfig);
 
         destinationOptions = servletConfig.getInitParameter("destinationOptions");
-        
+
         String name = servletConfig.getInitParameter("topic");
         if (name != null) {
             defaultTopicFlag = asBoolean(name);
         }
 
-        if (log.isDebugEnabled()) {
-            log.debug("Defaulting to use topics: " + defaultTopicFlag);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Defaulting to use topics: " + defaultTopicFlag);
         }
         name = servletConfig.getInitParameter("destination");
         if (name != null) {
             if (defaultTopicFlag) {
                 defaultDestination = new ActiveMQTopic(name);
-            }
-            else {
+            } else {
                 defaultDestination = new ActiveMQQueue(name);
             }
         }
@@ -92,17 +97,15 @@
     public static boolean asBoolean(String param) {
         return asBoolean(param, false);
     }
-    
+
     public static boolean asBoolean(String param, boolean defaultValue) {
         if (param == null) {
             return defaultValue;
-        }
-        else {
+        } else {
             return param.equalsIgnoreCase("true");
         }
     }
 
-
     protected void appendParametersToMessage(HttpServletRequest request, TextMessage message) throws JMSException {
         Map parameterMap = request.getParameterMap();
         if (parameterMap == null) {
@@ -121,31 +124,27 @@
         if (replyTo != null) {
             message.setJMSReplyTo(replyTo);
         }
-        String type = (String) asString(parameters.remove("JMSType"));
+        String type = (String)asString(parameters.remove("JMSType"));
         if (correlationID != null) {
             message.setJMSType(type);
         }
 
         for (Iterator iter = parameters.entrySet().iterator(); iter.hasNext();) {
-            Map.Entry entry = (Map.Entry) iter.next();
-            String name = (String) entry.getKey();
-            if (!destinationParameter.equals(name) 
-            		&& !typeParameter.equals(name) 
-            		&& !bodyParameter.equals(name)
-            		&& !"JMSDeliveryMode".equals(name)
-            		&& !"JMSPriority".equals(name)
-            		&& !"JMSTimeToLive".equals(name)) {
+            Map.Entry entry = (Map.Entry)iter.next();
+            String name = (String)entry.getKey();
+            if (!destinationParameter.equals(name) && !typeParameter.equals(name) && !bodyParameter.equals(name) && !"JMSDeliveryMode".equals(name) && !"JMSPriority".equals(name)
+                && !"JMSTimeToLive".equals(name)) {
                 Object value = entry.getValue();
                 if (value instanceof Object[]) {
-                    Object[] array = (Object[]) value;
+                    Object[] array = (Object[])value;
                     if (array.length == 1) {
                         value = array[0];
-                    }
-                    else {
-                        log.warn("Can't use property: " + name + " which is of type: " + value.getClass().getName() + " value");
+                    } else {
+                        LOG.warn("Can't use property: " + name + " which is of type: " + value.getClass().getName() + " value");
                         value = null;
-                        for (int i = 0, size = array.length; i < size; i++) {
-                             log.debug("value[" + i + "] = " + array[i]);
+                        int size = array.length;
+                        for (int i = 0; i < size; i++) {
+                            LOG.debug("value[" + i + "] = " + array[i]);
                         }
                     }
                 }
@@ -173,27 +172,23 @@
     }
 
     protected boolean isSendPersistent(HttpServletRequest request) {
-    	String text = request.getParameter("JMSDeliveryMode");
-    	if (text != null) {
-    		if (text.trim().equalsIgnoreCase("persistent")) {
-    			return true;
-    		} else {
-    			return false;
-    		}
-    	}
+        String text = request.getParameter("JMSDeliveryMode");
+        if (text != null) {
+            return text.trim().equalsIgnoreCase("persistent");
+        }
         return defaultMessagePersistent;
     }
 
     protected Destination asDestination(Object value) {
         if (value instanceof Destination) {
-            return (Destination) value;
+            return (Destination)value;
         }
         if (value instanceof String) {
-            String text = (String) value;
+            String text = (String)value;
             return ActiveMQDestination.createDestination(text, ActiveMQDestination.QUEUE_TYPE);
         }
         if (value instanceof String[]) {
-            String text = ((String[]) value)[0];
+            String text = ((String[])value)[0];
             if (text == null) {
                 return null;
             }
@@ -204,26 +199,26 @@
 
     protected Integer asInteger(Object value) {
         if (value instanceof Integer) {
-            return (Integer) value;
+            return (Integer)value;
         }
         if (value instanceof String) {
-            return Integer.valueOf((String) value);
+            return Integer.valueOf((String)value);
         }
         if (value instanceof String[]) {
-            return Integer.valueOf(((String[]) value)[0]);
+            return Integer.valueOf(((String[])value)[0]);
         }
         return null;
     }
 
     protected Long asLong(Object value) {
         if (value instanceof Long) {
-            return (Long) value;
+            return (Long)value;
         }
         if (value instanceof String) {
-            return Long.valueOf((String) value);
+            return Long.valueOf((String)value);
         }
         if (value instanceof String[]) {
-            return Long.valueOf(((String[]) value)[0]);
+            return Long.valueOf(((String[])value)[0]);
         }
         return null;
     }
@@ -231,7 +226,7 @@
     protected long asLong(String name) {
         return Long.parseLong(name);
     }
-    
+
     protected int asInt(String name) {
         return Integer.parseInt(name);
     }
@@ -256,8 +251,7 @@
         if (destinationName == null) {
             if (defaultDestination == null) {
                 return getDestinationFromURI(client, request);
-            }
-            else {
+            } else {
                 return defaultDestination;
             }
         }
@@ -266,23 +260,25 @@
     }
 
     /**
-     * @return the destination to use for the current request using the relative URI from
-     *         where this servlet was invoked as the destination name
+     * @return the destination to use for the current request using the relative
+     *         URI from where this servlet was invoked as the destination name
      */
     protected Destination getDestinationFromURI(WebClient client, HttpServletRequest request) throws JMSException {
         String uri = request.getPathInfo();
-        if (uri == null)
+        if (uri == null) {
             return null;
-        
+        }
+
         // replace URI separator with JMS destination separator
         if (uri.startsWith("/")) {
             uri = uri.substring(1);
-            if (uri.length()==0)
+            if (uri.length() == 0) {
                 return null;
+            }
         }
-        
+
         uri = uri.replace('/', '.');
-        System.err.println("destination uri="+uri);
+        System.err.println("destination uri=" + uri);
         return getDestination(client, request, uri);
     }
 
@@ -292,35 +288,32 @@
     protected Destination getDestination(WebClient client, HttpServletRequest request, String destinationName) throws JMSException {
 
         // TODO cache destinations ???
-        
-        boolean is_topic=defaultTopicFlag;
-        if (destinationName.startsWith("topic://"))
-        {
-            is_topic=true;
-            destinationName=destinationName.substring(8);
-        }
-        else if (destinationName.startsWith("channel://"))
-        {
-            is_topic=false;
-            destinationName=destinationName.substring(10);
-        }
-        else 
-            is_topic=isTopic(request);
-        
-        if( destinationOptions!=null ) {
+
+        boolean isTopic = defaultTopicFlag;
+        if (destinationName.startsWith("topic://")) {
+            isTopic = true;
+            destinationName = destinationName.substring(8);
+        } else if (destinationName.startsWith("channel://")) {
+            isTopic = false;
+            destinationName = destinationName.substring(10);
+        } else {
+            isTopic = isTopic(request);
+        }
+
+        if (destinationOptions != null) {
             destinationName += "?" + destinationOptions;
         }
-        
-        if (is_topic) {
+
+        if (isTopic) {
             return client.getSession().createTopic(destinationName);
-        }
-        else {
+        } else {
             return client.getSession().createQueue(destinationName);
         }
     }
 
     /**
-     * @return true if the current request is for a topic destination, else false if its for a queue
+     * @return true if the current request is for a topic destination, else
+     *         false if its for a queue
      */
     protected boolean isTopic(HttpServletRequest request) {
         String typeText = request.getParameter(typeParameter);

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/PortfolioPublishServlet.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/PortfolioPublishServlet.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/PortfolioPublishServlet.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/PortfolioPublishServlet.java Sat Aug 11 22:27:21 2007
@@ -16,6 +16,11 @@
  */
 package org.apache.activemq.web;
 
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Hashtable;
+import java.util.Map;
+
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
@@ -23,10 +28,6 @@
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Hashtable;
-import java.util.Map;
 
 /**
  * A servlet which will publish dummy market data prices
@@ -35,15 +36,11 @@
  */
 public class PortfolioPublishServlet extends MessageServletSupport {
 
-    private static final int maxDeltaPercent = 1;
-    private static final Map lastPrices = new Hashtable();
-    private boolean ricoStyle = true;
+    private static final int MAX_DELTA_PERCENT = 1;
+    private static final Map<String, Double> LAST_PRICES = new Hashtable<String, Double>();
 
-    
     public void init() throws ServletException {
         super.init();
-        
-        ricoStyle = asBoolean(getServletConfig().getInitParameter("rico"), true);
     }
 
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
@@ -51,17 +48,16 @@
         String[] stocks = request.getParameterValues("stocks");
         if (stocks == null || stocks.length == 0) {
             out.println("<html><body>No <b>stocks</b> query parameter specified. Cannot publish market data</body></html>");
-        }
-        else {
-            Integer total=(Integer)request.getSession(true).getAttribute("total");
-            if (total==null)
-                total=Integer.valueOf(0);
-            
-            
+        } else {
+            Integer total = (Integer)request.getSession(true).getAttribute("total");
+            if (total == null) {
+                total = Integer.valueOf(0);
+            }
+
             int count = getNumberOfMessages(request);
-            total=Integer.valueOf(total.intValue()+count);
-            request.getSession().setAttribute("total",total);
-            
+            total = Integer.valueOf(total.intValue() + count);
+            request.getSession().setAttribute("total", total);
+
             try {
                 WebClient client = WebClient.getWebClient(request);
                 for (int i = 0; i < count; i++) {
@@ -74,11 +70,10 @@
                 }
                 out.print(refreshRate);
                 out.println("'/></head>");
-                out.println("<body>Published <b>" + count + "</b> of "+total+ " price messages.  Refresh = "+refreshRate+"s");
+                out.println("<body>Published <b>" + count + "</b> of " + total + " price messages.  Refresh = " + refreshRate + "s");
                 out.println("</body></html>");
 
-            }
-            catch (JMSException e) {
+            } catch (JMSException e) {
                 out.println("<html><body>Failed sending price messages due to <b>" + e + "</b></body></html>");
                 log("Failed to send message: " + e, e);
             }
@@ -90,7 +85,7 @@
 
         int idx = 0;
         while (true) {
-            idx = (int) Math.round(stocks.length * Math.random());
+            idx = (int)Math.round(stocks.length * Math.random());
             if (idx < stocks.length) {
                 break;
             }
@@ -104,7 +99,7 @@
     }
 
     protected String createStockText(String stock) {
-        Double value = (Double) lastPrices.get(stock);
+        Double value = LAST_PRICES.get(stock);
         if (value == null) {
             value = new Double(Math.random() * 100);
         }
@@ -112,7 +107,7 @@
         // lets mutate the value by some percentage
         double oldPrice = value.doubleValue();
         value = new Double(mutatePrice(oldPrice));
-        lastPrices.put(stock, value);
+        LAST_PRICES.put(stock, value);
         double price = value.doubleValue();
 
         double offer = price * 1.001;
@@ -122,7 +117,7 @@
     }
 
     protected double mutatePrice(double price) {
-        double percentChange = (2 * Math.random() * maxDeltaPercent) - maxDeltaPercent;
+        double percentChange = (2 * Math.random() * MAX_DELTA_PERCENT) - MAX_DELTA_PERCENT;
 
         return price * (100 + percentChange) / 100;
     }

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/QueueBrowseServlet.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/QueueBrowseServlet.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/QueueBrowseServlet.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/QueueBrowseServlet.java Sat Aug 11 22:27:21 2007
@@ -33,15 +33,14 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.util.FactoryFinder;
 import org.apache.activemq.util.IntrospectionSupport;
 import org.apache.activemq.web.view.MessageRenderer;
-import org.apache.activemq.ActiveMQConnectionFactory;
 
 /**
  * Renders the contents of a queue using some kind of view. The URI is assumed
  * to be the queue. The following parameters can be used
- * 
  * <ul>
  * <li>view - specifies the type of the view such as simple, xml, rss</li>
  * <li>selector - specifies the SQL 92 selector to apply to the queue</li>
@@ -49,15 +48,16 @@
  * 
  * @version $Revision: $
  */
-//TODO Why do we implement our own session pool?
-//TODO This doesn't work, since nobody will be setting the connection factory (because nobody is able to). Just use the WebClient?
+// TODO Why do we implement our own session pool?
+// TODO This doesn't work, since nobody will be setting the connection factory
+// (because nobody is able to). Just use the WebClient?
 public class QueueBrowseServlet extends HttpServlet {
 
     private static FactoryFinder factoryFinder = new FactoryFinder("META-INF/services/org/apache/activemq/web/view/");
 
     private ConnectionFactory connectionFactory;
     private Connection connection;
-    private LinkedList sessions = new LinkedList();
+    private LinkedList<Session> sessions = new LinkedList<Session>();
 
     public Connection getConnection() throws JMSException {
         if (connection == null) {
@@ -76,8 +76,7 @@
             String uri = getServletContext().getInitParameter("org.apache.activemq.brokerURL");
             if (uri != null) {
                 connectionFactory = new ActiveMQConnectionFactory(uri);
-            }
-            else {
+            } else {
                 throw new IllegalStateException("missing ConnectionFactory in QueueBrowserServlet");
             }
         }
@@ -103,11 +102,9 @@
             MessageRenderer renderer = getMessageRenderer(request);
             configureRenderer(request, renderer);
             renderer.renderMessages(request, response, browser);
-        }
-        catch (JMSException e) {
+        } catch (JMSException e) {
             throw new ServletException(e);
-        }
-        finally {
+        } finally {
             returnSession(session);
         }
     }
@@ -118,23 +115,20 @@
             style = "simple";
         }
         try {
-            return (MessageRenderer) factoryFinder.newInstance(style);
-        }
-        catch (IllegalAccessException e) {
+            return (MessageRenderer)factoryFinder.newInstance(style);
+        } catch (IllegalAccessException e) {
             throw new NoSuchViewStyleException(style, e);
-        }
-        catch (InstantiationException e) {
+        } catch (InstantiationException e) {
             throw new NoSuchViewStyleException(style, e);
-        }
-        catch (ClassNotFoundException e) {
+        } catch (ClassNotFoundException e) {
             throw new NoSuchViewStyleException(style, e);
         }
     }
 
     protected void configureRenderer(HttpServletRequest request, MessageRenderer renderer) {
-        Map properties = new HashMap();
-        for (Enumeration iter = request.getParameterNames(); iter.hasMoreElements(); ) {
-            String name = (String) iter.nextElement();
+        Map<String, String> properties = new HashMap<String, String>();
+        for (Enumeration iter = request.getParameterNames(); iter.hasMoreElements();) {
+            String name = (String)iter.nextElement();
             properties.put(name, request.getParameter(name));
         }
         IntrospectionSupport.setProperties(renderer, properties);
@@ -145,9 +139,8 @@
         synchronized (sessions) {
             if (sessions.isEmpty()) {
                 answer = createSession();
-            }
-            else {
-                answer = (Session) sessions.removeLast();
+            } else {
+                answer = sessions.removeLast();
             }
         }
         return answer;
@@ -171,14 +164,16 @@
 
     protected Queue getQueue(HttpServletRequest request, Session session) throws JMSException {
         String uri = request.getPathInfo();
-        if (uri == null)
+        if (uri == null) {
             return null;
+        }
 
         // replace URI separator with JMS destination separator
         if (uri.startsWith("/")) {
             uri = uri.substring(1);
-            if (uri.length() == 0)
+            if (uri.length() == 0) {
                 return null;
+            }
         }
         uri = uri.replace('/', '.');
 

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionFilter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionFilter.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionFilter.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SessionFilter.java Sat Aug 11 22:27:21 2007
@@ -28,22 +28,22 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 
-
 /* ------------------------------------------------------------ */
-/** SessionFilter.
- * Simple filter to ensure that all clients have a session.
- * Prevents problems with AJAX requests. 
+/**
+ * SessionFilter. Simple filter to ensure that all clients have a session.
+ * Prevents problems with AJAX requests.
  */
-public class SessionFilter implements Filter{
+public class SessionFilter implements Filter {
 
     public void init(FilterConfig filterConfig) throws ServletException {
     }
 
     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
-        HttpSession session=((HttpServletRequest)request).getSession(true);
+        ((HttpServletRequest)request).getSession(true);
         // if (session.isNew())
-        //    System.err.println("NEW SESSION "+session.getId()+" for "+((HttpServletRequest)request).getRequestURI());
-        chain.doFilter(request,response);
+        // System.err.println("NEW SESSION "+session.getId()+" for
+        // "+((HttpServletRequest)request).getRequestURI());
+        chain.doFilter(request, response);
     }
 
     public void destroy() {

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SpringBrokerContextListener.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SpringBrokerContextListener.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SpringBrokerContextListener.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/SpringBrokerContextListener.java Sat Aug 11 22:27:21 2007
@@ -16,15 +16,15 @@
  */
 package org.apache.activemq.web;
 
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.xbean.BrokerFactoryBean;
 import org.springframework.core.io.Resource;
 import org.springframework.web.context.support.ServletContextResource;
 
-import javax.servlet.ServletContext;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
 /**
  * Used to configure and instance of ActiveMQ <tt>BrokerService</tt> using
  * ActiveMQ/Spring's xml configuration. <p/> The configuration file is specified
@@ -34,7 +34,6 @@
  * &lt;param-value&gt;/WEB-INF/activemq.xml&lt;/param-value&gt;
  * &lt;/context-param&gt;
  * </code>
- * 
  * As a a default, if a <tt>brokerURI</tt> is not specified it will look up
  * for <tt>activemq.xml</tt>
  * 
@@ -51,8 +50,7 @@
     /**
      * Set the broker container to be used by this listener
      * 
-     * @param container
-     *            the container to be used.
+     * @param container the container to be used.
      */
     protected void setBrokerService(BrokerService container) {
         this.brokerContainer = container;
@@ -75,8 +73,7 @@
             brokerContainer.start();
 
             context.log("Started ActiveMQ Broker");
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             context.log("Failed to start ActiveMQ broker: " + e, e);
         }
     }
@@ -86,8 +83,7 @@
         if (brokerContainer != null) {
             try {
                 brokerContainer.stop();
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
                 context.log("Failed to stop the ActiveMQ Broker: " + e, e);
             }
             brokerContainer = null;
@@ -107,8 +103,7 @@
         BrokerFactoryBean factory = new BrokerFactoryBean(resource);
         try {
             factory.afterPropertiesSet();
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             context.log("Failed to create broker: " + e, e);
         }
         return factory.getBroker();

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java Sat Aug 11 22:27:21 2007
@@ -26,6 +26,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Semaphore;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
@@ -49,30 +50,26 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import java.util.concurrent.Semaphore;
-
 /**
  * Represents a messaging client used from inside a web container typically
- * stored inside a HttpSession
- * 
- * TODO controls to prevent DOS attacks with users requesting many consumers
- * TODO configure consumers with small prefetch.
+ * stored inside a HttpSession TODO controls to prevent DOS attacks with users
+ * requesting many consumers TODO configure consumers with small prefetch.
  * 
  * @version $Revision: 1.1.1.1 $
  */
 public class WebClient implements HttpSessionActivationListener, HttpSessionBindingListener, Externalizable {
-    public static final String webClientAttribute = "org.apache.activemq.webclient";
-    public static final String connectionFactoryAttribute = "org.apache.activemq.connectionFactory";
 
-    public static final String connectionFactoryPrefetchParam = "org.apache.activemq.connectionFactory.prefetch";
-    public static final String connectionFactoryOptimizeAckParam = "org.apache.activemq.connectionFactory.optimizeAck";
-    public static final String brokerUrlInitParam = "org.apache.activemq.brokerURL";
+    public static final String WEB_CLIENT_ATTRIBUTE = "org.apache.activemq.webclient";
+    public static final String CONNECTION_FACTORY_ATTRIBUTE = "org.apache.activemq.connectionFactory";
+    public static final String CONNECTION_FACTORY_PREFETCH_PARAM = "org.apache.activemq.connectionFactory.prefetch";
+    public static final String CONNECTION_FACTORY_OPTIMIZE_ACK_PARAM = "org.apache.activemq.connectionFactory.optimizeAck";
+    public static final String BROKER_URL_INIT_PARAM = "org.apache.activemq.brokerURL";
 
-    private static final Log log = LogFactory.getLog(WebClient.class);
+    private static final Log LOG = LogFactory.getLog(WebClient.class);
 
     private static transient ConnectionFactory factory;
 
-    private transient Map consumers = new HashMap();
+    private transient Map<Destination, MessageConsumer> consumers = new HashMap<Destination, MessageConsumer>();
     private transient Connection connection;
     private transient Session session;
     private transient MessageProducer producer;
@@ -80,11 +77,16 @@
 
     private final Semaphore semaphore = new Semaphore(1);
 
+    public WebClient() {
+        if (factory == null) {
+            throw new IllegalStateException("initContext(ServletContext) not called");
+        }
+    }
 
     /**
      * Helper method to get the client for the current session, lazily creating
      * a client if there is none currently
-     *
+     * 
      * @param request is the current HTTP request
      * @return the current client or a newly creates
      */
@@ -93,28 +95,24 @@
         WebClient client = getWebClient(session);
         if (client == null || client.isClosed()) {
             client = WebClient.createWebClient(request);
-            session.setAttribute(webClientAttribute, client);
+            session.setAttribute(WEB_CLIENT_ATTRIBUTE, client);
         }
 
         return client;
     }
+
     /**
      * @return the web client for the current HTTP session or null if there is
      *         not a web client created yet
      */
     public static WebClient getWebClient(HttpSession session) {
-        return (WebClient) session.getAttribute(webClientAttribute);
+        return (WebClient)session.getAttribute(WEB_CLIENT_ATTRIBUTE);
     }
 
     public static void initContext(ServletContext context) {
         initConnectionFactory(context);
     }
 
-    public WebClient() {
-        if (factory == null)
-            throw new IllegalStateException("initContext(ServletContext) not called");
-    }
-
     public int getDeliveryMode() {
         return deliveryMode;
     }
@@ -124,17 +122,17 @@
     }
 
     public synchronized void closeConsumers() {
-        for (Iterator it = consumers.values().iterator(); it.hasNext();) {
-            MessageConsumer consumer = (MessageConsumer) it.next();
+        for (Iterator<MessageConsumer> it = consumers.values().iterator(); it.hasNext();) {
+            MessageConsumer consumer = it.next();
             it.remove();
             try {
                 consumer.setMessageListener(null);
-                if (consumer instanceof MessageAvailableConsumer)
-                    ((MessageAvailableConsumer) consumer).setAvailableListener(null);
+                if (consumer instanceof MessageAvailableConsumer) {
+                    ((MessageAvailableConsumer)consumer).setAvailableListener(null);
+                }
                 consumer.close();
-            }
-            catch (JMSException e) {
-                log.debug("caught exception closing consumer",e);
+            } catch (JMSException e) {
+                LOG.debug("caught exception closing consumer", e);
             }
         }
     }
@@ -142,18 +140,18 @@
     public synchronized void close() {
         try {
             closeConsumers();
-            if (connection != null)
+            if (connection != null) {
                 connection.close();
-        }
-        catch (JMSException e) {
-            log.debug("caught exception closing consumer",e);
-        }
-        finally {
+            }
+        } catch (JMSException e) {
+            LOG.debug("caught exception closing consumer", e);
+        } finally {
             producer = null;
             session = null;
             connection = null;
-            if (consumers != null)
+            if (consumers != null) {
                 consumers.clear();
+            }
             consumers = null;
         }
     }
@@ -165,33 +163,32 @@
     public void writeExternal(ObjectOutput out) throws IOException {
         if (consumers != null) {
             out.write(consumers.size());
-            Iterator i = consumers.keySet().iterator();
-            while (i.hasNext())
+            Iterator<Destination> i = consumers.keySet().iterator();
+            while (i.hasNext()) {
                 out.writeObject(i.next().toString());
-        }
-        else
+            }
+        } else {
             out.write(-1);
+        }
 
     }
 
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         int size = in.readInt();
         if (size >= 0) {
-            consumers = new HashMap();
+            consumers = new HashMap<Destination, MessageConsumer>();
             for (int i = 0; i < size; i++) {
                 String destinationName = in.readObject().toString();
 
                 try {
-                    Destination destination = destinationName.startsWith("topic://") ? (Destination) getSession().createTopic(destinationName)
-                            : (Destination) getSession().createQueue(destinationName);
+                    Destination destination = destinationName.startsWith("topic://") ? (Destination)getSession().createTopic(destinationName) : (Destination)getSession().createQueue(destinationName);
                     consumers.put(destination, getConsumer(destination, true));
-                }
-                catch (JMSException e) {
-                    log.debug("Caought Exception ",e);
+                } catch (JMSException e) {
+                    LOG.debug("Caought Exception ", e);
                     IOException ex = new IOException(e.getMessage());
                     ex.initCause(e.getCause() != null ? e.getCause() : e);
                     throw ex;
-                    
+
                 }
             }
         }
@@ -199,16 +196,16 @@
 
     public void send(Destination destination, Message message) throws JMSException {
         getProducer().send(destination, message);
-        if (log.isDebugEnabled()) {
-            log.debug("Sent! to destination: " + destination + " message: " + message);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Sent! to destination: " + destination + " message: " + message);
         }
     }
 
     public void send(Destination destination, Message message, boolean persistent, int priority, long timeToLive) throws JMSException {
         int deliveryMode = persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
         getProducer().send(destination, message, deliveryMode, priority, timeToLive);
-        if (log.isDebugEnabled()) {
-            log.debug("Sent! to destination: " + destination + " message: " + message);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Sent! to destination: " + destination + " message: " + message);
         }
     }
 
@@ -228,35 +225,35 @@
     }
 
     protected static synchronized void initConnectionFactory(ServletContext servletContext) {
-        if (factory == null)
-            factory = (ConnectionFactory) servletContext.getAttribute(connectionFactoryAttribute);
         if (factory == null) {
-            String brokerURL = servletContext.getInitParameter(brokerUrlInitParam);
-
+            factory = (ConnectionFactory)servletContext.getAttribute(CONNECTION_FACTORY_ATTRIBUTE);
+        }
+        if (factory == null) {
+            String brokerURL = servletContext.getInitParameter(BROKER_URL_INIT_PARAM);
 
-            log.debug("Value of: " + brokerUrlInitParam + " is: " + brokerURL);
+            LOG.debug("Value of: " + BROKER_URL_INIT_PARAM + " is: " + brokerURL);
 
             if (brokerURL == null) {
-            	throw new IllegalStateException("missing brokerURL (specified via "+brokerUrlInitParam+" init-Param");
+                throw new IllegalStateException("missing brokerURL (specified via " + BROKER_URL_INIT_PARAM + " init-Param");
             }
 
             ActiveMQConnectionFactory amqfactory = new ActiveMQConnectionFactory(brokerURL);
 
             // Set prefetch policy for factory
-            if (servletContext.getInitParameter(connectionFactoryPrefetchParam) != null) {
-                int prefetch = Integer.valueOf(servletContext.getInitParameter(connectionFactoryPrefetchParam)).intValue();
+            if (servletContext.getInitParameter(CONNECTION_FACTORY_PREFETCH_PARAM) != null) {
+                int prefetch = Integer.valueOf(servletContext.getInitParameter(CONNECTION_FACTORY_PREFETCH_PARAM)).intValue();
                 amqfactory.getPrefetchPolicy().setAll(prefetch);
             }
 
             // Set optimize acknowledge setting
-            if (servletContext.getInitParameter(connectionFactoryOptimizeAckParam) != null) {
-                boolean optimizeAck = Boolean.valueOf(servletContext.getInitParameter(connectionFactoryOptimizeAckParam)).booleanValue();
+            if (servletContext.getInitParameter(CONNECTION_FACTORY_OPTIMIZE_ACK_PARAM) != null) {
+                boolean optimizeAck = Boolean.valueOf(servletContext.getInitParameter(CONNECTION_FACTORY_OPTIMIZE_ACK_PARAM)).booleanValue();
                 amqfactory.setOptimizeAcknowledge(optimizeAck);
             }
 
             factory = amqfactory;
 
-            servletContext.setAttribute(connectionFactoryAttribute, factory);
+            servletContext.setAttribute(CONNECTION_FACTORY_ATTRIBUTE, factory);
         }
     }
 
@@ -277,7 +274,7 @@
     }
 
     public synchronized MessageConsumer getConsumer(Destination destination, boolean create) throws JMSException {
-        MessageConsumer consumer = (MessageConsumer) consumers.get(destination);
+        MessageConsumer consumer = consumers.get(destination);
         if (create && consumer == null) {
             consumer = getSession().createConsumer(destination);
             consumers.put(destination, consumer);
@@ -286,18 +283,19 @@
     }
 
     public synchronized void closeConsumer(Destination destination) throws JMSException {
-        MessageConsumer consumer = (MessageConsumer) consumers.get(destination);
+        MessageConsumer consumer = consumers.get(destination);
         if (consumer != null) {
             consumers.remove(destination);
             consumer.setMessageListener(null);
-            if (consumer instanceof MessageAvailableConsumer)
-                ((MessageAvailableConsumer) consumer).setAvailableListener(null);
+            if (consumer instanceof MessageAvailableConsumer) {
+                ((MessageAvailableConsumer)consumer).setAvailableListener(null);
+            }
             consumer.close();
         }
     }
 
-    public synchronized List getConsumers() {
-        return new ArrayList(consumers.values());
+    public synchronized List<MessageConsumer> getConsumers() {
+        return new ArrayList<MessageConsumer>(consumers.values());
     }
 
     protected Session createSession() throws JMSException {

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/MessageRenderer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/MessageRenderer.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/MessageRenderer.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/MessageRenderer.java Sat Aug 11 22:27:21 2007
@@ -17,6 +17,9 @@
 
 package org.apache.activemq.web.view;
 
+import java.io.IOException;
+import java.io.PrintWriter;
+
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.QueueBrowser;
@@ -24,9 +27,6 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import java.io.IOException;
-import java.io.PrintWriter;
-
 /**
  * Represents a rendering of the messages
  * 
@@ -34,10 +34,8 @@
  */
 public interface MessageRenderer {
 
-    public void renderMessages(HttpServletRequest request, HttpServletResponse response, QueueBrowser browser)
-            throws IOException, JMSException, ServletException;
+    void renderMessages(HttpServletRequest request, HttpServletResponse response, QueueBrowser browser) throws IOException, JMSException, ServletException;
 
-    public void renderMessage(PrintWriter writer, HttpServletRequest request, HttpServletResponse response,
-            QueueBrowser browser, Message message) throws JMSException, ServletException;
+    void renderMessage(PrintWriter writer, HttpServletRequest request, HttpServletResponse response, QueueBrowser browser, Message message) throws JMSException, ServletException;
 
 }

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/RssMessageRenderer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/RssMessageRenderer.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/RssMessageRenderer.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/RssMessageRenderer.java Sat Aug 11 22:27:21 2007
@@ -16,14 +16,10 @@
  */
 package org.apache.activemq.web.view;
 
-import com.sun.syndication.feed.synd.SyndContent;
-import com.sun.syndication.feed.synd.SyndContentImpl;
-import com.sun.syndication.feed.synd.SyndEntry;
-import com.sun.syndication.feed.synd.SyndEntryImpl;
-import com.sun.syndication.feed.synd.SyndFeed;
-import com.sun.syndication.feed.synd.SyndFeedImpl;
-import com.sun.syndication.io.FeedException;
-import com.sun.syndication.io.SyndFeedOutput;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Date;
+import java.util.List;
 
 import javax.jms.JMSException;
 import javax.jms.Message;
@@ -33,10 +29,14 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Date;
-import java.util.List;
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndContentImpl;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndEntryImpl;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndFeedImpl;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.SyndFeedOutput;
 
 /**
  * This renderer uses XStream to render messages on a queue as full XML elements
@@ -45,17 +45,16 @@
  */
 public class RssMessageRenderer extends SimpleMessageRenderer {
 
-    //private String feedType = "atom_0.3";
+    // private String feedType = "atom_0.3";
     private String feedType = "rss_2.0";
     private SyndFeed feed;
     private String description = "This feed is auto-generated by Apache ActiveMQ";
     private String entryContentType = "text/plain";
 
-    public void renderMessage(PrintWriter writer, HttpServletRequest request, HttpServletResponse response,
-            QueueBrowser browser, Message message) throws JMSException {
+    public void renderMessage(PrintWriter writer, HttpServletRequest request, HttpServletResponse response, QueueBrowser browser, Message message) throws JMSException {
         SyndFeed feed = getFeed(browser, request);
 
-        List entries = feed.getEntries();
+        List<SyndEntry> entries = feed.getEntries();
         SyndEntry entry = createEntry(browser, message, request);
         SyndContent description = createEntryContent(browser, message, request);
         entry.setDescription(description);
@@ -91,21 +90,18 @@
     // Implementation methods
     // -------------------------------------------------------------------------
 
-    protected void printFooter(PrintWriter writer, QueueBrowser browser, HttpServletRequest request)
-            throws IOException, JMSException, ServletException {
+    protected void printFooter(PrintWriter writer, QueueBrowser browser, HttpServletRequest request) throws IOException, JMSException, ServletException {
         // now lets actually write out the content
         SyndFeed feed = getFeed(browser, request);
         SyndFeedOutput output = new SyndFeedOutput();
         try {
             output.output(feed, writer);
-        }
-        catch (FeedException e) {
+        } catch (FeedException e) {
             throw new ServletException(e);
         }
     }
 
-    protected void printHeader(PrintWriter writer, QueueBrowser browser, HttpServletRequest request)
-            throws IOException, JMSException {
+    protected void printHeader(PrintWriter writer, QueueBrowser browser, HttpServletRequest request) throws IOException, JMSException {
     }
 
     public SyndFeed getFeed(QueueBrowser browser, HttpServletRequest request) throws JMSException {
@@ -130,7 +126,7 @@
         description.setType(entryContentType);
 
         if (message instanceof TextMessage) {
-            String text = ((TextMessage) message).getText();
+            String text = ((TextMessage)message).getText();
             description.setValue(text);
         }
         return description;

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/SimpleMessageRenderer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/SimpleMessageRenderer.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/SimpleMessageRenderer.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/SimpleMessageRenderer.java Sat Aug 11 22:27:21 2007
@@ -16,6 +16,10 @@
  */
 package org.apache.activemq.web.view;
 
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.QueueBrowser;
@@ -23,10 +27,6 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Enumeration;
-
 /**
  * A simple rendering of the contents of a queue appear as a list of message
  * elements which just contain an ID attribute.
@@ -36,10 +36,9 @@
 public class SimpleMessageRenderer implements MessageRenderer {
 
     private String contentType = "text/xml";
-    private int maxMessages = 0;
+    private int maxMessages;
 
-    public void renderMessages(HttpServletRequest request, HttpServletResponse response, QueueBrowser browser)
-            throws IOException, JMSException, ServletException {
+    public void renderMessages(HttpServletRequest request, HttpServletResponse response, QueueBrowser browser) throws IOException, JMSException, ServletException {
         // lets use XML by default
         response.setContentType(getContentType());
         PrintWriter writer = response.getWriter();
@@ -47,15 +46,14 @@
 
         Enumeration iter = browser.getEnumeration();
         for (int counter = 0; iter.hasMoreElements() && (maxMessages <= 0 || counter < maxMessages); counter++) {
-            Message message = (Message) iter.nextElement();
+            Message message = (Message)iter.nextElement();
             renderMessage(writer, request, response, browser, message);
         }
 
         printFooter(writer, browser, request);
     }
 
-    public void renderMessage(PrintWriter writer, HttpServletRequest request, HttpServletResponse response,
-            QueueBrowser browser, Message message) throws JMSException, ServletException {
+    public void renderMessage(PrintWriter writer, HttpServletRequest request, HttpServletResponse response, QueueBrowser browser, Message message) throws JMSException, ServletException {
         // lets just write the message IDs for now
         writer.print("<message id='");
         writer.print(message.getJMSMessageID());
@@ -83,8 +81,7 @@
     // Implementation methods
     // -------------------------------------------------------------------------
 
-    protected void printHeader(PrintWriter writer, QueueBrowser browser, HttpServletRequest request)
-            throws IOException, JMSException, ServletException {
+    protected void printHeader(PrintWriter writer, QueueBrowser browser, HttpServletRequest request) throws IOException, JMSException, ServletException {
         writer.println("");
         writer.print("<messages queue='");
         writer.print(browser.getQueue());
@@ -98,8 +95,7 @@
         writer.println(">");
     }
 
-    protected void printFooter(PrintWriter writer, QueueBrowser browser, HttpServletRequest request)
-            throws IOException, JMSException, ServletException {
+    protected void printFooter(PrintWriter writer, QueueBrowser browser, HttpServletRequest request) throws IOException, JMSException, ServletException {
         writer.println("</messages>");
     }
 

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/XmlMessageRenderer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/XmlMessageRenderer.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/XmlMessageRenderer.java (original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/view/XmlMessageRenderer.java Sat Aug 11 22:27:21 2007
@@ -16,7 +16,7 @@
  */
 package org.apache.activemq.web.view;
 
-import com.thoughtworks.xstream.XStream;
+import java.io.PrintWriter;
 
 import javax.jms.JMSException;
 import javax.jms.Message;
@@ -24,7 +24,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import java.io.PrintWriter;
+import com.thoughtworks.xstream.XStream;
 
 /**
  * This renderer uses XStream to render messages on a queue as full XML elements

Modified: activemq/trunk/activemq-web/src/test/java/org/apache/activemq/web/JettyServer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/test/java/org/apache/activemq/web/JettyServer.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-web/src/test/java/org/apache/activemq/web/JettyServer.java (original)
+++ activemq/trunk/activemq-web/src/test/java/org/apache/activemq/web/JettyServer.java Sat Aug 11 22:27:21 2007
@@ -23,23 +23,25 @@
 import org.mortbay.jetty.Handler;
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.nio.SelectChannelConnector;
-import org.mortbay.jetty.webapp.WebAppClassLoader;
 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 JettyServer {
-    
+public final class JettyServer {
+
     public static final int PORT = 8080;
 
     public static final String WEBAPP_DIR = "src/main/webapp";
 
     public static final String WEBAPP_CTX = "/";
 
+    private JettyServer() {
+    }
+
     public static void main(String[] args) throws Exception {
         // lets create a broker
         BrokerService broker = new BrokerService();
@@ -48,11 +50,13 @@
         broker.addConnector("tcp://localhost:61616");
         broker.addConnector("stomp://localhost:61613");
         broker.start();
-        
+
         // lets publish some messages so that there is some stuff to browse
-        DefaultQueueSender.main(new String[] {"FOO.BAR"});
-        
-        // now lets start the web server        
+        DefaultQueueSender.main(new String[] {
+            "FOO.BAR"
+        });
+
+        // now lets start the web server
         int port = PORT;
         if (args.length > 0) {
             String text = args[0];
@@ -64,12 +68,16 @@
         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();
     }
 }

Modified: activemq/trunk/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/ProtocolConverter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/ProtocolConverter.java?view=diff&rev=565003&r1=565002&r2=565003
==============================================================================
--- activemq/trunk/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/ProtocolConverter.java (original)
+++ activemq/trunk/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/ProtocolConverter.java Sat Aug 11 22:27:21 2007
@@ -16,6 +16,18 @@
  */
 package org.apache.activemq.transport.xmpp;
 
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.jms.JMSException;
+import org.w3c.dom.Element;
+
 import ietf.params.xml.ns.xmpp_sasl.Auth;
 import ietf.params.xml.ns.xmpp_sasl.Challenge;
 import ietf.params.xml.ns.xmpp_sasl.Success;
@@ -27,8 +39,28 @@
 import jabber.client.Message;
 import jabber.client.Presence;
 import jabber.iq.auth.Query;
+
 import org.apache.activemq.advisory.AdvisorySupport;
-import org.apache.activemq.command.*;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQMessage;
+import org.apache.activemq.command.ActiveMQTempQueue;
+import org.apache.activemq.command.ActiveMQTextMessage;
+import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.command.Command;
+import org.apache.activemq.command.ConnectionId;
+import org.apache.activemq.command.ConnectionInfo;
+import org.apache.activemq.command.ConsumerId;
+import org.apache.activemq.command.ConsumerInfo;
+import org.apache.activemq.command.DestinationInfo;
+import org.apache.activemq.command.ExceptionResponse;
+import org.apache.activemq.command.MessageAck;
+import org.apache.activemq.command.MessageDispatch;
+import org.apache.activemq.command.MessageId;
+import org.apache.activemq.command.ProducerId;
+import org.apache.activemq.command.ProducerInfo;
+import org.apache.activemq.command.Response;
+import org.apache.activemq.command.SessionId;
+import org.apache.activemq.command.SessionInfo;
 import org.apache.activemq.transport.xmpp.command.Handler;
 import org.apache.activemq.transport.xmpp.command.HandlerRegistry;
 import org.apache.activemq.util.IdGenerator;
@@ -40,31 +72,19 @@
 import org.jabber.protocol.disco_info.Identity;
 import org.jabber.protocol.disco_items.Item;
 import org.jabber.protocol.muc_user.X;
-import org.w3c.dom.Element;
-
-import javax.jms.JMSException;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
  * TODO lots of this code could be shared with Stomp
  */
 public class ProtocolConverter {
-    private static final transient Log log = LogFactory.getLog(ProtocolConverter.class);
+    private static final transient Log LOG = LogFactory.getLog(ProtocolConverter.class);
+    private static final IdGenerator CONNECTION_ID_GENERATOR = new IdGenerator();
+    private static final IdGenerator CLIENT_ID_GENERATOR = new IdGenerator("xmpp");
 
     private HandlerRegistry registry = new HandlerRegistry();
     private XmppTransport transport;
 
-
-    private static final IdGenerator connectionIdGenerator = new IdGenerator();
-    private static final IdGenerator clientIdGenerator = new IdGenerator("xmpp");
-    private final ConnectionId connectionId = new ConnectionId(connectionIdGenerator.generateId());
+    private final ConnectionId connectionId = new ConnectionId(CONNECTION_ID_GENERATOR.generateId());
     private final SessionId sessionId = new SessionId(connectionId, -1);
     private final ProducerId producerId = new ProducerId(sessionId, 1);
 
@@ -74,7 +94,6 @@
 
     private final LongSequenceGenerator consumerIdGenerator = new LongSequenceGenerator();
     private final LongSequenceGenerator messageIdGenerator = new LongSequenceGenerator();
-    private final LongSequenceGenerator transactionIdGenerator = new LongSequenceGenerator();
     private final IntSequenceGenerator tempDestinationIdGenerator = new IntSequenceGenerator();
 
     private final Map<Integer, Handler<Response>> resposeHandlers = new ConcurrentHashMap<Integer, Handler<Response>>();
@@ -82,8 +101,6 @@
     private final Map<String, ConsumerInfo> jidToConsumerMap = new HashMap<String, ConsumerInfo>();
     private final Map<String, ConsumerInfo> jidToInboxConsumerMap = new HashMap<String, ConsumerInfo>();
 
-    private final Map transactions = new ConcurrentHashMap();
-
     private final Object commnadIdMutex = new Object();
     private int lastCommandId;
     private final AtomicBoolean connected = new AtomicBoolean(false);
@@ -131,42 +148,39 @@
 
     public void onXmppCommand(Object command) throws Exception {
         // TODO we could do some nice code generation to boost performance
-        // by autogenerating the bytecode to statically lookup a handler from a registry maybe?
+        // by autogenerating the bytecode to statically lookup a handler from a
+        // registry maybe?
 
         Handler handler = registry.getHandler(command.getClass());
         if (handler == null) {
             unknownCommand(command);
-        }
-        else {
+        } else {
             handler.handle(command);
         }
     }
 
     public void onActiveMQCommad(Command command) throws Exception {
         if (command.isResponse()) {
-            Response response = (Response) command;
+            Response response = (Response)command;
             Handler<Response> handler = resposeHandlers.remove(new Integer(response.getCorrelationId()));
             if (handler != null) {
                 handler.handle(response);
+            } else {
+                LOG.warn("No handler for response: " + response);
             }
-            else {
-                log.warn("No handler for response: " + response);
-            }
-        }
-        else if (command.isMessageDispatch()) {
-            MessageDispatch md = (MessageDispatch) command;
+        } else if (command.isMessageDispatch()) {
+            MessageDispatch md = (MessageDispatch)command;
             Handler<MessageDispatch> handler = subscriptionsByConsumerId.get(md.getConsumerId());
             if (handler != null) {
                 handler.handle(md);
-            }
-            else {
-                log.warn("No handler for message: " + md);
+            } else {
+                LOG.warn("No handler for message: " + md);
             }
         }
     }
 
     protected void unknownCommand(Object command) throws Exception {
-        log.warn("Unkown command: " + command + " of type: " + command.getClass().getName());
+        LOG.warn("Unkown command: " + command + " of type: " + command.getClass().getName());
     }
 
     protected void onIq(final Iq iq) throws Exception {
@@ -175,44 +189,38 @@
         if (any instanceof Query) {
             onAuthQuery(any, iq);
 
-        }
-        else if (any instanceof jabber.iq._private.Query) {
-            jabber.iq._private.Query query = (jabber.iq._private.Query) any;
+        } else if (any instanceof jabber.iq._private.Query) {
+            jabber.iq._private.Query query = (jabber.iq._private.Query)any;
 
-            if (log.isDebugEnabled()) {
-                log.debug("Iq Private " + debugString(iq) + " any: " + query.getAny());
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Iq Private " + debugString(iq) + " any: " + query.getAny());
             }
 
             Iq result = createResult(iq);
             jabber.iq._private.Query answer = new jabber.iq._private.Query();
             result.setAny(answer);
             transport.marshall(result);
-        }
-        else if (any instanceof jabber.iq.roster.Query) {
-            jabber.iq.roster.Query query = (jabber.iq.roster.Query) any;
+        } else if (any instanceof jabber.iq.roster.Query) {
+            jabber.iq.roster.Query query = (jabber.iq.roster.Query)any;
 
-            if (log.isDebugEnabled()) {
-                log.debug("Iq Roster " + debugString(iq) + " item: " + query.getItem());
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Iq Roster " + debugString(iq) + " item: " + query.getItem());
             }
 
             Iq result = createResult(iq);
             jabber.iq.roster.Query roster = new jabber.iq.roster.Query();
             result.setAny(roster);
             transport.marshall(result);
-        }
-        else if (any instanceof org.jabber.protocol.disco_items.Query) {
-            onDiscoItems(iq, (org.jabber.protocol.disco_items.Query) any);
-        }
-        else if (any instanceof org.jabber.protocol.disco_info.Query) {
-            onDiscoInfo(iq, (org.jabber.protocol.disco_info.Query) any);
-        }
-        else {
+        } else if (any instanceof org.jabber.protocol.disco_items.Query) {
+            onDiscoItems(iq, (org.jabber.protocol.disco_items.Query)any);
+        } else if (any instanceof org.jabber.protocol.disco_info.Query) {
+            onDiscoInfo(iq, (org.jabber.protocol.disco_info.Query)any);
+        } else {
             if (any instanceof Element) {
-                Element element = (Element) any;
-                log.warn("Iq Unknown " + debugString(iq) + " element namespace: " + element.getNamespaceURI() + " localName: " + element.getLocalName());
-            }
-            else {
-                log.warn("Iq Unknown " + debugString(iq) + " any: " + any + " of type: " + any.getClass().getName());
+                Element element = (Element)any;
+                LOG.warn("Iq Unknown " + debugString(iq) + " element namespace: " + element.getNamespaceURI() + " localName: " + element.getLocalName());
+            } else {
+                LOG.warn("Iq Unknown " + debugString(iq) + " any: " + any + " of type: " + any.getClass().getName());
             }
             Iq result = createResult(iq);
             jabber.client.Error error = new Error();
@@ -223,9 +231,9 @@
     }
 
     protected void onAuthQuery(Object any, final Iq iq) throws IOException {
-        Query query = (Query) any;
-        if (log.isDebugEnabled()) {
-            log.debug("Iq Auth Query " + debugString(iq) + " resource: " + query.getResource() + " username: " + query.getUsername());
+        Query query = (Query)any;
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Iq Auth Query " + debugString(iq) + " resource: " + query.getResource() + " username: " + query.getUsername());
         }
         if (query.getPassword() == null) {
             Iq result = createResult(iq);
@@ -237,14 +245,14 @@
             return;
         }
 
-        //connectionInfo.setClientId(query.getResource());
+        // connectionInfo.setClientId(query.getResource());
         connectionInfo.setUserName(query.getUsername());
         connectionInfo.setPassword(query.getPassword());
 
         // TODO support digest?
 
         if (connectionInfo.getClientId() == null) {
-            connectionInfo.setClientId(clientIdGenerator.generateId());
+            connectionInfo.setClientId(CLIENT_ID_GENERATOR.generateId());
         }
 
         sendToActiveMQ(connectionInfo, new Handler<Response>() {
@@ -253,10 +261,10 @@
                 Iq result = createResult(iq);
 
                 if (response instanceof ExceptionResponse) {
-                    ExceptionResponse exceptionResponse = (ExceptionResponse) response;
+                    ExceptionResponse exceptionResponse = (ExceptionResponse)response;
                     Throwable exception = exceptionResponse.getException();
 
-                    log.warn("Failed to create connection: " + exception, exception);
+                    LOG.warn("Failed to create connection: " + exception, exception);
 
                     Error error = new Error();
                     result.setError(error);
@@ -264,8 +272,7 @@
                     StringWriter buffer = new StringWriter();
                     exception.printStackTrace(new PrintWriter(buffer));
                     error.setInternalServerError(buffer.toString());
-                }
-                else {
+                } else {
                     connected.set(true);
                 }
                 transport.marshall(result);
@@ -283,8 +290,8 @@
     protected void onDiscoItems(Iq iq, org.jabber.protocol.disco_items.Query query) throws IOException {
         String to = iq.getTo();
 
-        if (log.isDebugEnabled()) {
-            log.debug("Iq Disco Items query " + debugString(iq) + " node: " + query.getNode() + " item: " + query.getItem());
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Iq Disco Items query " + debugString(iq) + " node: " + query.getNode() + " item: " + query.getItem());
         }
 
         Iq result = createResult(iq);
@@ -292,8 +299,7 @@
         if (to == null || to.length() == 0) {
             answer.getItem().add(createItem("queues", "Queues", "queues"));
             answer.getItem().add(createItem("topics", "Topics", "topics"));
-        }
-        else {
+        } else {
             // lets not add anything?
         }
 
@@ -306,8 +312,8 @@
 
         // TODO lets create the topic 'to'
 
-        if (log.isDebugEnabled()) {
-            log.debug("Iq Disco Info query " + debugString(iq) + " node: " + query.getNode() + " features: " + query.getFeature() + " identity: " + query.getIdentity());
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Iq Disco Info query " + debugString(iq) + " node: " + query.getNode() + " features: " + query.getFeature() + " identity: " + query.getIdentity());
         }
 
         Iq result = createResult(iq);
@@ -319,22 +325,20 @@
             answer.getIdentity().add(createIdentity("directory", "chatroom", "queues"));
             answer.getIdentity().add(createIdentity("directory", "chatroom", "topics"));
             /*
-            answer.getIdentity().add(createIdentity("hierarchy", "queues", "branch"));
-            answer.getIdentity().add(createIdentity("hierarchy", "topics", "branch"));
-            */
-        }
-        else {
+             * answer.getIdentity().add(createIdentity("hierarchy", "queues",
+             * "branch")); answer.getIdentity().add(createIdentity("hierarchy",
+             * "topics", "branch"));
+             */
+        } else {
             // for queues/topics
             if (to.equals("queues")) {
                 answer.getIdentity().add(createIdentity("conference", "queue.a", "text"));
                 answer.getIdentity().add(createIdentity("conference", "queue.b", "text"));
-            }
-            else if (to.equals("topics")) {
+            } else if (to.equals("topics")) {
                 answer.getIdentity().add(createIdentity("conference", "topic.x", "text"));
                 answer.getIdentity().add(createIdentity("conference", "topic.y", "text"));
                 answer.getIdentity().add(createIdentity("conference", "topic.z", "text"));
-            }
-            else {
+            } else {
                 // lets reply to an actual room
                 answer.getIdentity().add(createIdentity("conference", to, "text"));
                 answer.getFeature().add(createFeature("http://jabber.org/protocol/muc"));
@@ -347,9 +351,9 @@
     }
 
     protected void onPresence(Presence presence) throws IOException, JMSException {
-        if (log.isDebugEnabled()) {
-            log.debug("Presence: " + presence.getFrom() + " id: " + presence.getId() + " to: " + presence.getTo() + " type: " + presence.getType()
-                    + " showOrStatusOrPriority: " + presence.getShowOrStatusOrPriority() + " any: " + presence.getAny());
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Presence: " + presence.getFrom() + " id: " + presence.getId() + " to: " + presence.getTo() + " type: " + presence.getType() + " showOrStatusOrPriority: "
+                      + presence.getShowOrStatusOrPriority() + " any: " + presence.getAny());
         }
         org.jabber.protocol.muc_user.Item item = new org.jabber.protocol.muc_user.Item();
         item.setAffiliation("owner");
@@ -358,18 +362,17 @@
         sendPresence(presence, item);
 
         /*
-        item = new org.jabber.protocol.muc_user.Item();
-        item.setAffiliation("admin");
-        item.setRole("moderator");
-        sendPresence(presence, item);
-        */
+         * item = new org.jabber.protocol.muc_user.Item();
+         * item.setAffiliation("admin"); item.setRole("moderator");
+         * sendPresence(presence, item);
+         */
 
         // lets create a subscription
         final String to = presence.getTo();
 
         ActiveMQDestination destination = createActiveMQDestination(to);
         if (destination == null) {
-            log.debug("No 'to' attribute specified for presence so not creating a JMS subscription");
+            LOG.debug("No 'to' attribute specified for presence so not creating a JMS subscription");
             return;
         }
         subscribe(to, destination, jidToConsumerMap);
@@ -415,8 +418,8 @@
         subscriptionsByConsumerId.put(consumerInfo.getConsumerId(), new Handler<MessageDispatch>() {
             public void handle(MessageDispatch messageDispatch) throws Exception {
                 // processing the inbound message
-                if (log.isDebugEnabled()) {
-                    log.debug("Receiving inbound: " + messageDispatch.getMessage());
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Receiving inbound: " + messageDispatch.getMessage());
                 }
 
                 // lets send back an ACK
@@ -425,8 +428,8 @@
 
                 Message message = createXmppMessage(to, messageDispatch);
                 if (message != null) {
-                    if (log.isDebugEnabled()) {
-                        log.debug("Sending message to XMPP client from: " + message.getFrom() + " to: " + message.getTo() + " type: " + message.getType() + " with body: " + message.getAny());
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Sending message to XMPP client from: " + message.getFrom() + " to: " + message.getTo() + " type: " + message.getType() + " with body: " + message.getAny());
                     }
                     transport.marshall(message);
                 }
@@ -447,18 +450,17 @@
         answer.setTo(to);
 
         org.apache.activemq.command.Message message = messageDispatch.getMessage();
-        //answer.setType(message.getType());
+        // answer.setType(message.getType());
         if (message instanceof ActiveMQTextMessage) {
-            ActiveMQTextMessage activeMQTextMessage = (ActiveMQTextMessage) message;
+            ActiveMQTextMessage activeMQTextMessage = (ActiveMQTextMessage)message;
             Body body = new Body();
             String text = activeMQTextMessage.getText();
-            log.info("Setting the body text to be: " + text);
+            LOG.info("Setting the body text to be: " + text);
             body.setValue(text);
             answer.getAny().add(body);
-        }
-        else {
+        } else {
             // TODO support other message types
-            log.warn("Could not convert the message to a complete Jabber message: " + message);
+            LOG.warn("Could not convert the message to a complete Jabber message: " + message);
         }
         return answer;
     }
@@ -474,7 +476,6 @@
         transport.marshall(answer);
     }
 
-
     protected Item createItem(String jid, String name, String node) {
         Item answer = new Item();
         answer.setJid(jid);
@@ -519,15 +520,14 @@
         transport.getTransportListener().onCommand(command);
     }
 
-
     protected void onStarttls(Starttls starttls) throws Exception {
-        log.debug("Starttls");
+        LOG.debug("Starttls");
         transport.marshall(new Proceed());
     }
 
     protected void onMessage(Message message) throws Exception {
-        if (log.isDebugEnabled()) {
-            log.debug("Message from: " + message.getFrom() + " to: " + message.getTo() + " subjectOrBodyOrThread: " + message.getSubjectOrBodyOrThread());
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Message from: " + message.getFrom() + " to: " + message.getTo() + " subjectOrBodyOrThread: " + message.getSubjectOrBodyOrThread());
         }
 
         final ActiveMQMessage activeMQMessage = createActiveMQMessage(message);
@@ -541,13 +541,13 @@
         addActiveMQMessageHeaders(activeMQMessage, message);
 
         /*
-        MessageDispatch dispatch = new MessageDispatch();
-        dispatch.setDestination(destination);
-        dispatch.setMessage(activeMQMessage);
-        */
+         * MessageDispatch dispatch = new MessageDispatch();
+         * dispatch.setDestination(destination);
+         * dispatch.setMessage(activeMQMessage);
+         */
 
-        if (log.isDebugEnabled()) {
-            log.debug("Sending ActiveMQ message: " + activeMQMessage);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Sending ActiveMQ message: " + activeMQMessage);
         }
         sendToActiveMQ(activeMQMessage, createErrorHandler("send message"));
     }
@@ -556,18 +556,16 @@
         return new Handler<Response>() {
             public void handle(Response event) throws Exception {
                 if (event instanceof ExceptionResponse) {
-                    ExceptionResponse exceptionResponse = (ExceptionResponse) event;
+                    ExceptionResponse exceptionResponse = (ExceptionResponse)event;
                     Throwable exception = exceptionResponse.getException();
-                    log.error("Failed to " + text + ". Reason: " + exception, exception);
-                }
-                else if (log.isDebugEnabled()) {
-                    log.debug("Completed " + text);
+                    LOG.error("Failed to " + text + ". Reason: " + exception, exception);
+                } else if (LOG.isDebugEnabled()) {
+                    LOG.debug("Completed " + text);
                 }
             }
         };
     }
 
-
     /**
      * Converts the Jabber destination name into a destination in ActiveMQ
      */
@@ -596,7 +594,7 @@
         List<Object> list = message.getSubjectOrBodyOrThread();
         for (Object object : list) {
             if (object instanceof Body) {
-                Body body = (Body) object;
+                Body body = (Body)object;
                 text = body.getValue();
                 break;
             }
@@ -620,16 +618,15 @@
     }
 
     protected void onAuth(Auth auth) throws Exception {
-        if (log.isDebugEnabled()) {
-            log.debug("Auth mechanism: " + auth.getMechanism() + " value: " + auth.getValue());
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Auth mechanism: " + auth.getMechanism() + " value: " + auth.getValue());
         }
         String value = createChallengeValue(auth);
         if (value != null) {
             Challenge challenge = new Challenge();
             challenge.setValue(value);
             transport.marshall(challenge);
-        }
-        else {
+        } else {
             transport.marshall(new Success());
         }
     }