Author: shane.bryzak(a)jboss.com
Date: 2009-12-01 02:00:40 -0500 (Tue, 01 Dec 2009)
New Revision: 11707
Removed:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationLiteralHandler.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/ReflectiveAnnotationLiteral.java
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationsParser.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/Call.java
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java
modules/trunk/remoting/src/main/resources/org/jboss/seam/remoting/remote.js
Log:
some cleanup
Deleted:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationLiteralHandler.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationLiteralHandler.java 2009-12-01
00:42:53 UTC (rev 11706)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationLiteralHandler.java 2009-12-01
07:00:40 UTC (rev 11707)
@@ -1,31 +0,0 @@
-package org.jboss.seam.remoting;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.Map;
-
-/**
- *
- * @author Shane Bryzak
- */
-public class AnnotationLiteralHandler implements InvocationHandler
-{
- private Class<? extends Annotation> annotationClass;
- private Map<String,Object> memberValues;
-
- public AnnotationLiteralHandler(Class<? extends Annotation> annotationClass,
- Map<String,Object> memberValues)
- {
- this.annotationClass = annotationClass;
- this.memberValues = memberValues;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable
- {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
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-01
00:42:53 UTC (rev 11706)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationsParser.java 2009-12-01
07:00:40 UTC (rev 11707)
@@ -2,12 +2,16 @@
import java.io.StringReader;
import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
import org.jboss.seam.remoting.annotationparser.AnnotationParser;
import org.jboss.seam.remoting.annotationparser.ParseException;
+import org.jboss.seam.remoting.annotationparser.syntaxtree.AnnotationsUnit;
import org.jboss.seam.remoting.annotationparser.syntaxtree.MarkerAnnotation;
+import org.jboss.seam.remoting.annotationparser.syntaxtree.MemberValuePair;
import org.jboss.seam.remoting.annotationparser.syntaxtree.Name;
import org.jboss.seam.remoting.annotationparser.syntaxtree.Node;
import org.jboss.seam.remoting.annotationparser.syntaxtree.NodeListOptional;
@@ -55,6 +59,7 @@
private Annotation[] annotations;
+ @SuppressWarnings("unchecked")
public AnnotationsParser(Class<?> beanType, String declaration)
{
// TODO cache the results somewhere
@@ -71,6 +76,21 @@
throw new IllegalArgumentException(
"Error while parsing annotation declaration: " + declaration);
}
+
+ annotations = new Annotation[meta.size()];
+
+ for (int i = 0; i < meta.size(); i++)
+ {
+ AnnotationMetadata ann = meta.get(i);
+ Class<?> annotationType = calcAnnotationType(ann.getName(), beanType);
+ InvocationHandler handler = new AnnotationInvocationHandler(
+ (Class<? extends Annotation>) annotationType, null);
+ annotations[i] = (Annotation) Proxy.newProxyInstance(
+ annotationType.getClassLoader(),
+ new Class[] {annotationType}, handler);
+ }
+
+ meta = null;
}
public Annotation[] getAnnotations()
@@ -78,7 +98,35 @@
return annotations;
}
+ @SuppressWarnings("unchecked")
+ private Class<? extends Annotation> calcAnnotationType(String name,
Class<?> beanType)
+ {
+ try
+ {
+ return (Class<? extends Annotation>) Class.forName(name);
+ }
+ catch (ClassNotFoundException e)
+ {
+ // Iterate through the annotations on the bean type and look for a simple name
match
+ for (Annotation beanAnnotation : beanType.getAnnotations())
+ {
+ if (name.equals(beanAnnotation.annotationType().getSimpleName()))
+ {
+ return beanAnnotation.annotationType();
+ }
+ }
+
+ return null;
+ }
+ }
+
@Override
+ public void visit(AnnotationsUnit node)
+ {
+ super.visit(node);
+ }
+
+ @Override
public void visit(org.jboss.seam.remoting.annotationparser.syntaxtree.Annotation
node)
{
Node choice = node.f0.choice;
@@ -101,13 +149,19 @@
type = AnnotationType.SINGLE_MEMBER;
name = ((SingleMemberAnnotation) choice).f1;
}
+
+ currentAnnotation = new AnnotationMetadata(type, extractName(name));
+ meta.add(currentAnnotation);
- super.visit(node);
-
- currentAnnotation = new AnnotationMetadata(type, extractName(name));
- meta.add(currentAnnotation);
+ super.visit(node);
}
+ @Override
+ public void visit(MemberValuePair node)
+ {
+
+ }
+
private String extractName(Name name)
{
StringBuilder sb = new StringBuilder();
Modified: modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/Call.java
===================================================================
--- modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/Call.java 2009-12-01
00:42:53 UTC (rev 11706)
+++ modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/Call.java 2009-12-01
07:00:40 UTC (rev 11707)
@@ -45,7 +45,7 @@
private Bean<?> targetBean = null;
public Call(BeanManager beanManager, String id, String beanName,
- String qualifierVal, String methodName)
+ String qualifiers, String methodName)
{
this.beanManager = beanManager;
this.id = id;
@@ -60,10 +60,10 @@
{
Class<?> beanType = Class.forName(beanName);
- Annotation[] qualifiers = qualifierVal != null &&
!qualifierVal.isEmpty() ?
- new AnnotationsParser(beanType, qualifierVal).getAnnotations() : null;
+ Annotation[] q = qualifiers != null && !qualifiers.isEmpty() ?
+ new AnnotationsParser(beanType, qualifiers).getAnnotations() : null;
- beans = beanManager.getBeans(beanType, qualifiers);
+ beans = beanManager.getBeans(beanType, q);
}
catch (ClassNotFoundException ex)
{
Modified:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java 2009-12-01
00:42:53 UTC (rev 11706)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/ExecutionHandler.java 2009-12-01
07:00:40 UTC (rev 11707)
@@ -145,10 +145,14 @@
for (Element e : callElements)
{
+ Element targetNode = e.element("target");
+ Element qualifiersNode = e.element("qualifiers");
+ Element methodNode = e.element("method");
+
Call call = new Call(beanManager, e.attributeValue("id"),
- e.attributeValue("component"),
- e.attributeValue("qualifiers"),
- e.attributeValue("method"));
+ targetNode.getText(),
+ qualifiersNode != null ? qualifiersNode.getText() : null,
+ methodNode.getText());
// First reconstruct all the references
Element refsNode = e.element("refs");
Deleted:
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/ReflectiveAnnotationLiteral.java
===================================================================
---
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/ReflectiveAnnotationLiteral.java 2009-12-01
00:42:53 UTC (rev 11706)
+++
modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/ReflectiveAnnotationLiteral.java 2009-12-01
07:00:40 UTC (rev 11707)
@@ -1,28 +0,0 @@
-package org.jboss.seam.remoting;
-
-import java.io.StringReader;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Proxy;
-import java.util.Map;
-
-import org.jboss.seam.remoting.annotationparser.AnnotationParser;
-
-public class ReflectiveAnnotationLiteral
-{
- private Class<? extends Annotation> annotationType;
- private Map<String,Object> memberValues;
-
- public ReflectiveAnnotationLiteral(String declaration)
- {
- AnnotationParser parser = new AnnotationParser(new StringReader(declaration));
-
- //this.annotationType = (Class<? extends Annotation>)
Class.forName(annotationType));
- }
-
- public <T extends Annotation> T getAnnotation()
- {
- return (T) Proxy.newProxyInstance(annotationType.getClassLoader(),
- new Class[] { annotationType },
- new AnnotationLiteralHandler(annotationType, memberValues));
- }
-}
Modified: modules/trunk/remoting/src/main/resources/org/jboss/seam/remoting/remote.js
===================================================================
--- modules/trunk/remoting/src/main/resources/org/jboss/seam/remoting/remote.js 2009-12-01
00:42:53 UTC (rev 11706)
+++ modules/trunk/remoting/src/main/resources/org/jboss/seam/remoting/remote.js 2009-12-01
07:00:40 UTC (rev 11707)
@@ -482,25 +482,23 @@
if (!callback)
callback = component.__callback[methodName];
- var data = "<call component=\"";
- data += Seam.Component.getComponentType(component).__name;
+ var data = "<call id=\"" + callId + "\">\n";
+ data += "<target>" + Seam.Component.getComponentType(component).__name
+ "</target>";
if (component.__qualifiers != null)
{
- data += "\" qualifiers=\"";
+ data += "<qualifiers>";
for (var i = 0; i < component.__qualifiers.length; i++)
{
data += component.__qualifiers[i];
if (i < component.__qualifiers.length - 1) data += ",";
}
+
+ data += "</qualifiers>";
}
- data += "\" method=\"";
- data += methodName;
- data += "\" id=\"";
- data += callId;
- data += "\">\n";
+ data += "<method>" + methodName + "</method>";
// Add parameters
data += "<params>";