You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2006/10/29 21:53:08 UTC

svn commit: r468987 - in /beehive/wsm/trunk: ./ samples/wsm-addressbook/src/web/ src/axis1/org/apache/beehive/wsm/axis/ src/axis1/org/apache/beehive/wsm/axis/handlers/ src/core/org/apache/beehive/wsm/processor/apt/ src/core/org/apache/beehive/wsm/proce...

Author: ekoneil
Date: Sun Oct 29 12:53:07 2006
New Revision: 468987

URL: http://svn.apache.org/viewvc?view=rev&rev=468987
Log:
- Rationalize some WSM class names -- these should make more sense now.
- Add support for passing in a code generator / metadata processor name.  This finishes the loose coupling between the metadata format and code generation.

Test: WSM pass


Added:
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/WsmServiceContext.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/impl/
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/impl/MirrorWsmServiceContext.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/impl/ReflectionWsmServiceContext.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/MetadataFormat.java
Removed:
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/TypeResolver.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/WsmServiceStyleFactory.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorTypeResolver.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/reflection/ReflectionTypeResolver.java
Modified:
    beehive/wsm/trunk/build.xml
    beehive/wsm/trunk/samples/wsm-addressbook/src/web/Service.java
    beehive/wsm/trunk/src/axis1/org/apache/beehive/wsm/axis/ServiceDescriptionFactory.java
    beehive/wsm/trunk/src/axis1/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/WsmResourceGenerator.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/axis/AxisGenerator.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/axis2/Axis2Generator.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/WsmServiceFactory.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorWsmServiceFactory.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/reflection/ReflectionWsmServiceFactory.java
    beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/wsdl/WsdlWsmServiceFactory.java

Modified: beehive/wsm/trunk/build.xml
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/build.xml?view=diff&rev=468987&r1=468986&r2=468987
==============================================================================
--- beehive/wsm/trunk/build.xml (original)
+++ beehive/wsm/trunk/build.xml Sun Oct 29 12:53:07 2006
@@ -66,7 +66,7 @@
     <property name="webservice-utils-xmlbeans.classes" location="${classes.dir}/webservice-utils-xmlbeans"/>
 
     <property name="wsdl.schema.dir" location="src/schema-wsdl"/>
-    <property name="wsdl.classes.dir" location="${build.dir}/temp-wsdltypes"/>
+    <property name="wsdl.classes.dir" location="${classes.dir}/wsdltypes"/>
 
     <property name="wsm.jar" location="${jars.dir}/beehive-wsm.jar"/>
     <property name="wsm-axis1.jar" location="${jars.dir}/beehive-wsm-axis1.jar"/>
@@ -354,13 +354,10 @@
         <echo message="generate"/>
         <build-schemas srcdir="${xsd.schema.dir}" destdir="${schema.build.dir}"/>
         <build-schemas srcdir="${api.schema.dir}" destdir="${schema.build.dir}"/>
-    </target>
-
-   <target name="schema-jar">
         <jar jarfile="${schema.jar}" basedir="${schema.build.dir}"/>
-   </target>
+    </target>
 
-    <target name="schema-clean">
+    <target name="clean-schema">
         <delete dir="${schema.build.dir}"/>
         <delete file="${schema.jar}"/>
     </target>

Modified: beehive/wsm/trunk/samples/wsm-addressbook/src/web/Service.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/samples/wsm-addressbook/src/web/Service.java?view=diff&rev=468987&r1=468986&r2=468987
==============================================================================
--- beehive/wsm/trunk/samples/wsm-addressbook/src/web/Service.java (original)
+++ beehive/wsm/trunk/samples/wsm-addressbook/src/web/Service.java Sun Oct 29 12:53:07 2006
@@ -39,9 +39,6 @@
 
     private AddressBook addressBook;
 
-    /**
-     * Constructor.
-     */
     public Service() {
         addressBook = new AddressBookImpl();
         addressBook.addEntry(
@@ -88,7 +85,7 @@
      * locally.
      * @return A random string.
      */
-    public String notWebService() {
+    public String notAWebMethod() {
         return "Not available through Web service";
     }
 }

Modified: beehive/wsm/trunk/src/axis1/org/apache/beehive/wsm/axis/ServiceDescriptionFactory.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/axis1/org/apache/beehive/wsm/axis/ServiceDescriptionFactory.java?view=diff&rev=468987&r1=468986&r2=468987
==============================================================================
--- beehive/wsm/trunk/src/axis1/org/apache/beehive/wsm/axis/ServiceDescriptionFactory.java (original)
+++ beehive/wsm/trunk/src/axis1/org/apache/beehive/wsm/axis/ServiceDescriptionFactory.java Sun Oct 29 12:53:07 2006
@@ -35,7 +35,6 @@
 import org.apache.axis.constants.Use;
 import org.apache.axis.description.ElementDesc;
 import org.apache.axis.description.FaultDesc;
-import org.apache.axis.description.FieldDesc;
 import org.apache.axis.description.JavaServiceDesc;
 import org.apache.axis.description.OperationDesc;
 import org.apache.axis.description.ParameterDesc;
@@ -69,8 +68,8 @@
 import org.apache.xmlbeans.XmlObject;
 
 /**
- * This class is used to configure an Axis ServiceDesc object which represents a web service in Axis.  The ServiceDesc
- * is created by using the WSM metadata classes created during processing of JSR-181 metadata.
+ * This class is used to configure an Axis ServiceDesc object which represents a web service in Axis.
+ * The ServiceDesc is created by using the WSM metadata classes created during processing of JSR-181 metadata.
  */
 public final class ServiceDescriptionFactory {
 
@@ -302,7 +301,7 @@
                 fd.setQName(qname);
                 fd.setComplex(true);
             }
-            LOG.info("========= operation description ' " + axisOperationDesc.getName() + "'\n" + axisOperationDesc + "\n==========\n");
+            LOG.info("Start Operation Description: " + axisOperationDesc.getName() + "\n" + axisOperationDesc + "\nEnd Operation Description\n");
         }
 
         return axisServiceDesc;
@@ -442,52 +441,49 @@
         if(Void.TYPE.equals(javaType))
             return null;
 
-        /* get built-in javaType QName */
+        // get the QName for the built-in Java type
         QName qname = axisServiceDesc.getTypeMapping().getTypeQName(javaType);
-        // QName builtInQName = AxisTypeMappingMetaData.getBuiltInTypeQname(javaType);
-        if(qname != null) {
-            // we may have found a qname, but that does not necessarily mean its been registered
-            if (axisServiceDesc.getTypeMapping().isRegistered(javaType, qname)) {
+
+        // if this name has been registered already, finish
+        if(qname != null && axisServiceDesc.getTypeMapping().isRegistered(javaType, qname))
                 return qname;
-            }
 
-        }
+        // the QName isn't registered, and needs to be explicitly configured
 
-        /*
-        If the type isn't a built-in type, the type mapping information needs to be explicitly configured
-        */
-
-        /*
-        Unwrap all Holder subclasses in order to determine the "interesting" type passed into the service
-        method
-        */
+        // if the Java type being configured is a Holder, unwrap the Holder to discover the "interesting"
+        // Java type and configure its QName
         if(Holder.class.isAssignableFrom(javaType))
             javaType = TypeUtils.getHolderValueClass(javaType);
 
+        // get the type mapping for the current Axis web service
         TypeMapping axisTypeMapping = axisServiceDesc.getTypeMapping();
 
         /*
         Use an Axis-specific method to lookup the Java type -> QName mapping
          */
         BindingLookupStrategy lookupStrategy = new AxisBindingLookupFactory().getInstance();
-        if (qname == null) {
+        if (qname == null)
             qname = lookupStrategy.class2qname(javaType, targetNamespace);
-        }
 
-        /* todo: what happens when this QName is null? */
+        /* todo: uh, what happens when this QName is null? */
 
         /*
         Support for arrays.  Ensure that the array's element type is registered correctly
         */
         if(javaType.isArray()) {
             /*
-            Don't register array serializer in document (bare or wrapped)/literal style.
+            Configure the Java type <> QName mapping for RPC-ENCODED services
             */
-            if(!axisTypeMapping.isRegistered(javaType, qname) && axisServiceDesc.getStyle() == Style.RPC && axisServiceDesc.getUse() == Use.ENCODED) {
-                axisTypeMapping.register(javaType, qname,
-                                         new ArraySerializerFactory(javaType, qname), new ArrayDeserializerFactory());
+            if(!axisTypeMapping.isRegistered(javaType, qname) &&
+                axisServiceDesc.getStyle() == Style.RPC &&
+                axisServiceDesc.getUse() == Use.ENCODED) {
+                axisTypeMapping.register(javaType,
+                                         qname,
+                                         new ArraySerializerFactory(javaType, qname),
+                                         new ArrayDeserializerFactory());
             }
 
+            // Configure the Java type <> QName mapping for RPC services
             if (axisServiceDesc.getStyle() == Style.RPC) {
                 configureTypeMapping(axisServiceDesc, javaType.getComponentType(), targetNamespace);
                 return XMLType.SOAP_ARRAY;
@@ -496,13 +492,16 @@
             QName qcomp = configureTypeMapping(axisServiceDesc, javaType.getComponentType(), targetNamespace);
             if(axisServiceDesc.getUse() == Use.LITERAL)
                 qname = qcomp;
+
+            // Note, Don't register array serializer in document (bare or wrapped)/literal style.
         }
         /*
         Support for XMLBeans.
         */
         else if(XmlObject.class.isAssignableFrom(javaType)) {
             qname = XmlBeans.typeForClass(javaType).getName();
-            axisTypeMapping.register(javaType, qname,
+            axisTypeMapping.register(javaType,
+                                     qname,
                                      new XmlBeanSerializerFactory(javaType, qname),
                                      new XmlBeanDeserializerFactory(javaType, qname));
         }
@@ -531,9 +530,8 @@
             If the namespace of the axisTypeDesc object doesn't match the needed targetNamespace,
             the TypeDesc object needs to be configured for the given namespace.
             */
-            if(axisTypeDesc != null && !axisTypeDesc.getXmlType().getNamespaceURI().equals(qname.getNamespaceURI())) {
+            if(axisTypeDesc != null && !axisTypeDesc.getXmlType().getNamespaceURI().equals(qname.getNamespaceURI()))
                 axisTypeDesc = null;
-            }
 
             TypeDesc superAxisTypeDesc = null;
             BeanPropertyDescriptor[] superPd = null;
@@ -542,6 +540,7 @@
             */
             if(axisTypeDesc == null) {
                 axisTypeDesc = new TypeDesc(javaType);
+                axisTypeDesc.setXmlType(qname);
 
                 /*
                 create javaType descriptor for this class --- NOT its super classes at this point. add super class types.
@@ -562,9 +561,9 @@
                     /* super class is a regular javabean with axis typedesc */
                     superPd = superAxisTypeDesc.getPropertyDescriptors();
                 }
-                axisTypeDesc.setXmlType(qname);
+
                 TypeDesc.registerTypeDescForClass(javaType, axisTypeDesc);
-                /*
+                /*                
                 NOTE: this is partially finished td, so more processing to follow that is why its td is not set to
                 null as it is for the case when it is already provided (when td !=null)
                 */
@@ -578,16 +577,17 @@
             }
 
             /*
-            Superclass Bean classes and their properties / attributes have been registered with
-            Axis's TypeMapping object.  Now, register the javaType.
+            Superclass Bean classes and their properties have been registered with Axis's type mapping
+            information; now, register the Java type dealt with during this invocation.
             */
             axisTypeMapping.register(javaType,
                                      qname,
-                                     new BeanSerializerFactory(javaType, qname), //, axisTypeDesc),
-                                     new BeanDeserializerFactory(javaType, qname)); //, axisTypeDesc));
+                                     new BeanSerializerFactory(javaType, qname),
+                                     new BeanDeserializerFactory(javaType, qname));
 
             /*
-            now register the types for this bean properties (attributes)
+            register this Java type's JavaBean properties.
+            
             Note: we have to consider the case that one of the properties may be XML bean
             or a class that can deal with its own serialization.
             */
@@ -597,22 +597,21 @@
             Iterator iterator = serProps.values().iterator();
             while(iterator.hasNext()) {
                 BeanPropertyDescriptor beanProps = (BeanPropertyDescriptor)iterator.next();
-                Class subType = beanProps.getType();
+                Class propertyType = beanProps.getType();
 
                 /*
-                Make sure the property javaType is configred with Type
-                mapping and its serializer information
+                ensure that the Java type for this property is registered with the Axis
+                type mapping registry
                 */
-                if(!(subType.isPrimitive() ||
-                    subType.getName().startsWith("java.") ||
-                    subType.getName().startsWith("javax."))) {
-                    configureTypeMapping(axisServiceDesc, subType, targetNamespace);
+                if(!(propertyType.isPrimitive() ||
+                    propertyType.getName().startsWith("java.") ||
+                    propertyType.getName().startsWith("javax."))) {
+                    configureTypeMapping(axisServiceDesc, propertyType, targetNamespace);
                 }
 
                 if(axisTypeDesc != null) {
                     /*
-                    if I didn't have javaType descriptor when I came to this method... I
-                    created partially filled one above now need to complete this.
+                    finish filling-out the axis type description for this property
                     */
                     String ns = qname.getNamespaceURI();
 
@@ -629,16 +628,14 @@
                             }
                         }
                     }
-                    FieldDesc fd = new ElementDesc();
-                    fd.setJavaType(subType);
+                    ElementDesc fd = new ElementDesc();
+                    fd.setJavaType(propertyType);
                     fd.setFieldName(beanProps.getName());
                     fd.setXmlName(new QName(ns, beanProps.getName()));
+                    fd.setXmlType(axisTypeMapping.getTypeQName(propertyType));
+                    fd.setNillable(true);
 
-                    // NOTE jcolwell@bea.com 2004-Oct-28 -- might need to do more to ensure a useful javaType QName.
-                    fd.setXmlType(axisTypeMapping.getTypeQName(subType));
-                    ((ElementDesc)fd).setNillable(true);
-
-                    // mmerz@apache.com 2005-Mar-09: required since Axis 1.2RC3 to allow for null values in complex
+                    // mmerz@apache.org 2005-Mar-09: required since Axis 1.2RC3 to allow for null values in complex
                     // objects; note that there is no (JSR-181) annotation that allows configuring this value.
                     axisTypeDesc.addFieldDesc(fd);
                 }

Modified: beehive/wsm/trunk/src/axis1/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/axis1/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java?view=diff&rev=468987&r1=468986&r2=468987
==============================================================================
--- beehive/wsm/trunk/src/axis1/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java (original)
+++ beehive/wsm/trunk/src/axis1/org/apache/beehive/wsm/axis/handlers/AnnotatedWebServiceDeploymentHandler.java Sun Oct 29 12:53:07 2006
@@ -115,7 +115,7 @@
 
         assert wsmService != null : "Unable to create SOAPService since the WSM object model is null";
 
-        /* todo: wire-up the ControlProvider as a handler.  is that possible? */
+        /* todo: wire-up the ControlProvider as a handler */
         SOAPService axisSoapService = new SOAPService(null, new ControlProvider(), null);
 
         /* add jaxrpc handlers if there are any. */

Modified: beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java?view=diff&rev=468987&r1=468986&r2=468987
==============================================================================
--- beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java (original)
+++ beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/apt/WsmAnnotationProcessor.java Sun Oct 29 12:53:07 2006
@@ -21,13 +21,17 @@
 import java.util.Set;
 import java.util.LinkedList;
 import java.util.Iterator;
-import java.util.Map;
 import java.lang.reflect.Method;
 
 import org.apache.beehive.wsm.processor.TwoPhaseAnnotationProcessor;
+import org.apache.beehive.wsm.processor.model.factory.WsmServiceFactory;
+import org.apache.beehive.wsm.processor.model.factory.MetadataFormat;
 import org.apache.beehive.wsm.processor.generator.axis.AxisGenerator;
 import org.apache.beehive.wsm.processor.generator.WsmResourceGenerator;
+import org.apache.beehive.wsm.processor.generator.WsmServiceContext;
+import org.apache.beehive.wsm.processor.generator.impl.MirrorWsmServiceContext;
 import org.apache.beehive.wsm.processor.checker.Jsr181AnnotationChecker;
+import org.apache.beehive.wsm.model.WsmService;
 import org.apache.beehive.common.glass.typesystem.declaration.ClassDeclaration;
 import org.apache.beehive.common.glass.typesystem.declaration.InterfaceDeclaration;
 import org.apache.beehive.common.glass.typesystem.declaration.AnnotationTypeDeclaration;
@@ -128,38 +132,42 @@
 
             TypeDeclaration typeDecl = (TypeDeclaration)decl;
 
-            WsmResourceGenerator generator = lookupResourceGenerator();
-            generator.generate(getAnnotationProcessorEnvironment(), typeDecl);
-        }
-    }
+            // context object used for code creating the JavaBean model for the web service
+            // and for doing code generation
+            WsmServiceContext context = new MirrorWsmServiceContext(getAnnotationProcessorEnvironment(),
+                                                                    typeDecl.getPosition().file().getParent());
 
-    private WsmResourceGenerator lookupResourceGenerator() {
-        Map options = getAnnotationProcessorEnvironment().getOptions();
+            // create the web service JavaBean model
+            String metadataTypeString = getOption("metadata", "mirror");
+            MetadataFormat metadataFormat =
+                MetadataFormat.getFactoryType(metadataTypeString);
 
-        String resourceGeneratorClassname = null;
-        System.out.println("options: " + options);
-        Iterator iterator = options.keySet().iterator();
-        while(iterator.hasNext()) {
-            String kv = (String)iterator.next();
-            if(kv.startsWith("-A" + Jsr181AnnotationConstants.PROCESSOR_OPTIONS_RESOURCE_GENERATOR)) {
-                resourceGeneratorClassname =
-                    kv.substring(2+Jsr181AnnotationConstants.PROCESSOR_OPTIONS_RESOURCE_GENERATOR.length()+1);
-            }
+            WsmServiceFactory wsmServiceFactory = WsmServiceFactory.getInstance(metadataFormat);
+            WsmService wsmService = wsmServiceFactory.create(context, typeDecl.getQualifiedName());
+
+            // generate any resources required to support deployment of the web service
+            WsmResourceGenerator generator = createResourceGenerator();
+            generator.generate(context, wsmService);
         }
+    }
 
-        System.out.println("resourceGeneratorClassname: " + resourceGeneratorClassname);
+    private WsmResourceGenerator createResourceGenerator() {
+        String resourceGeneratorClassName =
+                getOption(Jsr181AnnotationConstants.PROCESSOR_OPTIONS_RESOURCE_GENERATOR,
+                          DEFAULT_RESOURCE_GENERATOR);
 
-        if(resourceGeneratorClassname == null)
-            resourceGeneratorClassname = DEFAULT_RESOURCE_GENERATOR;
+        getAnnotationProcessorEnvironment().getMessager().printNotice
+                ("Web service resource generator: " + resourceGeneratorClassName);
 
         WsmResourceGenerator resourceGenerator = null;
         try {
-            Class clazz = Class.forName(resourceGeneratorClassname);
+            Class clazz = Class.forName(resourceGeneratorClassName);
             Method factoryMethod = clazz.getMethod("getInstance");
             resourceGenerator = (WsmResourceGenerator)factoryMethod.invoke(null);
         }
         catch(Exception e) {
-            throw new IllegalArgumentException("Unable to create WSM code generator \"" + resourceGeneratorClassname + "\".  Cause: " + e, e);
+            throw new IllegalArgumentException
+                    ("Unable to create web service code generator \"" + resourceGeneratorClassName + "\".  Cause: " + e, e);
         }
 
         return resourceGenerator;
@@ -178,4 +186,15 @@
 
         return _serviceInterfaces;
     }
+
+    private String getOption(String optionName, String defaultValue) {
+        String value = null;
+        Iterator iterator = getAnnotationProcessorEnvironment().getOptions().keySet().iterator();
+        while(iterator.hasNext()) {
+            String kv = (String)iterator.next();
+            if(kv.startsWith("-A"+optionName))
+                value = kv.substring(2+optionName.length()+1);
+        }
+        return (value != null ? value : defaultValue);
+    }    
 }

Modified: beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/WsmResourceGenerator.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/WsmResourceGenerator.java?view=diff&rev=468987&r1=468986&r2=468987
==============================================================================
--- beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/WsmResourceGenerator.java (original)
+++ beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/WsmResourceGenerator.java Sun Oct 29 12:53:07 2006
@@ -20,6 +20,7 @@
 
 import org.apache.beehive.common.glass.typesystem.declaration.TypeDeclaration;
 import org.apache.beehive.common.glass.typesystem.env.CoreAnnotationProcessorEnv;
+import org.apache.beehive.wsm.model.WsmService;
 
 /**
  * <p>
@@ -34,9 +35,9 @@
  */
 public abstract class WsmResourceGenerator {
 
-    /*
-    serviceEndpoint interface generation should be performed in implementations of this base class
-    depending on the service's target execution environment
-    */
-    public abstract void generate(CoreAnnotationProcessorEnv env, TypeDeclaration typeDeclaration);
+    public static final String OPTION_METADATA_FORMAT_MIRROR = "mirror";
+    public static final String OPTION_GENERATOR_AXIS2 = "axis2";
+
+    //TODO: move ServiceEndpoint generation to a baseclass
+    public abstract void generate(WsmServiceContext context, WsmService wsmService);
 }

Added: beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/WsmServiceContext.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/WsmServiceContext.java?view=auto&rev=468987
==============================================================================
--- beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/WsmServiceContext.java (added)
+++ beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/WsmServiceContext.java Sun Oct 29 12:53:07 2006
@@ -0,0 +1,17 @@
+package org.apache.beehive.wsm.processor.generator;
+
+import java.net.URL;
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.IOException;
+
+/**
+ */
+public abstract class WsmServiceContext {
+
+    public abstract Object resolveType(String typeName);
+
+    public abstract URL locateResource(String path);
+
+    public abstract PrintWriter createTextFile(String path) throws IOException;
+}

Modified: beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/axis/AxisGenerator.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/axis/AxisGenerator.java?view=diff&rev=468987&r1=468986&r2=468987
==============================================================================
--- beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/axis/AxisGenerator.java (original)
+++ beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/axis/AxisGenerator.java Sun Oct 29 12:53:07 2006
@@ -18,22 +18,14 @@
  */
 package org.apache.beehive.wsm.processor.generator.axis;
 
-import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
 
 import org.apache.beehive.wsm.model.WsmService;
-import org.apache.beehive.wsm.processor.model.factory.WsmServiceStyleFactory;
-import org.apache.beehive.wsm.processor.model.factory.WsmServiceFactory;
-import org.apache.beehive.wsm.processor.model.factory.TypeResolver;
-import org.apache.beehive.wsm.processor.model.factory.mirror.MirrorTypeResolver;
 import org.apache.beehive.wsm.processor.generator.WsmResourceGenerator;
+import org.apache.beehive.wsm.processor.generator.WsmServiceContext;
 import org.apache.beehive.wsm.util.WsmddUtils;
 import org.apache.beehive.wsm.exception.CodeGenerationException;
-import org.apache.beehive.common.glass.typesystem.env.CoreAnnotationProcessorEnv;
-import org.apache.beehive.common.glass.typesystem.env.Filer;
-import org.apache.beehive.common.glass.typesystem.declaration.TypeDeclaration;
-import org.apache.beehive.common.glass.typesystem.util.SourcePosition;
 
 public class AxisGenerator
     extends WsmResourceGenerator {
@@ -45,19 +37,8 @@
     private AxisGenerator() {
     }
 
-    public void generate(CoreAnnotationProcessorEnv env, TypeDeclaration typeDecl) {
-
-        WsmServiceFactory factory =
-            WsmServiceStyleFactory.create(WsmServiceStyleFactory.FactoryType.MIRROR);
-
-        String serviceBeanClassName = typeDecl.getQualifiedName();
-        TypeResolver typeResolver = MirrorTypeResolver.getInstance(env);
-
-        SourcePosition position = typeDecl.getPosition();
-        WsmService wsmService = factory.create(serviceBeanClassName,
-                                               typeResolver,
-                                               position.file().getParent());
-
+    public void generate(WsmServiceContext wsmServiceContext, WsmService wsmService) {
+        
         String implementationClass = wsmService.getServiceClassName();
         String packageName = "";
         String fileName = null;
@@ -74,8 +55,7 @@
 
         PrintWriter printWriter = null;
         try {
-            Filer filer = env.getFiler();
-            printWriter = filer.createTextFile(new File(packageName.replaceAll("\\.", "/") + "/" + fileName));
+            printWriter = wsmServiceContext.createTextFile(packageName.replaceAll("\\.", "/") + "/" + fileName);
 
             WsmddUtils.write(wsmService, printWriter);
             printWriter.close();

Modified: beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/axis2/Axis2Generator.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/axis2/Axis2Generator.java?view=diff&rev=468987&r1=468986&r2=468987
==============================================================================
--- beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/axis2/Axis2Generator.java (original)
+++ beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/axis2/Axis2Generator.java Sun Oct 29 12:53:07 2006
@@ -19,17 +19,11 @@
 package org.apache.beehive.wsm.processor.generator.axis2;
 
 import java.io.PrintWriter;
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
 import java.util.Date;
 import java.util.List;
-
 import javax.xml.transform.Result;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
 import javax.xml.transform.Source;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.dom.DOMSource;
@@ -39,17 +33,10 @@
 import javax.jws.soap.SOAPBinding;
 
 import org.apache.beehive.wsm.processor.generator.WsmResourceGenerator;
-import org.apache.beehive.wsm.processor.model.factory.WsmServiceFactory;
-import org.apache.beehive.wsm.processor.model.factory.WsmServiceStyleFactory;
-import org.apache.beehive.wsm.processor.model.factory.TypeResolver;
-import org.apache.beehive.wsm.processor.model.factory.mirror.MirrorTypeResolver;
+import org.apache.beehive.wsm.processor.generator.WsmServiceContext;
 import org.apache.beehive.wsm.model.WsmService;
 import org.apache.beehive.wsm.model.WsmOperation;
 import org.apache.beehive.wsm.exception.CodeGenerationException;
-import org.apache.beehive.common.glass.typesystem.env.CoreAnnotationProcessorEnv;
-import org.apache.beehive.common.glass.typesystem.env.Filer;
-import org.apache.beehive.common.glass.typesystem.declaration.TypeDeclaration;
-import org.apache.beehive.common.glass.typesystem.util.SourcePosition;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -68,25 +55,16 @@
         return new Axis2Generator();
     }
 
-    public void generate(CoreAnnotationProcessorEnv env, TypeDeclaration typeDeclaration) {
-        WsmServiceFactory factory = WsmServiceStyleFactory.create(WsmServiceStyleFactory.FactoryType.MIRROR);
-
-        String serviceBeanClassName = typeDeclaration.getQualifiedName();
-        TypeResolver typeResolver = MirrorTypeResolver.getInstance(env);
-
-        SourcePosition position = typeDeclaration.getPosition();
-        WsmService wsmService = factory.create(serviceBeanClassName,
-                                               typeResolver,
-                                               position.file().getParent());
+    public void generate(WsmServiceContext wsmServiceContext, WsmService wsmService) {
 
+        /*
+        Generate artifacts.
+         */
         String fileName = "META-INF/services.xml";
         PrintWriter printWriter = null;
         try {
-            Filer filer = env.getFiler();
-            printWriter = filer.createTextFile(new File(fileName));
-
+            printWriter = wsmServiceContext.createTextFile(fileName);
             generateServicesXml(wsmService, printWriter);
-
             printWriter.close();
         }
         catch(Exception e) {
@@ -163,7 +141,7 @@
     }
 }
 
-/*
+/* // sample service configuration file. 
 <service>
     <description>
         This is a sample Web Service with two operations, echo and ping.

Added: beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/impl/MirrorWsmServiceContext.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/impl/MirrorWsmServiceContext.java?view=auto&rev=468987
==============================================================================
--- beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/impl/MirrorWsmServiceContext.java (added)
+++ beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/impl/MirrorWsmServiceContext.java Sun Oct 29 12:53:07 2006
@@ -0,0 +1,62 @@
+package org.apache.beehive.wsm.processor.generator.impl;
+
+import org.apache.beehive.wsm.processor.generator.WsmServiceContext;
+import org.apache.beehive.wsm.exception.Jsr181ValidationException;
+import org.apache.beehive.common.glass.typesystem.env.CoreAnnotationProcessorEnv;
+import org.apache.beehive.common.glass.typesystem.env.Filer;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ */
+public class MirrorWsmServiceContext
+        extends WsmServiceContext {
+
+    private String _filePath;
+    private CoreAnnotationProcessorEnv _env;
+
+    public MirrorWsmServiceContext(CoreAnnotationProcessorEnv env, String filePath) {
+        _env = env;
+        _filePath = filePath;
+    }
+
+    public PrintWriter createTextFile(String path)
+        throws IOException {
+        Filer filer = _env.getFiler();
+        return filer.createTextFile(new File(path));
+    }
+
+    public Object resolveType(String typeName) {
+        assert typeName != null;
+        return _env.getTypeDeclaration(typeName);
+    }
+
+    public URL locateResource(String path) {
+        assert path != null;
+
+        /* assume that http:// and file:// are already URL-ized */
+        if(path.startsWith("http://") || path.startsWith("file://")) {
+            try {
+                return new URL(path);
+            }
+            catch(MalformedURLException e) {
+                throw new Jsr181ValidationException("The resource URL '" + path + "' could not be resolved.", e);
+            }
+        }
+        /* handle the relative case */
+        else {
+            File file = new File(_filePath, path);
+            try {
+                return file.toURL();
+            }
+            catch(MalformedURLException e) {
+                throw new Jsr181ValidationException("The resource URL '" + path +
+                    "' could not be loaded from the base path '" + _filePath + "'");
+            }
+        }        
+    }
+}

Added: beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/impl/ReflectionWsmServiceContext.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/impl/ReflectionWsmServiceContext.java?view=auto&rev=468987
==============================================================================
--- beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/impl/ReflectionWsmServiceContext.java (added)
+++ beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/generator/impl/ReflectionWsmServiceContext.java Sun Oct 29 12:53:07 2006
@@ -0,0 +1,53 @@
+package org.apache.beehive.wsm.processor.generator.impl;
+
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import org.apache.beehive.wsm.processor.generator.WsmServiceContext;
+import org.apache.beehive.wsm.exception.Jsr181ValidationException;
+import org.apache.beehive.common.glass.typesystem.env.CoreAnnotationProcessorEnv;
+import org.apache.beehive.common.glass.typesystem.env.Filer;
+
+/**
+ */
+public class ReflectionWsmServiceContext {
+
+    private String _filePath;
+    private CoreAnnotationProcessorEnv _env;
+
+    public ReflectionWsmServiceContext(CoreAnnotationProcessorEnv env, String filePath) {
+        _env = env;
+        _filePath = filePath;
+    }
+
+    public PrintWriter createTextFile(String path)
+        throws IOException {
+        Filer filer = _env.getFiler();
+        return filer.createTextFile(new File(path));
+    }
+
+    public Object resolveType(String typeName) {
+        assert typeName != null;
+        try {
+            return Class.forName(typeName);
+        }
+        catch(ClassNotFoundException e) {
+            throw new IllegalArgumentException("Unable to resolve type: " + typeName);
+        }
+    }
+
+    public URL locateResource(String path) {
+        assert path != null;
+        File file = new File(_filePath, path);
+        assert file != null;
+        try {
+            return file.toURL();
+        }
+        catch(MalformedURLException e) {
+            throw new IllegalArgumentException("Unable to create URL from path: " + file.getAbsolutePath());
+        }
+    }
+}
\ No newline at end of file

Added: beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/MetadataFormat.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/MetadataFormat.java?view=auto&rev=468987
==============================================================================
--- beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/MetadataFormat.java (added)
+++ beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/MetadataFormat.java Sun Oct 29 12:53:07 2006
@@ -0,0 +1,29 @@
+package org.apache.beehive.wsm.processor.model.factory;
+
+/**
+ * Enumeration of the supported ways in which to describe a web service.
+ */
+public enum MetadataFormat {
+    /**
+     * Supports describing the shape of a web service in Java 5 annotations.
+     */
+    MIRROR,
+
+    /**
+     * Supports describing the shape of a web service in Java 5 annotations parsed from a Java 1.4 class.
+     */
+    REFLECT,
+
+    /**
+     * Supports describing the shape of a web service from a WSDL.  This supports top-down service development.
+     */
+    WSDL;
+
+    public static MetadataFormat getFactoryType(String name) {
+        if("reflect".equals(name))
+            return REFLECT;
+        else if("wsdl".equals(name))
+            return WSDL;
+        else return MIRROR;
+    }
+}

Modified: beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/WsmServiceFactory.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/WsmServiceFactory.java?view=diff&rev=468987&r1=468986&r2=468987
==============================================================================
--- beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/WsmServiceFactory.java (original)
+++ beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/WsmServiceFactory.java Sun Oct 29 12:53:07 2006
@@ -19,6 +19,8 @@
 package org.apache.beehive.wsm.processor.model.factory;
 
 import org.apache.beehive.wsm.model.WsmService;
+import org.apache.beehive.wsm.processor.generator.WsmServiceContext;
+import org.apache.beehive.wsm.processor.ProcessorException;
 
 /**
  * <p>
@@ -30,7 +32,57 @@
  */
 public abstract class WsmServiceFactory {
 
-    public abstract WsmService create(String serviceBeanClassName,
-                                      TypeResolver typeResolver,
-                                      String baseLocation);
-}
+    private static final String FACTORY_MIRROR =
+        "org.apache.beehive.wsm.processor.model.factory.mirror.MirrorWsmServiceFactory";
+
+    private static final String FACTORY_REFLECTION =
+        "org.apache.beehive.wsm.processor.model.factory.reflection.ReflectionWsmServiceFactory";
+
+    /**
+     * <p>
+     * A factory used to create a processor that can determine the shape of a web service from
+     * a resource that describes a web service.  For example, a web service can be described by
+     * a Java 5 class decorated with WSM annotations, a Java 1.4 class decorated with WSM annotations,
+     * or a WSDL that describes a service.  Given a supported style of metadata, a {@link WsmServiceFactory}
+     * implementation is returned that can convert these descriptions into an instance of the WSM
+     * {@link org.apache.beehive.wsm.model.WsmService} JavaBean.
+     * </p>
+     * <p>
+     * A {@link org.apache.beehive.wsm.model.WsmService} can then be used to support generating
+     * resources / code needed to deploy a web service into a specific web service runtime.
+     * </p>
+     * @param metadataFormat an enumeration value describing the format of metadata used to describe a service
+     * @return the factory used to create a service's object model
+     */
+    public static WsmServiceFactory getInstance(MetadataFormat metadataFormat) {
+        String className = null;
+
+        if(metadataFormat == MetadataFormat.MIRROR)
+            className = FACTORY_MIRROR;
+        else if (metadataFormat == MetadataFormat.REFLECT)
+        	className = FACTORY_REFLECTION;
+        else throw new IllegalArgumentException("Can not create factory of type " + metadataFormat);
+
+        WsmServiceFactory factory = null;
+        try {
+            Class clazz = Class.forName(className);
+            factory = (WsmServiceFactory)clazz.newInstance();
+        }
+        catch(ClassNotFoundException e) {
+            throw new ProcessorException(e);
+        }
+        catch(InstantiationException e) {
+            throw new ProcessorException(e);
+        }
+        catch(IllegalAccessException e) {
+            throw new ProcessorException(e);
+        }
+
+        return factory;
+    }
+
+    protected WsmServiceFactory() {
+    }
+
+    public abstract WsmService create(WsmServiceContext wsmServiceContext, String serviceImplClassName);
+}
\ No newline at end of file

Modified: beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorWsmServiceFactory.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorWsmServiceFactory.java?view=diff&rev=468987&r1=468986&r2=468987
==============================================================================
--- beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorWsmServiceFactory.java (original)
+++ beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/mirror/MirrorWsmServiceFactory.java Sun Oct 29 12:53:07 2006
@@ -18,11 +18,9 @@
  */
 package org.apache.beehive.wsm.processor.model.factory.mirror;
 
-import java.io.File;
 import java.io.InputStream;
 import java.io.IOException;
 import java.net.URL;
-import java.net.MalformedURLException;
 import java.util.List;
 import javax.jws.WebService;
 import javax.jws.WebMethod;
@@ -31,12 +29,9 @@
 import javax.jws.WebParam;
 import javax.jws.HandlerChain;
 import javax.jws.soap.SOAPBinding;
-import javax.jws.soap.SOAPMessageHandler;
-import javax.jws.soap.SOAPMessageHandlers;
-import javax.jws.soap.InitParam;
 
 import org.apache.beehive.wsm.processor.model.factory.WsmServiceFactory;
-import org.apache.beehive.wsm.processor.model.factory.TypeResolver;
+import org.apache.beehive.wsm.processor.generator.WsmServiceContext;
 import org.apache.beehive.wsm.model.WsmService;
 import org.apache.beehive.wsm.model.WsmOperation;
 import org.apache.beehive.wsm.model.WsmParameter;
@@ -70,24 +65,22 @@
     private static final String SERVICE_SUFFIX = "Service";
     private static final String DEFAULT_WR_NAME = "return";
 
-    public WsmService create(String serviceBeanClassName,
-                             TypeResolver typeResolver,
-                             String baseLocation) {
+    public WsmService create(WsmServiceContext wsmServiceContext, String serviceImplClassName) {
 
         WsmService wsMetadata = new WsmService();
 
-        TypeDeclaration implDecl = (TypeDeclaration)typeResolver.resolveType(serviceBeanClassName);
+        TypeDeclaration implDecl = (TypeDeclaration)wsmServiceContext.resolveType(serviceImplClassName);
 
         TypeDeclaration endpointDecl = null;
 
         AnnotationInstance webService = AnnotationUtil.getAnnotation(implDecl, WebService.class.getName());
         String endpointInterface = AnnotationUtil.getStringValue(webService, "endpointInterface");
         if(endpointInterface != null && !endpointInterface.equals(""))
-            endpointDecl = (TypeDeclaration)typeResolver.resolveType(endpointInterface);
+            endpointDecl = (TypeDeclaration)wsmServiceContext.resolveType(endpointInterface);
 
         /* class-level annotations */
         if(endpointDecl != null) {
-            processClass(wsMetadata, endpointDecl, baseLocation);
+            processClass(wsmServiceContext, wsMetadata, endpointDecl);
 
             String serviceName = AnnotationUtil.getStringValue(webService, "serviceName");
             if(serviceName == null || serviceName.trim().length() == 0)
@@ -105,7 +98,7 @@
                 processMethod(wsMetadata, method);
         }
          else {
-            processClass(wsMetadata, implDecl, baseLocation);
+            processClass(wsmServiceContext, wsMetadata, implDecl);
 
             boolean allWebMethods = true;
             for(MethodDeclaration method: implDecl.getMethods()) {
@@ -123,7 +116,7 @@
                 */
                 AnnotationInstance webMethod = AnnotationUtil.getAnnotation(method, WebMethod.class.getName());
 
-                if(allWebMethods && acceptWebMethod(method, typeResolver))
+                if(allWebMethods && acceptWebMethod(wsmServiceContext, method))
                     processMethod(wsMetadata, method);
                 else if(webMethod != null)
                     processMethod(wsMetadata, method);
@@ -133,7 +126,7 @@
         return wsMetadata;
     }
 
-    private void processClass(WsmService wsMetadata, TypeDeclaration typeDecl, String baseLocation) {
+    private void processClass(WsmServiceContext wsmServiceContext, WsmService wsMetadata, TypeDeclaration typeDecl) {
         AnnotationInstance ws = AnnotationUtil.getAnnotation(typeDecl, WebService.class.getName());
 
         wsMetadata.setServiceClassName(typeDecl.getQualifiedName());
@@ -225,7 +218,7 @@
                  interface, the implementation's version wins */
         AnnotationInstance handlerChain = AnnotationUtil.getAnnotation(typeDecl, HandlerChain.class.getName());
         if(handlerChain != null)
-            configureHandlerChain(handlerChain, wsMetadata, baseLocation);
+            configureHandlerChain(wsmServiceContext, handlerChain, wsMetadata);
     }
 
     private void processMethod(WsmService wsMetadata, MethodDeclaration methodDecl) {
@@ -313,7 +306,7 @@
      * @throws IllegalHandlerConfigException when the given file does not exist, is invalid, or some other runtime error occurs
      *                                       during processing.
      */
-    private void configureHandlerChain(AnnotationInstance handlerChain, WsmService wsMetadata, String baseLocation) {
+    private void configureHandlerChain(WsmServiceContext wsmServiceContext, AnnotationInstance handlerChain, WsmService wsMetadata) {
         /*
         todo: need to figure out if URLs are the right thing to use here.  the spec says
         that URLs are relative (at the time of processing) or absolute.  how does
@@ -325,10 +318,9 @@
         String handlerChainFile = AnnotationUtil.getStringValue(handlerChain, "file");
         String chainName = AnnotationUtil.getStringValue(handlerChain, "name");
 
-        URL chainConfigURL = findResource(baseLocation, handlerChainFile);
+        URL chainConfigURL = wsmServiceContext.locateResource(handlerChainFile);
         if(null == chainConfigURL)
-            throw new IllegalHandlerConfigException("Can not resolve relative URL: " +
-                                                    handlerChainFile + " from directory: " + baseLocation);
+            throw new IllegalHandlerConfigException("Unable to find handler chain file: " + chainConfigURL);
 
         if(null == chainName)
             throw new Jsr181ValidationException("@HandlerChain: URL for handler-chain config required");
@@ -355,33 +347,6 @@
         }
     }
 
-    private static URL findResource(String baseLocation, String resourceName) {
-        /* todo: compost up into a base class */
-        assert resourceName != null;
-
-        /* handle the URL case */
-        if(resourceName.startsWith("http://") || resourceName.startsWith("file://")) {
-            try {
-                return new URL(resourceName);
-            }
-            catch(MalformedURLException e) {
-                throw new Jsr181ValidationException("The resource URL '" + resourceName + "' could not be resolved.", e);
-            }
-        }
-        /* todo: handle absolute URLs.  what would these be absolute to? */
-        /* handle the relative case */
-        else {
-            File file = new File(baseLocation, resourceName);
-            try {
-                return file.toURL();
-            }
-            catch(MalformedURLException e) {
-                throw new Jsr181ValidationException("The resource URL '" + resourceName +
-                    "' could not be loaded from the base path '" + baseLocation + "'");
-            }
-        }
-    }
-
     private static String computeTargetNamespace(String className) {
         /* todo: compost up into a base class */
         if(className == null || className.length() == 0)
@@ -395,8 +360,8 @@
         return "http://" + targetNamespace;
     }
 
-    private boolean acceptWebMethod(MethodDeclaration webMethod, TypeResolver typeResolver) {
-        TypeDeclaration objectDecl = (TypeDeclaration)typeResolver.resolveType("java.lang.Object");
+    private boolean acceptWebMethod(WsmServiceContext wsmServiceContext, MethodDeclaration webMethod) {
+        TypeDeclaration objectDecl = (TypeDeclaration)wsmServiceContext.resolveType("java.lang.Object");
 
         MethodDeclaration[] methods = objectDecl.getMethods();
         for(int i = 0; i < methods.length; i++) {

Modified: beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/reflection/ReflectionWsmServiceFactory.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/reflection/ReflectionWsmServiceFactory.java?view=diff&rev=468987&r1=468986&r2=468987
==============================================================================
--- beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/reflection/ReflectionWsmServiceFactory.java (original)
+++ beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/reflection/ReflectionWsmServiceFactory.java Sun Oct 29 12:53:07 2006
@@ -18,18 +18,13 @@
  */
 package org.apache.beehive.wsm.processor.model.factory.reflection;
 
-import org.apache.beehive.wsm.processor.model.factory.WsmServiceFactory;
-import org.apache.beehive.wsm.processor.model.factory.TypeResolver;
-import org.apache.beehive.wsm.model.WsmService;
-import org.apache.beehive.wsm.model.WsmParameter;
-import org.apache.beehive.wsm.model.WsmOperation;
-import org.apache.beehive.wsm.model.WsmSoapMessageHandler;
-import org.apache.beehive.wsm.model.WsmSoapBinding;
-import org.apache.beehive.wsm.exception.Jsr181ValidationException;
-import org.apache.beehive.wsm.exception.IllegalHandlerConfigException;
-import org.apache.beehive.wsm.util.HandlerChainParser;
-import org.codehaus.annogen.view.ReflectAnnoViewer;
-
+import java.io.InputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.URL;
+import java.util.List;
+import java.util.LinkedList;
 import javax.jws.WebService;
 import javax.jws.WebMethod;
 import javax.jws.Oneway;
@@ -41,389 +36,365 @@
 import javax.jws.soap.SOAPMessageHandlers;
 import javax.jws.soap.InitParam;
 
-import java.util.Vector;
-import java.util.List;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.io.File;
-import java.io.InputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.net.MalformedURLException;   
+import org.apache.beehive.wsm.processor.model.factory.WsmServiceFactory;
+import org.apache.beehive.wsm.processor.generator.WsmServiceContext;
+import org.apache.beehive.wsm.model.WsmService;
+import org.apache.beehive.wsm.model.WsmParameter;
+import org.apache.beehive.wsm.model.WsmOperation;
+import org.apache.beehive.wsm.model.WsmSoapMessageHandler;
+import org.apache.beehive.wsm.model.WsmSoapBinding;
+import org.apache.beehive.wsm.exception.Jsr181ValidationException;
+import org.apache.beehive.wsm.exception.IllegalHandlerConfigException;
+import org.apache.beehive.wsm.util.HandlerChainParser;
+import org.codehaus.annogen.view.ReflectAnnoViewer;
 
 /**
- * 
+ *
  */
-public class ReflectionWsmServiceFactory extends WsmServiceFactory {
+public class ReflectionWsmServiceFactory
+    extends WsmServiceFactory {
 
-	private ReflectAnnoViewer annoViewer;
+    private ReflectAnnoViewer annoViewer;
 
-	public WsmService create(String serviceBeanClassName,
-			TypeResolver typeResolver, String baseLocation) {
+    public WsmService create(WsmServiceContext context, String serviceImplClassName) {
 
-		Class serviceClass = (Class) typeResolver
-				.resolveType(serviceBeanClassName);
-		WsmService wsmService = new WsmService();
-		annoViewer = ReflectAnnoViewer.Factory.create();
-
-		WebService webService = (WebService) annoViewer.getAnnotation(
-				WebService.class, serviceClass);
-
-		// check for ServiceEndpointInterface
-		if (webService.endpointInterface() != null
-				&& !webService.endpointInterface().equals("")) {
-			Class endpointClass = (Class)typeResolver.resolveType(webService.endpointInterface());
-
-			processEndpointInterface(wsmService,endpointClass,serviceClass,webService);
-
-                        // all public methods should be exposed
-		        // also the methods in the endpoint interface are taken instead
-                        // of the implementing class.
-			processMethods(wsmService, endpointClass, true);
-		
-
-			SOAPMessageHandlers soapMsgHandlers  = (SOAPMessageHandlers)annoViewer.getAnnotation(
-                                SOAPMessageHandlers.class, serviceClass);
-
-                        // implementing class takes precedence over enpoint interface if both
-                        // have defined @SOAPMessageHandlers annotations
-                        if (soapMsgHandlers == null){
-                                // implementing class does not define so process the endpoint interface
-                        	processSoapMessageHandlers(wsmService, endpointClass);
-                        }else{
-                        	processSoapMessageHandlers(wsmService, serviceClass);
-			}
-	
-			HandlerChain handlerChain = (HandlerChain)annoViewer.getAnnotation(
-                                HandlerChain.class, serviceClass);
-
-			// implementing class takes precedence over enpoint interface if both
-                        // have defined @HandlerChain annotations 
-			if (handlerChain == null){
- 				// implementing class does not define so process the endpoint interface
-				processHandlerChain(wsmService, endpointClass,baseLocation);
-			}else{
-				processHandlerChain(wsmService, serviceClass,baseLocation);
-			}
-		        	
-		} else {
-			processServiceClass(wsmService, serviceClass, webService);
-			processMethods(wsmService, serviceClass, false);
-			processSoapMessageHandlers(wsmService,serviceClass);
-			processHandlerChain(wsmService,serviceClass,baseLocation);
-		}
+        Class serviceClass = (Class) context.resolveType(serviceImplClassName);
+        WsmService wsmService = new WsmService();
+        annoViewer = ReflectAnnoViewer.Factory.create();
+
+        WebService webService = (WebService) annoViewer.getAnnotation(
+            WebService.class, serviceClass);
+
+        // check for ServiceEndpointInterface
+        if (webService.endpointInterface() != null
+            && !webService.endpointInterface().equals("")) {
+            Class endpointClass = (Class) context.resolveType(webService.endpointInterface());
+
+            processEndpointInterface(wsmService, endpointClass, serviceClass, webService);
+
+            // all public methods should be exposed
+            // also the methods in the endpoint interface are taken instead
+            // of the implementing class.
+            processMethods(wsmService, endpointClass, true);
+
+
+            SOAPMessageHandlers soapMsgHandlers = (SOAPMessageHandlers) annoViewer.getAnnotation(
+                SOAPMessageHandlers.class, serviceClass);
+
+            // implementing class takes precedence over enpoint interface if both
+            // have defined @SOAPMessageHandlers annotations
+            if (soapMsgHandlers == null) {
+                // implementing class does not define so process the endpoint interface
+                processSoapMessageHandlers(wsmService, endpointClass);
+            } else {
+                processSoapMessageHandlers(wsmService, serviceClass);
+            }
+
+            HandlerChain handlerChain = (HandlerChain) annoViewer.getAnnotation(
+                HandlerChain.class, serviceClass);
+
+            // implementing class takes precedence over enpoint interface if both
+            // have defined @HandlerChain annotations
+            if (handlerChain == null) {
+                // implementing class does not define so process the endpoint interface
+                processHandlerChain(context, wsmService, endpointClass);
+            } else {
+                processHandlerChain(context, wsmService, serviceClass);
+            }
+
+        } else {
+            processServiceClass(wsmService, serviceClass, webService);
+            processMethods(wsmService, serviceClass, false);
+            processSoapMessageHandlers(wsmService, serviceClass);
+            processHandlerChain(context, wsmService, serviceClass);
+        }
 
-		return wsmService;
-	}
+        return wsmService;
+    }
 
-	private void processEndpointInterface(WsmService wsmService, Class endpointClass, Class serviceClass,
-			WebService webServiceFromImpl){
+    private void processEndpointInterface(WsmService wsmService, Class endpointClass, Class serviceClass,
+                                          WebService webServiceFromImpl) {
 
-		// The implementation class can contain only endpointInterface and serviceName
-		extractServiceName(wsmService,webServiceFromImpl);
-                
-		WebService webService = (WebService) annoViewer.getAnnotation(
-				WebService.class, endpointClass);
-
-		if(webService != null ){
-			// name
-        	        extractName(wsmService,webService,endpointClass);
-			
-			// targetNamespace
-                	extractTargetNamespace(wsmService,webService);
-
-                	// wsdl location , default is none
-                	wsmService.setWsdlLocation(webService.wsdlLocation());
-		}
-		processSoapBindings(wsmService,endpointClass);
-		
-	}
-	
-	/**
-	 * Processing is done based on the
-	 * 
-	 * @WebService annotation
-	 */
-	private void processServiceClass(WsmService wsmService, Class serviceClass,
-			WebService webService) {
-		// name
-                extractName(wsmService,webService,serviceClass);
-
-		// serviceName
-		extractServiceName(wsmService,webService);
+        // The implementation class can contain only endpointInterface and serviceName
+        extractServiceName(wsmService, webServiceFromImpl);
 
-		// targetNamespace
-		extractTargetNamespace(wsmService,webService);
+        WebService webService = (WebService) annoViewer.getAnnotation(
+            WebService.class, endpointClass);
 
-		// wsdl location , default is none
-		wsmService.setWsdlLocation(webService.wsdlLocation());
+        if (webService != null) {
+            // name
+            extractName(wsmService, webService, endpointClass);
 
-		processSoapBindings(wsmService,serviceClass);
+            // targetNamespace
+            extractTargetNamespace(wsmService, webService);
 
-	}
+            // wsdl location , default is none
+            wsmService.setWsdlLocation(webService.wsdlLocation());
+        }
+        processSoapBindings(wsmService, endpointClass);
 
-	private void extractName(WsmService wsmService, WebService webService, Class annotatedClass){
-		if (webService.name() != null && !webService.name().trim().equals("")) {
-			wsmService.setName(webService.name());
-		} else {
-			wsmService.setName(annotatedClass.getSimpleName());
-		}
-	}
+    }
 
-	private void extractServiceName(WsmService wsmService,WebService webService){
-		 if (webService.serviceName() != null
-                                && !webService.serviceName().trim().equals("")) {
-                        wsmService.setServiceName(webService.serviceName());
-                } else {
-                        wsmService.setServiceName(wsmService.getName().concat("Service"));
-                }
+    /**
+     * Processing is done based on the
+     *
+     * @WebService annotation
+     */
+    private void processServiceClass(WsmService wsmService, Class serviceClass,
+                                     WebService webService) {
+        // name
+        extractName(wsmService, webService, serviceClass);
+
+        // serviceName
+        extractServiceName(wsmService, webService);
 
-	}
+        // targetNamespace
+        extractTargetNamespace(wsmService, webService);
+
+        // wsdl location , default is none
+        wsmService.setWsdlLocation(webService.wsdlLocation());
 
+        processSoapBindings(wsmService, serviceClass);
 
-	private void extractTargetNamespace(WsmService wsmService,WebService webService){
-		if (webService.targetNamespace() != null
-                                && !webService.targetNamespace().trim().equals("")) {
-                        wsmService.setTargetNamespace(webService.targetNamespace());
-                } else {
-                        wsmService.setTargetNamespace("http://" + "todo");
+    }
+
+    private void extractName(WsmService wsmService, WebService webService, Class annotatedClass) {
+        if (webService.name() != null && !webService.name().trim().equals("")) {
+            wsmService.setName(webService.name());
+        } else {
+            wsmService.setName(annotatedClass.getSimpleName());
+        }
+    }
+
+    private void extractServiceName(WsmService wsmService, WebService webService) {
+        if (webService.serviceName() != null
+            && !webService.serviceName().trim().equals("")) {
+            wsmService.setServiceName(webService.serviceName());
+        } else {
+            wsmService.setServiceName(wsmService.getName().concat("Service"));
+        }
+
+    }
+
+
+    private void extractTargetNamespace(WsmService wsmService, WebService webService) {
+        if (webService.targetNamespace() != null
+            && !webService.targetNamespace().trim().equals("")) {
+            wsmService.setTargetNamespace(webService.targetNamespace());
+        } else {
+            wsmService.setTargetNamespace("http://" + "todo");
+        }
+    }
+
+    private void processMethods(WsmService wsmService, Class serviceClass, boolean exposeAllPublicMethods) {
+
+        LinkedList<Method> selectedMethods = new LinkedList<Method>();
+        LinkedList<Method> allPublicMethods = new LinkedList<Method>();
+
+        // Iterate through all the methods and find if they are public
+        for (Method method : serviceClass.getDeclaredMethods()) {
+            if (Modifier.isPublic(method.getModifiers())) {
+
+                // The rule is that if there are methods marked by the
+                // @WebMethod,
+                // then only those are exposed, if not all public methods are
+                // exposed.
+                allPublicMethods.add(method);
+
+                if (!exposeAllPublicMethods) {
+                    // Checking for @WebMethod if it's not an Endpoint interface
+                    WebMethod webMethod = (WebMethod) annoViewer.getAnnotation(
+                        WebMethod.class, method);
+                    if (webMethod != null) {
+                        selectedMethods.add(method);
+                    }
                 }
-	}
+            }
+        }
 
-	private void processMethods(WsmService wsmService, Class serviceClass,boolean exposeAllPublicMethods) {
+        // The class has no marked methods, so expose all
+        if (selectedMethods.size() == 0) {
+            exposeAllPublicMethods = true;
+        }
 
-		Vector<Method> selectedMethods = new Vector();
-		Vector<Method> allPublicMethods = new Vector();
+        // If it's an Endpoint interface then all methods are exposed
+        // whether marked with @WebMethod or not
+        if (exposeAllPublicMethods) {
+            for (Method method : allPublicMethods) {
+                processMethod(method, wsmService, null);
+            }
+        } else {
+            for (Method method : selectedMethods) {
+                WebMethod webMethod = (WebMethod) annoViewer.getAnnotation(
+                    WebMethod.class, method);
+                processMethod(method, wsmService, webMethod);
+            }
+        }
+    }
 
-		// Iterate through all the methods and find if they are public
-		for (Method method : serviceClass.getDeclaredMethods()) {
-			if (Modifier.isPublic(method.getModifiers())) {
-
-				// The rule is that if there are methods marked by the
-				// @WebMethod,
-				// then only those are exposed, if not all public methods are
-				// exposed.
-				allPublicMethods.add(method);
-
-				if (!exposeAllPublicMethods) {
-					// Checking for @WebMethod if it's not an Endpoint interface
-					WebMethod webMethod = (WebMethod) annoViewer.getAnnotation(
-							WebMethod.class, method);
-					if (webMethod != null) {
-						selectedMethods.add(method);
-					}
-				}
-			}
-		}
-
-		// The class has no marked methods, so expose all
-		if (selectedMethods.size() == 0) {
-			exposeAllPublicMethods = true;
-		}
-
-		// If it's an Endpoint interface then all methods are exposed
-		// whether marked with @WebMethod or not
-		if (exposeAllPublicMethods) {
-			for(Method method : allPublicMethods){
-				processMethod(method,wsmService,null);
-			}
-		} else {
-			for(Method method : selectedMethods){
-				WebMethod webMethod = (WebMethod) annoViewer.getAnnotation(
-						WebMethod.class, method);
-				processMethod(method,wsmService,webMethod);
-			}
-		}
-	}
+    private void processMethod(Method method, WsmService wsmService,
+                               WebMethod webMethod) {
+        // ============ @ WebMethod ======================
+        WsmOperation wsmOperation = new WsmOperation();
+        wsmOperation.setJavaReturnType(method.getReturnType().toString());
+        wsmOperation.setJavaMethodName(method.getName());
+
+        if (webMethod != null) {
+            wsmOperation.setAction(webMethod.action());
+            wsmOperation.setOperationName(webMethod.operationName());
+        }
 
-	private void processMethod(Method method, WsmService wsmService,
-			WebMethod webMethod) {
-		// ============ @ WebMethod ======================
-		WsmOperation wsmOperation = new WsmOperation();
-		wsmOperation.setJavaReturnType(method.getReturnType().toString());
-		wsmOperation.setJavaMethodName(method.getName());
-
-		if (webMethod != null) {
-			wsmOperation.setAction(webMethod.action());
-			wsmOperation.setOperationName(webMethod.operationName());
-		}
-
-		if (wsmOperation.getOperationName() == null
-				|| wsmOperation.getOperationName().length() == 0) {
-			wsmOperation.setOperationName(method.getName());
-		}
-
-		if (wsmOperation.getAction() == null
-				|| wsmOperation.getAction().length() == 0) {
-			wsmOperation.setAction("");
-		}
-
-		// ============ @ Oneway ======================
-		Oneway oneway = (Oneway) annoViewer.getAnnotation(Oneway.class,
-				method);
-		if (oneway != null) {
-			wsmOperation.setOneWay(true);
-		}
-
-		// ============ @ WebResult ======================
-		WebResult webResult = (WebResult) annoViewer.getAnnotation(
-				WebResult.class, method);
-		if (webResult != null) {
-			wsmOperation.setName(webResult.name());
-			wsmOperation.setTargetNamespace(webResult.targetNamespace());
-		} else {
-			wsmOperation.setName("return");
-			wsmOperation.setTargetNamespace(wsmService.getTargetNamespace());
-		}
-
-		// ============ @ WebParam ======================
-		int counter = 0;
-		for (Class paramClass : method.getParameterTypes()) {
-			WsmParameter wsParam = new WsmParameter();
-
-			wsParam.setJavaType(paramClass.toString());
-			// the regular APIs don't reflect on the params name
-			wsParam.setName("Param" + counter);
-			wsParam.setMode(WebParam.Mode.IN);
-
-			WebParam webParam = (WebParam) annoViewer
-					.getAnnotation(WebParam.class,method,counter);
-			if (webParam != null) {
-				if (webParam != null && !webParam.name().equals("")) {
-					wsParam.setName(webParam.name());
-				}
-				wsParam.setTargetNamespace(webParam.targetNamespace());
-				wsParam.setMode(webParam.mode());
-				wsParam.setHeader(webParam.header());
-			}
-
-			if (wsParam.getTargetNamespace() == null
-					|| wsParam.getTargetNamespace().trim().length() == 0) {
-				wsParam.setTargetNamespace(wsmService.getTargetNamespace());
-			}
-
-			wsmOperation.addParameter(wsParam);
-			counter++;
-		}
+        if (wsmOperation.getOperationName() == null
+            || wsmOperation.getOperationName().length() == 0) {
+            wsmOperation.setOperationName(method.getName());
+        }
 
-		wsmService.addOperation(wsmOperation); 
-	}
+        if (wsmOperation.getAction() == null
+            || wsmOperation.getAction().length() == 0) {
+            wsmOperation.setAction("");
+        }
+
+        // ============ @ Oneway ======================
+        Oneway oneway = (Oneway) annoViewer.getAnnotation(Oneway.class,
+                                                          method);
+        if (oneway != null) {
+            wsmOperation.setOneWay(true);
+        }
+
+        // ============ @ WebResult ======================
+        WebResult webResult = (WebResult) annoViewer.getAnnotation(
+            WebResult.class, method);
+        if (webResult != null) {
+            wsmOperation.setName(webResult.name());
+            wsmOperation.setTargetNamespace(webResult.targetNamespace());
+        } else {
+            wsmOperation.setName("return");
+            wsmOperation.setTargetNamespace(wsmService.getTargetNamespace());
+        }
 
-	private void processSoapBindings(WsmService wsmService, Class serviceClass){
-		// SOAP binding
-                SOAPBinding soapBinding = (SOAPBinding) annoViewer.getAnnotation(
-                                SOAPBinding.class, serviceClass);
-
-                if (soapBinding != null) {
-                        WsmSoapBinding soapBindingInfo = new WsmSoapBinding();
-                        soapBindingInfo.setStyle(soapBinding.style());
-                        soapBindingInfo.setUse(soapBinding.use());
-                        soapBindingInfo.setParameterStyle(soapBinding.parameterStyle());
-                        wsmService.setSoapBinding(soapBindingInfo);
+        // ============ @ WebParam ======================
+        int counter = 0;
+        for (Class paramClass : method.getParameterTypes()) {
+            WsmParameter wsParam = new WsmParameter();
+
+            wsParam.setJavaType(paramClass.toString());
+            // the regular APIs don't reflect on the params name
+            wsParam.setName("Param" + counter);
+            wsParam.setMode(WebParam.Mode.IN);
+
+            WebParam webParam = (WebParam) annoViewer
+                .getAnnotation(WebParam.class, method, counter);
+            if (webParam != null) {
+                if (webParam != null && !webParam.name().equals("")) {
+                    wsParam.setName(webParam.name());
                 }
+                wsParam.setTargetNamespace(webParam.targetNamespace());
+                wsParam.setMode(webParam.mode());
+                wsParam.setHeader(webParam.header());
+            }
+
+            if (wsParam.getTargetNamespace() == null
+                || wsParam.getTargetNamespace().trim().length() == 0) {
+                wsParam.setTargetNamespace(wsmService.getTargetNamespace());
+            }
 
-	}
-	
-	private void processHandlerChain(WsmService wsmService, Class serviceClass,  String baseLocation) {
+            wsmOperation.addParameter(wsParam);
+            counter++;
+        }
+
+        wsmService.addOperation(wsmOperation);
+    }
 
-		HandlerChain handlerChain = (HandlerChain)annoViewer.getAnnotation(
-                                HandlerChain.class, serviceClass);
-	
-		if(handlerChain == null){
-			return;
-		}
-
-	        String handlerChainFile = handlerChain.file();
-        	String chainName = handlerChain.name();
-
-       		 URL chainConfigURL = findResource(baseLocation, handlerChainFile);
-        	if(null == chainConfigURL)
-            		throw new IllegalHandlerConfigException("Can not resolve relative URL: " +
-                                                    handlerChainFile + " from directory: " + baseLocation);
-
-       		 if(null == chainName)
-           		 throw new Jsr181ValidationException("@HandlerChain: URL for handler-chain config required");
-	
-		// The spec doesn't allow to combine @SOAPMessageHandlers with HandlerChain
-        	if(!wsmService.getSoapHandlers().isEmpty())
-            		throw new Jsr181ValidationException("@HandlerChain: annotation doesn't allow for @SOAPMessageHandlers");
-
-	        final String xmlResourcePath = chainConfigURL.toString();
-        	InputStream xmlInputStream = null;
-	        try {
-        	    xmlInputStream = chainConfigURL.openStream();
-
-	            List soapHandlers = HandlerChainParser.getInstance().parse(xmlInputStream, xmlResourcePath);
-        	    for(int i = 0; i < soapHandlers.size(); i++) {
-                	wsmService.addSoapHandler((WsmSoapMessageHandler)soapHandlers.get(i));
-            	    }
-        	}
-	        catch(Exception e) {
-        	    throw new IllegalHandlerConfigException("Exception parsing handler config file.  Cause: " + e, e);
-	        }
-        	finally {
-	            try {if(xmlInputStream != null) xmlInputStream.close();} catch(IOException ignore) {/**/}
-        	}
+    private void processSoapBindings(WsmService wsmService, Class serviceClass) {
+        // SOAP binding
+        SOAPBinding soapBinding = (SOAPBinding) annoViewer.getAnnotation(
+            SOAPBinding.class, serviceClass);
+
+        if (soapBinding != null) {
+            WsmSoapBinding soapBindingInfo = new WsmSoapBinding();
+            soapBindingInfo.setStyle(soapBinding.style());
+            soapBindingInfo.setUse(soapBinding.use());
+            soapBindingInfo.setParameterStyle(soapBinding.parameterStyle());
+            wsmService.setSoapBinding(soapBindingInfo);
+        }
 
-	}
+    }
 
-	private void processSoapMessageHandlers(WsmService wsmService, Class serviceClass){
-		SOAPMessageHandlers soapMessageHandlers = (SOAPMessageHandlers)annoViewer.getAnnotation(SOAPMessageHandlers.class,serviceClass);
-        	if(soapMessageHandlers ==  null) {
-			return;
-		}
-            	for(SOAPMessageHandler soapMessageHandlerAnnot : soapMessageHandlers.value()) {
-               		WsmSoapMessageHandler soapMessageHandlerInfo = new WsmSoapMessageHandler();
-
-               		String className = soapMessageHandlerAnnot.className();
-        	        soapMessageHandlerInfo.setClassName(className);
-
-                	if(soapMessageHandlerAnnot.name() != null && soapMessageHandlerAnnot.name().length() > 0){
-        	            soapMessageHandlerInfo.setName(soapMessageHandlerAnnot.name());
-	                }else{
-			    soapMessageHandlerInfo.setName(className);
-			}
-
-	                for(InitParam p : soapMessageHandlerAnnot.initParams()){
-        	            soapMessageHandlerInfo.addInitParam(p.name(), p.value());
-			}
-
-	                String[] roles = soapMessageHandlerAnnot.roles();
-        	        for(String role : roles){
-	                    soapMessageHandlerInfo.addRole(role);
-			}
-        	
-		        for(String header : soapMessageHandlerAnnot.headers()){
-	                    soapMessageHandlerInfo.addHeader(header);
-			}
-	                wsmService.addSoapHandler(soapMessageHandlerInfo);
-           	 }
-	}
+    private void processHandlerChain(WsmServiceContext wsmServiceContext,
+                                     WsmService wsmService,
+                                     Class serviceClass) {
+        HandlerChain handlerChain = (HandlerChain) annoViewer.getAnnotation(
+            HandlerChain.class, serviceClass);
 
-	private static URL findResource(String baseLocation, String resourceName) {
-        	/* todo: compost up into a base class */
-        	assert resourceName != null;
-
-        	/* handle the URL case */
-        	if(resourceName.startsWith("http://") || resourceName.startsWith("file://")) {
-            		try {
-                		return new URL(resourceName);
-        	    	}
-	            	catch(MalformedURLException e) {
-                		throw new Jsr181ValidationException("The resource URL '" + resourceName + "' could not be resolved.", e);
-            		}
-        	}
-       		/* todo: handle absolute URLs.  what would these be absolute to? */
-       		/* handle the relative case */
-       		else {
-           	 File file = new File(baseLocation, resourceName);
-           	 try {
-                	return file.toURL();
-            	}
-           	 catch(MalformedURLException e) {
-                	throw new Jsr181ValidationException("The resource URL '" + resourceName +
-                   	 "' could not be loaded from the base path '" + baseLocation + "'");
-               }
+        if (handlerChain == null) {
+            return;
         }
+
+        String handlerChainFile = handlerChain.file();
+        String chainName = handlerChain.name();
+
+        URL chainConfigURL = wsmServiceContext.locateResource(handlerChainFile);
+        if (null == chainConfigURL)
+            throw new IllegalHandlerConfigException("Unable to find handler chain file: " + chainConfigURL);
+
+        if (null == chainName)
+            throw new Jsr181ValidationException("@HandlerChain: URL for handler-chain config required");
+
+        // The spec doesn't allow to combine @SOAPMessageHandlers with HandlerChain
+        if (!wsmService.getSoapHandlers().isEmpty())
+            throw new Jsr181ValidationException("@HandlerChain: annotation doesn't allow for @SOAPMessageHandlers");
+
+        final String xmlResourcePath = chainConfigURL.toString();
+        InputStream xmlInputStream = null;
+        try {
+            xmlInputStream = chainConfigURL.openStream();
+
+            List soapHandlers = HandlerChainParser.getInstance().parse(xmlInputStream, xmlResourcePath);
+            for (int i = 0; i < soapHandlers.size(); i++) {
+                wsmService.addSoapHandler((WsmSoapMessageHandler) soapHandlers.get(i));
+            }
+        }
+        catch (Exception e) {
+            throw new IllegalHandlerConfigException("Exception parsing handler config file.  Cause: " + e, e);
+        }
+        finally {
+            try {
+                if (xmlInputStream != null) xmlInputStream.close();
+            } catch (IOException ignore) {/**/}
+        }
+
     }
+
+    private void processSoapMessageHandlers(WsmService wsmService, Class serviceClass) {
+        SOAPMessageHandlers soapMessageHandlers = (SOAPMessageHandlers) annoViewer.getAnnotation(SOAPMessageHandlers.class, serviceClass);
+        if (soapMessageHandlers == null) {
+            return;
+        }
+        for (SOAPMessageHandler soapMessageHandlerAnnot : soapMessageHandlers.value()) {
+            WsmSoapMessageHandler soapMessageHandlerInfo = new WsmSoapMessageHandler();
+
+            String className = soapMessageHandlerAnnot.className();
+            soapMessageHandlerInfo.setClassName(className);
+
+            if (soapMessageHandlerAnnot.name() != null && soapMessageHandlerAnnot.name().length() > 0) {
+                soapMessageHandlerInfo.setName(soapMessageHandlerAnnot.name());
+            } else {
+                soapMessageHandlerInfo.setName(className);
+            }
+
+            for (InitParam p : soapMessageHandlerAnnot.initParams()) {
+                soapMessageHandlerInfo.addInitParam(p.name(), p.value());
+            }
+
+            String[] roles = soapMessageHandlerAnnot.roles();
+            for (String role : roles) {
+                soapMessageHandlerInfo.addRole(role);
+            }
+
+            for (String header : soapMessageHandlerAnnot.headers()) {
+                soapMessageHandlerInfo.addHeader(header);
+            }
+            wsmService.addSoapHandler(soapMessageHandlerInfo);
+        }
+	}
 }

Modified: beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/wsdl/WsdlWsmServiceFactory.java
URL: http://svn.apache.org/viewvc/beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/wsdl/WsdlWsmServiceFactory.java?view=diff&rev=468987&r1=468986&r2=468987
==============================================================================
--- beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/wsdl/WsdlWsmServiceFactory.java (original)
+++ beehive/wsm/trunk/src/core/org/apache/beehive/wsm/processor/model/factory/wsdl/WsdlWsmServiceFactory.java Sun Oct 29 12:53:07 2006
@@ -18,9 +18,9 @@
  */
 package org.apache.beehive.wsm.processor.model.factory.wsdl;
 
-import org.apache.beehive.wsm.processor.model.factory.WsmServiceFactory;
-import org.apache.beehive.wsm.processor.model.factory.TypeResolver;
 import org.apache.beehive.wsm.model.WsmService;
+import org.apache.beehive.wsm.processor.model.factory.WsmServiceFactory;
+import org.apache.beehive.wsm.processor.generator.WsmServiceContext;
 
 /**
  * Factory for constructing a {@link WsmService} object from a WSDL.
@@ -28,12 +28,9 @@
 class WsdlWsmServiceFactory
     extends WsmServiceFactory {
 
-    public WsmService create(String serviceBeanClassName,
-                             TypeResolver typeResolver,
-                             String baseLocation) {
-
-        throw new UnsupportedOperationException("Support for constructing a WsmService object " +
-                "from a WSDL is not yet implemented");
+    public WsmService create(WsmServiceContext wsmServiceContext, String serviceImplClassName) {
+        throw new UnsupportedOperationException
+            ("Support for constructing a WsmService object from a WSDL is not yet implemented");
     }
 
 }