Author: mmerz
Date: Tue Jan 25 09:24:41 2005
New Revision: 126394

URL: http://svn.apache.org/viewcvs?view=rev&rev=126394
Log:
Major cleanup on the object model's interfaces:
- using IoC to parse information from source files -> clear structure, generic 
annotation processor and object model
- added Java*Info interfaces: that describe how to extract information from 
Java files (source or class)
- added Mirror*Info classes: encapsulate knowledge on how to extract 
information from source files using the mirror API
- removed: AnnotationMetadata, Jsr181Modifiers (functionality moved into new 
*Info classes, where it should reside)
- removed: AnnotationModel


Added:
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/java/
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/java/JavaMethodInfo.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/java/JavaParameterInfo.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/java/JavaTypeInfo.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/MirrorMethodInfo.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/MirrorParameterInfo.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/MirrorTypeInfo.java
Removed:
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/AnnotationMetadata.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/AnnotationModel.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181Modifiers.java
Modified:
   
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar2TestCase.java
   
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar3TestCase.java
   
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java
   
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadata.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadataImpl.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadata.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar2TestCase.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar2TestCase.java?view=diff&rev=126394&p1=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar2TestCase.java&r1=126393&p2=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar2TestCase.java&r2=126394
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar2TestCase.java
 (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar2TestCase.java
 Tue Jan 25 09:24:41 2005
@@ -34,7 +34,7 @@
     protected static final String CLASSNAME = "web.Bar2";
     protected static final String SRCFILENAME = "web/Bar2.jws";
 
-    protected AnnotationMetadata objectModel;
+    protected Jsr181TypeMetadata objectModel;
 
     protected Jsr181MethodMetadata getMethod(String methodName) {
         if ((null == methodName) || (null == objectModel)) {

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar3TestCase.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar3TestCase.java?view=diff&rev=126394&p1=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar3TestCase.java&r1=126393&p2=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar3TestCase.java&r2=126394
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar3TestCase.java
 (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/Bar3TestCase.java
 Tue Jan 25 09:24:41 2005
@@ -34,7 +34,7 @@
     protected static final String CLASSNAME = "web.Bar3";
     protected static final String SRCFILENAME = "web/Bar3.jws";
 
-    protected AnnotationMetadata objectModel;
+    protected Jsr181TypeMetadata objectModel;
 
     protected Jsr181MethodMetadata getMethod(String methodName) {
         if ((null == methodName) || (null == objectModel)) {

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java?view=diff&rev=126394&p1=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java&r1=126393&p2=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java&r2=126394
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java
  (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java
  Tue Jan 25 09:24:41 2005
@@ -34,7 +34,7 @@
     protected static final String CLASSNAME = "web.Bar";
     protected static final String[] SRCFILENAMES = {"web/Bar.jws"};
 
-    protected AnnotationMetadata objectModel;
+    protected Jsr181TypeMetadata objectModel;
 
     public void testObjectModel() throws Exception {
         assertNotNull("Failed to retrieve object model;", objectModel);

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java?view=diff&rev=126394&p1=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java&r1=126393&p2=incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java&r2=126394
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java
  (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/FooTestCase.java
  Tue Jan 25 09:24:41 2005
@@ -31,7 +31,7 @@
     protected static final String CLASSNAME = "web.Foo";
     protected static final String SRCFILENAME = "web/Foo.jws";
 
-    protected AnnotationMetadata objectModel;
+    protected Jsr181TypeMetadata objectModel;
 
     public void testObjectModel() throws Exception {
         assertNotNull("Failed to retrieve object model;", objectModel);

Deleted: 
/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/AnnotationMetadata.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/AnnotationMetadata.java?view=auto&rev=126393
==============================================================================

Deleted: 
/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/AnnotationModel.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/AnnotationModel.java?view=auto&rev=126393
==============================================================================

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java?view=diff&rev=126394&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java&r1=126393&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java&r2=126394
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java
       (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadata.java
       Tue Jan 25 09:24:41 2005
@@ -25,7 +25,7 @@
 /**
  * @author Daryoush
  */
-public interface Jsr181MethodMetadata extends AnnotationMetadata {
+public interface Jsr181MethodMetadata {
     
     boolean isOneWay();
     void setOneWay(boolean oneway);

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java?view=diff&rev=126394&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java&r1=126393&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java&r2=126394
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java
   (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181MethodMetadataImpl.java
   Tue Jan 25 09:24:41 2005
@@ -29,7 +29,11 @@
 import javax.jws.WebParam;
 import javax.jws.WebResult;
 import javax.jws.security.SecurityRoles;
-import javax.xml.namespace.QName;
+
+import javax.xml.namespace.QName; // todo ([EMAIL PROTECTED], 01/25/05): this 
needs to go...
+
+import org.apache.beehive.wsm.jsr181.model.java.JavaMethodInfo;
+import org.apache.beehive.wsm.jsr181.model.java.JavaParameterInfo;
 
 public class Jsr181MethodMetadataImpl implements Jsr181MethodMetadata, 
java.io.Serializable {
 
@@ -52,82 +56,78 @@
     public void validate() throws ValidationException {
         return; // no validation required
     }
-
     
-    public Jsr181MethodMetadataImpl(String operationName,
-            Class javaType,
-            QName xmlReturnType) {
+    public Jsr181MethodMetadataImpl(
+        String operationName,
+        Class javaType,
+        QName xmlReturnType)
+    {
        this(operationName, javaType);
        setXmlReturnType(xmlReturnType);
     }
 
-
     public Jsr181MethodMetadataImpl(String methodName, Class returnType) {
         super();
         javaMethodName = methodName;
         javaReturnType = returnType;
     }
 
-    public Jsr181MethodMetadataImpl(
-        String javaMethodName,
-        Class javaReturnType,
-        Jsr181Modifiers modifiers,
-        boolean throwsExceptions,
-        Collection<Annotation> annotations,
-        List<? extends Jsr181ParameterMetadata> webParams
-    )
-        throws Exception
-    {
+    public Jsr181MethodMetadataImpl(JavaMethodInfo jm) throws Exception {
+
         super();
 
-        // check parameters
-        if ((null == javaMethodName) || (null == javaReturnType)) {
-            throw new IllegalArgumentException("javaMethodName or 
javaReturnType not set");
+        // check input param
+        if (null == jm) {
+            throw new IllegalArgumentException("illegal java method info: 
<null>");
+        }
+        
+        javaMethodName = jm.getMethodName();
+        javaReturnType = jm.getReturnType();
+
+        // get webMethod's webParams
+        List<Jsr181ParameterMetadata> webParams =
+            new ArrayList<Jsr181ParameterMetadata>();
+        for (JavaParameterInfo param : jm.getParameters()) {
+            Jsr181ParameterMetadata wspm = new 
Jsr181ParameterMetadataImpl(param);
+            if (null == wspm) {
+                throw new ValidationException("cannot create web param: " + 
param.getName());
+            }
+            webParams.add(wspm);
         }
-        this.javaMethodName = javaMethodName;
-        this.javaReturnType = javaReturnType;
 
-        // initialize @WebResult.name
+        // set defaults
         setWrName(DEFAULT_WRNAME);
         
         // enforce JSR-181 rules
-        if (! modifiers.isPublic()) {
+        if (! jm.isPublic()) {
             throw new ValidationException("@WebMethod must be public: " + 
javaMethodName);
         }
-        if (AnnotationModel.hasAnnotationType(annotations, Oneway.class)) {
+        if (null != jm.getAnnotation(Oneway.class)) {
             // prohibit @Oneway with @WebResult
-            if (AnnotationModel.hasAnnotationType(annotations, 
WebResult.class)) {
-                // todo needs to be proper Exception subclass
-                throw new Exception("@Oneway method " + javaMethodName +
-                        " has incompatible annotation: @WebResult");
+            if (null != jm.getAnnotation(WebResult.class)) {
+                throw new ValidationException("@Oneway method " + 
javaMethodName + " has incompatible annotation: @WebResult");
             }
             // prohibit @Oneway with return types other than <code>void</code>
             if (void.class != javaReturnType) {
-                // todo needs to be proper Exception subclass
-                throw new Exception("@Oneway method " + javaMethodName +
-                        " has illegal non-void return type: " + 
javaReturnType);
+                throw new ValidationException("@Oneway method " + 
javaMethodName + " has illegal non-void return type: " + javaReturnType);
             }
             // prohibit @Oneway methods that throw Exceptions
-            if (throwsExceptions) {
-                // todo needs to be proper Exception subclass
-                throw new Exception("@Oneway method " + javaMethodName +
-                        " must not throw exceptions");
+            if (jm.throwsExceptions()) {
+                throw new ValidationException("@Oneway method " + 
javaMethodName + " must not throw exceptions");
             }
-            // prohibit @Oneway with "OUT" and "INOUT" parameters
+            // todo??? prohibit @Oneway with "OUT" and "INOUT" parameters
+                    
             if (null != webParams) {
                 for (Jsr181ParameterMetadata param : webParams) {
-                    if ((WebParam.Mode.OUT == param.getWpMode()) ||
-                            (WebParam.Mode.INOUT == param.getWpMode())) {
-                        // todo needs to be proper Exception subclass
-                        throw new Exception("@Oneway method " + javaMethodName 
+
-                                " has illegal INOUT or OUT parameter: " +
-                                param.getWpName());
+                    if ((WebParam.Mode.OUT == param.getWpMode()) || 
(WebParam.Mode.INOUT == param.getWpMode())) {
+                        throw new ValidationException("@Oneway method " + 
javaMethodName + " has illegal INOUT or OUT parameter: " + param.getWpName());
                     }
                 }
             }
         }
         
         // set optional annotations
+        Collection<Annotation> annotations = jm.getAnnotations();
         if (null != annotations) {
             for (Annotation a : annotations) {
                 if (a.annotationType() == javax.jws.WebMethod.class) {
@@ -148,7 +148,7 @@
             }
         }
 
-        // set defaults for @WebMethod -- always, even when @WebMethod not 
present
+        // set default values
         if ((null == getWmOperationName()) || (0 == 
getWmOperationName().length())) {
             setWmOperationName(javaMethodName);
         }
@@ -274,8 +274,6 @@
         sb.append(')');
         return sb.toString();
     }
-
-
     
     public String toString() {
         String signature = getJavaReturnType().toString() + " " + 
getJavaMethodName() + "( ";
@@ -326,7 +324,6 @@
     public String getJavaReturnTypeFullName() {
         return getClassName(getJavaReturnType());
     }
-    
 
     private String getClassName(Class cls) {
             if (cls.isArray()) {
@@ -344,5 +341,4 @@
     public void setXmlReturnType(QName xmlReturnType) {
        mXMLReturnType = xmlReturnType;
     }
-       
 }

Deleted: 
/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181Modifiers.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181Modifiers.java?view=auto&rev=126393
==============================================================================

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadata.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadata.java?view=diff&rev=126394&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadata.java&r1=126393&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadata.java&r2=126394
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadata.java
    (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadata.java
    Tue Jan 25 09:24:41 2005
@@ -24,7 +24,7 @@
 /**
  * @author Daryoush
  */
-public interface Jsr181ParameterMetadata extends AnnotationMetadata {
+public interface Jsr181ParameterMetadata {
     
     boolean isWpHeader();
     void setWpHeader(boolean wpHeader);

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadataImpl.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadataImpl.java?view=diff&rev=126394&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadataImpl.java&r1=126393&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadataImpl.java&r2=126394
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadataImpl.java
        (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181ParameterMetadataImpl.java
        Tue Jan 25 09:24:41 2005
@@ -22,9 +22,12 @@
 import java.util.Collection;
 
 import javax.jws.WebParam;
-import javax.xml.namespace.QName;
 
-public class Jsr181ParameterMetadataImpl  implements Jsr181ParameterMetadata, 
java.io.Serializable {
+import javax.xml.namespace.QName; // todo ([EMAIL PROTECTED], 01/25/05): this 
needs to go...
+
+import org.apache.beehive.wsm.jsr181.model.java.JavaParameterInfo;
+
+public class Jsr181ParameterMetadataImpl implements Jsr181ParameterMetadata, 
java.io.Serializable {
     
     private static final long serialVersionUID = 1L;
 
@@ -41,28 +44,31 @@
     }
 
     public Jsr181ParameterMetadataImpl() {
-        super();
     }
 
     // defaultName is argument name in the source file. It can be null if the
     // name is not known.
-    public Jsr181ParameterMetadataImpl(Class javaType,
-                                       String defaultName,
-                                       Collection<Annotation> annotations) {
-        // check parameters
-        if (null == javaType) {
-            throw new IllegalArgumentException("javaType not set");
+    public Jsr181ParameterMetadataImpl(JavaParameterInfo jp) {
+
+        // check input params
+        if (null == jp) {
+            throw new IllegalArgumentException("illegal parameter info: 
<null>");
         }
-        this.javaType = javaType;
-        setWpMode(WebParam.Mode.IN);  // by default if there were no anotations
-        setWpName(defaultName);       // in case there are no annotations
+        
+        javaType = jp.getType();
+        
+        // set default values
+        setWpName(jp.getName());
+        setWpMode(WebParam.Mode.IN);
         
         // set optional annotations
+        Collection<Annotation> annotations = jp.getAnnotations();
         if (null != annotations) {
             for (Annotation a : annotations) {
-                if (a.annotationType() == javax.jws.WebParam.class) {
-                    initFromAnnotation((javax.jws.WebParam) a);
-                } else {
+                if (a.annotationType() == WebParam.class) {
+                    initFromAnnotation((WebParam) a);
+                }
+                else {
                     // todo: warning -- unknown annotation
                 }
             }

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadata.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadata.java?view=diff&rev=126394&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadata.java&r1=126393&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadata.java&r2=126394
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadata.java
 (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadata.java
 Tue Jan 25 09:24:41 2005
@@ -38,7 +38,7 @@
 /**
  * @author Daryoush
  */
-public interface Jsr181TypeMetadata extends AnnotationMetadata {
+public interface Jsr181TypeMetadata {
 
     void initHandlersFromChainConfig(URL chainConfigURL, String chainName)
         throws Exception;

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java?view=diff&rev=126394&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java&r1=126393&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java&r2=126394
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java
     (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/Jsr181TypeMetadataImpl.java
     Tue Jan 25 09:24:41 2005
@@ -41,6 +41,7 @@
 import java.util.Set;
 
 import javax.jws.HandlerChain;
+import javax.jws.WebMethod;
 import javax.jws.WebService;
 import javax.jws.security.SecurityIdentity;
 import javax.jws.security.SecurityRoles;
@@ -58,6 +59,9 @@
 import org.w3c.dom.NodeList;
 import org.xmlsoap.schemas.wsdl.DefinitionsDocument;
 
+import org.apache.beehive.wsm.jsr181.model.java.JavaTypeInfo;
+import org.apache.beehive.wsm.jsr181.model.java.JavaMethodInfo;
+
 public class Jsr181TypeMetadataImpl implements Jsr181TypeMetadata, 
java.io.Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -87,53 +91,67 @@
     }
 
     /**
-     * @param wsAnnotation The @WebService annotation of the class.
-     * @param className The fully-qualified name of the class.
-     * @param baseLocation The location of the file being processed;
-     *   if null, relative paths (e.g. in @HandlerChain) cannot be resolved.
-     * @param annotations All annotations (including @WebService) of the class.
-     * @param webMethods All methods that are published by the service.
-     * @throws Exception
+     * @param jws
+     * @throws
      */
-    public Jsr181TypeMetadataImpl(
-        WebService wsAnnotation,
-        boolean isInterface,
-        boolean hasDefaultConstructor,
-        boolean hasFinalize,
-        String className,
-        File baseLocation,
-        Jsr181Modifiers modifiers,
-        Collection<Annotation> annotations,
-        Collection<? extends Jsr181MethodMetadata> webMethods
-    ) throws Exception
-    {
+    public Jsr181TypeMetadataImpl(JavaTypeInfo jt) throws Exception {
+
         super();
+        
+        if (null == jt) {
+            throw new IllegalArgumentException("illegal java type info: 
<null>");
+        }
 
         // check required parameter: wsAnnotation
+        WebService wsAnnotation = jt.getAnnotation(WebService.class);
         if (null == wsAnnotation) {
-            throw new IllegalArgumentException("missing annotation: 
@WebService");
+            throw new IllegalArgumentException("no @WebService annotation 
found");
         }
 
+        // get webMethods
+        Collection<Jsr181MethodMetadata> webMethods =
+            new ArrayList<Jsr181MethodMetadata>();
+        // SEI: add all methods from service endpoint interface
+        if (jt.isInterface()) {
+            for (JavaMethodInfo jm : jt.getMethods()) {
+                Jsr181MethodMetadata wsmm = new Jsr181MethodMetadataImpl(jm);
+                webMethods.add(wsmm);
+            }
+        }        
+        // SIB: add only annotated methods
+        else {
+            for (JavaMethodInfo jm : jt.getMethods()) {
+                if (null != jm.getAnnotation(WebMethod.class)) {
+                    Jsr181MethodMetadata wsmm = new 
Jsr181MethodMetadataImpl(jm);
+                    if (null == wsmm) {
+                        throw new ValidationException("illegal web method: " + 
jm.getMethodName());
+                    }
+                    webMethods.add(wsmm);
+                }
+            }
+        }
+        
         // check required parameters: annotations, webMethods
+        Collection<Annotation> annotations = jt.getAnnotations();
         if ((null == annotations) || (null == webMethods)) {
-            throw new IllegalArgumentException("annotations or webMethods are 
null");
+            throw new IllegalArgumentException("no annotations or web methods 
found");
         }
 
         // check required parameter: className
+        className = jt.getName();
         if ((null == className) || (0 == className.length())) {
             throw new IllegalArgumentException("web service class is null");
         }
-        this.className = className;
-        this.baseLocation = baseLocation;
+        baseLocation = jt.getLocation();
 
         // enforce JSR-181 rules
-        if (modifiers.isFinal() || ! modifiers.isPublic()) {
+        if (jt.isFinal() || ! jt.isPublic()) {
             throw new ValidationException("@WebService class must be public 
but not final");
         }
-        if (hasFinalize) {
+        if (jt.hasFinalize()) {
             throw new ValidationException("web service class must not declare 
method: finalize()");
         }
-        if (isInterface) {
+        if (jt.isInterface()) {
             if (null != wsAnnotation.endpointInterface() && 0 < 
wsAnnotation.endpointInterface().trim().length()) {
                 throw new ValidationException("@WebService.endpointInterface 
not allowed on interfaces");
             }
@@ -142,20 +160,18 @@
             }
         }
         else {
-            if (modifiers.isAbstract()) {
+            if (jt.isAbstract()) {
                 throw new ValidationException("service implementation bean 
must not be abstract");
             }
-            if (! hasDefaultConstructor) {
+            if (! jt.hasDefaultConstructor()) {
                 throw new ValidationException("service implementation bean 
must have default constructor");
             }
         }
-        if (AnnotationModel.hasAnnotationType(annotations, 
SOAPMessageHandlers.class) &&
-                AnnotationModel.hasAnnotationType(annotations, 
HandlerChain.class)) {
+        if (null != jt.getAnnotation(SOAPMessageHandlers.class) && null != 
jt.getAnnotation(HandlerChain.class)) {
             throw new ValidationException("Illegal combination of 
@SOAPMessageHandlers and @HandlerChain");
         }
         String wsdlLocation = wsAnnotation.wsdlLocation();
         if (null != wsdlLocation && 0 < wsdlLocation.trim().length()) {
-            URL wsdlUrl = null;
             try {
                 findResource(wsdlLocation.trim(), baseLocation).openStream();
             }
@@ -203,7 +219,7 @@
             
             // unsupported annotation
             else {
-                throw new Exception("found unsupported annotation: " + 
a.annotationType().getName());
+                throw new ValidationException("found unsupported annotation: " 
+ a.annotationType().getName());
             }
         }
         
@@ -875,7 +891,7 @@
      * @param os
      * @param objectModel
      */
-    public static void store(OutputStream os, AnnotationMetadata objectModel) 
throws IOException {
+    public static void store(OutputStream os, Jsr181TypeMetadata objectModel) 
throws IOException {
         
         ObjectOutputStream oos = null;
         try {

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/java/JavaMethodInfo.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/java/JavaMethodInfo.java?view=auto&rev=126394
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/java/JavaMethodInfo.java
        Tue Jan 25 09:24:41 2005
@@ -0,0 +1,37 @@
+package org.apache.beehive.wsm.jsr181.model.java;
+
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.List;
+
+public interface JavaMethodInfo {
+
+    boolean isPublic();
+    boolean throwsExceptions();
+
+    String getMethodName();
+    Class getReturnType();
+
+    Collection<Annotation> getAnnotations();
+    <A extends Annotation> A getAnnotation(Class<A> annotationType);
+    
+    List<JavaParameterInfo> getParameters();
+}

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/java/JavaParameterInfo.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/java/JavaParameterInfo.java?view=auto&rev=126394
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/java/JavaParameterInfo.java
     Tue Jan 25 09:24:41 2005
@@ -0,0 +1,33 @@
+package org.apache.beehive.wsm.jsr181.model.java;
+
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+
+public interface JavaParameterInfo {
+
+    boolean isFinal();
+
+    String getName();
+    Class getType();
+    
+    <A extends Annotation> A getAnnotation(Class<A> annotationType);
+    Collection<Annotation> getAnnotations();
+}

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/java/JavaTypeInfo.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/java/JavaTypeInfo.java?view=auto&rev=126394
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/java/JavaTypeInfo.java
  Tue Jan 25 09:24:41 2005
@@ -0,0 +1,41 @@
+package org.apache.beehive.wsm.jsr181.model.java;
+
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+import java.io.File;
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+
+public interface JavaTypeInfo {
+
+    boolean isAbstract();
+    boolean isFinal();
+    boolean isPublic();
+    boolean isInterface();
+    boolean hasFinalize();
+    boolean hasDefaultConstructor();
+    
+    String getName();
+    File getLocation();
+
+    <A extends Annotation> A getAnnotation(Class<A> annotationType);
+    Collection<Annotation> getAnnotations();
+    
+    Collection<JavaMethodInfo> getMethods();
+}

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/MirrorMethodInfo.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/MirrorMethodInfo.java?view=auto&rev=126394
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/MirrorMethodInfo.java
   Tue Jan 25 09:24:41 2005
@@ -0,0 +1,101 @@
+package org.apache.beehive.wsm.jsr181.processor.apt;
+
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+import java.lang.annotation.Annotation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.sun.mirror.declaration.AnnotationMirror;
+import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.declaration.Modifier;
+import com.sun.mirror.declaration.ParameterDeclaration;
+
+import com.sun.mirror.type.AnnotationType;
+
+import org.apache.beehive.wsm.jsr181.model.java.JavaMethodInfo;
+import org.apache.beehive.wsm.jsr181.model.java.JavaParameterInfo;
+
+public class MirrorMethodInfo implements JavaMethodInfo {
+    
+    protected MethodDeclaration decl;
+    protected List<JavaParameterInfo> parameters =
+        new ArrayList<JavaParameterInfo>();
+    
+    public MirrorMethodInfo(MethodDeclaration decl) {
+        if (null == decl) {
+            throw new IllegalArgumentException("method declaration: <null>");
+        }
+        this.decl = decl;
+
+        Collection<ParameterDeclaration> pdecls = decl.getParameters();
+        if (null != pdecls) {
+            for (ParameterDeclaration pdecl : pdecls) {
+                parameters.add(new MirrorParameterInfo(pdecl));
+            }
+        }
+    }
+
+    public boolean isPublic() {
+        return decl.getModifiers().contains(Modifier.PUBLIC);
+    }
+    
+    public boolean throwsExceptions() {
+        return 0 < decl.getThrownTypes().size();
+    }
+
+    public String getMethodName() {
+        return decl.getSimpleName();
+    }
+    
+    public Class getReturnType() {
+        Class clazz = null;
+        try {
+            clazz = TypeMirrorUtil.classForName(decl.getReturnType());
+        }
+        catch (Throwable t) { }
+        return clazz;
+    }
+    
+    public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
+        return decl.getAnnotation(annotationType);
+    }
+    
+    public Collection<Annotation> getAnnotations() {
+        Collection<Annotation> annotations = new ArrayList<Annotation>();
+        for (AnnotationMirror am : decl.getAnnotationMirrors()) {
+            AnnotationType at = am.getAnnotationType();
+            try {
+                Class clazz = 
Class.forName(at.getDeclaration().getQualifiedName());
+                Annotation a = decl.getAnnotation(clazz);
+                if (null != a) {
+                    annotations.add(a);
+                }
+            } catch (ClassNotFoundException e) {
+            }
+        }
+        return annotations;
+    }
+    
+    public List<JavaParameterInfo> getParameters() {
+        return parameters;
+    }
+}
\ No newline at end of file

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/MirrorParameterInfo.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/MirrorParameterInfo.java?view=auto&rev=126394
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/MirrorParameterInfo.java
        Tue Jan 25 09:24:41 2005
@@ -0,0 +1,82 @@
+package org.apache.beehive.wsm.jsr181.processor.apt;
+
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import com.sun.mirror.declaration.AnnotationMirror;
+import com.sun.mirror.declaration.Modifier;
+import com.sun.mirror.declaration.ParameterDeclaration;
+
+import com.sun.mirror.type.AnnotationType;
+
+import org.apache.beehive.wsm.jsr181.processor.apt.TypeMirrorUtil;
+
+import org.apache.beehive.wsm.jsr181.model.java.JavaParameterInfo;
+
+public class MirrorParameterInfo implements JavaParameterInfo {
+    
+    protected ParameterDeclaration decl;
+    
+    public MirrorParameterInfo(ParameterDeclaration decl) {
+        if (null == decl) {
+            throw new IllegalArgumentException("parameter declaration: 
<null>");
+        }
+        this.decl = decl;
+    }
+
+    public boolean isFinal() {
+        return decl.getModifiers().contains(Modifier.FINAL);
+    }
+
+    public String getName() {
+        return decl.getSimpleName();
+    }
+    
+    public Class getType() {
+        Class clazz = null;
+        try {
+            clazz = TypeMirrorUtil.classForName(decl.getType());
+        }
+        catch (Throwable t) { }
+        return clazz;
+    }
+    
+    public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
+        return decl.getAnnotation(annotationType);
+    }
+    
+    public Collection<Annotation> getAnnotations() {
+        Collection<Annotation> annotations = new ArrayList<Annotation>();
+        for (AnnotationMirror am : decl.getAnnotationMirrors()) {
+            AnnotationType at = am.getAnnotationType();
+            try {
+                Class clazz = 
Class.forName(at.getDeclaration().getQualifiedName());
+                Annotation a = decl.getAnnotation(clazz);
+                if (null != a) {
+                    annotations.add(a);
+                }
+            } catch (ClassNotFoundException e) {
+            }
+        }
+        return annotations;
+    }
+}
\ No newline at end of file

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/MirrorTypeInfo.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/MirrorTypeInfo.java?view=auto&rev=126394
==============================================================================
--- (empty file)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/MirrorTypeInfo.java
     Tue Jan 25 09:24:41 2005
@@ -0,0 +1,134 @@
+package org.apache.beehive.wsm.jsr181.processor.apt;
+
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+import java.io.File;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import com.sun.mirror.declaration.AnnotationMirror;
+import com.sun.mirror.declaration.ClassDeclaration;
+import com.sun.mirror.declaration.ConstructorDeclaration;
+import com.sun.mirror.declaration.InterfaceDeclaration;
+import com.sun.mirror.declaration.MethodDeclaration;
+import com.sun.mirror.declaration.Modifier;
+import com.sun.mirror.declaration.TypeDeclaration;
+
+import com.sun.mirror.type.AnnotationType;
+
+import org.apache.beehive.wsm.jsr181.model.java.JavaMethodInfo;
+import org.apache.beehive.wsm.jsr181.model.java.JavaTypeInfo;
+
+public class MirrorTypeInfo implements JavaTypeInfo {
+
+    protected TypeDeclaration decl;
+    protected Collection<JavaMethodInfo> methods =
+        new ArrayList<JavaMethodInfo>();
+    
+    public MirrorTypeInfo(TypeDeclaration decl) {
+        if (null == decl) {
+            throw new IllegalArgumentException("type declaration: <null>");
+        }
+        this.decl = decl;
+
+        Collection<? extends MethodDeclaration> mdecls = decl.getMethods();
+        if (null != mdecls) {
+            for (MethodDeclaration mdecl : mdecls) {
+                methods.add(new MirrorMethodInfo(mdecl));
+            }
+        }
+    }
+
+    public String getName() {
+        return decl.getQualifiedName();
+    }
+    
+    public File getLocation() {
+        return decl.getPosition().file().getParentFile();
+    }
+    
+    public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
+        return decl.getAnnotation(annotationType);
+    }
+    
+    public Collection<Annotation> getAnnotations() {
+        Collection<Annotation> annotations = new ArrayList<Annotation>();
+        for (AnnotationMirror am : decl.getAnnotationMirrors()) {
+            AnnotationType at = am.getAnnotationType();
+            try {
+                Class clazz = 
Class.forName(at.getDeclaration().getQualifiedName());
+                Annotation a = decl.getAnnotation(clazz);
+                if (null != a) {
+                    annotations.add(a);
+                }
+            } catch (ClassNotFoundException e) {
+            }
+        }
+        return annotations;
+    }
+    
+    public Collection<JavaMethodInfo> getMethods() {
+        return methods;
+    }
+    
+    public boolean hasDefaultConstructor() {
+        boolean result = false;
+        if (decl instanceof InterfaceDeclaration) {
+            result = false;
+        }
+        else {
+            ClassDeclaration cdecl = (ClassDeclaration) decl;
+            for (ConstructorDeclaration c : cdecl.getConstructors()) {
+                if (c.getParameters().isEmpty()) {
+                    result = true;
+                    break;
+                }
+            }
+        }
+
+        return result;
+    }
+    
+    public boolean hasFinalize() {
+        boolean result = false;
+        for (MethodDeclaration mdecl : decl.getMethods()) {
+            if (mdecl.getSimpleName().equals("finalize") && (null == 
mdecl.getParameters() || mdecl.getParameters().isEmpty())) {
+                result = true;
+            }
+        }
+        return result;
+    }
+
+    public boolean isAbstract() {
+        return decl.getModifiers().contains(Modifier.ABSTRACT);
+    }
+    
+    public boolean isFinal() {
+        return decl.getModifiers().contains(Modifier.FINAL);
+    }
+    
+    public boolean isPublic() {
+        return decl.getModifiers().contains(Modifier.PUBLIC);
+    }
+    
+    public boolean isInterface() {
+        return (decl instanceof InterfaceDeclaration);
+    }
+}
\ No newline at end of file

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java?view=diff&rev=126394&p1=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java&r1=126393&p2=incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java&r2=126394
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
     (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
     Tue Jan 25 09:24:41 2005
@@ -47,14 +47,8 @@
 import com.sun.mirror.declaration.ParameterDeclaration;
 import com.sun.mirror.declaration.TypeDeclaration;
 
-import com.sun.mirror.type.AnnotationType;
-
-import org.apache.beehive.wsm.jsr181.model.AnnotationMetadata;
 import org.apache.beehive.wsm.jsr181.model.Jsr181MethodMetadata;
 import org.apache.beehive.wsm.jsr181.model.Jsr181MethodMetadataImpl;
-import org.apache.beehive.wsm.jsr181.model.Jsr181Modifiers;
-import org.apache.beehive.wsm.jsr181.model.Jsr181ParameterMetadata;
-import org.apache.beehive.wsm.jsr181.model.Jsr181ParameterMetadataImpl;
 import org.apache.beehive.wsm.jsr181.model.Jsr181TypeMetadata;
 import org.apache.beehive.wsm.jsr181.model.Jsr181TypeMetadataImpl;
 
@@ -81,34 +75,32 @@
      * Checks whether a source file complies with JSR-181.
      * @see TwoPhaseAnnotationProcessor
      * todo: should this always run all tests whenever called for any 
supported annotation?
-     * todo: store in object models created by endpoint interfaces in temp 
file only -- *delete* when apt is done
-     * todo: always process all interfaces before implementations
      */
     @Override
     public void check(Declaration _decl) {
 
         Messager messager = _env.getMessager();
-        
-        // check if we've already handled this declaration
-        if (handledDecls.contains(_decl)) {
-            return;
-        }
-        
-        // check if we're interested in declaration
-        if (! (_decl instanceof TypeDeclaration)) {
-            return;
-        }
-        WebService wsAnnotation = _decl.getAnnotation(WebService.class);
-        if (null == wsAnnotation) {
-            messager.printWarning(_decl.getPosition(), "@WebService annotation 
missing; unable to process: " + ((TypeDeclaration) _decl).getQualifiedName());
-            return;
-        }
-        
-        // store declaration so we don't handle it multiple times
-        handledDecls.add((TypeDeclaration) _decl);
-        
+
         try {
 
+            // check if we've already handled this declaration
+            if (handledDecls.contains(_decl)) {
+                return;
+            }
+
+            // check if we're interested in declaration
+            if (! (_decl instanceof TypeDeclaration)) {
+                return;
+            }
+            WebService wsAnnotation = _decl.getAnnotation(WebService.class);
+            if (null == wsAnnotation) {
+                messager.printWarning(_decl.getPosition(), "@WebService 
annotation missing; unable to process: " + ((TypeDeclaration) 
_decl).getQualifiedName());
+                return;
+            }
+
+            // store declaration so we don't handle it multiple times
+            handledDecls.add((TypeDeclaration) _decl);
+        
             // service implementation bean
             if (_decl instanceof ClassDeclaration) {
                 ClassDeclaration classDecl = (ClassDeclaration) _decl;
@@ -124,7 +116,7 @@
                     om = getEndpointInterfaceObjectModel(endpointInterface);
                     
                     // merge abstract and concrete object models
-                    Jsr181TypeMetadata com = 
getWebServiceTYPEMetadata(classDecl);
+                    Jsr181TypeMetadata com = new Jsr181TypeMetadataImpl(new 
MirrorTypeInfo(classDecl));
                     if (null == com) {
                         messager.printError(classDecl.getPosition(), "cannot 
load object model for service implementation bean: " + 
classDecl.getQualifiedName());
                         return;
@@ -137,7 +129,7 @@
                 
                 // create object model from scratch
                 else {
-                    om = getWebServiceTYPEMetadata(classDecl);
+                    om = new Jsr181TypeMetadataImpl(new 
MirrorTypeInfo(classDecl));
                 }
 
                 // check if we have an object model
@@ -156,7 +148,7 @@
                 messager.printNotice("processing service endpoint interface: " 
+ interfaceDecl.getQualifiedName());
                 
                 // create object model
-                Jsr181TypeMetadata om = 
getWebServiceTYPEMetadata(interfaceDecl);
+                Jsr181TypeMetadata om = new Jsr181TypeMetadataImpl(new 
MirrorTypeInfo(interfaceDecl));
                 if (null == om) {
                     return;
                 }
@@ -186,148 +178,6 @@
         // todo: persist all object models that have been created [by check()]
     }
 
-    protected Jsr181TypeMetadata getWebServiceTYPEMetadata(TypeDeclaration 
decl) {
-
-        Jsr181TypeMetadata objectModel = null;
-        
-        // get WebService annotation
-        WebService wsAnnotation = decl.getAnnotation(WebService.class);
-        if (null == wsAnnotation) {
-            _env.getMessager().printError(decl.getPosition(), "cannot create 
object model for class: " + decl.getQualifiedName());
-            return null;
-        }
-        
-        // webMethods
-        Collection<Jsr181MethodMetadata> webMethods =
-            new ArrayList<Jsr181MethodMetadata>();
-        Collection<Annotation> annotations = new ArrayList();
-        
-        // add all methods from service endpoint interface
-        boolean isServiceEndpointInterface = (decl instanceof 
InterfaceDeclaration);
-        if (isServiceEndpointInterface) {
-            for (MethodDeclaration mdecl : decl.getMethods()) {
-                webMethods.add(getWebServiceMETHODMetadata(mdecl));
-            }
-        }
-        // add only annotated methods
-        else {
-            for (MethodDeclaration mdecl : decl.getMethods()) {
-                if (null != mdecl.getAnnotation(WebMethod.class)) {
-                    Jsr181MethodMetadata wsmm = 
getWebServiceMETHODMetadata(mdecl);
-                    if (null != wsmm) {
-                        webMethods.add(wsmm);
-                    }
-                }
-            }
-        }
-
-        // check default constructor
-        boolean hasDefaultConstructor = false;
-        if (isServiceEndpointInterface) {
-            hasDefaultConstructor = true; // not used for interface
-        }
-        else {
-            ClassDeclaration cdecl = (ClassDeclaration) decl;
-            for (ConstructorDeclaration c : cdecl.getConstructors()) {
-                if (c.getParameters().isEmpty()) {
-                    hasDefaultConstructor = true;
-                    break;
-                }
-            }
-        }
-        
-        // check finalize
-        boolean hasFinalize = false;
-        if (isServiceEndpointInterface) {
-            hasFinalize = false; // not used for interface
-        }
-        else {
-            for (MethodDeclaration mdecl : decl.getMethods()) {
-                if (mdecl.getSimpleName().equals("finalize") && (null == 
mdecl.getParameters() || mdecl.getParameters().isEmpty())) {
-                    hasFinalize = true;
-                }
-            }
-        }
-        
-        // create & return WebService
-        Jsr181Modifiers modifiers = new Jsr181Modifiers(
-            
decl.getModifiers().contains(com.sun.mirror.declaration.Modifier.ABSTRACT),
-            
decl.getModifiers().contains(com.sun.mirror.declaration.Modifier.FINAL),
-            
decl.getModifiers().contains(com.sun.mirror.declaration.Modifier.PUBLIC)
-        );
-        try {
-            objectModel = new Jsr181TypeMetadataImpl(
-                wsAnnotation,
-                isServiceEndpointInterface,
-                hasDefaultConstructor,
-                hasFinalize,
-                decl.getQualifiedName(),
-                decl.getPosition().file().getParentFile(),
-                modifiers,
-                getAnnotations(decl),
-                webMethods
-            );
-        }
-        catch (Throwable t) {
-            _env.getMessager().printError(decl.getPosition(), t.getMessage());
-        }
-        
-        return objectModel;
-    }
-
-    protected Jsr181MethodMetadata 
getWebServiceMETHODMetadata(MethodDeclaration decl) {
-        
-        Jsr181MethodMetadata wsmm = null;
-
-        // get webMethod's webParams
-        List<Jsr181ParameterMetadata> webParams =
-                new ArrayList<Jsr181ParameterMetadata>();
-        for (ParameterDeclaration paramDecl : decl.getParameters()) {
-            Jsr181ParameterMetadata wspm = 
getWebServicePARAMETERMetadata(paramDecl);
-            if (null != wspm) {
-                webParams.add(wspm);
-            }
-        }
-
-        // create & return webMethod
-        Jsr181Modifiers modifiers = new Jsr181Modifiers(
-            
decl.getModifiers().contains(com.sun.mirror.declaration.Modifier.ABSTRACT),
-            
decl.getModifiers().contains(com.sun.mirror.declaration.Modifier.FINAL),
-            
decl.getModifiers().contains(com.sun.mirror.declaration.Modifier.PUBLIC)
-        );
-        try {
-            wsmm = new Jsr181MethodMetadataImpl(
-                decl.getSimpleName(),
-                TypeMirrorUtil.classForName(decl.getReturnType()),
-                modifiers,
-                (0 < decl.getThrownTypes().size()),
-                getAnnotations(decl),
-                webParams
-            );
-        }
-        catch (Throwable t) {
-            _env.getMessager().printError(decl.getPosition(), t.getMessage());
-        }
-        return wsmm;
-    }
-
-    /**
-     *
-     */
-    protected Jsr181ParameterMetadata 
getWebServicePARAMETERMetadata(ParameterDeclaration decl) {
-        // create & return webParam
-        Jsr181ParameterMetadata wspm = null;
-        try {
-            wspm = new 
Jsr181ParameterMetadataImpl(TypeMirrorUtil.classForName(decl.getType()),
-                    decl.getSimpleName(),
-                    getAnnotations(decl));
-        }
-        catch (Throwable t) {
-            _env.getMessager().printError(decl.getPosition(), t.getMessage());
-        }
-        return wspm;
-    }
-
     private Jsr181TypeMetadata getEndpointInterfaceObjectModel(String 
endpointInterface) {
 
         Jsr181TypeMetadata om = null;
@@ -353,13 +203,6 @@
     
     /**
      * todo: should this go into Jsr181TypeMetadataImpl
-     *
-     * Validate implementation bean against object model:
-     *   - If a service endpoint interface is referenced, check if all declared
-     *     methods are implemented by implementation bean
-     * 
-     * Note that this can only be called for concrete object models!
-     * @throws ValidationException
      */
     protected void validate(Jsr181TypeMetadata objectModel, ClassDeclaration 
classDecl) {
         
@@ -372,11 +215,16 @@
         Collection<Jsr181MethodMetadata> implementedMethods =
             new HashSet<Jsr181MethodMetadata>();
         for (MethodDeclaration impl : classDecl.getMethods()) {
-            implementedMethods.add(getWebServiceMETHODMetadata(impl));
+            try {
+                implementedMethods.add(new Jsr181MethodMetadataImpl(new 
MirrorMethodInfo(impl)));
+            }
+            catch (Throwable t) {
+                _env.getMessager().printError(classDecl.getPosition(), 
"Invalid method declaration found: " + classDecl.getSimpleName() + ": " + impl);
+            }
         }
         for (Jsr181MethodMetadata methodDecl : objectModel.getMethods()) {
             boolean foundImpl = false;
-            for (Jsr181MethodMetadata methodImpl :implementedMethods) {
+            for (Jsr181MethodMetadata methodImpl : implementedMethods) {
                 if (methodImpl.equals(methodDecl)) {
                     foundImpl = true;
                     break;
@@ -386,25 +234,5 @@
                 _env.getMessager().printError(classDecl.getPosition(), "Method 
not implemented by " + classDecl.getSimpleName() + ": " + methodDecl);
             }
         }
-    }
-
-    /**
-     * @param decl
-     * @return
-     */
-    protected Collection<Annotation> getAnnotations(Declaration decl) {
-        Collection<Annotation> annotations = new ArrayList<Annotation>();
-        for (AnnotationMirror am : decl.getAnnotationMirrors()) {
-            AnnotationType at = am.getAnnotationType();
-            try {
-                Class clazz = 
Class.forName(at.getDeclaration().getQualifiedName());
-                Annotation a = decl.getAnnotation(clazz);
-                if (null != a) {
-                    annotations.add(a);
-                }
-            } catch (ClassNotFoundException e) {
-            }
-        }
-        return annotations;
     }
 }

Reply via email to