Author: mmerz
Date: Wed Oct 20 10:48:49 2004
New Revision: 55170

Modified:
   incubator/beehive/trunk/wsm/drt/tests/Bar.java
   incubator/beehive/trunk/wsm/drt/tests/Bar2.java
   incubator/beehive/trunk/wsm/drt/tests/Bar3.java
   incubator/beehive/trunk/wsm/drt/tests/Cheetorama.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/processor/apt/WsmAnnotationProcessorEndpointInterfaceTest.java
   
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorTest.java
   
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterface2Test.java
   
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterface3Test.java
   
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterfaceTest.java
   
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorTest.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorFactory.java
   
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java
Log:
Aligned the reflection "annotation processor" with the apt counter part, which 
is required for the extensibility model. Also fixed some bugs in test cases and 
test files.
Service implementation beans are currently not validated against the endpoint 
interfaces.



Modified: incubator/beehive/trunk/wsm/drt/tests/Bar.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/Bar.java      (original)
+++ incubator/beehive/trunk/wsm/drt/tests/Bar.java      Wed Oct 20 10:48:49 2004
@@ -21,7 +21,7 @@
  *
  * @author Jonathan Colwell
  */
[EMAIL PROTECTED](name = "Abacus", endpointInterface = "Cheetorama")
[EMAIL PROTECTED](serviceName = "Bar1Service", endpointInterface = "Cheetorama")
 public class Bar
 {
     public boolean getNutty(int level, String detail)

Modified: incubator/beehive/trunk/wsm/drt/tests/Bar2.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/Bar2.java     (original)
+++ incubator/beehive/trunk/wsm/drt/tests/Bar2.java     Wed Oct 20 10:48:49 2004
@@ -25,7 +25,7 @@
  * the endpoint interface (cheetorama).
  *
  */
[EMAIL PROTECTED](name = "Abacus", endpointInterface = "Cheetorama")
[EMAIL PROTECTED](serviceName = "Bar2Service", endpointInterface = "Cheetorama")
 public class Bar2
 {
     @WebMethod

Modified: incubator/beehive/trunk/wsm/drt/tests/Bar3.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/Bar3.java     (original)
+++ incubator/beehive/trunk/wsm/drt/tests/Bar3.java     Wed Oct 20 10:48:49 2004
@@ -24,7 +24,7 @@
  * annotated with @WebMethod.
  *
  */
[EMAIL PROTECTED](name = "Abacus", endpointInterface = "Cheetorama")
[EMAIL PROTECTED](serviceName = "Bar3Service", endpointInterface = "Cheetorama")
 public class Bar3
 {
     @WebMethod

Modified: incubator/beehive/trunk/wsm/drt/tests/Cheetorama.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/Cheetorama.java       (original)
+++ incubator/beehive/trunk/wsm/drt/tests/Cheetorama.java       Wed Oct 20 
10:48:49 2004
@@ -31,7 +31,7 @@
  *
  *
  */
[EMAIL PROTECTED](name = "Abacus", targetNamespace = 
"http://www.superflaco.com/AnnotationEndpointInterfaceTest";)
[EMAIL PROTECTED](name="Abacus", targetNamespace = 
"http://www.superflaco.com/AnnotationEndpointInterfaceTest";)
 public interface Cheetorama
 {
     @WebMethod(operationName = "GoLocoCheetorama", 
action="LocoActionCheetorama")

Modified: 
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/BarTestCase.java
  (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java
  Wed Oct 20 10:48:49 2004
@@ -33,7 +33,7 @@
 public class BarTestCase extends TestCase
 {
     protected static final String CLASSNAME = "Bar";
-    protected static final String SRCFILENAME = "Bar.java";
+    protected static final String[] SRCFILENAMES = { "Bar.java", "Bar2.java", 
"Bar3.java", "Cheetorama.java" };
 
     protected AnnotationModel objectModel;
 

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorEndpointInterfaceTest.java
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorEndpointInterfaceTest.java
  (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorEndpointInterfaceTest.java
  Wed Oct 20 10:48:49 2004
@@ -21,7 +21,8 @@
 import com.sun.tools.apt.Main;
 
 import org.apache.beehive.wsm.jsr181.model.BarTestCase;
-import org.apache.beehive.wsm.jsr181.processor.apt.WsmAnnotationProcessor;
+import org.apache.beehive.wsm.jsr181.model.WebServicePARAMETERMetadata;
+import 
org.apache.beehive.wsm.jsr181.processor.reflection.WsmReflectionAnnotationProcessor;
 
 
 /**
@@ -40,26 +41,29 @@
             throw new Exception("BEEHIVE_HOME not set properly");
         }
 
-        // initialize "command line args"
-        String[] _args = {
-            "-factory",
-            
"org.apache.beehive.wsm.jsr181.processor.apt.WsmAnnotationProcessorFactory",
-            "-AsrcPath=" + new java.io.File(BEEHIVE_HOME, 
"/wsm/drt/tests/").getCanonicalPath(),
-            new java.io.File(
-                new java.io.File(BEEHIVE_HOME, "/wsm/drt/tests/"),
-                SRCFILENAME
-            ).getCanonicalPath()
-        };
-
-        // compile source file
-        int status = new Main().compile(_args);
-        if (0 != status)
+        for (String srcFilename : java.util.Arrays.asList(SRCFILENAMES))
         {
-            throw new Exception("error compiling: " + SRCFILENAME);
+            // initialize "command line args"
+            String[] _args = {
+                "-factory",
+                
"org.apache.beehive.wsm.jsr181.processor.apt.WsmAnnotationProcessorFactory",
+                "-AsrcPath=" + new java.io.File(BEEHIVE_HOME, 
"/wsm/drt/tests/").getCanonicalPath(),
+                new java.io.File(
+                    new java.io.File(BEEHIVE_HOME, "/wsm/drt/tests/"),
+                    srcFilename
+                ).getCanonicalPath()
+            };
+
+            // compile source file
+            int status = new Main().compile(_args);
+            if (0 != status)
+            {
+                throw new Exception("error compiling: " + SRCFILENAMES);
+            }
         }
 
         // check if we have an object model
-        this.objectModel = WsmAnnotationProcessor.getObjectModel(CLASSNAME);
+        objectModel = 
WsmReflectionAnnotationProcessor.getInstance().getObjectModel(Class.forName(CLASSNAME));
 
     }
 
@@ -67,6 +71,40 @@
     public void tearDown() throws Exception
     {
         // empty
+    }
+
+    /**
+     * We can't derive default values for WebParam from binaries. Thus, we use
+     * our own default name "in<number>".
+     */
+    @Override
+    public void testWebParamGoLocoFirst() throws Exception
+    {
+        final int paramNo = 0;
+        WebServicePARAMETERMetadata param = getParam("GoLocoCheetorama", 
paramNo);
+        assertNotNull("Cannot find first param for WebMethod 
GoLocoCheetorama()", param);
+        assertEquals("Invalid wpName", "in" + paramNo, param.getWpName());
+        assertEquals("Invalid return type: " + param.getJavaType(),
+            int.class,
+            param.getJavaType()
+        );
+    }
+
+    /**
+     * We can't derive default values for WebParam from binaries. Thus, we use
+     * our own default name "in<number>".
+     */
+    @Override
+    public void testWebParamDropMoneyFirst() throws Exception
+    {
+        final int paramNo = 0;
+        WebServicePARAMETERMetadata param = getParam("dropMoney", paramNo);
+        assertNotNull("Cannot find first param for WebMethod dropMoeny()", 
param);
+        assertEquals("Invalid wpName", "in" + paramNo, param.getWpName());
+        assertEquals("Invalid return type: " + param.getJavaType(),
+            int.class,
+            param.getJavaType()
+        );
     }
 }
 

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorTest.java
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorTest.java
   (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorTest.java
   Wed Oct 20 10:48:49 2004
@@ -21,7 +21,8 @@
 import com.sun.tools.apt.Main;
 
 import org.apache.beehive.wsm.jsr181.model.FooTestCase;
-import org.apache.beehive.wsm.jsr181.processor.apt.WsmAnnotationProcessor;
+import org.apache.beehive.wsm.jsr181.model.WebServicePARAMETERMetadata;
+import 
org.apache.beehive.wsm.jsr181.processor.reflection.WsmReflectionAnnotationProcessor;
 
 
 /**
@@ -58,12 +59,29 @@
         }
 
         // check if we have an object model
-        this.objectModel = WsmAnnotationProcessor.getObjectModel(CLASSNAME);
+        objectModel = 
WsmReflectionAnnotationProcessor.getInstance().getObjectModel(Class.forName(CLASSNAME));
     }
     
     @Override
     public void tearDown() throws Exception
     {
         // empty
+    }
+    
+    /**
+     * We can't derive default values for WebParam from binaries. Thus, we use
+     * our own default name "in<number>".
+     */
+    @Override
+    public void testWebParamGoLocoFirst() throws Exception
+    {
+        final int paramNo = 0;
+        WebServicePARAMETERMetadata param = getParam("GoLoco", paramNo);
+        assertNotNull("Cannot find first param for WebMethod GoLoco()", param);
+        assertEquals("Invalid wpName", "in" + paramNo, param.getWpName());
+        assertEquals("Invalid return type: " + param.getJavaType(),
+            int.class,
+            param.getJavaType()
+        );
     }
 }

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterface2Test.java
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterface2Test.java
  (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterface2Test.java
  Wed Oct 20 10:48:49 2004
@@ -40,7 +40,7 @@
         Class clazz = Class.forName(CLASSNAME);
         try
         {
-            objectModel = 
WsmReflectionAnnotationProcessor.getObjectModel(clazz);
+            objectModel = 
WsmReflectionAnnotationProcessor.getInstance().getObjectModel(clazz);
             fail("Failed to generate error for the service implementation 
which doesn't implement the methods declared "
                + "in the corresponding endpoint interface.");
         }

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterface3Test.java
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterface3Test.java
  (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterface3Test.java
  Wed Oct 20 10:48:49 2004
@@ -40,7 +40,7 @@
         Class clazz = Class.forName(CLASSNAME);
         try
         {
-            objectModel = 
WsmReflectionAnnotationProcessor.getObjectModel(clazz);
+            objectModel = 
WsmReflectionAnnotationProcessor.getInstance().getObjectModel(clazz);
         }
         catch(Exception e)
         {

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterfaceTest.java
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterfaceTest.java
   (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorEndpointInterfaceTest.java
   Wed Oct 20 10:48:49 2004
@@ -34,7 +34,7 @@
     public void setUp() throws Exception
     {
         Class clazz = Class.forName(CLASSNAME);
-        objectModel = WsmReflectionAnnotationProcessor.getObjectModel(clazz);
+        objectModel = 
WsmReflectionAnnotationProcessor.getInstance().getObjectModel(clazz);
         WebServiceMetadataViewer.print( (WebServiceTYPEMetadata) objectModel );
     }
 

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorTest.java
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorTest.java
    (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/reflection/WsmAnnotationProcessorTest.java
    Wed Oct 20 10:48:49 2004
@@ -32,7 +32,7 @@
     public void setUp() throws Exception
     {
         Class clazz = Class.forName(CLASSNAME);
-        objectModel = WsmReflectionAnnotationProcessor.getObjectModel(clazz);
+        objectModel = 
WsmReflectionAnnotationProcessor.getInstance().getObjectModel(clazz);
     }
 
     @Override

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java
    (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/DropInDeploymentHandler.java
    Wed Oct 20 10:48:49 2004
@@ -147,7 +147,7 @@
             if (null == rpc)
             {
                 WebServiceTYPEMetadata wsm =
-                    WsmReflectionAnnotationProcessor.getObjectModel(clazz);
+                    (WebServiceTYPEMetadata) 
WsmReflectionAnnotationProcessor.getInstance().getObjectModel(clazz);
 
                 rpc = createSOAPServiceUsingAnnotations(wsm, clazz);
             }

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
==============================================================================
--- 
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
     Wed Oct 20 10:48:49 2004
@@ -45,280 +45,97 @@
 
 import com.sun.tools.apt.Main;
 
+//import 
org.apache.beehive.controls.runtime.generator.apt.TwoPhaseAnnotationProcessor;
+
 import org.apache.beehive.wsm.jsr181.model.AnnotationModel;
 import org.apache.beehive.wsm.jsr181.model.WebServiceMETHODMetadata;
 import org.apache.beehive.wsm.jsr181.model.WebServicePARAMETERMetadata;
 import org.apache.beehive.wsm.jsr181.model.WebServiceTYPEMetadata;
 
-import 
org.apache.beehive.wsm.jsr181.processor.reflection.WsmReflectionAnnotationProcessor;
+import org.apache.beehive.wsm.jsr181.processor.ProcessorException;
 
+import 
org.apache.beehive.wsm.jsr181.processor.reflection.WsmReflectionAnnotationProcessor;
 
 public class WsmAnnotationProcessor extends TwoPhaseAnnotationProcessor
 {
     /**
      * Constructor.
      */
-    public WsmAnnotationProcessor(
-        Set<AnnotationTypeDeclaration> _atds,
-        AnnotationProcessorEnvironment _env
-    )
+    public WsmAnnotationProcessor(Set<AnnotationTypeDeclaration> _atds, 
AnnotationProcessorEnvironment _env)
     {
         super(_atds, _env);
     }
 
+    /**
+     * @see TwoPhaseAnnotationProcessor
+     */
     @Override
     public void check(Declaration decl)
     {
         // check type of declaration
-        if ((null == decl) || (! ((decl instanceof ClassDeclaration) || (decl 
instanceof InterfaceDeclaration)) ))
+        if (null == decl)
         {
-            return;
-            // todo: error --> @WebService is @Target(TYPE)
+            throw new ProcessorException("Declaration type \"null\" not 
allowed");
         }
-        
-        if (null == decl.getAnnotation(javax.jws.WebService.class))
+            
+        // check if we're interested
+        if (! (decl instanceof ClassDeclaration) && ! (decl instanceof 
InterfaceDeclaration))
         {
             return;
-            // todo: log warning/error "@WebService" not defined (should never 
happen)
-        }
-
-        AnnotationModel objectModel = null;
-        if ( decl instanceof ClassDeclaration )
-        {
-            // create & store an object model of the service implemetation bean
-
-            objectModel = getWebServiceTYPEMetadata((TypeDeclaration) decl, 
true);
-            objectModel = handleEndpointInterface((WebServiceTYPEMetadata) 
objectModel);
-        }
-        else
-        {
-            // create & store an object model of the service endpoint interface
-
-            objectModel = getWebServiceTYPEMetadata((TypeDeclaration) decl, 
false);
         }
 
-        objectModels.put(((TypeDeclaration) decl).getQualifiedName(), 
objectModel);
-    }
-
-    @Override
-    public void generate(Declaration decl)
-    {
-        // todo: on demand code generation
-
-        // todo: do something useful with the object model
-    }
-
-    private WebServiceTYPEMetadata 
handleEndpointInterface(WebServiceTYPEMetadata webServiceTYPEMetadata)
-    {
-        String endpointInterface = 
webServiceTYPEMetadata.getWsEndpointInterface();
-        if (null == endpointInterface || 0 == endpointInterface.length())
+        // verify @WebService annotation (being paranoid)
+        javax.jws.WebService ws = 
decl.getAnnotation(javax.jws.WebService.class);
+        if (null == ws)
         {
-            return webServiceTYPEMetadata;
+            throw new ProcessorException("@WebService annotation missing in 
source file");
         }
 
-        // the endpoint interface is specified by this webServiceTYPEMetadata.
-        // Thus, load it.
-
-        String canonicalSourcePath = null;
-        WebServiceTYPEMetadata endpointInterfaceMetadata = null;
-
-        if (endpointInterface.endsWith(".java"))
+        // service implementation bean
+        if (0 == ws.endpointInterface().length())
         {
-            // a java SOURCE file is specified for the endpoint interface.
-            // Thus, load annotations from it.
-            canonicalSourcePath = findSourceFile ( endpointInterface );
-            readServiceEndpointInterface(canonicalSourcePath);
-
-            // create a class name of the endpoint interface from the java 
source path.
-            String endpointInterfaceClassName =
-                endpointInterface.substring(0, 
endpointInterface.indexOf(".java"));
-            // path to class name
-            endpointInterfaceClassName =
-                
endpointInterfaceClassName.replaceAll("/",".").replaceAll("\\",".");
-
-            endpointInterfaceMetadata =
-                
(WebServiceTYPEMetadata)objectModels.get(endpointInterfaceClassName);
+            checkObjectModel((TypeDeclaration) decl, ws);
         }
+        
+        // service endpoint interface
         else
         {
-            // a java CLASS file is specified for the endpoint interface.
-            // First, try to find the corresponding java source file.
-            canonicalSourcePath = findSourceFile ( endpointInterface );
-
-            if (null != canonicalSourcePath)
-            {
-                readServiceEndpointInterface(canonicalSourcePath);
-                endpointInterfaceMetadata =
-                    
(WebServiceTYPEMetadata)objectModels.get(endpointInterface);
-            }
-            else
-            {
-                // the source file was not found. thus, load the class with
-                //  reflection and get annotations from it.
-                endpointInterfaceMetadata =
-                    createObjectModelWithReflection(endpointInterface);
-            }
-        }
-
-        if (null == endpointInterfaceMetadata)
-        {
-            // The endpoint interface is specified, but couldn't be found !
-            // todo: Must throw an Exception but just return the original
-            //     webServiceTYPEMetadata for now.
-            return webServiceTYPEMetadata;
-        }
-
-        endpointInterfaceMetadata.setWsServiceName(
-            webServiceTYPEMetadata.getWsServiceName()
-        );
-        endpointInterfaceMetadata.setWsEndpointInterface(
-            webServiceTYPEMetadata.getWsEndpointInterface()
-        );
-
-        return endpointInterfaceMetadata;
-    }
-
-    private WebServiceTYPEMetadata createObjectModelWithReflection(String 
endpointInterface)
-    {
-
-        WebServiceTYPEMetadata webServiceTYPEMetadata = null;
-
-        try{
-
-            Class clazz = Class.forName(endpointInterface);
-            webServiceTYPEMetadata =
-                WsmReflectionAnnotationProcessor.getObjectModel(clazz);
-        }
-        catch(java.lang.ClassNotFoundException cnfe)
-        {
-            cnfe.printStackTrace();
-            // throw new ClassNotFoundException("The class of the specified 
service endpoint interface was not found : " + endpointInterface );
-        }
-        catch (Throwable t)
-        {
-            t.printStackTrace(); // todo: proper error handling
-        }
-
-        return webServiceTYPEMetadata;
-
-    }
-
-    // find a source file of the specified className.
-    private String findSourceFile(String className)
-    {
-        // todo: search the specified file. Need a precise algorithm.
-
-        String sourcePath = null;
-
-        if (! className.endsWith(".java"))
-        {
-            // modify the class name to a file path
-            sourcePath =
-                className.replaceAll("\\.", File.separator).concat(".java");
-        }
-
-        String baseDir = "";
-
-        Map<String,String> opt = _env.getOptions();
-        for( String key : opt.keySet() ){
-            // Options passed to apt cannot be retrieved with 
getOptions().get(key). bug?
-            // A key-value pair always sticks together and placed in key (and 
null in value.)
-            // Thus, gotta strip off the name of the key.
-            if( key.startsWith("-AsrcPath=") ){
-                baseDir = key.substring( key.indexOf("=") + 1 );
-            }
-        }
-
-        File srcPath = new File(new File(baseDir), sourcePath);
-        if (srcPath.exists() && !srcPath.isDirectory())
-        {
             try {
-                return srcPath.getCanonicalPath();
-            }
-            catch (java.io.IOException ioe)
-            {
-                return null;
-            }
-        }
-
-        return null;
-    }
-
-    private void readServiceEndpointInterface(String filePath)
-    {
-        try {
-            // check these options are available and
-            // pass only available options to APT
-            String[] args = new String[] {
-                "-classpath",
-                "-cp",
-                "-d",
-                "-s",
-                "-source",
-                "-factorypath",
-                "-factory"
-            };
-
-            List<String> argList = new ArrayList<String>();
-            Map<String,String> opt = _env.getOptions();
-            for (String arg : args)
-            {
-                if (opt.get(arg) != null)
-                {
-                    argList.add(arg);
-                    argList.add(opt.get(arg));
-                }
+                Class clazz = Class.forName(ws.endpointInterface());
+                checkObjectModel(clazz, ws);
             }
-            argList.add(filePath);
-            String[] aptArgs = argList.toArray(new String[] {});
-
-            // compile source file
-            int status = new Main().compile(aptArgs);
-            if (0 != status)
-            {
-                throw new Exception("error compiling: " + filePath);
+            catch (ClassNotFoundException e) {
+                e.printStackTrace(); // todo: proper error handling
             }
-
-        }
-        catch (Throwable t)
-        {
-            t.printStackTrace(); // todo: proper error handling
         }
-
-    }
-    
-    public static AnnotationModel getObjectModel(String name)
-    {
-        return objectModels.get(name);
     }
 
-    public static Set<String> getObjectModelNames()
+    /**
+     * @see TwoPhaseAnnotationProcessor
+     */
+    @Override
+    public void generate(Declaration decl)
     {
-        return objectModels.keySet();
+        // jws-class file is the only artifact to be generated, which is
+        // done automatically as part of apt
     }
 
-    // isImplemetationBean indicates the specified decl is a declaration of 
whether the service implementation bean
-    //    or the service endpoint interface.
-    protected WebServiceTYPEMetadata getWebServiceTYPEMetadata(TypeDeclaration 
decl, boolean isImplementationBean)
+    /**
+     * Check object model for implementation beans.
+     * @param decl
+     * @param ws
+     * @returns
+     */
+    protected AnnotationModel checkObjectModel(TypeDeclaration decl, 
javax.jws.WebService ws)
     {
-        // get webService's webMethods
         Collection<WebServiceMETHODMetadata> webMethods =
             new ArrayList<WebServiceMETHODMetadata>();
 
-        for ( MethodDeclaration methodDecl : decl.getMethods() )
+        // publish methods @WebMethod annotations
+        for (MethodDeclaration methodDecl : decl.getMethods())
         {
-            if ( isImplementationBean )
-            {
-                // Methods annotated with @WebMethod in the service 
implementation bean are exposed.
-                if (null != 
methodDecl.getAnnotation(javax.jws.WebMethod.class))
-                {
-                    webMethods.add(getWebServiceMETHODMetadata(methodDecl));
-                }
-            }
-            else
+            if (null != methodDecl.getAnnotation(javax.jws.WebMethod.class))
             {
-                // All methods declared in the service endpoint interface are 
exposed.
-                // (Doesn't matter annotated with @WebMethod or not. anyway 
all methods)
                 webMethods.add(getWebServiceMETHODMetadata(methodDecl));
             }
         }
@@ -343,6 +160,29 @@
         }
         return wstm;
     }
+
+    /**
+     * Check object model for service endpoint interface.
+     * @param clazz
+     * @param ws
+     * @return
+     */
+    protected AnnotationModel checkObjectModel(Class clazz, 
javax.jws.WebService ws)
+    {
+        WebServiceTYPEMetadata wstm =
+            (WebServiceTYPEMetadata) 
WsmReflectionAnnotationProcessor.getInstance().getObjectModelFromServiceEndpointInterface(clazz);
+
+        if (null == wstm)
+        {
+            throw new ProcessorException("Failed to create object model for 
class: " + clazz.getName());
+            // todo: proper error handling
+        }
+
+        wstm.setWsServiceName(ws.serviceName());
+        wstm.setWsEndpointInterface(ws.endpointInterface());
+
+        return wstm;
+    }
     
     protected WebServiceMETHODMetadata getWebServiceMETHODMetadata(
         MethodDeclaration decl)
@@ -417,6 +257,17 @@
     {
         return TypeMirrorUtil.classForName(type);
     }
+    
+    public static AnnotationModel getObjectModel(String name)
+    {
+        return objectModels.get(name);
+    }
+
+    public static Set<String> getObjectModelNames()
+    {
+        return objectModels.keySet();
+    }
+
     private static Map<String, AnnotationModel> objectModels =
         new HashMap<String, AnnotationModel>();
 }

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorFactory.java
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorFactory.java
      (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorFactory.java
      Wed Oct 20 10:48:49 2004
@@ -33,7 +33,18 @@
 {
     private static final Collection<String> supportedAnnotations =
         unmodifiableCollection(
-            asList(new String[] { "javax.jws.WebService" }));
+            asList(new String[] {
+                "javax.jws.WebService",
+                "javax.jws.WebMethod",
+                "javax.jws.WebParam",
+                "javax.jws.Oneway",
+                "javax.jws.WebResult",
+                "javax.jws.HandlerResult",
+                "javax.jws.soap.SOAPBinding",
+                "javax.jws.soap.SOAPMessageHandlers",
+                "javax.jws.security.SecurityRoles",
+                "javax.jws.security.SecurityIdentity"
+            }));
 
     private static final Collection<String> supportedOptions = emptySet();
 

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java
    (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/reflection/WsmReflectionAnnotationProcessor.java
    Wed Oct 20 10:48:49 2004
@@ -36,226 +36,199 @@
 
 import org.apache.beehive.wsm.jsr181.processor.ProcessorException;
 
-public class WsmReflectionAnnotationProcessor {
-
-    /**
-     *  
-     */
-    public WsmReflectionAnnotationProcessor() {
+public class WsmReflectionAnnotationProcessor
+{
+    private static WsmReflectionAnnotationProcessor _instance;
+    
+    private WsmReflectionAnnotationProcessor()
+    {
         super();
-        // TODO Auto-generated constructor stub
+    }
+    
+    public static WsmReflectionAnnotationProcessor getInstance()
+    {
+        if (null == _instance)
+        {
+            _instance = new WsmReflectionAnnotationProcessor();
+        }
+        
+        return _instance;
     }
 
-    public static WebServiceTYPEMetadata getObjectModel(Class clazz)
+    /**
+     * Create object model from class.
+     * @param clazz Service implementation bean class.
+     * @return
+     */
+    public AnnotationModel getObjectModel(Class clazz)
     {
-        WebService wsAnnotation;
-        if (null == (wsAnnotation = (WebService) 
clazz.getAnnotation(WebService.class))) // no @WebService
+        WebService ws = (WebService) clazz.getAnnotation(WebService.class);
+        if (null == ws)
         {
             return null;
         }
-
-        // isImplementationBean indicates the specified clazz is whether a 
service implementation bean or
-        //     service endpoint interface.
-        boolean isImplementationBean = (! clazz.isInterface());
-        boolean hasEndpointInterface = false;
         
-        if (isImplementationBean)
+        WebServiceTYPEMetadata wstm = null;
+        if (0 == ws.endpointInterface().length())
         {
-            hasEndpointInterface = 
(wsAnnotation.endpointInterface().trim().length() != 0);
+            wstm = (WebServiceTYPEMetadata) 
getObjectModelFromServiceImplementationBean(clazz);
         }
+        else
+        {
+            try {
+                Class seiClass = Class.forName(ws.endpointInterface());
+                wstm = (WebServiceTYPEMetadata) 
getObjectModelFromServiceEndpointInterface(clazz, seiClass);
+                wstm.setWsServiceName(ws.serviceName());
+                wstm.setWsEndpointInterface(ws.endpointInterface());
 
-         Method[] methods = clazz.getMethods();
-         Collection<WebServiceMETHODMetadata> webMethods =
-             new ArrayList<WebServiceMETHODMetadata>();
-         for (Method method : methods)
-         {
-            boolean isAnnotated = method.getAnnotation(WebMethod.class) != 
null ? true : false ;
-
-            if (isImplementationBean && !isAnnotated && !hasEndpointInterface )
-             {
-                // This method is declared in a service implementation bean 
and not annotated with @WebMethod.
-                // Furthermore, the service implementation bean doesn't 
specify an endpoint interface.
-                // Thus, this method should NOT be stored in the object model.
-                 continue;
-             }
-
-            // get all parameters
-            List<WebServicePARAMETERMetadata> params =
-                new ArrayList<WebServicePARAMETERMetadata>();
-            int offset = 0;
-            Class< ? >[] methodParamTypes = method.getParameterTypes();
-            Annotation[][] allAnnotations = method.getParameterAnnotations();
-            for (Class paramType : methodParamTypes)
+                // todo verify equivalence of SEI and SIB
+            }
+            catch (ClassNotFoundException e)
             {
-                List<Annotation> allParmAnnotation =
-                    Arrays.asList(allAnnotations[offset]);
-                WebParam wpAnnotation =
-                    
(WebParam)AnnotationModel.getAnnotationOfType(allParmAnnotation, 
WebParam.class);
-                WebServicePARAMETERMetadata paramMetaData =
-                    new WebServicePARAMETERMetadata(
-                        paramType,
-                        "in" + offset,   // by default parameter should be IN
-                        allParmAnnotation // class
-                    );
-                // reflection
-                // doesn't keep the
-                // name of
-                // the parameter
-                params.add(paramMetaData);
-                offset++;
+                wstm = null;
             }
+        }
+        
+        return wstm;
+    }
+    
+    /**
+     * Create object model from service endpoint interface.
+     * @param clazz
+     * @return
+     */
+    public AnnotationModel getObjectModelFromServiceEndpointInterface(Class 
clazz, Class seiClass)
+    {
+        return getWebServiceTYPEMetadata(seiClass, false);
+    }
 
-            try {
-                WebServiceMETHODMetadata wsmm =
-                    new WebServiceMETHODMetadata(
-                        method.getName(),
-                        method.getReturnType(),
-                        (0 < method.getExceptionTypes().length),
-                        Arrays.asList(method.getAnnotations()),
-                        params
-                    );
-                webMethods.add(wsmm);
-            }
-            catch (Throwable t)
+    /**
+     * Create object model from service implementation bean.
+     * @param clazz
+     * @return
+     */
+    public AnnotationModel getObjectModelFromServiceImplementationBean(Class 
clazz)
+    {
+        return getWebServiceTYPEMetadata(clazz, true);
+    }
+
+    /**
+     * @param clazz
+     * @param isServiceImplementationBean
+     * @return
+     */
+    protected WebServiceTYPEMetadata getWebServiceTYPEMetadata(Class clazz, 
boolean isServiceImplementationBean)
+    {
+        Collection<WebServiceMETHODMetadata> webMethods =
+            new ArrayList<WebServiceMETHODMetadata>();
+
+        // publish methods
+        for (Method method : clazz.getMethods())
+        {
+            
+            if ((! isServiceImplementationBean) ||
+                (isServiceImplementationBean && 
AnnotationModel.hasAnnotationType(Arrays.asList(method.getAnnotations()), 
WebMethod.class)))
             {
-                t.printStackTrace(); // todo proper error handling
-                return null;
+                webMethods.add(getWebServiceMETHODMetadata(method));
             }
-
         }
 
+        // create & return webService
         WebServiceTYPEMetadata wstm = null;
         try {
             wstm = new WebServiceTYPEMetadata(
-                wsAnnotation,
+                (WebService) clazz.getAnnotation(WebService.class),
                 clazz.getName(),
-                Arrays.asList(clazz.getAnnotations()),
+                (Collection<Annotation>) Arrays.asList(clazz.getAnnotations()),
                 webMethods
             );
         }
         catch (Throwable t)
         {
-            t.printStackTrace(); // todo proper error handling
+            t.printStackTrace(); // todo: proper error handling
+            wstm = null;
         }
+        return wstm;
+    }
+        
+    /**
+     * @param method
+     * @return
+     */
+    protected WebServiceMETHODMetadata getWebServiceMETHODMetadata(Method 
method)
+    {
+        List<WebServicePARAMETERMetadata> webParams =
+            new ArrayList<WebServicePARAMETERMetadata>();
 
-        try{
-            if( hasEndpointInterface ){
-                // this service implementation bean specifies the endpoint 
interface.
-                // Thus, process it.
-                 wstm = handleEndpointInterface(wstm);
-             }
-        }
-        catch (ProcessorException pe)
-         {
-            // todo proper error handling
-            // actually, this try-catch clause is NOT needed, just throw the 
ProcessorException
-            // up to the caller.
-            pe.printStackTrace();
-            Throwable t = pe.getCause();
-            if ( t != null )
-            {
-                t.printStackTrace();
-            }
-            // throw a RuntimeException for now.
-            throw new RuntimeException("Failed to build the object model of 
the endpoint interface.");
-         }
-
-         return wstm;
-     }
-
-     // constructs the endpoint interface of the specified 
webServiceTYPEMetadata.
-     public static WebServiceTYPEMetadata 
handleEndpointInterface(WebServiceTYPEMetadata webServiceTYPEMetadata)
-         throws ProcessorException
-     {
-         String endpointInterface = 
webServiceTYPEMetadata.getWsEndpointInterface();
-         if (0 == endpointInterface.trim().length())
-         {
-             return webServiceTYPEMetadata;
-         }
-
-        // the endpoint interface is specified by this webServiceTYPEMetadata.
-        // Thus, load it.
-
-        String canonicalSourcePath = null;
-        WebServiceTYPEMetadata endpointInterfaceMetadata = null;
-
-        if (endpointInterface.endsWith(".java"))
-        {
-            /* Not implemented.
-            // a java SOURCE file is specified for the endpoint interface.
-            // Thus, load annotations from it.
-            canonicalSourcePath = findSourceFile ( endpointInterface );
-            readServiceEndpointInterface(canonicalSourcePath);
-
-            // create a class name of the endpoint interface from the java 
source path.
-            String endpointInterfaceClassName =
-                endpointInterface.substring(0, 
endpointInterface.indexOf(".java"));
-            // path to class name
-            endpointInterfaceClassName =
-                
endpointInterfaceClassName.replaceAll("/",".").replaceAll("\\",".");
-
-            endpointInterfaceMetadata =
-                
(WebServiceTYPEMetadata)objectModels.get(endpointInterfaceClassName);
-            */
-        }
-        else
+        // publish all params
+        Annotation[][] allAnnotations = method.getParameterAnnotations();
+        int offset = 0;
+        for (Class paramType : method.getParameterTypes())
         {
-            try
-            {
-                endpointInterfaceMetadata =
-                    getObjectModel(Class.forName(endpointInterface));
-            }
-            catch (ClassNotFoundException cnfe)
-            {
-                ProcessorException processException =
-                    new ProcessorException ("The endpoint interface 
["+endpointInterface+"] couldn't be found.");
-                processException.initCause(cnfe);
-                throw processException;
-            }
-
-            /* Not implemented.
-            // a java CLASS file is specified for the endpoint interface.
-            // First, try to find the corresponding java source file.
-            canonicalSourcePath = findSourceFile ( endpointInterface );
-
-            if (null != canonicalSourcePath)
-            {
-                readServiceEndpointInterface(canonicalSourcePath);
-                endpointInterfaceMetadata =
-                    
(WebServiceTYPEMetadata)objectModels.get(endpointInterface);
-            }
-            else
-            {
-                // the source file was not found. thus, load the class with
-                //  reflection and get annotations from it.
-                endpointInterfaceMetadata =
-                    createObjectModelWithReflection(endpointInterface);
-            }
-            */
+            webParams.add(
+                getWebServicePARAMETERMetadata(
+                    paramType,
+                    offset,
+                    Arrays.asList(allAnnotations[offset])
+                )
+            );
+            offset++;
         }
 
-        if (null == endpointInterfaceMetadata)
-        {
-            // The endpoint interface is specified, but couldn't be found !
-            throw new ProcessorException(
-                "The endpoint interface ("+endpointInterface+") is specified " 
+
-                "but building the object model of the interface failed."
+        // create & return webMethod
+        WebServiceMETHODMetadata wsmm = null;
+        try {
+            wsmm = new WebServiceMETHODMetadata(
+                method.getName(),
+                method.getReturnType(),
+                (0 < method.getExceptionTypes().length),
+                Arrays.asList(method.getAnnotations()),
+                webParams
             );
         }
+        catch (Throwable t)
+        {
+            t.printStackTrace(); // todo proper error handling
+            wsmm = null;
+        }
+        return wsmm;
+    }
 
-        endpointInterfaceMetadata.setWsServiceName(
-            webServiceTYPEMetadata.getWsServiceName()
-        );
-        endpointInterfaceMetadata.setWsEndpointInterface(
-            webServiceTYPEMetadata.getWsEndpointInterface()
-        );
-
-        validate(webServiceTYPEMetadata, endpointInterfaceMetadata);
-
-        return endpointInterfaceMetadata;
+    /**
+     * @param paramType
+     * @param offset
+     * @param annotations
+     * @return
+     */
+    protected WebServicePARAMETERMetadata getWebServicePARAMETERMetadata(Class 
paramType, int offset, List<Annotation> annotations)
+    {
+        // create & return webParam
+        WebServicePARAMETERMetadata wspm = null;
+        try {
+            wspm = new WebServicePARAMETERMetadata(
+                paramType,
+                "in" + offset, // by default parameter should be IN
+                annotations
+            );
+        }
+        catch (Throwable t)
+        {
+            t.printStackTrace(); // todo: proper error handling
+            wspm = null;
+        }
+        return wspm;
     }
 
-    // check whether the implementation bean implements all the methods 
specified in the endpointInterface.
+    /**
+     * todo: needs to move into "object model"
+     *
+     * Checks whether the implementation bean implements all the methods
+     * specified in the endpointInterface.
+     * @param
+     * @param
+     * @return
+     * @throws
+     */
     private static void validate(WebServiceTYPEMetadata 
implementationMetadata, WebServiceTYPEMetadata interfaceMetadata)
         throws ProcessorException
     {
@@ -288,7 +261,14 @@
 
     }
 
-    // compare the signature of specified methods.
+    /**
+     * todo: needs to move into "object model"
+     *
+     * Compares the signature of specified methods.
+     * @param
+     * @param
+     * @return
+     */
     private static boolean isSameMethodSignature(WebServiceMETHODMetadata m1, 
WebServiceMETHODMetadata m2)
     {
         // check java method names.
@@ -326,5 +306,4 @@
 
         return true;
     }
-
 }

Reply via email to