axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntha...@apache.org
Subject svn commit: r552920 - in /webservices/axis2/trunk/java/modules: jaxws/src/org/apache/axis2/jaxws/ jaxws/src/org/apache/axis2/jaxws/binding/ jaxws/src/org/apache/axis2/jaxws/handler/ jaxws/src/org/apache/axis2/jaxws/server/ jaxws/src/org/apache/axis2/ja...
Date Tue, 03 Jul 2007 17:14:02 GMT
Author: nthaker
Date: Tue Jul  3 10:14:00 2007
New Revision: 552920

URL: http://svn.apache.org/viewvc?view=rev&rev=552920
Log:
JIRA = AXIS2-2894

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java?view=diff&rev=552920&r1=552919&r2=552920
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
Tue Jul  3 10:14:00 2007
@@ -18,6 +18,11 @@
  */
 package org.apache.axis2.jaxws;
 
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.xml.ws.Binding;
+import javax.xml.ws.handler.HandlerResolver;
 import org.apache.axis2.jaxws.binding.BindingUtils;
 import org.apache.axis2.jaxws.binding.SOAPBinding;
 import org.apache.axis2.jaxws.client.PropertyValidator;
@@ -29,11 +34,8 @@
 import org.apache.axis2.jaxws.spi.ServiceDelegate;
 import org.apache.axis2.transport.http.HTTPConstants;
 
-import javax.xml.ws.Binding;
-import javax.xml.ws.handler.HandlerResolver;
-
-import java.util.Hashtable;
-import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class BindingProvider implements org.apache.axis2.jaxws.spi.BindingProvider {
 
@@ -46,7 +48,7 @@
     protected ServiceDelegate serviceDelegate;
 
     private Binding binding = null;
-
+    private static final Log log = LogFactory.getLog(BindingProvider.class);
     public BindingProvider(ServiceDelegate svcDelegate, EndpointDescription epDesc) {
         endpointDesc = epDesc;
         serviceDelegate = svcDelegate;
@@ -75,11 +77,23 @@
         // so we can also set the handlerchain
         if (binding == null) {
             binding = BindingUtils.createBinding(endpointDesc);
-            
+            if(log.isDebugEnabled()){
+                log.debug("Lookign for Handler Resolver");
+            }
             // TODO should we allow the ServiceDelegate to figure out the default handlerresolver?
 Probably yes, since a client app may look for one there.
-            HandlerResolver handlerResolver =
-                    serviceDelegate.getHandlerResolver() != null ? serviceDelegate.getHandlerResolver()
-                            : new HandlerResolverImpl(endpointDesc);
+            HandlerResolver handlerResolver = null;
+            if(serviceDelegate.getHandlerResolver() != null){
+                if(log.isDebugEnabled()){
+                    log.debug("Reading default Handler Resolver ");
+                }
+                handlerResolver= serviceDelegate.getHandlerResolver();
+            }
+            else{
+                handlerResolver = new HandlerResolverImpl(endpointDesc.getServiceDescription());
+                if(log.isDebugEnabled()){
+                    log.debug("Creating new Handler Resolver using HandlerResolverImpl");
+                }
+            }
             binding.setHandlerChain(handlerResolver.getHandlerChain(endpointDesc.getPortInfo()));
         }
 

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingImpl.java?view=diff&rev=552920&r1=552919&r2=552920
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingImpl.java
Tue Jul  3 10:14:00 2007
@@ -19,16 +19,15 @@
 
 package org.apache.axis2.jaxws.binding;
 
-import org.apache.axis2.jaxws.description.EndpointDescription;
-import org.apache.axis2.jaxws.handler.HandlerResolverImpl;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
 
 import javax.xml.ws.Binding;
 import javax.xml.ws.handler.Handler;
 
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
+import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.handler.HandlerResolverImpl;
 
 /**
  * @author rott classes that would normally "implement javax.xml.ws.Binding"
@@ -63,11 +62,10 @@
     }
 
     public List<Handler> getHandlerChain() {
-        if (handlers == null && endpointDesc != null) {
-            handlers = new HandlerResolverImpl(endpointDesc).getHandlerChain(endpointDesc
-                            .getPortInfo());
-        }
         if (handlers == null) {
+            handlers =
+                    new HandlerResolverImpl(endpointDesc.getServiceDescription()).getHandlerChain(endpointDesc.getPortInfo());
+            if (handlers == null)
             handlers = new ArrayList<Handler>(); // non-null so client
                                                  // apps can manipulate
         }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java?view=diff&rev=552920&r1=552919&r2=552920
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java
Tue Jul  3 10:14:00 2007
@@ -18,36 +18,37 @@
  */
 package org.apache.axis2.jaxws.handler;
 
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.WebServiceException;
-import javax.xml.ws.handler.Handler;
-import javax.xml.ws.handler.HandlerResolver;
-import javax.xml.ws.handler.LogicalHandler;
-import javax.xml.ws.handler.PortInfo;
-import javax.xml.ws.handler.soap.SOAPHandler;
-
+import org.apache.axis2.client.OperationClient;
 import org.apache.axis2.java.security.AccessController;
 import org.apache.axis2.jaxws.ExceptionFactory;
-import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.description.ServiceDescription;
 import org.apache.axis2.jaxws.description.xml.handler.HandlerChainType;
 import org.apache.axis2.jaxws.description.xml.handler.HandlerChainsType;
 import org.apache.axis2.jaxws.description.xml.handler.HandlerType;
-import org.apache.axis2.jaxws.handler.lifecycle.factory.HandlerLifecycleManager;
-import org.apache.axis2.jaxws.handler.lifecycle.factory.HandlerLifecycleManagerFactory;
 import org.apache.axis2.jaxws.i18n.Messages;
-import org.apache.axis2.jaxws.registry.FactoryRegistry;
+import org.apache.axis2.jaxws.runtime.description.injection.ResourceInjectionServiceRuntimeDescription;
+import org.apache.axis2.jaxws.runtime.description.injection.impl.ResourceInjectionServiceRuntimeDescriptionBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.HandlerResolver;
+import javax.xml.ws.handler.LogicalHandler;
+import javax.xml.ws.handler.PortInfo;
+import javax.xml.ws.handler.soap.SOAPHandler;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 /* 
  * This class should be created by the ServiceDelegate.
  * HandlerResolverImpl.getHandlerChain(PortInfo) will be called by the
@@ -78,10 +79,12 @@
       */
 
     // we'll need to refer to this object to get the port, and thus handlers
-    private EndpointDescription endpointDesc;
+    //private EndpointDescription endpointDesc;
+    private ServiceDescription serviceDesc;
 
-    public HandlerResolverImpl(EndpointDescription ed) {
-        this.endpointDesc = ed;
+    public HandlerResolverImpl(ServiceDescription sd) { //EndpointDescription ed) {
+        //this.endpointDesc = ed;
+        this.serviceDesc = sd;
     }
 
     public ArrayList<Handler> getHandlerChain(PortInfo portinfo) {
@@ -142,12 +145,25 @@
 
         ArrayList<Handler> handlers = new ArrayList<Handler>();
 
-		/*
-		 * TODO: do a better job checking that the return value matches up
+        /*
+         * TODO: do a better job checking that the return value matches up
          * with the PortInfo object before we add it to the chain.
-		 */
-		
-        HandlerChainsType handlerCT = endpointDesc.getHandlerChain();
+         */
+        
+        HandlerChainsType handlerCT = serviceDesc.getHandlerChain();  
+        // if there's a handlerChain on the serviceDesc, it means the WSDL defined an import
for a HandlerChain.
+        // the spec indicates that if a handlerchain also appears on the SEI on the client.
+        EndpointDescription ed = null;
+        if(portinfo !=null){
+             ed = serviceDesc.getEndpointDescription(portinfo.getPortName());
+        }
+        
+        if (ed != null) {
+            HandlerChainsType handlerCT_fromEndpointDesc = ed.getHandlerChain();
+            if (handlerCT == null) {
+                handlerCT = handlerCT_fromEndpointDesc;
+            } 
+        }
 
         Iterator it = handlerCT == null ? null : handlerCT.getHandlerChain().iterator();
 
@@ -171,17 +187,21 @@
                 // or will schema not allow it?
                 String portHandler = handlerType.getHandlerClass().getValue();
                 Handler handler;
-                              
-                // Create temporary MessageContext to pass information to HandlerLifecycleManager
-                MessageContext ctx = new MessageContext();
-                ctx.setEndpointDescription(endpointDesc);
-                
-                HandlerLifecycleManager hlm = createHandlerlifecycleManager();
-                    
-                //  instantiate portHandler class 
+                // instantiate portHandler class
                 try {
-                    handler = hlm.createHandlerInstance(ctx, loadClass(portHandler));
-                } catch (Exception e) {
+                    // TODO: review: ok to use system classloader?
+                    handler = (Handler) loadClass(portHandler).newInstance();
+                    // TODO: must also do resource injection according to JAXWS 9.3.1
+                    callHandlerPostConstruct(handler, serviceDesc);
+                } catch (ClassNotFoundException e) {
+                    // TODO: should we just ignore this problem?
+                    // TODO: NLS log and throw
+                    throw ExceptionFactory.makeWebServiceException(e);
+                } catch (InstantiationException ie) {
+                    // TODO: should we just ignore this problem?
+                    // TODO: NLS log and throw
+                    throw ExceptionFactory.makeWebServiceException(ie);
+                } catch (IllegalAccessException e) {
                     // TODO: should we just ignore this problem?
                     // TODO: NLS log and throw
                     throw ExceptionFactory.makeWebServiceException(e);
@@ -210,11 +230,6 @@
         return handlers;
     }
 
-    private HandlerLifecycleManager createHandlerlifecycleManager() {
-        HandlerLifecycleManagerFactory elmf = (HandlerLifecycleManagerFactory)FactoryRegistry
-                .getFactory(HandlerLifecycleManagerFactory.class);
-        return elmf.createHandlerLifecycleManager();
-    }
     
     private static Class loadClass(String clazz) throws ClassNotFoundException {
         try {
@@ -272,6 +287,60 @@
         }
 
         return cl;
+    }
+
+    private static void callHandlerPostConstruct(Handler handler, ServiceDescription serviceDesc)
+                                                                                        
        throws WebServiceException {
+        ResourceInjectionServiceRuntimeDescription resInj =
+                ResourceInjectionServiceRuntimeDescriptionBuilder.create(serviceDesc,
+                                                                         handler.getClass());
+        if (resInj != null) {
+            Method pcMethod = resInj.getPostConstructMethod();
+            if (pcMethod != null) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Invoking Method with @PostConstruct annotation");
+                }
+                invokeMethod(handler, pcMethod, null);
+                if (log.isDebugEnabled()) {
+                    log.debug("Completed invoke on Method with @PostConstruct annotation");
+                }
+            }
+        }
+    }
+    /*
+     * Helper method to destroy all instantiated Handlers once the runtime
+     * is done with them.
+     */
+    private static void callHandlerPreDestroy(Handler handler, ServiceDescription serviceDesc)
+                                                                                        
     throws WebServiceException {
+        ResourceInjectionServiceRuntimeDescription resInj =
+                ResourceInjectionServiceRuntimeDescriptionBuilder.create(serviceDesc,
+                                                                         handler.getClass());
+        if (resInj != null) {
+            Method pcMethod = resInj.getPreDestroyMethod();
+            if (pcMethod != null) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Invoking Method with @PostConstruct annotation");
+                }
+                invokeMethod(handler, pcMethod, null);
+                if (log.isDebugEnabled()) {
+                    log.debug("Completed invoke on Method with @PostConstruct annotation");
+                }
+            }
+        }
+    }
+
+    private static void invokeMethod(Handler handlerInstance, Method m, Object[] params)
+                                                                                        throws
WebServiceException {
+        try {
+            m.invoke(handlerInstance, params);
+        } catch (InvocationTargetException e) {
+            // TODO perhaps a "HandlerLifecycleException" would be better?
+            throw ExceptionFactory.makeWebServiceException(e);
+        } catch (IllegalAccessException e) {
+            // TODO perhaps a "HandlerLifecycleException" would be better?
+            throw ExceptionFactory.makeWebServiceException(e);
+        }
     }
 
     private static boolean chainResolvesToPort(HandlerChainType handlerChainType, PortInfo
portinfo) {

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java?view=diff&rev=552920&r1=552919&r2=552920
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
Tue Jul  3 10:14:00 2007
@@ -110,9 +110,7 @@
          * Since we're on the server, and there apparently is no Binding object
          * anywhere to be found...
          */
-        if (ic.getHandlers() == null) {
-            ic.setHandlers(new HandlerResolverImpl(endpointDesc).getHandlerChain(endpointDesc.getPortInfo()));
-        }
+        ic.setHandlers(new HandlerResolverImpl(endpointDesc.getServiceDescription()).getHandlerChain(endpointDesc.getPortInfo()));
 
         if (!bindingTypesMatch(requestMsgCtx, endpointDesc.getServiceDescription())) {
             Protocol protocol = requestMsgCtx.getMessage().getProtocol();

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java?view=diff&rev=552920&r1=552919&r2=552920
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
Tue Jul  3 10:14:00 2007
@@ -282,6 +282,9 @@
     * @see javax.xml.ws.spi.ServiceDelegate#getHandlerResolver()
     */
     public HandlerResolver getHandlerResolver() {
+        if (handlerResolver == null) {
+            handlerResolver = new HandlerResolverImpl(serviceDescription);
+        }
         return handlerResolver;
     }
 

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java?view=diff&rev=552920&r1=552919&r2=552920
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
Tue Jul  3 10:14:00 2007
@@ -492,4 +492,19 @@
 
         return new StreamSource(new StringReader(reqString));
     }
+    
+    public void testAddNumbersHandlerHandlerResolver() {
+        try {
+        System.out.println("----------------------------------");
+        System.out.println("test: " + getName());
+        AddNumbersHandlerService service = new AddNumbersHandlerService(); // will give NPE:
+        List<Handler> handlers = service.getHandlerResolver().getHandlerChain(null);
+        assertNotNull("Default handlers list should not be null but empty.", handlers);
+        System.out.println("----------------------------------");
+        } catch (Exception e) {
+        e.printStackTrace();
+        fail(e.getMessage());
+        }
+        } 
+
 }

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java?view=diff&rev=552920&r1=552919&r2=552920
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
Tue Jul  3 10:14:00 2007
@@ -20,7 +20,7 @@
 
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
-
+import org.apache.axis2.jaxws.description.xml.handler.HandlerChainsType;
 import javax.xml.namespace.QName;
 import java.util.Collection;
 import java.util.List;
@@ -84,6 +84,7 @@
 
     public abstract QName getServiceQName();
 
+    public abstract HandlerChainsType getHandlerChain();
     /**
      * Returns a list of the ports for this serivce.  The ports returned are the - Ports
declared
      * ports for this Service.  They can be delcared in the WSDL or via annotations. - Dynamic
ports

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?view=diff&rev=552920&r1=552919&r2=552920
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
Tue Jul  3 10:14:00 2007
@@ -18,6 +18,39 @@
  */
 package org.apache.axis2.jaxws.description.impl;
 
+import static org.apache.axis2.jaxws.description.builder.MDQConstants.RETURN_TYPE_FUTURE;
+import static org.apache.axis2.jaxws.description.builder.MDQConstants.RETURN_TYPE_RESPONSE;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.ConnectException;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.jws.HandlerChain;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.ws.soap.SOAPBinding;
+
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.description.AxisService;
@@ -32,36 +65,15 @@
 import org.apache.axis2.jaxws.description.ServiceRuntimeDescription;
 import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
 import org.apache.axis2.jaxws.description.builder.MDQConstants;
-import static org.apache.axis2.jaxws.description.builder.MDQConstants.RETURN_TYPE_FUTURE;
-import static org.apache.axis2.jaxws.description.builder.MDQConstants.RETURN_TYPE_RESPONSE;
 import org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite;
 import org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite;
+import org.apache.axis2.jaxws.description.xml.handler.HandlerChainsType;
 import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.util.WSDL4JWrapper;
 import org.apache.axis2.jaxws.util.WSDLWrapper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.wsdl.Definition;
-import javax.wsdl.Port;
-import javax.wsdl.PortType;
-import javax.wsdl.Service;
-import javax.wsdl.WSDLException;
-import javax.wsdl.extensions.ExtensibilityElement;
-import javax.xml.namespace.QName;
-import javax.xml.ws.soap.SOAPBinding;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.ConnectException;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
 
 /** @see ../ServiceDescription */
 class ServiceDescriptionImpl
@@ -79,6 +91,10 @@
     // TODO: Possibly remove Definition and delegate to the Defn on the AxisSerivce set as
a paramater by WSDLtoAxisServicBuilder?
     private WSDLWrapper wsdlWrapper;
     private WSDLWrapper generatedWsdlWrapper;
+    
+    //ANNOTATION: @HandlerChain
+    private HandlerChain handlerChainAnnotation;
+    private HandlerChainsType handlerChainsType;
 
     private Map<QName, EndpointDescription> endpointDescriptions =
             new HashMap<QName, EndpointDescription>();
@@ -1322,8 +1338,87 @@
         return wsdlSpecified;
     }
 
+    
+    // ===========================================
+    // ANNOTATION: HandlerChain
+    // ===========================================
+
     /**
-     * Returns the WSDL definiton as specified in the metadata.  Note that this WSDL may
not be
+     * Returns a schema derived java class containing the the handler configuration filel
+     *  
+     * @return HandlerChainsType This is the top-level element for the Handler configuration
file
+     * 
+     */
+    public HandlerChainsType getHandlerChain() {
+
+        if (handlerChainsType == null) {
+
+            getAnnoHandlerChainAnnotation();
+            if (handlerChainAnnotation != null) {
+
+                String handlerFileName = handlerChainAnnotation.file();
+
+                // TODO RAS & NLS
+                if (log.isDebugEnabled()) {
+                    if (composite != null) {
+                        log.debug("EndpointDescriptionImpl.getHandlerChain: fileName: "
+                                + handlerFileName + " className: " + composite.getClassName());
+                    }
+                    else {
+                        log.debug("EndpointDescriptionImpl.getHandlerChain: fileName: "
+                                + handlerFileName + " className: " + serviceClass.getName());
+                    }
+                }
+
+                String className =
+                        (composite != null) ? composite.getClassName() : serviceClass.getName();
+
+                ClassLoader classLoader =
+                        (composite != null) ? composite.getClassLoader() : this.getClass()
+                                                                               .getClassLoader();
+
+                InputStream is =
+                        DescriptionUtils.openHandlerConfigStream(handlerFileName,
+                                                                 className,
+                                                                 classLoader);
+
+                try {
+
+                    // All the classes we need should be part of this package
+                    JAXBContext jc =
+                            JAXBContext.newInstance("org.apache.axis2.jaxws.description.xml.handler",
+                                                    this.getClass().getClassLoader());
+
+                    Unmarshaller u = jc.createUnmarshaller();
+
+                    JAXBElement<?> o = (JAXBElement<?>) u.unmarshal(is);
+                    handlerChainsType = (HandlerChainsType) o.getValue();
+
+                } catch (Exception e) {
+                    throw ExceptionFactory.makeWebServiceException("EndpointDescriptionImpl:
getHandlerChain: thrown when attempting to unmarshall JAXB content");
+                }
+            }
+        }
+        return handlerChainsType;
+    }
+
+    
+    /*
+     * This is a client side only method. The generated service class may contain 
+     * handler chain annotations
+     */
+    public HandlerChain getAnnoHandlerChainAnnotation() {
+        if (this.handlerChainAnnotation == null) {
+                if (serviceClass != null) {
+                    handlerChainAnnotation =
+                            (HandlerChain) serviceClass.getAnnotation(HandlerChain.class);
+            }
+        }
+
+        return handlerChainAnnotation;
+    }
+    
+    /* Returns the WSDL definiton as specified in the metadata.  Note that this WSDL may
not be
      * complete.
      */
     public Definition getWSDLDefinition() {



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message