Author: mmerz
Date: Fri Feb 18 13:22:09 2005
New Revision: 154351

URL: http://svn.apache.org/viewcvs?view=rev&rev=154351
Log:
New Jsr181ObjectModelStore encapsulates knowledge of how and where to persist 
object models. A few more tweaks are needed in this context, mostly to clean up 
WsmAnnotationProcessor.
Also removed some dead code.


Added:
    
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181ObjectModelStore.java
Modified:
    
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorEndpointInterfaceTest.java
    
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorTest.java
    
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDL2AnnotatedJavaTest.java
    
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessorTest.java
    
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedWebServiceDeploymentHandler.java
    
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AuthenticationHandler.java
    
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/ControlProvider.java
    
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/BeehiveWsTypeMetadata.java
    
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181TypeMetadataImpl.java
    
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorEndpointInterfaceTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorEndpointInterfaceTest.java?view=diff&r1=154350&r2=154351
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorEndpointInterfaceTest.java
 (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorEndpointInterfaceTest.java
 Fri Feb 18 13:22:09 2005
@@ -22,8 +22,7 @@
 
 import org.apache.beehive.wsm.jsr181.model.BarTestCase;
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsParameterMetadata;
-import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181TypeMetadataImpl;
-//import 
org.apache.beehive.wsm.jsr181.processor.reflection.WsmReflectionAnnotationProcessor;
+import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181ObjectModelStore;
 
 /**
  * Test case verifies that a source file can be read and its annotations can be
@@ -35,7 +34,7 @@
     public void setUp() throws Exception {
 
         // check if we have an object model
-        objectModel = Jsr181TypeMetadataImpl.load(Class.forName(CLASSNAME));
+        objectModel = Jsr181ObjectModelStore.load(Class.forName(CLASSNAME));
         if (null == objectModel) {
             throw new Exception ("No object model found.");
         }

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorTest.java?view=diff&r1=154350&r2=154351
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorTest.java
 (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessorTest.java
 Fri Feb 18 13:22:09 2005
@@ -21,8 +21,7 @@
 import com.sun.tools.apt.Main;
 import org.apache.beehive.wsm.jsr181.model.FooTestCase;
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsParameterMetadata;
-import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181TypeMetadataImpl;
-//import 
org.apache.beehive.wsm.jsr181.processor.reflection.WsmReflectionAnnotationProcessor;
+import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181ObjectModelStore;
 
 /**
  * Test case verifies that a source file can be read and its annotations can be
@@ -34,7 +33,7 @@
     public void setUp() throws Exception {
 
         // check if we have an object model
-        objectModel = Jsr181TypeMetadataImpl.load(Class.forName(CLASSNAME));
+        objectModel = Jsr181ObjectModelStore.load(Class.forName(CLASSNAME));
 
         if (null == objectModel) {
             throw new Exception ("No object model found.");

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDL2AnnotatedJavaTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDL2AnnotatedJavaTest.java?view=diff&r1=154350&r2=154351
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDL2AnnotatedJavaTest.java
 (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/WSDL2AnnotatedJavaTest.java
 Fri Feb 18 13:22:09 2005
@@ -48,7 +48,7 @@
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsTypeMetadata;
 import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181MethodMetadataImpl;
 import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181ParameterMetadataImpl;
-import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181TypeMetadataImpl;
+//import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181TypeMetadataImpl;
 import org.apache.beehive.wsm.jsr181.model.wsdl.XmlBeanWSDLProcessor;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;

Modified: 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessorTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessorTest.java?view=diff&r1=154350&r2=154351
==============================================================================
--- 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessorTest.java
 (original)
+++ 
incubator/beehive/trunk/wsm/drt/tests/org/apache/beehive/wsm/jsr181/wsdl/XmlBeanWSDLProcessorTest.java
 Fri Feb 18 13:22:09 2005
@@ -39,9 +39,8 @@
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsMethodMetadata;
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsParameterMetadata;
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsTypeMetadata;
-import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181TypeMetadataImpl;
+import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181ObjectModelStore;
 import org.apache.beehive.wsm.jsr181.model.wsdl.XmlBeanWSDLProcessor;
-//import 
org.apache.beehive.wsm.jsr181.processor.reflection.WsmReflectionAnnotationProcessor;
 
 
/*******************************************************************************
  * 
@@ -61,7 +60,7 @@
                           "wsm/drt/tests/schemas/starwars.wsdl");
         
         Class clazz = Class.forName(CLASSNAME);
-        serverModel = Jsr181TypeMetadataImpl.load(clazz);
+        serverModel = Jsr181ObjectModelStore.load(clazz);
         
         XmlBeanWSDLProcessor xbwp = new XmlBeanWSDLProcessor();
         clientModel = xbwp.createObjectModel(new FileInputStream(f));

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedWebServiceDeploymentHandler.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedWebServiceDeploymentHandler.java?view=diff&r1=154350&r2=154351
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedWebServiceDeploymentHandler.java
 (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AnnotatedWebServiceDeploymentHandler.java
 Fri Feb 18 13:22:09 2005
@@ -18,6 +18,9 @@
  * 
  */
 
+import java.io.File;
+import java.io.FilenameFilter;
+
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -37,8 +40,7 @@
 import org.apache.commons.logging.Log;
 
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsTypeMetadata;
-import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181TypeMetadataImpl;
-//import 
org.apache.beehive.wsm.jsr181.processor.reflection.WsmReflectionAnnotationProcessor;
+import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181ObjectModelStore;
 
 /**
  * ****************************************************************************
@@ -52,8 +54,8 @@
  * @author Sam Ruby ([EMAIL PROTECTED])
  *         todo: fix directory structure/classloaders for output files
  */
-public class AnnotatedWebServiceDeploymentHandler extends BasicHandler
-{
+public class AnnotatedWebServiceDeploymentHandler extends BasicHandler {
+    
     protected static Log log =
         
LogFactory.getLog(AnnotatedWebServiceDeploymentHandler.class.getName());
 
@@ -64,13 +66,11 @@
      * @param mc
      * @throws AxisFault
      */
-    public void invoke(MessageContext mc) throws AxisFault
-    {
-        try
-        {
-            SOAPService ss = getSOAPService(findWebServiceClass(mc));
-            if (null != ss)
-            {
+    public void invoke(MessageContext mc) throws AxisFault {
+        
+        try {
+            SOAPService ss = getSOAPService(getWebServiceClass(mc));
+            if (null != ss) {
                 ss.setEngine(mc.getAxisEngine());
                 mc.setService(ss);
                 /*
@@ -87,8 +87,7 @@
                 mc.removeProperty(Constants.MC_REALPATH);
             }
         }
-        catch (Exception e)
-        {
+        catch (Exception e) {
             throw AxisFault.makeFault(e);
         }
     }
@@ -97,8 +96,7 @@
      * @param mc
      * @throws AxisFault
      */
-    public void generateWSDL(MessageContext mc) throws AxisFault
-    {
+    public void generateWSDL(MessageContext mc) throws AxisFault {
         invoke(mc);
     }
 
@@ -107,17 +105,15 @@
      * @return SOAPService
      * @throws Exception
      */
-    protected SOAPService getSOAPService(Class clazz) throws Exception
-    {
-        SOAPService rpc = null;
+    protected SOAPService getSOAPService(Class clazz) throws Exception {
+        SOAPService ss = null;
         if (null != clazz) {
-            rpc = soapServices.get(clazz.getName());
-            if (null == rpc) {
-                BeehiveWsTypeMetadata wsm = Jsr181TypeMetadataImpl.load(clazz);
-                rpc = createSOAPService(wsm, clazz);
+            ss = soapServices.get(clazz.getName());
+            if (null == ss) {
+                ss = createSOAPService(Jsr181ObjectModelStore.load(clazz), 
clazz);
             }
         }
-        return rpc;
+        return ss;
     }
 
     /**
@@ -126,18 +122,18 @@
      * @return
      * @throws Exception
      */
-    protected SOAPService createSOAPService(BeehiveWsTypeMetadata wsm, Class 
cls) throws Exception
-    {
-        SOAPService rpc = null;
+    protected SOAPService createSOAPService(BeehiveWsTypeMetadata wsm, Class 
cls) throws Exception {
+
+        SOAPService ss = null;
         if (null != wsm) {
             HandlerHandler hh = new HandlerHandler(wsm);
             hh.init();
             // NOTE [EMAIL PROTECTED] 2004-Nov-01 -- 
-            // not calling rpc.init() since ControlProvider won't do anything 
+            // not calling ss.init() since ControlProvider won't do anything 
             // with it and I don't want the HandlerHandler initialized twice.
-            rpc = new SOAPService(hh, new ControlProvider(), hh);
-            rpc.setName(wsm.getWsName());
-            rpc.setOption(RPCProvider.OPTION_CLASSNAME, cls.getName());
+            ss = new SOAPService(hh, new ControlProvider(), hh);
+            ss.setName(wsm.getWsName());
+            ss.setOption(RPCProvider.OPTION_CLASSNAME, cls.getName());
 
             // Take the setting for the scope option from the handler
             // parameter named "scope"
@@ -145,9 +141,9 @@
             if (null == scope) {
                 scope = "Request";
             }
-            rpc.setOption(RPCProvider.OPTION_SCOPE, scope);
+            ss.setOption(RPCProvider.OPTION_SCOPE, scope);
             ServiceDesc sd = AxisHook.createServiceDesc(wsm, 
cls.getClassLoader());
-            rpc.setServiceDescription(sd);
+            ss.setServiceDescription(sd);
             List allowedMethodNames = sd.getAllowedMethods();
             Iterator allowIt = allowedMethodNames.iterator();
             StringBuffer sb = new StringBuffer();
@@ -159,65 +155,55 @@
                 }
                 sb.append(((String) allowIt.next()));
             }
-            rpc.setOption(RPCProvider.OPTION_ALLOWEDMETHODS,
-                    sb.toString());
-            rpc.setOption(RPCProvider.OPTION_WSDL_PORTTYPE,
-                    wsm.getWsName());
-            rpc.setOption(RPCProvider.OPTION_WSDL_SERVICEPORT,
-                    wsm.getWsName());
-            rpc.setOption(RPCProvider.OPTION_WSDL_SERVICEELEMENT,
-                    wsm.getWsServiceName());
-            rpc.setOption(RPCProvider.OPTION_WSDL_TARGETNAMESPACE,
-                    wsm.getWsTargetNamespace());
-            rpc.setStyle(sd.getStyle());
-            rpc.setUse(sd.getUse());
-            soapServices.put(cls.getName(), rpc);
+            ss.setOption(RPCProvider.OPTION_ALLOWEDMETHODS, sb.toString());
+            ss.setOption(RPCProvider.OPTION_WSDL_PORTTYPE, wsm.getWsName());
+            ss.setOption(RPCProvider.OPTION_WSDL_SERVICEPORT, wsm.getWsName());
+            ss.setOption(RPCProvider.OPTION_WSDL_SERVICEELEMENT, 
wsm.getWsServiceName());
+            ss.setOption(RPCProvider.OPTION_WSDL_TARGETNAMESPACE, 
wsm.getWsTargetNamespace());
+            ss.setStyle(sd.getStyle());
+            ss.setUse(sd.getUse());
+            soapServices.put(cls.getName(), ss);
         }
-        return rpc;
+        return ss;
     }
 
     /**
-     * Mostly taken from Axis code base.
-     *
      * @param mc
      * @return
      * @throws Exception
      */
-    protected Class findWebServiceClass(MessageContext mc) throws Exception
+    protected Class getWebServiceClass(MessageContext mc)
+            throws Exception
     {
-        Class result = null;
-        if (null != mc)
-        {
-            String relPath = mc.getStrProp(Constants.MC_RELATIVE_PATH);
-            if (null != relPath)
-            {
-                // check to see if this is annotated class
-                // clean up the relative path to use as the class destination
-                // dir
-                if ('/' == relPath.charAt(0))
-                {
-                    relPath = relPath.substring(1);
-                }
-                int indexOfDot = relPath.indexOf(".");
-                if (-1 != indexOfDot) relPath = relPath.substring(0, 
indexOfDot);
-                String clsName = relPath.replaceAll("/", ".");
-                try
-                {
-                    if (log.isDebugEnabled())
-                    {
-                        log.debug("looking for webserivce in class: " + 
clsName);
-                    }
-                    result = getClass().getClassLoader().loadClass(clsName);
-                }
-                catch (ClassNotFoundException e)
-                {
-                    if (log.isDebugEnabled())
-                    {
-                        log.debug("class: " + clsName + " not found by 
AnnotatedWebServiceDeploymentHandler continue to the next handler. ");
-                    }
-                }
+        // check message context
+        if (null == mc) {
+            throw new IllegalArgumentException("message context not set");
+        }
+            
+        // retrieve & check relative path
+        String relativePath = mc.getStrProp(Constants.MC_RELATIVE_PATH);
+        if (null == relativePath) {
+            throw new Exception("relative path not set properly in message 
context");
+        }
+        
+        // turn relative path into fq class name
+        final String JWS_EXTENSION = ".jws";
+        if ((! relativePath.startsWith("/")) || (! 
relativePath.endsWith(JWS_EXTENSION))) {
+            throw new Exception ("invalid relative path: " + relativePath);
+        }
+        String className = relativePath.substring(1, relativePath.length() - 
JWS_EXTENSION.length()).replaceAll("/", ".");
+
+        // load class
+        if (log.isDebugEnabled()) {
+            log.debug("trying to load web service class: " + className);
+        }
+        Class clazz = Jsr181ObjectModelStore.loadWebServiceClass(className);
+        if (null == clazz) {
+            if (log.isDebugEnabled()) {
+                log.debug("failed to load web service class: " + className);
             }
         }
-        return result;
+        
+        return clazz;
     }
 }

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AuthenticationHandler.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AuthenticationHandler.java?view=diff&r1=154350&r2=154351
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AuthenticationHandler.java
 (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/AuthenticationHandler.java
 Fri Feb 18 13:22:09 2005
@@ -22,9 +22,9 @@
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsTypeMetadata;
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsMethodMetadata;
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsParameterMetadata;
+import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181ObjectModelStore;
 import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181TypeMetadataImpl;
 import org.apache.beehive.wsm.jsr181.model.jsr181.SecurityRolesInfo;
-//import org.apache.beehive.wsm.jsr181.processor.apt.WsmAnnotationProcessor;
 
 import org.apache.beehive.wsm.axis.security.SecurityModel;
 
@@ -97,7 +97,7 @@
         // get a object model of the requested class.
         BeehiveWsTypeMetadata wsm = null;
         try {
-            wsm = Jsr181TypeMetadataImpl.load(clazz);
+            wsm = Jsr181ObjectModelStore.load(clazz);
         }
         catch (Exception e) {
             e.printStackTrace();

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/ControlProvider.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/ControlProvider.java?view=diff&r1=154350&r2=154351
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/ControlProvider.java
 (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/axis/ControlProvider.java
 Fri Feb 18 13:22:09 2005
@@ -37,30 +37,30 @@
  * @author Jonathan Colwell
  */
 public class ControlProvider extends RPCProvider {
+    
     protected Object makeNewServiceObject(MessageContext msgContext, String 
clsName)
-            throws Exception {
+            throws Exception
+    {
         Object obj = super.makeNewServiceObject(msgContext, clsName);
         initializeControls(obj);
         return obj;
     }
 
     private void initializeControls(Object obj) throws Exception {
+    
         Class cls = obj.getClass();
-        Field[] fields = cls.getFields();
 
         // search for fields with @Control annotations
-        for (Field field : fields) {
+        for (Field field : cls.getFields()) {
             if (null != field.getAnnotation(Control.class)) {
+        
                 //attempt to load using client initializer.
-                ControlContainerContext ccc =
-                        ControlThreadContext.getContext();
+                ControlContainerContext ccc = 
ControlThreadContext.getContext();
                 if (null == ccc) {
                     throw new Exception("no control container context found");
                 }
-                Class clientInitializer =
-                        cls.getClassLoader().loadClass(cls.getName() + 
"ClientInitializer");
-                Method init =
-                        clientInitializer.getMethod("initialize", 
ControlBeanContext.class, cls);
+                Class clientInitializer = 
cls.getClassLoader().loadClass(cls.getName() + "ClientInitializer");
+                Method init = clientInitializer.getMethod("initialize", 
ControlBeanContext.class, cls);
                 init.invoke(null, ccc, obj);
                 break;
             }

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/BeehiveWsTypeMetadata.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/BeehiveWsTypeMetadata.java?view=diff&r1=154350&r2=154351
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/BeehiveWsTypeMetadata.java
 (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/BeehiveWsTypeMetadata.java
 Fri Feb 18 13:22:09 2005
@@ -35,7 +35,7 @@
 
 import org.xmlsoap.schemas.wsdl.DefinitionsDocument;
 
-import org.apache.xmlbeans.XmlException;
+//import org.apache.xmlbeans.XmlException;
 
 import org.apache.beehive.wsm.jsr181.model.java.JavaTypeInfo;
 import org.apache.beehive.wsm.jsr181.model.jsr181.SecurityRolesInfo;
@@ -48,9 +48,6 @@
     void initHandlersFromChainConfig(URL chainConfigURL, String chainName)
         throws Exception;
 
-    DefinitionsDocument getWSDLAsDocument()
-        throws IOException, XmlException;
-
     String getHcFileName();
     void setHcFileName(String hcFileName);
     
@@ -84,8 +81,7 @@
     
     Collection<? extends BeehiveWsMethodMetadata> getMethods();
 
-    public abstract BeehiveWsMethodMetadata getMethod(String methodName,
-                                                   Class... paramTypes);
+    public abstract BeehiveWsMethodMetadata getMethod(String methodName, 
Class... paramTypes);
     
     /**
      * @throws ValidateException if duplicate methods are encountered or if a

Added: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181ObjectModelStore.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181ObjectModelStore.java?view=auto&rev=154351
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181ObjectModelStore.java
 (added)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181ObjectModelStore.java
 Fri Feb 18 13:22:09 2005
@@ -0,0 +1,150 @@
+package org.apache.beehive.wsm.jsr181.model.jsr181;
+
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$Factory
+ */
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import java.net.URL;
+
+import org.apache.beehive.wsm.jsr181.model.BeehiveWsTypeMetadata;
+
+/**
+ * Encapsulates all knowledge about where and how object models are persisted.
+ */
+public class Jsr181ObjectModelStore {
+    
+    private final static String EXTENSION = ".ser";
+    private final static String LOCATOR = ".webservices";
+    
+    /**
+     * Constructor.
+     */
+    private Jsr181ObjectModelStore() {
+        // empty
+    }
+    
+    /**
+     * Encapsulates the encoding of the pathname for object models.
+     * @param
+     * @return
+     */
+    public static File getLocation(String className) {
+        return new File(className + EXTENSION);
+    }
+
+    /**
+     * @param clazz
+     */
+    public static BeehiveWsTypeMetadata load(Class clazz)
+            throws IOException, ClassNotFoundException
+    {
+        String resourceName = getLocation(clazz.getName()).toString();
+        URL url = clazz.getClassLoader().getResource(resourceName);
+        return load(url.openStream());
+    }
+    
+    /**
+     * @param is
+     */
+    public static BeehiveWsTypeMetadata load(InputStream is)
+            throws IOException, ClassNotFoundException
+    {
+        Jsr181TypeMetadataImpl objectModel = null;
+        ObjectInputStream ois = null;
+
+        try {
+            if (null == is) {
+                throw new IOException("cannot load object model without input 
stream");
+            }
+            ois = new ObjectInputStream(is);
+            objectModel = (Jsr181TypeMetadataImpl) ois.readObject();
+        }
+        finally {
+            if (null != ois) {
+                ois.close();
+            }
+        }
+
+        return objectModel;
+    }
+
+    /**
+     * @param os
+     * @param objectModel
+     */
+    public static void store(OutputStream os, BeehiveWsTypeMetadata 
objectModel)
+            throws IOException
+    {
+        ObjectOutputStream oos = null;
+        try {
+            if (null == os) {
+                throw new IOException("cannot persist object model without 
output stream");
+            }
+            if (null == objectModel) {
+                throw new IOException("cannot persist empty object model ");
+            }
+            oos = new ObjectOutputStream(os);
+            oos.writeObject(objectModel);
+        }
+        finally {
+            if (null != oos) {
+                oos.flush();
+                oos.close();
+            }
+        }
+    }
+    
+    public static Class loadWebServiceClass(String className) throws 
ClassNotFoundException {
+
+        Class clazz = null;
+        ClassLoader cl = Jsr181ObjectModelStore.class.getClassLoader();
+
+        // try className as fully qualified class name
+        try {
+            clazz = cl.loadClass(className);
+        }
+        
+        // try className as simple class name
+        catch (ClassNotFoundException e) {
+            final File wsDirectory = new File(new 
File(cl.getResource(LOCATOR).getFile()).getParent());
+            final String _className = className;
+            FilenameFilter filenameFilter = new FilenameFilter() {
+                public boolean accept(File dir, String name) {
+                    return (wsDirectory.equals(dir) && 
(name.endsWith(_className + EXTENSION)));
+                }
+            };
+            for (File file : wsDirectory.listFiles(filenameFilter)) {
+                String filename = file.getName();
+                if (! filename.endsWith(EXTENSION)) {
+                    continue;
+                }
+                className = filename.substring(0, filename.length() - 
EXTENSION.length());
+                clazz = cl.loadClass(className);
+            }
+        }
+
+        return clazz;
+    }
+}
\ No newline at end of file

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181TypeMetadataImpl.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181TypeMetadataImpl.java?view=diff&r1=154350&r2=154351
==============================================================================
--- 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181TypeMetadataImpl.java
 (original)
+++ 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/model/jsr181/Jsr181TypeMetadataImpl.java
 Fri Feb 18 13:22:09 2005
@@ -19,17 +19,12 @@
  */
 
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
+
 import java.net.MalformedURLException;
 import java.net.URL;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -48,16 +43,13 @@
 import javax.jws.soap.SOAPBinding;
 import javax.jws.soap.SOAPMessageHandler;
 import javax.jws.soap.SOAPMessageHandlers;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import org.apache.beehive.wsm.jsr181.wsdl.WSDLProcessor;
-import org.apache.xmlbeans.XmlException;
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
-import org.xmlsoap.schemas.wsdl.DefinitionsDocument;
 
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsMethodMetadata;
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsParameterMetadata;
@@ -66,9 +58,13 @@
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsSecurityRolesInfo;
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsTypeMetadata;
 import org.apache.beehive.wsm.jsr181.model.ValidationException;
+
 import org.apache.beehive.wsm.jsr181.model.java.JavaTypeInfo;
 import org.apache.beehive.wsm.jsr181.model.java.JavaMethodInfo;
 
+/**
+ *
+ */
 public class Jsr181TypeMetadataImpl implements BeehiveWsTypeMetadata, 
java.io.Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -95,6 +91,7 @@
      * Default constructor.
      */
     public Jsr181TypeMetadataImpl() {
+        // empty
     }
 
     /**
@@ -470,12 +467,9 @@
         factory.setNamespaceAware(true);
         factory.setIgnoringComments(true);
         
-        // parse handler-chain config file
-        InputStream is = chainConfigURL.openStream();
-        
         // todo: this is broken; validate the document!!!
         
-        NodeList handlerChainNodes = 
factory.newDocumentBuilder().parse(is).getElementsByTagName("handler-chain");
+        NodeList handlerChainNodes = 
factory.newDocumentBuilder().parse(chainConfigURL.openStream()).getElementsByTagName("handler-chain");
         for (int j = 0; j < handlerChainNodes.getLength(); j++) {
             Node handlerChainNode = handlerChainNodes.item(j);
             if (handlerChainNode.getNodeType() == Node.ELEMENT_NODE) {
@@ -548,20 +542,13 @@
         }
     }
     
+    /**
+     *
+     */
     public void validate() {
         // empty
     }
 
-    public DefinitionsDocument getWSDLAsDocument()
-            throws IOException, XmlException {
-
-        // NOTE [EMAIL PROTECTED] 2004-Nov-30 -- removing this while the 
-        // WSDLProcessor is being refactored.  
-
-        //return WSDLProcessor.parseWSDL(getWsWsdlLocation());
-        return null;
-    }
-
     /**
      * @return Returns the hcFileName.
      */
@@ -827,35 +814,6 @@
     }
 
     /**
-     * @param objectModel Object model for service implementation bean. Note:
-     *   only the @WebService.endpointInterface and @WebService.serviceName are
-     *   relevant.
-     * @throws Exception
-    public void merge(Jsr181TypeMetadata objectModel) throws Exception {
-        
-        // check if this has endpointInterface --> error
-        String myEndpointInterface = getWsEndpointInterface();
-        if (null != myEndpointInterface && 0 < myEndpointInterface.length())
-            throw new Exception("service endpoint interface can't reference 
another service endpoint interface: " + myEndpointInterface);
-        
-        // check if objectModel doesn't reference this endpointInterface --> 
error
-        String omEndpointInterface = objectModel.getWsEndpointInterface();
-        if (null == omEndpointInterface || 0 >= omEndpointInterface.length() 
|| ! omEndpointInterface.equals(getClassName()))
-            throw new Exception("Internal error: object model for " + 
objectModel.getClassName() + " does not reference endpoint interface "+ 
omEndpointInterface);
-
-        // check if objectModel.wsWsdlLocation != null --> error
-        if (null != objectModel.getWsWsdlLocation() && 0 < 
objectModel.getWsWsdlLocation().length()) {
-            throw new Exception("implementation bean must not reference a 
service endpoint interface and a WSDL location at the same time");
-        }
-        
-        setWsServiceName(objectModel.getWsServiceName());
-        setWsEndpointInterface(objectModel.getWsEndpointInterface());
-        
-        setClassName(objectModel.getClassName());
-    }
-     */
-
-    /**
      * @param jt SIB type info.
      * @throws Exception
      */
@@ -887,6 +845,7 @@
     }
 
     /**
+     * Checks if "jt" implements "this".
      * @param jt SIB type info.
      * @throws ValidationException
      */
@@ -914,73 +873,6 @@
             }
             if (! implementationFound) {
                 throw new ValidationException("method not implemented by " + 
jt.getName() + ": " + declaredMethod);
-            }
-        }
-    }
-    
-    /**
-     * Encapsulates the encoding of the pathname for object models.
-     * @param
-     * @return
-     */
-    public static File getLocation(String className) {
-        return new File(className + ".ser");
-    }
-
-    /**
-     * @param clazz
-     */
-    public static BeehiveWsTypeMetadata load(Class clazz) throws IOException, 
ClassNotFoundException {
-        String resourceName = getLocation(clazz.getName()).toString();
-        URL url = clazz.getClassLoader().getResource(resourceName);
-        return load(url.openStream());
-    }
-    
-    /**
-     * @param is
-     */
-    public static BeehiveWsTypeMetadata load(InputStream is) throws 
IOException, ClassNotFoundException {
-
-        Jsr181TypeMetadataImpl objectModel = null;
-        ObjectInputStream ois = null;
-
-        try {
-            if (null == is) {
-                throw new IOException("cannot load object model without input 
stream");
-            }
-            ois = new ObjectInputStream(is);
-            objectModel = (Jsr181TypeMetadataImpl) ois.readObject();
-        }
-        finally {
-            if (null != ois) {
-                ois.close();
-            }
-        }
-
-        return objectModel;
-    }
-
-    /**
-     * @param os
-     * @param objectModel
-     */
-    public static void store(OutputStream os, BeehiveWsTypeMetadata 
objectModel) throws IOException {
-        
-        ObjectOutputStream oos = null;
-        try {
-            if (null == os) {
-                throw new IOException("cannot persist object model without 
output stream");
-            }
-            if (null == objectModel) {
-                throw new IOException("cannot persist empty object model ");
-            }
-            oos = new ObjectOutputStream(os);
-            oos.writeObject(objectModel);
-        }
-        finally {
-            if (null != oos) {
-                oos.flush();
-                oos.close();
             }
         }
     }

Modified: 
incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java
URL: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/wsm/src/runtime/org/apache/beehive/wsm/jsr181/processor/apt/WsmAnnotationProcessor.java?view=diff&r1=154350&r2=154351
==============================================================================
--- 
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
 Fri Feb 18 13:22:09 2005
@@ -35,6 +35,7 @@
 import javax.jws.WebService;
 
 import org.apache.beehive.wsm.jsr181.model.BeehiveWsTypeMetadata;
+import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181ObjectModelStore;
 import org.apache.beehive.wsm.jsr181.model.jsr181.Jsr181TypeMetadataImpl;
 
 
@@ -114,7 +115,13 @@
                 }
 
                 // persist object model
-                
Jsr181TypeMetadataImpl.store(_env.getFiler().createBinaryFile(Filer.Location.CLASS_TREE,
 "", Jsr181TypeMetadataImpl.getLocation(classDecl.getQualifiedName())), om);
+                
Jsr181ObjectModelStore.store(_env.getFiler().createBinaryFile(Filer.Location.CLASS_TREE,
 "", Jsr181ObjectModelStore.getLocation(classDecl.getQualifiedName())), om);
+        // todo: this needs to move into Jsr181ObjectModelStore -- use IoC to 
provide context
+                try {
+                _env.getFiler().createBinaryFile(Filer.Location.CLASS_TREE, 
"", new java.io.File(".webservices"));
+                }
+                catch (Throwable t) { } 
+        // todo:
             }
             
             // service endpoint interface
@@ -130,7 +137,7 @@
                 }
 
                 // store the object model
-                
Jsr181TypeMetadataImpl.store(_env.getFiler().createBinaryFile(Filer.Location.CLASS_TREE,
 "", Jsr181TypeMetadataImpl.getLocation(interfaceDecl.getQualifiedName())), om);
+                
Jsr181ObjectModelStore.store(_env.getFiler().createBinaryFile(Filer.Location.CLASS_TREE,
 "", Jsr181ObjectModelStore.getLocation(interfaceDecl.getQualifiedName())), om);
             }
 
             // @WebService annotation on unknown/unsupported type definition
@@ -160,7 +167,7 @@
 
         // search for persistent object model
         try {
-            om = 
Jsr181TypeMetadataImpl.load(getClass().getClassLoader().getResourceAsStream(Jsr181TypeMetadataImpl.getLocation(endpointInterface).toString()));
+            om = 
Jsr181ObjectModelStore.load(getClass().getClassLoader().getResourceAsStream(Jsr181ObjectModelStore.getLocation(endpointInterface).toString()));
         }
         catch (Throwable t) { }
 
@@ -169,7 +176,7 @@
             try {
                 _env.getMessager().printNotice("-> loading object model for 
required endpoint interface:" + endpointInterface);
                 check(_env.getTypeDeclaration(endpointInterface));
-                om = 
Jsr181TypeMetadataImpl.load(getClass().getClassLoader().getResourceAsStream(Jsr181TypeMetadataImpl.getLocation(endpointInterface).toString()));
+                om = 
Jsr181ObjectModelStore.load(getClass().getClassLoader().getResourceAsStream(Jsr181ObjectModelStore.getLocation(endpointInterface).toString()));
             }
             catch (Throwable t) { }
         }


Reply via email to