Author: shane.bryzak(a)jboss.com
Date: 2009-12-02 04:36:04 -0500 (Wed, 02 Dec 2009)
New Revision: 11713
Added:
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/Casual.java
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/CasualHelloAction.java
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/CasualRussianHelloAction.java
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/Localized.java
Modified:
modules/trunk/remoting/examples/helloworld/src/main/webapp/helloworld.xhtml
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationsParser.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/AnnotationParser.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/syntaxtree/ClassOrInterfaceType.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/DepthFirstVisitor.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJDepthFirst.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJNoArguDepthFirst.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJNoArguVisitor.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJVisitor.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJVoidDepthFirst.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJVoidVisitor.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/Visitor.java
modules/trunk/remoting/src/main/javacc/AnnotationParser.jj
Log:
oops, add enum support
Added:
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/Casual.java
===================================================================
---
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/Casual.java
(rev 0)
+++
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/Casual.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -0,0 +1,17 @@
+package org.jboss.seam.remoting.examples.helloworld;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+@Qualifier
+public @interface Casual
+{
+
+}
Added:
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/CasualHelloAction.java
===================================================================
---
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/CasualHelloAction.java
(rev 0)
+++
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/CasualHelloAction.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -0,0 +1,13 @@
+package org.jboss.seam.remoting.examples.helloworld;
+
+import org.jboss.seam.remoting.annotations.WebRemote;
+
+@Casual
+public class CasualHelloAction extends HelloAction
+{
+ @WebRemote
+ public String sayHello(String name)
+ {
+ return "Hi, " + name;
+ }
+}
Added:
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/CasualRussianHelloAction.java
===================================================================
---
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/CasualRussianHelloAction.java
(rev 0)
+++
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/CasualRussianHelloAction.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -0,0 +1,15 @@
+package org.jboss.seam.remoting.examples.helloworld;
+
+import static org.jboss.seam.remoting.examples.helloworld.Localized.Language.RUSSIAN;
+
+import org.jboss.seam.remoting.annotations.WebRemote;
+
+@Casual @Localized(RUSSIAN)
+public class CasualRussianHelloAction extends HelloAction
+{
+ @WebRemote
+ public String sayHello(String name)
+ {
+ return "Privyet, " + name;
+ }
+}
Added:
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/Localized.java
===================================================================
---
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/Localized.java
(rev 0)
+++
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/Localized.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -0,0 +1,19 @@
+package org.jboss.seam.remoting.examples.helloworld;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+@Qualifier
+public @interface Localized
+{
+ public static enum Language { ENGLISH, RUSSIAN }
+
+ Language value() default Language.ENGLISH;
+}
Modified: modules/trunk/remoting/examples/helloworld/src/main/webapp/helloworld.xhtml
===================================================================
--- modules/trunk/remoting/examples/helloworld/src/main/webapp/helloworld.xhtml 2009-12-02
08:25:30 UTC (rev 11712)
+++ modules/trunk/remoting/examples/helloworld/src/main/webapp/helloworld.xhtml 2009-12-02
09:36:04 UTC (rev 11713)
@@ -13,9 +13,11 @@
<h1>Seam Remoting - Hello World Example</h1>
- <p>
-
- </p>
+ <div style="border:1px solid
black;margin:8px;padding:8px;width:360px">
+ <span style="font-weight:bold">Select bean
qualifiers</span><br/>
+ <input id="qualifier_casual"
type="checkbox">Casual</input><br/>
+ <input id="qualifier_russian" type="checkbox">Localized
(Russian)</input><br/>
+ </div>
<script type="text/javascript"
src="seam/resource/remoting/resource/remote.js"></script>
<script type="text/javascript"
src="seam/resource/remoting/interface.js?org.jboss.seam.remoting.examples.helloworld.HelloAction"></script>
@@ -25,11 +27,22 @@
var name = prompt("What is your name?");
if (name == null) return;
var callback = function(result) { alert(result); };
-
Seam.Component.create("org.jboss.seam.remoting.examples.helloworld.HelloAction",
"(a)Casual").sayHello(name, callback);
+
+ var qualifiers = "";
+ if (document.getElementById("qualifier_casual").checked)
+ qualifiers += "@Casual";
+
+ if (document.getElementById("qualifier_russian").checked)
+ {
+ if (qualifiers.length > 0) qualifiers += ",";
+ qualifiers += "@Localized(RUSSIAN)";
+ }
+
+
Seam.Component.create("org.jboss.seam.remoting.examples.helloworld.HelloAction",
qualifiers).sayHello(name, callback);
}
</script>
- <button onclick="javascript:sayHello()">Say Hello</button>
+ <button onclick="javascript:sayHello()">Invoke</button>
</body>
</html>
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationsParser.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationsParser.java 2009-12-02
08:25:30 UTC (rev 11712)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationsParser.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -290,7 +290,8 @@
value = convertLiteral((Literal) memberValue.f0.choice);
break;
case 3: // ClassOrInterfaceType
- value = convertClassOrInterfaceType((ClassOrInterfaceType)
memberValue.f0.choice);
+ value = convertClassOrInterfaceType(
+ (ClassOrInterfaceType) memberValue.f0.choice, memberType);
break;
}
@@ -318,7 +319,7 @@
return null;
}
- private Class<?> convertClassOrInterfaceType(ClassOrInterfaceType node)
+ private Object convertClassOrInterfaceType(ClassOrInterfaceType node, Class<?>
memberType)
{
StringBuilder sb = new StringBuilder();
sb.append(node.f0.tokenImage);
@@ -342,25 +343,38 @@
String className = sb.toString();
- try
+ if (memberType.isEnum())
{
- return Class.forName(className);
+ for (Object e : memberType.getEnumConstants())
+ {
+ if (className.equals(((Enum<?>) e).name())) return e;
+ }
+
+ throw new IllegalArgumentException(
+ "Invalid enum specified for annotation member value: " +
className);
}
- catch (ClassNotFoundException e)
+ else
{
- if (!className.startsWith("java.lang."))
+ try
{
- // try finding the class in the java.lang package
- try
+ return Class.forName(className);
+ }
+ catch (ClassNotFoundException e)
+ {
+ if (!className.startsWith("java.lang."))
{
- return Class.forName("java.lang." + className);
+ // try finding the class in the java.lang package
+ try
+ {
+ return Class.forName("java.lang." + className);
+ }
+ catch (ClassNotFoundException e1) { }
}
- catch (ClassNotFoundException e1) { }
+
+ throw new IllegalArgumentException(
+ "Invalid class name specified for annotation member value: "
+ className);
}
-
- throw new IllegalArgumentException(
- "Invalid class name specified for annotation member value: " +
className);
- }
+ }
}
private String extractName(Name name)
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/AnnotationParser.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/AnnotationParser.java 2009-12-02
08:25:30 UTC (rev 11712)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/AnnotationParser.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -467,10 +467,12 @@
Token n5;
NodeToken n6;
Token n7;
- NodeToken n8;
- Token n9;
+ NodeOptional n8 = new NodeOptional();
+ NodeSequence n9;
NodeToken n10;
Token n11;
+ NodeToken n12;
+ Token n13;
n1 = jj_consume_token(IDENTIFIER);
n0 = JTBToolkit.makeNodeToken(n1);
label_4:
@@ -490,11 +492,21 @@
n2.addNode(n3);
}
n2.nodes.trimToSize();
- n9 = jj_consume_token(DOT);
- n8 = JTBToolkit.makeNodeToken(n9);
- n11 = jj_consume_token(CLASS);
- n10 = JTBToolkit.makeNodeToken(n11);
- {if (true) return new ClassOrInterfaceType(n0,n2,n8,n10);}
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case DOT:
+ n9 = new NodeSequence(2);
+ n11 = jj_consume_token(DOT);
+ n10 = JTBToolkit.makeNodeToken(n11);
+ n9.addNode(n10);
+ n13 = jj_consume_token(CLASS);
+ n12 = JTBToolkit.makeNodeToken(n13);
+ n9.addNode(n12);
+ n8.addNode(n9);
+ break;
+ default:
+ ;
+ }
+ {if (true) return new ClassOrInterfaceType(n0,n2,n8);}
throw new Error("Missing return statement in function");
}
@@ -670,27 +682,38 @@
return false;
}
- private boolean jj_3R_23() {
- if (jj_scan_token(CHARACTER_LITERAL)) return true;
- return false;
- }
-
private boolean jj_3_3() {
if (jj_scan_token(DOT)) return true;
if (jj_scan_token(IDENTIFIER)) return true;
return false;
}
+ private boolean jj_3R_23() {
+ if (jj_scan_token(CHARACTER_LITERAL)) return true;
+ return false;
+ }
+
private boolean jj_3R_22() {
if (jj_scan_token(FLOATING_POINT_LITERAL)) return true;
return false;
}
+ private boolean jj_3_4() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_8()) return true;
+ return false;
+ }
+
private boolean jj_3R_31() {
if (jj_scan_token(NULL)) return true;
return false;
}
+ private boolean jj_3R_17() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
private boolean jj_3R_27() {
if (jj_scan_token(AT)) return true;
return false;
@@ -707,8 +730,8 @@
return false;
}
- private boolean jj_3R_17() {
- if (jj_scan_token(IDENTIFIER)) return true;
+ private boolean jj_3R_15() {
+ if (jj_scan_token(LBRACE)) return true;
return false;
}
@@ -739,22 +762,11 @@
return false;
}
- private boolean jj_3_4() {
- if (jj_scan_token(COMMA)) return true;
- if (jj_3R_8()) return true;
- return false;
- }
-
private boolean jj_3R_33() {
if (jj_scan_token(FALSE)) return true;
return false;
}
- private boolean jj_3R_15() {
- if (jj_scan_token(LBRACE)) return true;
- return false;
- }
-
private boolean jj_3_2() {
if (jj_scan_token(AT)) return true;
if (jj_3R_6()) return true;
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/syntaxtree/ClassOrInterfaceType.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/syntaxtree/ClassOrInterfaceType.java 2009-12-02
08:25:30 UTC (rev 11712)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/syntaxtree/ClassOrInterfaceType.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -8,29 +8,19 @@
* Grammar production:
* f0 -> <IDENTIFIER>
* f1 -> ( "." <IDENTIFIER> )*
- * f2 -> "."
- * f3 -> "class"
+ * f2 -> [ "." "class" ]
*/
public class ClassOrInterfaceType implements Node {
public NodeToken f0;
public NodeListOptional f1;
- public NodeToken f2;
- public NodeToken f3;
+ public NodeOptional f2;
- public ClassOrInterfaceType(NodeToken n0, NodeListOptional n1, NodeToken n2, NodeToken
n3) {
+ public ClassOrInterfaceType(NodeToken n0, NodeListOptional n1, NodeOptional n2) {
f0 = n0;
f1 = n1;
f2 = n2;
- f3 = n3;
}
- public ClassOrInterfaceType(NodeToken n0, NodeListOptional n1) {
- f0 = n0;
- f1 = n1;
- f2 = new NodeToken(".");
- f3 = new NodeToken("class");
- }
-
public void accept(org.jboss.seam.remoting.annotationparser.visitor.Visitor v) {
v.visit(this);
}
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/DepthFirstVisitor.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/DepthFirstVisitor.java 2009-12-02
08:25:30 UTC (rev 11712)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/DepthFirstVisitor.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -179,14 +179,12 @@
/**
* f0 -> <IDENTIFIER>
* f1 -> ( "." <IDENTIFIER> )*
- * f2 -> "."
- * f3 -> "class"
+ * f2 -> [ "." "class" ]
*/
public void visit(ClassOrInterfaceType n) {
n.f0.accept(this);
n.f1.accept(this);
n.f2.accept(this);
- n.f3.accept(this);
}
/**
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJDepthFirst.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJDepthFirst.java 2009-12-02
08:25:30 UTC (rev 11712)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJDepthFirst.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -225,15 +225,13 @@
/**
* f0 -> <IDENTIFIER>
* f1 -> ( "." <IDENTIFIER> )*
- * f2 -> "."
- * f3 -> "class"
+ * f2 -> [ "." "class" ]
*/
public R visit(ClassOrInterfaceType n, A argu) {
R _ret=null;
n.f0.accept(this, argu);
n.f1.accept(this, argu);
n.f2.accept(this, argu);
- n.f3.accept(this, argu);
return _ret;
}
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJNoArguDepthFirst.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJNoArguDepthFirst.java 2009-12-02
08:25:30 UTC (rev 11712)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJNoArguDepthFirst.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -225,15 +225,13 @@
/**
* f0 -> <IDENTIFIER>
* f1 -> ( "." <IDENTIFIER> )*
- * f2 -> "."
- * f3 -> "class"
+ * f2 -> [ "." "class" ]
*/
public R visit(ClassOrInterfaceType n) {
R _ret=null;
n.f0.accept(this);
n.f1.accept(this);
n.f2.accept(this);
- n.f3.accept(this);
return _ret;
}
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJNoArguVisitor.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJNoArguVisitor.java 2009-12-02
08:25:30 UTC (rev 11712)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJNoArguVisitor.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -125,8 +125,7 @@
/**
* f0 -> <IDENTIFIER>
* f1 -> ( "." <IDENTIFIER> )*
- * f2 -> "."
- * f3 -> "class"
+ * f2 -> [ "." "class" ]
*/
public R visit(ClassOrInterfaceType n);
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJVisitor.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJVisitor.java 2009-12-02
08:25:30 UTC (rev 11712)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJVisitor.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -125,8 +125,7 @@
/**
* f0 -> <IDENTIFIER>
* f1 -> ( "." <IDENTIFIER> )*
- * f2 -> "."
- * f3 -> "class"
+ * f2 -> [ "." "class" ]
*/
public R visit(ClassOrInterfaceType n, A argu);
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJVoidDepthFirst.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJVoidDepthFirst.java 2009-12-02
08:25:30 UTC (rev 11712)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJVoidDepthFirst.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -189,14 +189,12 @@
/**
* f0 -> <IDENTIFIER>
* f1 -> ( "." <IDENTIFIER> )*
- * f2 -> "."
- * f3 -> "class"
+ * f2 -> [ "." "class" ]
*/
public void visit(ClassOrInterfaceType n, A argu) {
n.f0.accept(this, argu);
n.f1.accept(this, argu);
n.f2.accept(this, argu);
- n.f3.accept(this, argu);
}
/**
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJVoidVisitor.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJVoidVisitor.java 2009-12-02
08:25:30 UTC (rev 11712)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/GJVoidVisitor.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -125,8 +125,7 @@
/**
* f0 -> <IDENTIFIER>
* f1 -> ( "." <IDENTIFIER> )*
- * f2 -> "."
- * f3 -> "class"
+ * f2 -> [ "." "class" ]
*/
public void visit(ClassOrInterfaceType n, A argu);
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/Visitor.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/Visitor.java 2009-12-02
08:25:30 UTC (rev 11712)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/annotationparser/visitor/Visitor.java 2009-12-02
09:36:04 UTC (rev 11713)
@@ -125,8 +125,7 @@
/**
* f0 -> <IDENTIFIER>
* f1 -> ( "." <IDENTIFIER> )*
- * f2 -> "."
- * f3 -> "class"
+ * f2 -> [ "." "class" ]
*/
public void visit(ClassOrInterfaceType n);
Modified: modules/trunk/remoting/src/main/javacc/AnnotationParser.jj
===================================================================
--- modules/trunk/remoting/src/main/javacc/AnnotationParser.jj 2009-12-02 08:25:30 UTC
(rev 11712)
+++ modules/trunk/remoting/src/main/javacc/AnnotationParser.jj 2009-12-02 09:36:04 UTC
(rev 11713)
@@ -446,7 +446,7 @@
void ClassOrInterfaceType():
{}
{
- <IDENTIFIER> ( LOOKAHEAD(2) "." <IDENTIFIER> )* "."
"class"
+ <IDENTIFIER> ( LOOKAHEAD(2) "." <IDENTIFIER> )* ["."
"class"]
}
void MemberValueArrayInitializer():