tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1420654 - /tomcat/trunk/java/org/apache/tomcat/websocket/
Date Wed, 12 Dec 2012 13:12:35 GMT
Author: markt
Date: Wed Dec 12 13:12:32 2012
New Revision: 1420654

URL: http://svn.apache.org/viewvc?rev=1420654&view=rev
Log:
Experiment with Eclipse's code formatter

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/ClientContainerImpl.java
    tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java
    tomcat/trunk/java/org/apache/tomcat/websocket/PathParam.java
    tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerAsync.java
    tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerBase.java
    tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerBasic.java
    tomcat/trunk/java/org/apache/tomcat/websocket/PojoMethodMapping.java
    tomcat/trunk/java/org/apache/tomcat/websocket/PojoServerEndpointConfiguration.java
    tomcat/trunk/java/org/apache/tomcat/websocket/ServerContainerImpl.java
    tomcat/trunk/java/org/apache/tomcat/websocket/UriTemplate.java
    tomcat/trunk/java/org/apache/tomcat/websocket/Utf8Decoder.java
    tomcat/trunk/java/org/apache/tomcat/websocket/Util.java
    tomcat/trunk/java/org/apache/tomcat/websocket/WsEndpointPojo.java
    tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java
    tomcat/trunk/java/org/apache/tomcat/websocket/WsPongMessage.java
    tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java
    tomcat/trunk/java/org/apache/tomcat/websocket/WsSci.java
    tomcat/trunk/java/org/apache/tomcat/websocket/WsServlet.java
    tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/ClientContainerImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/ClientContainerImpl.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/ClientContainerImpl.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/ClientContainerImpl.java Wed Dec 12 13:12:32 2012
@@ -34,6 +34,7 @@ public class ClientContainerImpl impleme
         return null;
     }
 
+
     @Override
     public Session connectToServer(Endpoint endpoint,
             ClientEndpointConfiguration clientEndpointConfiguration, URI path)
@@ -42,52 +43,56 @@ public class ClientContainerImpl impleme
         return null;
     }
 
+
     @Override
     public Set<Session> getOpenSessions() {
         // TODO Auto-generated method stub
         return null;
     }
 
+
     @Override
     public long getMaxSessionIdleTimeout() {
         // TODO Auto-generated method stub
         return 0;
     }
 
+
     @Override
     public void setMaxSessionIdleTimeout(long timeout) {
         // TODO Auto-generated method stub
-
     }
 
+
     @Override
     public long getMaxBinaryMessageBufferSize() {
         // TODO Auto-generated method stub
         return 0;
     }
 
+
     @Override
     public void setMaxBinaryMessageBufferSize(long max) {
         // TODO Auto-generated method stub
-
     }
 
+
     @Override
     public long getMaxTextMessageBufferSize() {
         // TODO Auto-generated method stub
         return 0;
     }
 
+
     @Override
     public void setMaxTextMessageBufferSize(long max) {
         // TODO Auto-generated method stub
-
     }
 
+
     @Override
     public Set<String> getInstalledExtensions() {
         // TODO Auto-generated method stub
         return null;
     }
-
 }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java Wed Dec 12 13:12:32 2012
@@ -22,9 +22,7 @@ package org.apache.tomcat.websocket;
 public class Constants {
 
     protected static final String PACKAGE_NAME = "org.apache.tomcat.websocket";
-
     protected static final String SERVLET_NAME = WsServlet.class.getName();
-
     // OP Codes
     public static final byte OPCODE_CONTINUATION = 0x00;
     public static final byte OPCODE_TEXT = 0x01;
@@ -33,6 +31,7 @@ public class Constants {
     public static final byte OPCODE_PING = 0x09;
     public static final byte OPCODE_PONG = 0x0A;
 
+
     private Constants() {
         // Hide default constructor
     }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/PathParam.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/PathParam.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/PathParam.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/PathParam.java Wed Dec 12 13:12:32 2012
@@ -24,18 +24,22 @@ package org.apache.tomcat.websocket;
  * parameters, {@link #getName()} will always return <code>null</code>.
  */
 public class PathParam {
+
     private final Class<?> type;
     private final String name;
 
+
     public PathParam(Class<?> type, String name) {
         this.type = type;
         this.name = name;
     }
 
+
     public Class<?> getType() {
         return type;
     }
 
+
     public String getName() {
         return name;
     }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerAsync.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerAsync.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerAsync.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerAsync.java Wed Dec 12 13:12:32 2012
@@ -22,24 +22,24 @@ import java.lang.reflect.Method;
 import javax.websocket.MessageHandler;
 
 public class PojoMessageHandlerAsync<T> extends PojoMessageHandlerBase<T>
-        implements MessageHandler.Async<T>{
+        implements MessageHandler.Async<T> {
 
     public PojoMessageHandlerAsync(Object pojo, Method method,
             WsSession wsSession) {
         super(pojo, method, wsSession);
     }
 
+
     @Override
     public void onMessage(T message, boolean last) {
-
-        Object[] params = null; // TODO insert message, last and session into params
+        Object[] params = null; // TODO insert message, last and session into
+                                // params
         Object result;
         try {
-             result = method.invoke(pojo, params);
+            result = method.invoke(pojo, params);
         } catch (IllegalAccessException | InvocationTargetException e) {
             throw new IllegalArgumentException();
         }
-
         processResult(result);
     }
 }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerBase.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerBase.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerBase.java Wed Dec 12 13:12:32 2012
@@ -40,12 +40,12 @@ public abstract class PojoMessageHandler
     protected void processResult(Object result) {
         try {
             if (result instanceof String) {
-                wsSession.getRemote().sendString((String)result);
-            } else if (result instanceof ByteBuffer){
-                wsSession.getRemote().sendBytes((ByteBuffer)result);
+                wsSession.getRemote().sendString((String) result);
+            } else if (result instanceof ByteBuffer) {
+                wsSession.getRemote().sendBytes((ByteBuffer) result);
             } else if (result instanceof byte[]) {
                 wsSession.getRemote().sendBytes(
-                        ByteBuffer.wrap((byte[])result));
+                        ByteBuffer.wrap((byte[]) result));
             } else if (result != null) {
                 wsSession.getRemote().sendObject(result);
             }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerBasic.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerBasic.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerBasic.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/PojoMessageHandlerBasic.java Wed Dec 12 13:12:32 2012
@@ -21,25 +21,24 @@ import java.lang.reflect.Method;
 
 import javax.websocket.MessageHandler;
 
-public class PojoMessageHandlerBasic<T>  extends PojoMessageHandlerBase<T>
-        implements MessageHandler.Basic<T>{
+public class PojoMessageHandlerBasic<T> extends PojoMessageHandlerBase<T>
+        implements MessageHandler.Basic<T> {
 
     public PojoMessageHandlerBasic(Object pojo, Method method,
             WsSession wsSession) {
         super(pojo, method, wsSession);
     }
 
+
     @Override
     public void onMessage(T message) {
-
         Object[] params = null; // TODO insert message and session into params
         Object result;
         try {
-             result = method.invoke(pojo, params);
+            result = method.invoke(pojo, params);
         } catch (IllegalAccessException | InvocationTargetException e) {
             throw new IllegalArgumentException();
         }
-
         processResult(result);
     }
 }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/PojoMethodMapping.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/PojoMethodMapping.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/PojoMethodMapping.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/PojoMethodMapping.java Wed Dec 12 13:12:32 2012
@@ -43,17 +43,15 @@ public class PojoMethodMapping {
     private final PathParam[] onOpenParams;
     private final PathParam[] onCloseParams;
     private final PathParam[] onErrorParams;
-
     private final Set<MessageMethod> onMessage = new HashSet<>();
-
     private final UriTemplate template;
 
-    public PojoMethodMapping(Class<?> clazzPojo, String path,
-            String mappingPath) {
+
+    public PojoMethodMapping(Class<?> clazzPojo, String path, String mappingPath) {
         Method open = null;
         Method close = null;
         Method error = null;
-        for (Method method: clazzPojo.getMethods()) {
+        for (Method method : clazzPojo.getMethods()) {
             if (open == null &&
                     method.getAnnotation(WebSocketOpen.class) != null) {
                 open = method;
@@ -70,14 +68,11 @@ public class PojoMethodMapping {
         this.onOpen = open;
         this.onClose = close;
         this.onError = error;
-
         if (path.length() > mappingPath.length()) {
-            template =
-                    new UriTemplate(path.substring(mappingPath.length() - 2));
+            template = new UriTemplate(path.substring(mappingPath.length() - 2));
         } else {
             template = null;
         }
-
         onOpenParams = getPathParams(onOpen, false);
         onCloseParams = getPathParams(onClose, false);
         onErrorParams = getPathParams(onError, true);
@@ -103,6 +98,7 @@ public class PojoMethodMapping {
         return buildArgs(onCloseParams, template, pathInfo, session, null);
     }
 
+
     public Method getOnError() {
         return onError;
     }
@@ -116,14 +112,11 @@ public class PojoMethodMapping {
 
     public Set<MessageHandler> getMessageHandlers(Object pojo, String pathInfo,
             Session session) {
-
         Set<MessageHandler> result = new HashSet<>();
-
         for (MessageMethod messageMethod : onMessage) {
-            result.add(buildMessageHandler(
-                    messageMethod, pojo, pathInfo, session));
+            result.add(buildMessageHandler(messageMethod, pojo, pathInfo,
+                    session));
         }
-
         return result;
     }
 
@@ -131,20 +124,18 @@ public class PojoMethodMapping {
     private static MessageHandler buildMessageHandler(
             MessageMethod messageMethod, Object pojo, String pathInfo,
             Session session) {
-
         return null;
     }
 
+
     private static PathParam[] getPathParams(Method m, boolean isError) {
         if (m == null) {
             return new PathParam[0];
         }
-
         boolean foundError = !isError;
         Class<?>[] types = m.getParameterTypes();
         Annotation[][] paramsAnnotations = m.getParameterAnnotations();
         PathParam[] result = new PathParam[types.length];
-
         for (int i = 0; i < types.length; i++) {
             Class<?> type = types[i];
             if (type.equals(Session.class)) {
@@ -168,11 +159,9 @@ public class PojoMethodMapping {
                 }
             }
         }
-
         if (!foundError) {
             throw new IllegalArgumentException();
         }
-
         return result;
     }
 
@@ -181,8 +170,7 @@ public class PojoMethodMapping {
             UriTemplate template, String pathInfo, Session session,
             Throwable throwable) {
         Object[] result = new Object[pathParams.length];
-        Map<String, String> pathValues = template.match(pathInfo);
-
+        Map<String,String> pathValues = template.match(pathInfo);
         for (int i = 0; i < pathParams.length; i++) {
             Class<?> type = pathParams[i].getType();
             if (type.equals(Session.class)) {
@@ -204,7 +192,6 @@ public class PojoMethodMapping {
 
 
     private static Object coerceToType(Class<?> type, String value) {
-
         if (type.equals(String.class)) {
             return value;
         } else if (type.equals(boolean.class) || type.equals(Boolean.class)) {
@@ -230,19 +217,21 @@ public class PojoMethodMapping {
         }
     }
 
-
     private static class MessageMethod {
 
         private final Method m;
 
+
         public MessageMethod(Method m) {
             this.m = m;
         }
 
+
         public Method getMethod() {
             return m;
         }
 
+
         public Object[] getParameters() {
             return null;
         }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/PojoServerEndpointConfiguration.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/PojoServerEndpointConfiguration.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/PojoServerEndpointConfiguration.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/PojoServerEndpointConfiguration.java Wed Dec 12 13:12:32 2012
@@ -28,14 +28,14 @@ public class PojoServerEndpointConfigura
         // Allow all
         return true;
     }
-
     private final EndpointFactory<Endpoint> endpointFactory;
     private final String servletPath;
 
+
     PojoServerEndpointConfiguration(Class<?> pojo,
             PojoMethodMapping methodMapping, String servletPath, String pathInfo) {
-        this.endpointFactory =
-                new PojoEndpointFactory(pojo, methodMapping, pathInfo);
+        this.endpointFactory = new PojoEndpointFactory(pojo, methodMapping,
+                pathInfo);
         this.servletPath = servletPath;
     }
 
@@ -45,18 +45,20 @@ public class PojoServerEndpointConfigura
         return endpointFactory;
     }
 
+
     @Override
     public String getPath() {
         return servletPath;
     }
 
-    private static class PojoEndpointFactory
-            implements EndpointFactory<Endpoint> {
+    private static class PojoEndpointFactory implements
+            EndpointFactory<Endpoint> {
 
         private final Class<?> pojo;
         private final PojoMethodMapping methodMapping;
         private final String pathInfo;
 
+
         public PojoEndpointFactory(Class<?> pojo,
                 PojoMethodMapping methodMapping, String pathInfo) {
             this.pojo = pojo;
@@ -64,6 +66,7 @@ public class PojoServerEndpointConfigura
             this.pathInfo = pathInfo;
         }
 
+
         @Override
         public Endpoint createEndpoint() {
             Endpoint ep;

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/ServerContainerImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/ServerContainerImpl.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/ServerContainerImpl.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/ServerContainerImpl.java Wed Dec 12 13:12:32 2012
@@ -39,26 +39,20 @@ public class ServerContainerImpl extends
 
     // Needs to be a WeakHashMap to prevent memory leaks when a context is
     // stopped
-    private static Map<ClassLoader, ServerContainerImpl>
-            classLoaderContainerMap = new WeakHashMap<>();
-    private static Object classLoaderContainerMapLock = new  Object();
-
-    private static StringManager sm = StringManager.getManager(
-            Constants.PACKAGE_NAME);
-
+    private static Map<ClassLoader,ServerContainerImpl> classLoaderContainerMap = new WeakHashMap<>();
+    private static Object classLoaderContainerMapLock = new Object();
+    private static StringManager sm = StringManager.getManager(Constants.PACKAGE_NAME);
     protected Log log = LogFactory.getLog(ServerContainerImpl.class);
 
 
     /**
-     * Intended to be used by implementations of {@link
-     * javax.websocket.ContainerProvider#getServerContainer()} to obtain the
-     * correct {@link ServerContainer} instance.
+     * Intended to be used by implementations of
+     * {@link javax.websocket.ContainerProvider#getServerContainer()} to obtain
+     * the correct {@link ServerContainer} instance.
      */
     public static ServerContainerImpl getServerContainer() {
         ClassLoader tccl = Thread.currentThread().getContextClassLoader();
-
         ServerContainerImpl result = null;
-
         synchronized (classLoaderContainerMapLock) {
             result = classLoaderContainerMap.get(tccl);
             if (result == null) {
@@ -68,17 +62,10 @@ public class ServerContainerImpl extends
         }
         return result;
     }
-
-
     private volatile ServletContext servletContext = null;
-
-    private Map<String, ServerEndpointConfiguration<?>> configMap =
-            new ConcurrentHashMap<>();
-
-    private Map<String, Class<?>> pojoMap = new ConcurrentHashMap<>();
-
-    private Map<Class<?>, PojoMethodMapping> pojoMethodMap =
-            new ConcurrentHashMap<>();
+    private Map<String,ServerEndpointConfiguration<?>> configMap = new ConcurrentHashMap<>();
+    private Map<String,Class<?>> pojoMap = new ConcurrentHashMap<>();
+    private Map<Class<?>,PojoMethodMapping> pojoMethodMap = new ConcurrentHashMap<>();
 
 
     private ServerContainerImpl() {
@@ -92,30 +79,26 @@ public class ServerContainerImpl extends
 
 
     @Override
-    public void publishServer(Class<? extends ServerEndpointConfiguration<?>> clazz)
+    public void publishServer(
+            Class<? extends ServerEndpointConfiguration<?>> clazz)
             throws DeploymentException {
-
         if (servletContext == null) {
             throw new IllegalArgumentException(
                     sm.getString("serverContainer.servletContextMissing"));
         }
-
         ServerEndpointConfiguration<?> sec = null;
         try {
             sec = clazz.newInstance();
         } catch (InstantiationException | IllegalAccessException e) {
-            throw new DeploymentException(
-                    sm.getString("sci.newInstance.fail", clazz.getName()), e);
+            throw new DeploymentException(sm.getString("sci.newInstance.fail",
+                    clazz.getName()), e);
         }
-
         String path = sec.getPath();
         String mappingPath = Util.getServletMappingPath(path);
-
         if (log.isDebugEnabled()) {
             log.debug(sm.getString("serverContainer.endpointDeploy",
                     clazz.getName(), path, servletContext.getContextPath()));
         }
-
         configMap.put(mappingPath.substring(0, mappingPath.length() - 2), sec);
         addWsServletMapping(mappingPath);
     }
@@ -126,16 +109,15 @@ public class ServerContainerImpl extends
      * plain old java objects (POJOs) that have been annotated as WebSocket
      * endpoints.
      *
-     * @param pojo  The annotated POJO
-     * @param ctxt  The ServletContext the endpoint is to be published in
-     * @param path  The path at which the endpoint is to be published
+     * @param pojo The annotated POJO
+     * @param ctxt The ServletContext the endpoint is to be published in
+     * @param path The path at which the endpoint is to be published
      */
     public void publishServer(Class<?> pojo, ServletContext ctxt, String path) {
         if (ctxt == null) {
             throw new IllegalArgumentException(
                     sm.getString("serverContainer.servletContextMissing"));
         }
-
         // Set the ServletContext if it hasn't already been set
         if (servletContext == null) {
             servletContext = ctxt;
@@ -145,14 +127,11 @@ public class ServerContainerImpl extends
                     "serverContainer.servletContextMismatch", path,
                     servletContext.getContextPath(), ctxt.getContextPath()));
         }
-
         if (log.isDebugEnabled()) {
-            log.debug(sm.getString("serverContainer.pojoDeploy", pojo.getName(),
-                    path, servletContext.getContextPath()));
+            log.debug(sm.getString("serverContainer.pojoDeploy",
+                    pojo.getName(), path, servletContext.getContextPath()));
         }
-
         String mappingPath = Util.getServletMappingPath(path);
-
         pojoMap.put(mappingPath.substring(0, mappingPath.length() - 2), pojo);
         pojoMethodMap.put(pojo, new PojoMethodMapping(pojo, path, mappingPath));
         addWsServletMapping(mappingPath);
@@ -160,37 +139,31 @@ public class ServerContainerImpl extends
 
 
     private void addWsServletMapping(String mapping) {
-        ServletRegistration sr =
-                servletContext.getServletRegistration(Constants.SERVLET_NAME);
+        ServletRegistration sr = servletContext.getServletRegistration(Constants.SERVLET_NAME);
         if (sr == null) {
             sr = servletContext.addServlet(Constants.SERVLET_NAME,
                     WsServlet.class);
         }
-
         sr.addMapping(mapping);
     }
 
 
     public ServerEndpointConfiguration<?> getServerEndpointConfiguration(
             String servletPath, String pathInfo) {
-
         ServerEndpointConfiguration<?> sec = configMap.get(servletPath);
         if (sec != null) {
             return sec;
         }
-
         Class<?> pojo = pojoMap.get(servletPath);
         if (pojo != null) {
             PojoMethodMapping mapping = pojoMethodMap.get(pojo);
             if (mapping != null) {
-                PojoServerEndpointConfiguration pojoSec =
-                        new PojoServerEndpointConfiguration(pojo, mapping,
-                                servletPath, pathInfo);
+                PojoServerEndpointConfiguration pojoSec = new PojoServerEndpointConfiguration(
+                        pojo, mapping, servletPath, pathInfo);
                 return pojoSec;
             }
         }
-
-        throw new IllegalStateException(
-                sm.getString("serverContainer.missingEndpoint", servletPath));
+        throw new IllegalStateException(sm.getString(
+                "serverContainer.missingEndpoint", servletPath));
     }
 }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/UriTemplate.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/UriTemplate.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/UriTemplate.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/UriTemplate.java Wed Dec 12 13:12:32 2012
@@ -31,20 +31,16 @@ import org.apache.tomcat.util.res.String
  */
 public class UriTemplate {
 
-    private static StringManager sm = StringManager.getManager(
-            Constants.PACKAGE_NAME);
-
+    private static StringManager sm = StringManager.getManager(Constants.PACKAGE_NAME);
     private final String template;
     private final Pattern pattern;
     private final List<String> names = new ArrayList<>();
 
-    public UriTemplate(String template) {
 
+    public UriTemplate(String template) {
         this.template = template;
-
         // +10 is just a guess at this point
         StringBuilder pattern = new StringBuilder(template.length() + 10);
-
         int pos = 0;
         int end = 0;
         int start = template.indexOf('{');
@@ -57,14 +53,12 @@ public class UriTemplate {
             pos = end + 1;
             start = template.indexOf('{', pos);
         }
-
         // No more matches, append current position to end
         if (pos < template.length()) {
             pattern.append('(');
             pattern.append(template.substring(pos));
             pattern.append(")?");
         }
-
         this.pattern = Pattern.compile(pattern.toString());
     }
 
@@ -78,19 +72,17 @@ public class UriTemplate {
      * Extract the path parameters from the provided pathInfo based on the
      * template with which this UriTemplate was constructed.
      *
-     * @param pathInfo  The pathInfo from which the path parameters are to be
-     *                  extracted
-     * @return  A map of parameter names to values
+     * @param pathInfo The pathInfo from which the path parameters are to be
+     *            extracted
+     * @return A map of parameter names to values
      */
     public Map<String,String> match(String pathInfo) {
         Map<String,String> result = new HashMap<>();
         Matcher m = pattern.matcher(pathInfo);
-
         if (!m.matches()) {
             throw new IllegalArgumentException(sm.getString(
                     "uriTemplate.noMatch", template, pattern, pathInfo));
         }
-
         int group = 2;
         for (String name : names) {
             String value = m.group(group);
@@ -99,7 +91,6 @@ public class UriTemplate {
             }
             group += 2;
         }
-
         return result;
     }
 }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/Utf8Decoder.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/Utf8Decoder.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/Utf8Decoder.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/Utf8Decoder.java Wed Dec 12 13:12:32 2012
@@ -36,13 +36,12 @@ public class Utf8Decoder extends Charset
     //
     // Please note, o means 0, actually.
     // -------------------------------------------------------------------
-    // 0         1         2         3          Value
+    // 0 1 2 3 Value
     // -------------------------------------------------------------------
-    // oxxxxxxx                                 00000000 00000000 0xxxxxxx
-    // 11oyyyyy  1oxxxxxx                       00000000 00000yyy yyxxxxxx
-    // 111ozzzz  1oyyyyyy  1oxxxxxx             00000000 zzzzyyyy yyxxxxxx
-    // 1111ouuu  1ouuzzzz  1oyyyyyy  1oxxxxxx   000uuuuu zzzzyyyy yyxxxxxx
-
+    // oxxxxxxx 00000000 00000000 0xxxxxxx
+    // 11oyyyyy 1oxxxxxx 00000000 00000yyy yyxxxxxx
+    // 111ozzzz 1oyyyyyy 1oxxxxxx 00000000 zzzzyyyy yyxxxxxx
+    // 1111ouuu 1ouuzzzz 1oyyyyyy 1oxxxxxx 000uuuuu zzzzyyyy yyxxxxxx
     private static final int remainingBytes[] = {
             // 1owwwwww
             -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@@ -57,21 +56,21 @@ public class Utf8Decoder extends Charset
             // 1111ouuu
             3, 3, 3, 3, 3, 3, 3, 3,
             // > 11110111
-            -1, -1, -1, -1, -1, -1, -1, -1 };
-
-    private static final int remainingNumbers[] = {
-                   0, //                0                 1                2           3
-                4224, // (01o00000b <<  6)+(1o000000b)
-              401536, // (011o0000b << 12)+(1o000000b <<  6)+(1o000000b)
-            29892736  // (0111o000b << 18)+(1o000000b << 12)+(1o000000b << 6)+(1o000000b)
+            -1, -1, -1, -1, -1, -1, -1, -1};
+    private static final int remainingNumbers[] = {0, // 0 1 2 3
+            4224, // (01o00000b << 6)+(1o000000b)
+            401536, // (011o0000b << 12)+(1o000000b << 6)+(1o000000b)
+            29892736 // (0111o000b << 18)+(1o000000b << 12)+(1o000000b <<
+                     // 6)+(1o000000b)
     };
+    private static final int lowerEncodingLimit[] = {-1, 0x80, 0x800, 0x10000};
 
-    private static final int lowerEncodingLimit[] = { -1, 0x80, 0x800, 0x10000 };
 
     public Utf8Decoder() {
         super(B2CConverter.UTF_8, 1.0f, 1.0f);
     }
 
+
     @Override
     protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
         if (in.hasArray() && out.hasArray()) {
@@ -80,6 +79,7 @@ public class Utf8Decoder extends Charset
         return decodeNotHasArray(in, out);
     }
 
+
     private CoderResult decodeNotHasArray(ByteBuffer in, CharBuffer out) {
         int outRemaining = out.remaining();
         int pos = in.position();
@@ -89,7 +89,6 @@ public class Utf8Decoder extends Charset
                 if (outRemaining == 0) {
                     return CoderResult.OVERFLOW;
                 }
-
                 int jchar = in.get();
                 if (jchar < 0) {
                     jchar = jchar & 0x7F;
@@ -100,13 +99,11 @@ public class Utf8Decoder extends Charset
                     if (limit - pos < 1 + tail) {
                         return CoderResult.UNDERFLOW;
                     }
-
                     int nextByte;
                     for (int i = 0; i < tail; i++) {
                         nextByte = in.get() & 0xFF;
                         if ((nextByte & 0xC0) != 0x80) {
-                            return CoderResult
-                                    .malformedForLength(1 + i);
+                            return CoderResult.malformedForLength(1 + i);
                         }
                         jchar = (jchar << 6) + nextByte;
                     }
@@ -118,15 +115,15 @@ public class Utf8Decoder extends Charset
                     pos += tail;
                 }
                 if (jchar <= 0xffff) {
-                  out.put((char) jchar);
-                  outRemaining--;
+                    out.put((char) jchar);
+                    outRemaining--;
                 } else {
-                  if (outRemaining < 2) {
-                      return CoderResult.OVERFLOW;
-                  }
-                  out.put((char) ((jchar >> 0xA) + 0xD7C0));
-                  out.put((char) ((jchar & 0x3FF) + 0xDC00));
-                  outRemaining -= 2;
+                    if (outRemaining < 2) {
+                        return CoderResult.OVERFLOW;
+                    }
+                    out.put((char) ((jchar >> 0xA) + 0xD7C0));
+                    out.put((char) ((jchar & 0x3FF) + 0xDC00));
+                    outRemaining -= 2;
                 }
                 pos++;
             }
@@ -136,6 +133,7 @@ public class Utf8Decoder extends Charset
         }
     }
 
+
     private CoderResult decodeHasArray(ByteBuffer in, CharBuffer out) {
         int outRemaining = out.remaining();
         int pos = in.position();
@@ -143,10 +141,8 @@ public class Utf8Decoder extends Charset
         final byte[] bArr = in.array();
         final char[] cArr = out.array();
         final int inIndexLimit = limit + in.arrayOffset();
-
         int inIndex = pos + in.arrayOffset();
         int outIndex = out.position() + out.arrayOffset();
-
         // if someone would change the limit in process,
         // he would face consequences
         for (; inIndex < inIndexLimit && outRemaining > 0; inIndex++) {
@@ -154,7 +150,6 @@ public class Utf8Decoder extends Charset
             if (jchar < 0) {
                 jchar = jchar & 0x7F;
                 int tail = remainingBytes[jchar];
-
                 if (tail == -1) {
                     in.position(inIndex - in.arrayOffset());
                     out.position(outIndex - out.arrayOffset());
@@ -163,7 +158,6 @@ public class Utf8Decoder extends Charset
                 if (inIndexLimit - inIndex < 1 + tail) {
                     break;
                 }
-
                 for (int i = 0; i < tail; i++) {
                     int nextByte = bArr[inIndex + i + 1] & 0xFF;
                     if ((nextByte & 0xC0) != 0x80) {
@@ -183,25 +177,24 @@ public class Utf8Decoder extends Charset
                 inIndex += tail;
             }
             // Note: This is the additional test added
-            if (jchar >= 0xD800 && jchar <=0xDFFF) {
+            if (jchar >= 0xD800 && jchar <= 0xDFFF) {
                 return CoderResult.unmappableForLength(3);
             }
             if (jchar <= 0xffff) {
-              cArr[outIndex++] = (char) jchar;
-              outRemaining--;
+                cArr[outIndex++] = (char) jchar;
+                outRemaining--;
             } else {
-              if (outRemaining < 2) {
-                  return CoderResult.OVERFLOW;
-              }
-              cArr[outIndex++] = (char) ((jchar >> 0xA) + 0xD7C0);
-              cArr[outIndex++] = (char) ((jchar & 0x3FF) + 0xDC00);
-              outRemaining -= 2;
+                if (outRemaining < 2) {
+                    return CoderResult.OVERFLOW;
+                }
+                cArr[outIndex++] = (char) ((jchar >> 0xA) + 0xD7C0);
+                cArr[outIndex++] = (char) ((jchar & 0x3FF) + 0xDC00);
+                outRemaining -= 2;
             }
         }
         in.position(inIndex - in.arrayOffset());
         out.position(outIndex - out.arrayOffset());
-        return (outRemaining == 0 && inIndex < inIndexLimit) ?
-                CoderResult.OVERFLOW :
-                CoderResult.UNDERFLOW;
+        return (outRemaining == 0 && inIndex < inIndexLimit) ? CoderResult.OVERFLOW
+                : CoderResult.UNDERFLOW;
     }
 }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/Util.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/Util.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/Util.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/Util.java Wed Dec 12 13:12:32 2012
@@ -17,8 +17,8 @@
 package org.apache.tomcat.websocket;
 
 /**
- * Utility class for internal use only within the {@link
- * org.apache.tomcat.websocket} package.
+ * Utility class for internal use only within the
+ * {@link org.apache.tomcat.websocket} package.
  */
 class Util {
 
@@ -26,13 +26,13 @@ class Util {
         // Hide default constructor
     }
 
+
     /**
      * Converts a path defined for a WebSocket endpoint into a path that can be
      * used as a servlet mapping.
      *
-     * @param wsPath    The WebSocket endpoint path to convert
-     *
-     * @return  The servlet mapping
+     * @param wsPath The WebSocket endpoint path to convert
+     * @return The servlet mapping
      */
     static String getServletMappingPath(String wsPath) {
         int templateStart = wsPath.indexOf('{');

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsEndpointPojo.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsEndpointPojo.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsEndpointPojo.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsEndpointPojo.java Wed Dec 12 13:12:32 2012
@@ -35,42 +35,43 @@ public class WsEndpointPojo extends Endp
     private final PojoMethodMapping methodMapping;
     private Session session = null;
 
+
     public WsEndpointPojo(Class<?> clazzPojo, PojoMethodMapping methodMapping,
-            String pathInfo)
-            throws InstantiationException, IllegalAccessException {
+            String pathInfo) throws InstantiationException,
+            IllegalAccessException {
         // TODO Use factory from annotation if present
         this.pojo = clazzPojo.newInstance();
         this.methodMapping = methodMapping;
         this.pathInfo = pathInfo;
     }
 
+
     @Override
     public void onOpen(Session session) {
         this.session = session;
-
         if (methodMapping.getOnOpen() != null) {
             try {
-                methodMapping.getOnOpen().invoke(
-                        pojo, methodMapping.getOnOpenArgs(pathInfo, session));
+                methodMapping.getOnOpen().invoke(pojo,
+                        methodMapping.getOnOpenArgs(pathInfo, session));
             } catch (IllegalAccessException | IllegalArgumentException
                     | InvocationTargetException e) {
                 // TODO Auto-generated catch block
                 e.printStackTrace();
             }
         }
-
-        for (MessageHandler mh :
-                methodMapping.getMessageHandlers(pojo, pathInfo, session)) {
+        for (MessageHandler mh : methodMapping.getMessageHandlers(pojo,
+                pathInfo, session)) {
             session.addMessageHandler(mh);
         }
     }
 
+
     @Override
     public void onClose(CloseReason closeReason) {
         if (methodMapping.getOnClose() != null) {
             try {
-                methodMapping.getOnClose().invoke(
-                        pojo, methodMapping.getOnCloseArgs(pathInfo, session));
+                methodMapping.getOnClose().invoke(pojo,
+                        methodMapping.getOnCloseArgs(pathInfo, session));
             } catch (IllegalAccessException | IllegalArgumentException
                     | InvocationTargetException e) {
                 // TODO Auto-generated catch block
@@ -79,13 +80,15 @@ public class WsEndpointPojo extends Endp
         }
     }
 
+
     @Override
     public void onError(Throwable throwable) {
         if (methodMapping.getOnError() != null) {
             try {
-                methodMapping.getOnError().invoke(pojo,
-                        methodMapping.getOnErrorArgs(
-                                pathInfo, session, throwable));
+                methodMapping.getOnError().invoke(
+                        pojo,
+                        methodMapping.getOnErrorArgs(pathInfo, session,
+                                throwable));
             } catch (IllegalAccessException | IllegalArgumentException
                     | InvocationTargetException e) {
                 // TODO Auto-generated catch block

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsFrame.java Wed Dec 12 13:12:32 2012
@@ -33,20 +33,16 @@ import org.apache.tomcat.util.res.String
  */
 public class WsFrame {
 
-    private static StringManager sm = StringManager.getManager(
-            Constants.PACKAGE_NAME);
-
+    private static StringManager sm = StringManager.getManager(Constants.PACKAGE_NAME);
     private final ServletInputStream sis;
     private final WsSession wsSession;
     private final byte[] inputBuffer;
     private int pos = 0;
-
     private State state = State.NEW_FRAME;
     private int headerLength = 0;
     private boolean continutationExpected = false;
     private boolean textMessage = false;
     private long payloadSent = 0;
-
     private long payloadLength = 0;
     private boolean fin;
     private int rsv;
@@ -58,7 +54,6 @@ public class WsFrame {
     public WsFrame(ServletInputStream sis, WsSession wsSession) {
         this.sis = sis;
         this.wsSession = wsSession;
-
         inputBuffer = new byte[8192];
     }
 
@@ -77,7 +72,6 @@ public class WsFrame {
                 throw new EOFException();
             }
             pos += read;
-
             while (true) {
                 if (state == State.NEW_FRAME) {
                     if (!processInitialHeader()) {
@@ -108,12 +102,10 @@ public class WsFrame {
         if (pos < 2) {
             return false;
         }
-
         int b = inputBuffer[0];
         fin = (b & 0x80) > 0;
         rsv = (b & 0x70) >>> 4;
         opCode = (byte) (b & 0x0F);
-
         if (!isControl()) {
             if (continutationExpected) {
                 if (opCode != Constants.OPCODE_CONTINUATION) {
@@ -130,19 +122,14 @@ public class WsFrame {
                     throw new UnsupportedOperationException();
                 }
             }
-
             continutationExpected = !fin;
         }
-
-
         b = inputBuffer[1];
         // Client data must be masked
         if ((b & 0x80) == 0) {
             throw new IOException(sm.getString("wsFrame.notMasked"));
         }
-
         payloadLength = b & 0x7F;
-
         state = State.PARTIAL_HEADER;
         return true;
     }
@@ -155,25 +142,21 @@ public class WsFrame {
     private boolean processRemainingHeader() throws IOException {
         // Initial 2 bytes already read + 4 for the mask
         headerLength = 6;
-
         // Add additional bytes depending on length
         if (payloadLength == 126) {
-            headerLength +=2;
+            headerLength += 2;
         } else if (payloadLength == 127) {
-            headerLength +=8;
+            headerLength += 8;
         }
-
         if (pos < headerLength) {
             return false;
         }
-
         // Calculate new payload length if necessary
         if (payloadLength == 126) {
             payloadLength = byteArrayToLong(inputBuffer, 2, 2);
         } else if (payloadLength == 127) {
             payloadLength = byteArrayToLong(inputBuffer, 2, 8);
         }
-
         if (isControl()) {
             if (payloadLength > 125) {
                 throw new IOException(sm.getString(
@@ -184,9 +167,7 @@ public class WsFrame {
                 throw new IOException("wsFrame.controlNoFin");
             }
         }
-
         System.arraycopy(inputBuffer, headerLength - 4, mask, 0, 4);
-
         state = State.DATA;
         return true;
     }
@@ -202,8 +183,7 @@ public class WsFrame {
             } else if (opCode == Constants.OPCODE_PING) {
                 wsSession.getRemote().sendPong(getPayloadBinary());
             } else if (opCode == Constants.OPCODE_PONG) {
-                MessageHandler.Basic<PongMessage> mhPong =
-                        wsSession.getPongMessageHandler();
+                MessageHandler.Basic<PongMessage> mhPong = wsSession.getPongMessageHandler();
                 if (mhPong != null) {
                     mhPong.onMessage(new WsPongMessage(getPayloadBinary()));
                 }
@@ -226,7 +206,6 @@ public class WsFrame {
         } else {
             sendPayload(true);
         }
-
         state = State.NEW_FRAME;
         payloadLength = 0;
         payloadSent = 0;
@@ -242,8 +221,7 @@ public class WsFrame {
             MessageHandler mh = wsSession.getTextMessageHandler();
             if (mh != null) {
                 if (mh instanceof MessageHandler.Async<?>) {
-                    ((MessageHandler.Async<String>) mh).onMessage(payload,
-                            last);
+                    ((MessageHandler.Async<String>) mh).onMessage(payload, last);
                 } else {
                     ((MessageHandler.Basic<String>) mh).onMessage(payload);
                 }
@@ -262,6 +240,7 @@ public class WsFrame {
         }
     }
 
+
     private boolean isControl() {
         return (opCode & 0x08) > 0;
     }
@@ -271,6 +250,7 @@ public class WsFrame {
         return (payloadSent + pos - headerLength) >= payloadLength;
     }
 
+
     private boolean usePartial() {
         if (opCode == Constants.OPCODE_BINARY) {
             MessageHandler mh = wsSession.getBinaryMessageHandler();
@@ -290,6 +270,7 @@ public class WsFrame {
         }
     }
 
+
     private ByteBuffer getPayloadBinary() {
         int end;
         if (isPayloadComplete()) {
@@ -297,9 +278,7 @@ public class WsFrame {
         } else {
             end = pos;
         }
-
         ByteBuffer result = ByteBuffer.allocate(end - headerLength);
-
         for (int i = headerLength; i < end; i++) {
             result.put(i - headerLength,
                     (byte) ((inputBuffer[i] ^ mask[maskIndex]) & 0xFF));
@@ -308,42 +287,35 @@ public class WsFrame {
                 maskIndex = 0;
             }
         }
-
         // May have read past end of current frame into next
-
         pos = 0;
         headerLength = 0;
-
         return result;
     }
 
+
     private String getPayloadText() {
         ByteBuffer bb = getPayloadBinary();
-
         return new String(bb.array(), Charset.forName("UTF-8"));
     }
 
+
     protected static long byteArrayToLong(byte[] b, int start, int len)
             throws IOException {
-
         if (len > 8) {
-            throw new IOException(
-                    sm.getString("wsFrame.byteToLongFail", Long.valueOf(len)));
+            throw new IOException(sm.getString("wsFrame.byteToLongFail",
+                    Long.valueOf(len)));
         }
-
         int shift = 0;
         long result = 0;
         for (int i = start + len - 1; i >= start; i--) {
             result = result + ((b[i] & 0xFF) << shift);
             shift += 8;
         }
-
         return result;
     }
 
     private static enum State {
-        NEW_FRAME,
-        PARTIAL_HEADER,
-        DATA
+        NEW_FRAME, PARTIAL_HEADER, DATA
     }
 }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsPongMessage.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsPongMessage.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsPongMessage.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsPongMessage.java Wed Dec 12 13:12:32 2012
@@ -24,10 +24,12 @@ public class WsPongMessage implements Po
 
     private final ByteBuffer applicationData;
 
+
     public WsPongMessage(ByteBuffer applicationData) {
         this.applicationData = applicationData;
     }
 
+
     @Override
     public ByteBuffer getApplicationData() {
         return applicationData;

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java Wed Dec 12 13:12:32 2012
@@ -35,15 +35,16 @@ public class WsProtocolHandler implement
     private final ClassLoader applicationClassLoader;
     private final WsSession wsSession;
 
+
     public WsProtocolHandler(Endpoint ep) {
         this.ep = ep;
         applicationClassLoader = Thread.currentThread().getContextClassLoader();
         wsSession = new WsSession(ep);
     }
 
+
     @Override
     public void init(WebConnection connection) {
-
         // Need to call onOpen using the web application's class loader
         Thread t = Thread.currentThread();
         ClassLoader cl = t.getContextClassLoader();
@@ -53,7 +54,6 @@ public class WsProtocolHandler implement
         } finally {
             t.setContextClassLoader(cl);
         }
-
         ServletInputStream sis;
         ServletOutputStream sos;
         try {
@@ -62,9 +62,7 @@ public class WsProtocolHandler implement
         } catch (IOException e) {
             throw new IllegalStateException(e);
         }
-
         WsFrame wsFrame = new WsFrame(sis, wsSession);
-
         sis.setReadListener(new WsReadListener(this, wsFrame));
         sos.setWriteListener(new WsWriteListener(this));
     }
@@ -87,12 +85,14 @@ public class WsProtocolHandler implement
         private final WsProtocolHandler wsProtocolHandler;
         private final WsFrame wsFrame;
 
+
         private WsReadListener(WsProtocolHandler wsProtocolHandler,
                 WsFrame wsFrame) {
             this.wsProtocolHandler = wsProtocolHandler;
             this.wsFrame = wsFrame;
         }
 
+
         @Override
         public void onDataAvailable() {
             try {
@@ -102,33 +102,36 @@ public class WsProtocolHandler implement
             }
         }
 
+
         @Override
         public void onAllDataRead() {
             // Will never happen with WebSocket
             throw new IllegalStateException();
         }
 
+
         @Override
         public void onError(Throwable throwable) {
             wsProtocolHandler.onError(throwable);
         }
     }
 
-
     private static class WsWriteListener implements WriteListener {
 
         private final WsProtocolHandler wsProtocolHandler;
 
+
         private WsWriteListener(WsProtocolHandler wsProtocolHandler) {
             this.wsProtocolHandler = wsProtocolHandler;
         }
 
+
         @Override
         public void onWritePossible() {
             // TODO Auto-generated method stub
-
         }
 
+
         @Override
         public void onError(Throwable throwable) {
             wsProtocolHandler.onError(throwable);

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsSci.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsSci.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsSci.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsSci.java Wed Dec 12 13:12:32 2012
@@ -26,8 +26,8 @@ import javax.websocket.WebSocketEndpoint
 
 /**
  * Registers an interest in any class that is annotated with
- * {@link WebSocketEndpoint} so that Endpoint can be published via the
- * WebSocket server.
+ * {@link WebSocketEndpoint} so that Endpoint can be published via the WebSocket
+ * server.
  */
 @HandlesTypes({WebSocketEndpoint.class})
 public class WsSci implements ServletContainerInitializer {
@@ -35,18 +35,14 @@ public class WsSci implements ServletCon
     @Override
     public void onStartup(Set<Class<?>> clazzes, ServletContext ctx)
             throws ServletException {
-
         // Need to configure the ServletContext in all cases
         ServerContainerImpl sc = ServerContainerImpl.getServerContainer();
         sc.setServletContext(ctx);
-
         if (clazzes == null || clazzes.size() == 0) {
             return;
         }
-
         for (Class<?> clazz : clazzes) {
-            WebSocketEndpoint annotation =
-                    clazz.getAnnotation(WebSocketEndpoint.class);
+            WebSocketEndpoint annotation = clazz.getAnnotation(WebSocketEndpoint.class);
             sc.publishServer(clazz, ctx, annotation.value());
         }
     }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsServlet.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsServlet.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsServlet.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsServlet.java Wed Dec 12 13:12:32 2012
@@ -43,77 +43,61 @@ import javax.xml.bind.DatatypeConverter;
 public class WsServlet extends HttpServlet {
 
     private static final long serialVersionUID = 1L;
-
     private static final Charset ISO_8859_1;
     static {
         ISO_8859_1 = Charset.forName("ISO-8859-1");
     }
-
-    private static final byte[] WS_ACCEPT =
-            "258EAFA5-E914-47DA-95CA-C5AB0DC85B11".getBytes(ISO_8859_1);
-
-    private final Queue<MessageDigest> sha1Helpers =
-            new ConcurrentLinkedQueue<>();
-
+    private static final byte[] WS_ACCEPT = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11".getBytes(ISO_8859_1);
+    private final Queue<MessageDigest> sha1Helpers = new ConcurrentLinkedQueue<>();
 
 
     @Override
     protected void doGet(HttpServletRequest req, HttpServletResponse resp)
             throws ServletException, IOException {
-
         // Information required to send the server handshake message
         String key;
         String subProtocol = null;
         List<String> extensions = Collections.emptyList();
-
         if (!headerContainsToken(req, "upgrade", "websocket")) {
             resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
             return;
         }
-
         if (!headerContainsToken(req, "connection", "upgrade")) {
             resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
             return;
         }
-
         if (!headerContainsToken(req, "sec-websocket-version", "13")) {
             resp.setStatus(426);
             resp.setHeader("Sec-WebSocket-Version", "13");
             return;
         }
-
         key = req.getHeader("Sec-WebSocket-Key");
         if (key == null) {
             resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
             return;
         }
-
         // Need an Endpoint instance to progress this further
         ServerContainerImpl cp = ServerContainerImpl.getServerContainer();
         ServerEndpointConfiguration<?> sec = cp.getServerEndpointConfiguration(
                 req.getServletPath(), req.getPathInfo());
-
         // Origin check
         String origin = req.getHeader("Origin");
         if (!sec.checkOrigin(origin)) {
             resp.sendError(HttpServletResponse.SC_FORBIDDEN);
             return;
         }
-
         // Sub-protocols
-        List<String> subProtocols =
-                getTokensFromHeader(req, "Sec-WebSocket-Protocol");
+        List<String> subProtocols = getTokensFromHeader(req,
+                "Sec-WebSocket-Protocol");
         if (!subProtocols.isEmpty()) {
             subProtocol = sec.getNegotiatedSubprotocol(subProtocols);
         }
-
         // Extensions
-        List<String> requestedExtensions =
-                getTokensFromHeader(req, "Sec-WebSocket-Extensions");
+        List<String> requestedExtensions = getTokensFromHeader(req,
+                "Sec-WebSocket-Extensions");
         if (!extensions.isEmpty()) {
             extensions = sec.getNegotiatedExtensions(requestedExtensions);
         }
-
         // If we got this far, all is good. Accept the connection.
         resp.setHeader("Upgrade", "websocket");
         resp.setHeader("Connection", "upgrade");
@@ -132,10 +116,8 @@ public class WsServlet extends HttpServl
             }
             resp.setHeader("Sec-WebSocket-Extensions", sb.toString());
         }
-
         Endpoint ep = (Endpoint) sec.getEndpointFactory().createEndpoint();
         ProtocolHandler wsHandler = new WsProtocolHandler(ep);
-
         req.upgrade(wsHandler);
     }
 
@@ -167,7 +149,6 @@ public class WsServlet extends HttpServl
     private List<String> getTokensFromHeader(HttpServletRequest req,
             String headerName) {
         List<String> result = new ArrayList<>();
-
         Enumeration<String> headers = req.getHeaders(headerName);
         while (headers.hasMoreElements()) {
             String header = headers.nextElement();
@@ -181,7 +162,6 @@ public class WsServlet extends HttpServl
 
 
     private String getWebSocketAccept(String key) throws ServletException {
-
         MessageDigest sha1Helper = sha1Helpers.poll();
         if (sha1Helper == null) {
             try {
@@ -190,14 +170,10 @@ public class WsServlet extends HttpServl
                 throw new ServletException(e);
             }
         }
-
         sha1Helper.reset();
         sha1Helper.update(key.getBytes(ISO_8859_1));
-        String result = DatatypeConverter.printBase64Binary(
-                sha1Helper.digest(WS_ACCEPT));
-
+        String result = DatatypeConverter.printBase64Binary(sha1Helper.digest(WS_ACCEPT));
         sha1Helpers.add(sha1Helper);
-
         return result;
     }
 }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java?rev=1420654&r1=1420653&r2=1420654&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java Wed Dec 12 13:12:32 2012
@@ -38,21 +38,23 @@ public class WsSession implements Sessio
 
     private MessageHandler textMessageHandler = null;
     private MessageHandler binaryMessageHandler = null;
-    private MessageHandler.Basic<PongMessage> pongMessageHandler =
-            new DefaultPingMessageHandler(this);
-
+    private MessageHandler.Basic<PongMessage> pongMessageHandler = new DefaultPingMessageHandler(
+            this);
     private final Endpoint localEndpoint;
 
+
     public WsSession(Endpoint localEndpoint) {
         this.localEndpoint = localEndpoint;
     }
 
+
     @Override
     public ClientContainer getContainer() {
         // TODO Auto-generated method stub
         return null;
     }
 
+
     @SuppressWarnings("unchecked")
     @Override
     public void addMessageHandler(MessageHandler listener) {
@@ -67,13 +69,13 @@ public class WsSession implements Sessio
                 throw new IllegalStateException();
             }
             textMessageHandler = listener;
-        } else if (types[0].getClass().equals(ByteBuffer.class)){
+        } else if (types[0].getClass().equals(ByteBuffer.class)) {
             if (binaryMessageHandler != null) {
                 // TODO i18n
                 throw new IllegalStateException();
             }
             binaryMessageHandler = listener;
-        } else if (types[0].getClass().equals(PongMessage.class)){
+        } else if (types[0].getClass().equals(PongMessage.class)) {
             if (pongMessageHandler != null) {
                 // TODO i18n
                 throw new IllegalStateException();
@@ -90,6 +92,7 @@ public class WsSession implements Sessio
         }
     }
 
+
     @Override
     public Set<MessageHandler> getMessageHandlers() {
         Set<MessageHandler> result = new HashSet<>();
@@ -105,6 +108,7 @@ public class WsSession implements Sessio
         return result;
     }
 
+
     @Override
     public void removeMessageHandler(MessageHandler listener) {
         if (listener == null) {
@@ -120,109 +124,125 @@ public class WsSession implements Sessio
         // TODO Ignore? ISE?
     }
 
+
     @Override
     public String getProtocolVersion() {
         // TODO Auto-generated method stub
         return null;
     }
 
+
     @Override
     public String getNegotiatedSubprotocol() {
         // TODO Auto-generated method stub
         return null;
     }
 
+
     @Override
     public List<String> getNegotiatedExtensions() {
         // TODO Auto-generated method stub
         return null;
     }
 
+
     @Override
     public boolean isSecure() {
         // TODO Auto-generated method stub
         return false;
     }
 
+
     @Override
     public long getInactiveTime() {
         // TODO Auto-generated method stub
         return 0;
     }
 
+
     @Override
     public boolean isOpen() {
         // TODO Auto-generated method stub
         return false;
     }
 
+
     @Override
     public long getTimeout() {
         // TODO Auto-generated method stub
         return 0;
     }
 
+
     @Override
     public void setTimeout(long seconds) {
         // TODO Auto-generated method stub
-
     }
 
+
     @Override
     public void setMaximumMessageSize(long length) {
         // TODO Auto-generated method stub
-
     }
 
+
     @Override
     public long getMaximumMessageSize() {
         // TODO Auto-generated method stub
         return 0;
     }
 
+
     @Override
     public RemoteEndpoint getRemote() {
         // TODO Auto-generated method stub
         return null;
     }
 
+
     @Override
     public void close() throws IOException {
         close(new CloseReason(CloseCodes.GOING_AWAY, ""));
     }
 
+
     @Override
     public void close(CloseReason closeStatus) throws IOException {
         // TODO Send the close message to the remote endpoint
         localEndpoint.onClose(closeStatus);
     }
 
+
     @Override
     public URI getRequestURI() {
         // TODO Auto-generated method stub
         return null;
     }
 
+
     @Override
-    public Map<String, String[]> getRequestParameterMap() {
+    public Map<String,String[]> getRequestParameterMap() {
         // TODO Auto-generated method stub
         return null;
     }
 
+
     @Override
     public String getQueryString() {
         // TODO Auto-generated method stub
         return null;
     }
 
+
     @Override
-    public Map<String, String> getPathParameters() {
+    public Map<String,String> getPathParameters() {
         // TODO Auto-generated method stub
         return null;
     }
 
+
     @Override
-    public Map<String, Object> getUserProperties() {
+    public Map<String,Object> getUserProperties() {
         // TODO Auto-generated method stub
         return null;
     }
@@ -232,24 +252,27 @@ public class WsSession implements Sessio
         return textMessageHandler;
     }
 
+
     public MessageHandler getBinaryMessageHandler() {
         return binaryMessageHandler;
     }
 
+
     public MessageHandler.Basic<PongMessage> getPongMessageHandler() {
         return pongMessageHandler;
     }
 
-
-    private static class DefaultPingMessageHandler
-            implements MessageHandler.Basic<PongMessage>{
+    private static class DefaultPingMessageHandler implements
+            MessageHandler.Basic<PongMessage> {
 
         private final WsSession wsSession;
 
+
         private DefaultPingMessageHandler(WsSession wsSession) {
             this.wsSession = wsSession;
         }
 
+
         @Override
         public void onMessage(PongMessage message) {
             RemoteEndpoint remoteEndpoint = wsSession.getRemote();



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message