You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by mm...@apache.org on 2004/10/04 23:16:15 UTC

svn commit: rev 53747 - in incubator/beehive/trunk/wsm: drt drt/tests drt/tests/org/apache/beehive/wsm/jsr181/model drt/tests/org/apache/beehive/wsm/jsr181/processor/apt src/runtime/org/apache/beehive/wsm/jsr181/processor/apt

Author: mmerz
Date: Mon Oct  4 14:16:13 2004
New Revision: 53747

Added:
   incubator/beehive/trunk/wsm/drt/tests/Bar.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/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/TypeMirrorUtil.java
Modified:
   incubator/beehive/trunk/wsm/drt/build.xml
   incubator/beehive/trunk/wsm/drt/tests/Foo.java
   incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
Log:
Added support and test cases for endpointInterface.

Contributor: Wolfgang



Modified: incubator/beehive/trunk/wsm/drt/build.xml
==============================================================================
--- incubator/beehive/trunk/wsm/drt/build.xml	(original)
+++ incubator/beehive/trunk/wsm/drt/build.xml	Mon Oct  4 14:16:13 2004
@@ -68,7 +68,9 @@
     <target name="clean">
         <delete dir="${build.dir}"/>
         <delete dir="${drt.logs}"/>
-        <delete file="tests/Foo.class" />
+        <delete>
+            <fileset dir="${tests.src}" includes="*.class" />
+        </delete>
     </target>
 
     <target name="dirs">

Added: incubator/beehive/trunk/wsm/drt/tests/Bar.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/drt/tests/Bar.java	Mon Oct  4 14:16:13 2004
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2001-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.
+ */
+
+
+import javax.jws.Oneway;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+
+/*******************************************************************************
+ *
+ *
+ * @author Jonathan Colwell
+ */
+@WebService(name = "Abacus", endpointInterface = "Cheetorama")
+public class Bar
+{
+    @WebMethod(operationName = "GoLoco", action="LocoAction")
+    @WebResult
+    public boolean getNutty(@WebParam int level, @WebParam(name="detail") String detail)
+    {
+        return (level > 5);
+    }
+
+    @WebMethod
+    @Oneway
+    public void goHome(@WebParam(name="when") long time)
+    {
+        return;
+    }
+}
\ No newline at end of file

Added: incubator/beehive/trunk/wsm/drt/tests/Cheetorama.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/drt/tests/Cheetorama.java	Mon Oct  4 14:16:13 2004
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2001-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
+/*
+ * Copyright 2001-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.
+ */
+
+
+import javax.jws.Oneway;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+
+/*******************************************************************************
+ *
+ *
+ */
+@WebService(name = "Abacus", targetNamespace = "http://www.superflaco.com/AnnotationEndpointInterfaceTest")
+public interface Cheetorama
+{
+    @WebMethod(operationName = "GoLocoCheetorama", action="LocoActionCheetorama")
+    @WebResult
+    public boolean getNutty(@WebParam int level, @WebParam(name="detailCheetorama") String detail);
+
+    @WebMethod
+    @Oneway
+    public void goHome(@WebParam(name="whenCheetorama") long time);
+}
\ No newline at end of file

Modified: incubator/beehive/trunk/wsm/drt/tests/Foo.java
==============================================================================
--- incubator/beehive/trunk/wsm/drt/tests/Foo.java	(original)
+++ incubator/beehive/trunk/wsm/drt/tests/Foo.java	Mon Oct  4 14:16:13 2004
@@ -26,21 +26,20 @@
  *
  * @author Jonathan Colwell
  */
-@WebService(name = "Abacus",
-            endpointInterface = "Cheetorama",
-            targetNamespace = "http://www.superflaco.com/AnnotationTest")
-  public class Foo {
-
+@WebService(name = "Abacus", targetNamespace = "http://www.superflaco.com/AnnotationTest")
+public class Foo
+{
     @WebMethod(operationName = "GoLoco", action="LocoAction")
-      @WebResult
-      public boolean getNutty(@WebParam int level,
-                              @WebParam(name="detail") String detail) {
-        
-      return (level > 5);
+    @WebResult
+    public boolean getNutty(@WebParam int level, @WebParam(name="detail") String detail)
+    {
+        return (level > 5);
     }
 
-    @WebMethod @Oneway public void goHome(@WebParam(name="when") long time)
+    @WebMethod
+    @Oneway
+    public void goHome(@WebParam(name="when") long time)
     {
-
+        return;
     }
-  }
+}

Added: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/model/BarTestCase.java	Mon Oct  4 14:16:13 2004
@@ -0,0 +1,152 @@
+package org.apache.beehive.wsm.jsr181.model;
+
+/*
+ * 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:$
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * This class serves as the base class for all TestCases based on Bar.java. It
+ * verifies the values of all parameters in the object model defined in Cheetorama.java
+ * specified as the @WebService.endpointInterface annotation in Bar.java.
+ * Default values are expected to be filled in. If a subclass can't fully comply
+ * with JSR-181 (e.g. if it can't fill in all default values) it needs to
+ * override the respective tests.
+ */
+public class BarTestCase extends TestCase
+{
+    protected static final String CLASSNAME = "Bar";
+    protected static final String SRCFILENAME = "Bar.java";
+
+    protected AnnotationModel objectModel;
+
+    public void testObjectModel() throws Exception
+    {
+        assertNotNull("Failed to retrieve object model;", objectModel);
+    }
+
+    public void testWebServiceAbacus() throws Exception
+    {
+        assertEquals("Invalid wsName;", "Abacus",
+            ((WebServiceTYPEMetadata) objectModel).getWsName()
+        );
+
+        assertEquals("Invalid wsTargetNamespace;",
+            "http://www.superflaco.com/AnnotationEndpointInterfaceTest",
+            ((WebServiceTYPEMetadata) objectModel).getWsTargetNamespace()
+        );
+    }
+
+
+    public void testWebMethodGoLoco() throws Exception
+    {
+        WebServiceMETHODMetadata method = getMethod("GoLoco");
+        assertNull("WebMethod GoLoco() must be null", method);
+
+        method = getMethod("GoLocoCheetorama");
+        assertNotNull("Cannot find WebMethod GoLocoCheetorama();", method);
+        assertEquals("Invalid wmAction;", "LocoActionCheetorama", method.getWmAction());
+        assertFalse("Unexpected @Oneway;", method.isOneWay());
+        assertEquals("Invalid wrName;", "result", method.getWrName());
+        assertEquals("Invalid return type;",
+            boolean.class,
+            method.getJavaReturnType()
+        );
+    }
+
+    public void testWebMethodGoHome() throws Exception
+    {
+        WebServiceMETHODMetadata method = getMethod("goHome");
+        assertNotNull("Cannot find WebMethod goHome();", method);
+        assertEquals("Invalid wmAction;", "", method.getWmAction());
+        assertTrue("Cannot find @Oneway;", method.isOneWay());
+        assertEquals("Unexpected @WebResult;", "result", method.getWrName());
+        assertEquals("Unexpected return type;",
+            void.class,
+            method.getJavaReturnType()
+        );
+    }
+
+    public void testWebParamGoLocoFirst() throws Exception
+    {
+        final int paramNo = 0;
+        WebServicePARAMETERMetadata param = getParam("GoLocoCheetorama", paramNo);
+        assertNotNull("Cannot find first param for WebMethod GoLoco();", param);
+        assertEquals("Invalid wpName;", "level", param.getWpName());
+        assertEquals("Invalid return type: " + param.getJavaType(),
+            int.class,
+            param.getJavaType()
+        );
+    }
+
+    public void testWebParamGoLocoSecond() throws Exception
+    {
+        final int paramNo = 1;
+        WebServicePARAMETERMetadata param = getParam("GoLocoCheetorama", paramNo);
+        assertNotNull("Cannot find second param for WebMethod GoLoco();", param);
+        assertEquals("Invalid wpName;", "detailCheetorama", param.getWpName());
+        assertEquals("Invalid return type: " + param.getJavaType(),
+            String.class,
+            param.getJavaType()
+        );
+    }
+
+    public void testWebParamGoHomeFirst() throws Exception
+    {
+        final int paramNo = 0;
+        WebServicePARAMETERMetadata param = getParam("goHome", paramNo);
+        assertNotNull("Cannot find first param for method goHome();", param);
+        assertEquals("Invalid wpName;", "whenCheetorama", param.getWpName());
+        assertEquals("Invalid return type: " + param.getJavaType(),
+            long.class,
+            param.getJavaType()
+        );
+    }
+
+    protected WebServiceMETHODMetadata getMethod(String methodName)
+    {
+        for (WebServiceMETHODMetadata method : ((WebServiceTYPEMetadata) objectModel).getMethods())
+        {
+            if (method.getWmOperationName().equals(methodName))
+            {
+                return method;
+            }
+        }
+        return null;
+    }
+
+    protected WebServicePARAMETERMetadata getParam(String methodName, int pos)
+    {
+        for (WebServiceMETHODMetadata method : ((WebServiceTYPEMetadata) objectModel).getMethods())
+        {
+            if (method.getWmOperationName().equals(methodName))
+            {
+                int i = 0;
+                for (WebServicePARAMETERMetadata param : method.getParams())
+                {
+                    if (i == pos)
+                    {
+                        return param;
+                    }
+                    i++;
+                }
+            }
+        }
+        return null;
+    }
+}
\ No newline at end of file

Added: incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorEndpointInterfaceTest.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorEndpointInterfaceTest.java	Mon Oct  4 14:16:13 2004
@@ -0,0 +1,72 @@
+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:$
+ */
+
+import com.sun.tools.apt.Main;
+
+import org.apache.beehive.wsm.jsr181.model.BarTestCase;
+import org.apache.beehive.wsm.jsr181.processor.apt.WsmAnnotationProcessor;
+
+
+/**
+ * Test case verifies that a source file can be read and its annotations can be
+ * interpreted by the annotation processor.
+ */
+public class WsmAnnotationProcessorEndpointInterfaceTest extends BarTestCase {
+
+    @Override
+    public void setUp() throws Exception
+    {
+        // get project root from environment
+        String BEEHIVE_HOME;
+        if (null == (BEEHIVE_HOME = System.getenv("BEEHIVE_HOME")))
+        {
+            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)
+        {
+            throw new Exception("error compiling: " + SRCFILENAME);
+        }
+
+        // check if we have an object model
+        this.objectModel = WsmAnnotationProcessor.getObjectModel(CLASSNAME);
+
+    }
+
+    @Override
+    public void tearDown() throws Exception
+    {
+        // empty
+    }
+}
+

Added: incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/TypeMirrorUtil.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/TypeMirrorUtil.java	Mon Oct  4 14:16:13 2004
@@ -0,0 +1,127 @@
+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:$
+ */
+
+import com.sun.mirror.type.*; 
+
+public class TypeMirrorUtil {
+
+    // returns a class object of the specified type.
+    public static Class classForName(TypeMirror type) throws ClassNotFoundException
+    {
+
+        if( type instanceof PrimitiveType )
+        {
+            return getPrimitiveClass( ( (PrimitiveType) type).getKind() );
+        }
+        else if ( type instanceof VoidType )
+        {
+            return void.class;
+        }
+        else if ( type instanceof ArrayType )
+        {
+            Object[] typeOfArray = new Object[]{new Object()};
+            int arrayDepth = arrayDepth((ArrayType)type,0,typeOfArray);
+
+            StringBuffer className = new StringBuffer();
+            for( int i = 0 ; i < arrayDepth ; i++ ){
+               className.append("[");
+            }
+
+            TypeMirror mirrorTypeOfArray = (TypeMirror)typeOfArray[0];
+            if( mirrorTypeOfArray instanceof PrimitiveType ){
+                // e.g.   an array of int will be "[I".
+                className.append( getTypeSignatureOfPrimitiveType( ((PrimitiveType)mirrorTypeOfArray).getKind()) );
+            }else{
+                // e.g.   an array of String will be "[Ljava.lang.String;".
+                className.append("L").append(((TypeMirror)typeOfArray[0]).toString()).append(";");
+            } 
+
+            return Class.forName( className.toString() );
+
+        }
+
+        return Class.forName(type.toString());
+
+    }
+
+    private static Class getPrimitiveClass(PrimitiveType.Kind kind) {
+
+        // todo: change order of the cases for better performance.
+        switch(kind){
+           case BOOLEAN:
+               return boolean.class;
+           case BYTE:
+               return byte.class;
+           case CHAR:
+               return char.class;
+           case DOUBLE:
+               return double.class;
+           case FLOAT:
+               return float.class;
+           case INT:
+               return int.class;
+           case LONG:
+               return long.class;
+           case SHORT:
+               return short.class;
+        }
+
+        // todo: throw ClassNotFoundException
+        return null;
+    }
+
+    private static String getTypeSignatureOfPrimitiveType(PrimitiveType.Kind kind){
+
+        // todo: change order of the cases for better performance.
+        switch(kind){
+           case BOOLEAN:
+               return "Z";
+           case BYTE:
+               return "B";
+           case CHAR:
+               return "C";
+           case DOUBLE:
+               return "D";
+           case FLOAT:
+               return "F";
+           case INT:
+               return "I";
+           case LONG:
+               return "J";
+           case SHORT:
+               return "S";
+        }
+
+        // todo: throw ClassNotFoundException
+        return null;
+    }
+
+    private static int arrayDepth( ArrayType type, int depth, Object[] typeOfArray){
+        if ( type.getComponentType() instanceof ArrayType ){
+            return arrayDepth((ArrayType)type.getComponentType(),++depth, typeOfArray); 
+        }else{
+            typeOfArray[0] = type.getComponentType(); 
+        }
+        return ++depth;
+    }
+
+}
+
+

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	Mon Oct  4 14:16:13 2004
@@ -27,31 +27,41 @@
 import java.util.Map;
 import java.util.Set;
 
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+import java.io.File;
 
 import com.sun.mirror.declaration.AnnotationMirror;
 import com.sun.mirror.declaration.AnnotationTypeDeclaration;
 import com.sun.mirror.declaration.ClassDeclaration;
 import com.sun.mirror.declaration.Declaration;
+import com.sun.mirror.declaration.InterfaceDeclaration;
 import com.sun.mirror.declaration.MethodDeclaration;
 import com.sun.mirror.declaration.ParameterDeclaration;
+import com.sun.mirror.declaration.TypeDeclaration;
 
 import com.sun.mirror.type.AnnotationType;
+import com.sun.mirror.type.TypeMirror;
+
+import com.sun.mirror.apt.AnnotationProcessorEnvironment;
+
+import com.sun.tools.apt.Main;
 
 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;
+
+
 public class WsmAnnotationProcessor extends TwoPhaseAnnotationProcessor
 {
     /**
      * Constructor.
-     * @param _atds
-     * @param _env
      */
-    public WsmAnnotationProcessor(Set<AnnotationTypeDeclaration> _atds,
-        AnnotationProcessorEnvironment _env)
+    public WsmAnnotationProcessor(
+        Set<AnnotationTypeDeclaration> _atds,
+        AnnotationProcessorEnvironment _env
+    )
     {
         super(_atds, _env);
     }
@@ -60,7 +70,8 @@
     public void check(Declaration decl)
     {
         // check type of declaration
-        if ((null == decl) || (! (decl instanceof ClassDeclaration)))
+//        if ((null == decl) || (! (decl instanceof ClassDeclaration)))
+        if ((null == decl) || (! ((decl instanceof ClassDeclaration) || (decl instanceof InterfaceDeclaration)) ))
         {
             return;
             // todo: error --> @WebService is @Target(TYPE)
@@ -73,20 +84,201 @@
         }
 
         // create & store object model
-        AnnotationModel objectModel =
-            getWebServiceTYPEMetadata((ClassDeclaration) decl);
-        objectModels.put(
-            ((ClassDeclaration) decl).getQualifiedName(), objectModel);
+         AnnotationModel objectModel =
+            getWebServiceTYPEMetadata((TypeDeclaration) decl);
+
+        objectModel = handleEndpointInterface((WebServiceTYPEMetadata) objectModel);
+
+        objectModels.put(((TypeDeclaration) decl).getQualifiedName(), objectModel);
     }
-    
-    @Override
-    public void generate(Declaration decl)
+
+    public WebServiceTYPEMetadata handleEndpointInterface(WebServiceTYPEMetadata webServiceTYPEMetadata)
     {
+        String endpointInterface = webServiceTYPEMetadata.getWsEndpointInterface();
+        if (null == endpointInterface || 0 == endpointInterface.length())
+        {
+            return webServiceTYPEMetadata;
+        }
+
+        // the endpoint interface is specified by this webServiceTYPEMetadata.
+        // Thus, load it.
+
+        String canonicalSourcePath = null;
+        WebServiceTYPEMetadata endpointInterfaceMetadata = null;
+
+        if (endpointInterface.endsWith(".java"))
+        {
+            // 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
+        {
+            // 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;
+    }
+
+     @Override
+     public void generate(Declaration decl)
+     {
         // todo: on demand code generation
-        
+
         // todo: do something useful with the object model
+     }
+
+    public 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.
+    public 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;
     }
 
+    public 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));
+                }
+            }
+            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 (Throwable t)
+        {
+            t.printStackTrace(); // todo: proper error handling
+        }
+
+    }
+    
     public static AnnotationModel getObjectModel(String name)
     {
         return objectModels.get(name);
@@ -97,8 +289,7 @@
         return objectModels.keySet();
     }
 
-    protected WebServiceTYPEMetadata getWebServiceTYPEMetadata(
-        ClassDeclaration decl)
+    protected WebServiceTYPEMetadata getWebServiceTYPEMetadata(TypeDeclaration decl)
     {
         // get webService's webMethods
         Collection<WebServiceMETHODMetadata> webMethods =
@@ -116,7 +307,10 @@
         try {
             Collection<Annotation> annotations = getAnnotations(decl);
             wstm = new WebServiceTYPEMetadata((javax.jws.WebService)
-                AnnotationModel.getAnnotationOfType(annotations, javax.jws.WebService.class),
+                AnnotationModel.getAnnotationOfType(
+                    annotations,
+                    javax.jws.WebService.class
+                ),
                 decl.getQualifiedName(),
                 annotations,
                 webMethods
@@ -148,9 +342,12 @@
         try {
             Collection<Annotation> annotations = getAnnotations(decl);
             wsmm = new WebServiceMETHODMetadata(
-                (javax.jws.WebMethod)AnnotationModel.getAnnotationOfType(annotations, javax.jws.WebMethod.class),
+                (javax.jws.WebMethod)AnnotationModel.getAnnotationOfType(
+                    annotations,
+                    javax.jws.WebMethod.class
+                ),
                 decl.getSimpleName(),
-                classForName(decl.getReturnType().toString()),
+                classForName(decl.getReturnType()),
                 (0 < decl.getThrownTypes().size()),
                 annotations,
                 webParams
@@ -172,7 +369,7 @@
             Collection<Annotation> annotations = getAnnotations(decl);
             wspm = new WebServicePARAMETERMetadata(
                (javax.jws.WebParam)AnnotationModel.getAnnotationOfType(annotations, javax.jws.WebParam.class),
-                classForName(decl.getType().toString()),
+                classForName(decl.getType()),
                 decl.getSimpleName(),
                 annotations
             );
@@ -203,54 +400,10 @@
         return annotations;
     }
     
-    private Class classForName(String name) throws ClassNotFoundException
+    private Class classForName(TypeMirror type) throws ClassNotFoundException
     {
-        if ((null == name) || (0 == name.length()))
-        {
-            throw new IllegalArgumentException("class name must not be null");
-        }
-        else if (name.equals("boolean"))
-        {
-            return boolean.class;
-        }
-        else if (name.equals("byte"))
-        {
-            return byte.class;
-        }
-        else if (name.equals("char"))
-        {
-            return char.class;
-        }
-        else if (name.equals("double"))
-        {
-            return double.class;
-        }
-        else if (name.equals("float"))
-        {
-            return float.class;
-        }
-        else if (name.equals("int"))
-        {
-            return int.class;
-        }
-        else if (name.equals("long"))
-        {
-            return long.class;
-        }
-        else if (name.equals("short"))
-        {
-            return short.class;
-        }
-        else if (name.equals("void"))
-        {
-            return void.class;
-        }
-        else
-        {
-            return Class.forName(name);
-        }
+        return TypeMirrorUtil.classForName(type);
     }
-    
     private static Map<String, AnnotationModel> objectModels =
         new HashMap<String, AnnotationModel>();
 }