Author: markt Date: Thu Jun 27 15:55:47 2013 New Revision: 1497407 URL: http://svn.apache.org/r1497407 Log: Ensure methods with WebSocket annotations are public
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java Modified: tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties?rev=1497407&r1=1497406&r2=1497407&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/pojo/LocalStrings.properties Thu Jun 27 15:55:47 2013 @@ -27,6 +27,7 @@ pojoMethodMapping.duplicatePongMessagePa pojoMethodMapping.duplicateSessionParam=Multiple session parameters present on the method [{0}] of class [{1}] that was annotated with OnMessage pojoMethodMapping.invalidDecoder=The specified decoder of type [{0}] could not be instantiated pojoMethodMapping.invalidPathParamType=Parameters annotated with @PathParam may only be Strings, Java primitives or a boxed version thereof +pojoMethodMapping.methodNotPublic=The annotated method [{0}] is not public pojoMethodMapping.noPayload=No payload parameter present on the method [{0}] of class [{1}] that was annotated with OnMessage pojoMethodMapping.onErrorNoThrowable=No Throwable parameter was present on the method [{0}] of class [{1}] that was annotated with OnError pojoMethodMapping.paramWithoutAnnotation=A parameter of type [{0}] was found on method[{1}] of class [{2}] that did not have a @PathParam annotation Modified: tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java?rev=1497407&r1=1497406&r2=1497407&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/pojo/PojoMethodMapping.java Thu Jun 27 15:55:47 2013 @@ -20,6 +20,7 @@ import java.io.InputStream; import java.io.Reader; import java.lang.annotation.Annotation; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.nio.ByteBuffer; import java.util.HashMap; import java.util.HashSet; @@ -79,6 +80,7 @@ public class PojoMethodMapping { Method error = null; for (Method method : clazzPojo.getDeclaredMethods()) { if (method.getAnnotation(OnOpen.class) != null) { + checkPublic(method); if (open == null) { open = method; } else { @@ -88,6 +90,7 @@ public class PojoMethodMapping { OnOpen.class, clazzPojo)); } } else if (method.getAnnotation(OnClose.class) != null) { + checkPublic(method); if (close == null) { close = method; } else { @@ -97,6 +100,7 @@ public class PojoMethodMapping { OnClose.class, clazzPojo)); } } else if (method.getAnnotation(OnError.class) != null) { + checkPublic(method); if (error == null) { error = method; } else { @@ -106,6 +110,7 @@ public class PojoMethodMapping { OnError.class, clazzPojo)); } } else if (method.getAnnotation(OnMessage.class) != null) { + checkPublic(method); onMessage.add(new MessageHandlerInfo(method, decoders)); } else { // Method not annotated @@ -120,6 +125,14 @@ public class PojoMethodMapping { } + private void checkPublic(Method m) throws DeploymentException { + if (!Modifier.isPublic(m.getModifiers())) { + throw new DeploymentException(sm.getString( + "pojoMethodMapping.methodNotPublic", m.getName())); + } + } + + public String getWsPath() { return wsPath; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org