geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r535062 - in /geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf: CXFEndpoint.java ejb/EJBEndpoint.java ejb/EJBInterceptor.java ejb/EJBMethodInvoker.java pojo/POJOEndpoint.java
Date Fri, 04 May 2007 02:55:34 GMT
Author: gawor
Date: Thu May  3 19:55:33 2007
New Revision: 535062

URL: http://svn.apache.org/viewvc?view=rev&rev=535062
Log:
much improved jaxws ejb web service support

Added:
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBInterceptor.java
  (with props)
Modified:
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFEndpoint.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBEndpoint.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBMethodInvoker.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOEndpoint.java

Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFEndpoint.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFEndpoint.java?view=diff&rev=535062&r1=535061&r2=535062
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFEndpoint.java
(original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFEndpoint.java
Thu May  3 19:55:33 2007
@@ -27,6 +27,8 @@
 import javax.xml.transform.Source;
 import javax.xml.ws.Binding;
 import javax.xml.ws.Endpoint;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.Handler;
 import javax.xml.ws.http.HTTPBinding;
 import javax.xml.ws.soap.SOAPBinding;
 
@@ -34,12 +36,15 @@
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.endpoint.ServerImpl;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.jaxws.handler.PortInfoImpl;
+import org.apache.cxf.jaxws.javaee.HandlerChainsType;
 import org.apache.cxf.jaxws.support.AbstractJaxWsServiceFactoryBean;
 import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
 import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
-import org.apache.cxf.message.Message;
 import org.apache.cxf.service.Service;
 import org.apache.geronimo.jaxws.PortInfo;
+import org.apache.geronimo.jaxws.annotations.AnnotationException;
+import org.apache.geronimo.jaxws.annotations.AnnotationProcessor;
 
 public abstract class CXFEndpoint extends Endpoint {
 
@@ -56,6 +61,8 @@
     protected AbstractJaxWsServiceFactoryBean serviceFactory;
 
     protected PortInfo portInfo;
+    
+    protected AnnotationProcessor annotationProcessor;
 
     public CXFEndpoint(Bus bus, Object implementor) {
         this.bus = bus;
@@ -91,7 +98,7 @@
         return this.implementor.getClass();
     }
     
-    org.apache.cxf.endpoint.Endpoint getEndpoint() {
+    protected org.apache.cxf.endpoint.Endpoint getEndpoint() {
         return ((ServerImpl) getServer()).getEndpoint();
     }
 
@@ -187,7 +194,53 @@
     protected void init() { 
     }
           
-    public void stop() {
+    /*
+     * Set appropriate handlers for the port/service/bindings.
+     */
+    protected void initHandlers() throws Exception {        
+        HandlerChainsType handlerChains = this.portInfo.getHandlers(HandlerChainsType.class);
+        CXFHandlerResolver handlerResolver =
+            new CXFHandlerResolver(getImplementorClass().getClassLoader(), 
+                                   getImplementorClass(),
+                                   handlerChains, 
+                                   null);
+                      
+        PortInfoImpl portInfo = new PortInfoImpl(implInfo.getBindingType(), 
+                                                 serviceFactory.getEndpointName(),
+                                                 service.getName());
+        
+        List<Handler> chain = handlerResolver.getHandlerChain(portInfo);
+
+        getBinding().setHandlerChain(chain);
+    }
+        
+    protected void injectResources(Object instance) throws AnnotationException {
+        this.annotationProcessor.processAnnotations(instance);
+        this.annotationProcessor.invokePostConstruct(instance);
+    }
+    
+    protected void injectHandlers() {
+        List<Handler> handlers = getBinding().getHandlerChain();
+        try {
+            for (Handler handler : handlers) {
+                injectResources(handler);
+            }
+        } catch (AnnotationException e) {
+            throw new WebServiceException("Handler annotation failed", e);
+        }
+    }
+    
+    protected void destroyHandlers() {
+        if (this.annotationProcessor != null) {
+            // call handlers preDestroy
+            List<Handler> handlers = getBinding().getHandlerChain();
+            for (Handler handler : handlers) {
+                this.annotationProcessor.invokePreDestroy(handler);
+            }
+        }
+    }
+    
+    public void stop() {        
         // shutdown server
         if (this.server != null) {
             this.server.stop();

Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBEndpoint.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBEndpoint.java?view=diff&rev=535062&r1=535061&r2=535062
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBEndpoint.java
(original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBEndpoint.java
Thu May  3 19:55:33 2007
@@ -19,18 +19,32 @@
 package org.apache.geronimo.cxf.ejb;
 
 import java.net.URL;
+import java.util.List;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.WebServiceException;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.binding.soap.SoapBinding;
+import org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor;
+import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.jaxws.handler.LogicalHandlerInterceptor;
+import org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
-import org.apache.cxf.message.Message;
 import org.apache.geronimo.cxf.CXFEndpoint;
 import org.apache.geronimo.cxf.CXFServiceConfiguration;
 import org.apache.geronimo.cxf.GeronimoJaxWsImplementorInfo;
+import org.apache.geronimo.jaxws.JAXWSAnnotationProcessor;
 import org.apache.geronimo.jaxws.JAXWSUtils;
+import org.apache.geronimo.jaxws.JNDIResolver;
 import org.apache.openejb.DeploymentInfo;
 
 public class EJBEndpoint extends CXFEndpoint {
-
+    
     public EJBEndpoint(Bus bus,
                        URL configurationBaseUrl,
                        Class instance) {
@@ -61,14 +75,75 @@
         service = serviceFactory.create();        
     }
     
-    protected void init() {         
+    protected Class getImplementorClass() {
+        return (Class)this.implementor;
+    }
+    
+    protected void init() {
+        // configure handlers
+        try {
+            initHandlers();
+        } catch (Exception e) {
+            throw new WebServiceException("Error configuring handlers", e);
+        }
+                
         DeploymentInfo deploymentInfo = 
             (DeploymentInfo)bus.getExtension(DeploymentInfo.class);
-        service.setInvoker(new EJBMethodInvoker(deploymentInfo));        
+        
+        service.setInvoker(new EJBMethodInvoker(this, this.bus, deploymentInfo));  
+        
+        Endpoint endpoint = getEndpoint();
+        
+        /* 
+         * Remove interceptors that perform handler processing since
+         * handler processing must happen within the EJB container.
+         */        
+        removeHandlerInterceptors(bus.getInInterceptors());
+        removeHandlerInterceptors(endpoint.getInInterceptors());
+        removeHandlerInterceptors(endpoint.getBinding().getInInterceptors());
+        removeHandlerInterceptors(endpoint.getService().getInInterceptors());
+        
+        // install SAAJ interceptor        
+        if (endpoint.getBinding() instanceof SoapBinding &&
+            !this.implInfo.isWebServiceProvider()) {
+            endpoint.getService().getInInterceptors().add(new SAAJInInterceptor());
+        }        
+    }
+        
+    private static void removeHandlerInterceptors(List<Interceptor> interceptors) {
+        for (Interceptor interceptor : interceptors) {
+            if (interceptor instanceof MustUnderstandInterceptor ||
+                interceptor instanceof LogicalHandlerInterceptor ||
+                interceptor instanceof SOAPHandlerInterceptor) {
+                interceptors.remove(interceptor);
+            }
+        } 
     }
     
-    protected Class getImplementorClass() {
-        return (Class)this.implementor;
+    public synchronized void injectHandlers() {
+        if (this.annotationProcessor != null) {
+            // assume injection was already done
+            return;
+        }
+        
+        WebServiceContext wsContext = null;
+        try {
+            InitialContext ctx = new InitialContext();
+            wsContext = (WebServiceContext) ctx.lookup("java:comp/WebServiceContext");
+        } catch (NamingException e) {
+            throw new WebServiceException("Failed to lookup WebServiceContext", e);
+        }
+        
+        this.annotationProcessor = new JAXWSAnnotationProcessor(new JNDIResolver(), wsContext);
+        super.injectHandlers();
+    }
+    
+    public void stop() {
+        // call handler preDestroy
+        destroyHandlers();
+
+        // shutdown server
+        super.stop();
     }
     
 }

Added: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBInterceptor.java?view=auto&rev=535062
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBInterceptor.java
(added)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBInterceptor.java
Thu May  3 19:55:33 2007
@@ -0,0 +1,197 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.geronimo.cxf.ejb;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.ws.Binding;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.Bus;
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.interceptor.OutgoingChainInterceptor;
+import org.apache.cxf.interceptor.ServiceInvokerInterceptor;
+import org.apache.cxf.jaxws.handler.LogicalHandlerInterceptor;
+import org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor;
+import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.w3c.dom.Element;
+
+public class EJBInterceptor {
+
+    private static final Log LOG = LogFactory.getLog(EJBInterceptor.class);
+
+    private Exchange exchange;
+    private Bus bus;
+    private EJBEndpoint ejbEndpoint;
+    private List<Object> params;
+    private Method method;
+
+    public EJBInterceptor(List<Object> params,
+                          Method method,
+                          EJBEndpoint endpoint,
+                          Bus bus,
+                          Exchange exchange) {
+        this.params = params;
+        this.method = method;
+        this.ejbEndpoint = endpoint;
+        this.bus = bus;
+        this.exchange = exchange;
+    }
+
+    private static void copyDataBindingInterceptors(PhaseInterceptorChain newChain,
+                                                    InterceptorChain oldChain) {
+        for (Interceptor interceptor : oldChain) {
+            if (interceptor instanceof AbstractInDatabindingInterceptor) {
+                LOG.debug("Added data binding interceptor: " + interceptor);
+                newChain.add(interceptor);
+            }
+        }
+    }
+
+    @AroundInvoke
+    public Object intercept(InvocationContext context) throws Exception {
+        Endpoint endpoint = this.exchange.get(Endpoint.class);
+        Service service = endpoint.getService();
+        Binding binding = ((JaxWsEndpointImpl) endpoint).getJaxwsBinding();
+
+        this.exchange.put(InvocationContext.class, context);
+
+        if (binding.getHandlerChain() == null || binding.getHandlerChain().isEmpty()) {
+            // no handlers so let's just directly invoke the bean
+            LOG.debug("No handlers found.");
+            
+            EJBMethodInvoker invoker = (EJBMethodInvoker) service.getInvoker();
+            return invoker.directEjbInvoke(this.exchange, this.method, this.params);
+
+        } else {
+            // have handlers so have to run handlers now and redo data binding
+            // as handlers can change the soap message
+            LOG.debug("Handlers found.");
+                        
+            // inject handlers (on first call only)
+            this.ejbEndpoint.injectHandlers();
+
+            Message inMessage = this.exchange.getInMessage();
+            PhaseInterceptorChain chain = 
+                new PhaseInterceptorChain(this.bus.getExtension(PhaseManager.class).getInPhases());
+
+            chain.setFaultObserver(endpoint.getOutFaultObserver());
+
+            /*
+             * Since we have to re-do data binding and the XMLStreamReader
+             * contents are already consumed by prior data binding step
+             * we have to reinitialize the XMLStreamReader from the SOAPMessage
+             * created by SAAJInInterceptor. 
+             */
+            if (inMessage instanceof SoapMessage) {
+                try {
+                    reserialize((SoapMessage)inMessage);
+                } catch (Exception e) {
+                    throw new RuntimeException("Failed to reserialize soap message", e);
+                }
+            } else {
+                // TODO: how to handle XML/HTTP binding?
+            }
+            
+            this.exchange.setOutMessage(null);
+
+            // install default interceptors
+            chain.add(new ServiceInvokerInterceptor());
+            chain.add(new OutgoingChainInterceptor());
+
+            // install interceptors for handler processing
+            chain.add(new MustUnderstandInterceptor());
+            chain.add(new LogicalHandlerInterceptor(binding));
+            chain.add(new SOAPHandlerInterceptor(binding));
+
+            // install data binding interceptors
+            copyDataBindingInterceptors(chain, inMessage.getInterceptorChain());
+
+            InterceptorChain oldChain = inMessage.getInterceptorChain();
+            inMessage.setInterceptorChain(chain);
+            try {
+                chain.doIntercept(inMessage);
+            } finally {
+                inMessage.setInterceptorChain(oldChain);
+            }
+
+            // TODO: the result should be deserialized from SOAPMessage
+            Object result = getResult();
+
+            return result;
+        }
+    }
+
+    private Object getResult() {
+        Message outMessage = this.exchange.getOutMessage();
+        if (outMessage == null) {
+            return null;
+        } else {
+            List<?> result = outMessage.getContent(List.class);
+            if (result == null) {
+                return outMessage.get(Object.class);
+            } else if (result.isEmpty()) {
+                return null;
+            } else {
+                return result.get(0);
+            }
+        }
+    }
+    
+    private void reserialize(SoapMessage message) throws Exception {
+        SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
+        if (soapMessage == null) {
+            return;
+        }
+        
+        //replace header element if necessary
+        if (message.hasHeaders(Element.class)) {
+            Element headerElements = soapMessage.getSOAPHeader();    
+            message.setHeaders(Element.class, headerElements);
+        }
+        
+        XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
+        StaxUtils.readDocElements(soapMessage.getSOAPBody(), xmlReader, true);
+        DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody());
+        xmlReader = StaxUtils.createXMLStreamReader(bodySource);
+        xmlReader.nextTag();
+        xmlReader.nextTag(); // move past body tag
+        message.setContent(XMLStreamReader.class, xmlReader);
+    }
+        
+}
\ No newline at end of file

Propchange: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBMethodInvoker.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBMethodInvoker.java?view=diff&rev=535062&r1=535061&r2=535062
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBMethodInvoker.java
(original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ejb/EJBMethodInvoker.java
Thu May  3 19:55:33 2007
@@ -19,27 +19,37 @@
 
 package org.apache.geronimo.cxf.ejb;
 
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.interceptor.InvocationContext;
 import javax.xml.ws.handler.MessageContext;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.cxf.Bus;
 import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.jaxws.JAXWSMethodInvoker;
 import org.apache.cxf.jaxws.context.WebServiceContextImpl;
 import org.apache.cxf.jaxws.support.ContextPropertiesMapping;
 import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.FaultMode;
+import org.apache.cxf.service.invoker.AbstractInvoker;
 import org.apache.openejb.DeploymentInfo;
-import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.RpcContainer;
 
-public class EJBMethodInvoker extends JAXWSMethodInvoker {
+public class EJBMethodInvoker extends AbstractInvoker {
 
+    private static final Log LOG = LogFactory.getLog(EJBMethodInvoker.class);
+    
     private DeploymentInfo deploymentInfo;
+    private Bus bus;
+    private EJBEndpoint endpoint;
 
-    public EJBMethodInvoker(DeploymentInfo deploymentInfo) {
-        super(null, null);
+    public EJBMethodInvoker(EJBEndpoint endpoint, Bus bus, DeploymentInfo deploymentInfo)
{
+        this.endpoint = endpoint;
+        this.bus = bus;
         this.deploymentInfo = deploymentInfo;
     }
 
@@ -47,42 +57,108 @@
         return null;
     }
 
-    protected Object invoke(Exchange exchange,
-                            Object serviceObject,
-                            Method m,
-                            List<Object> params) {
-
+    protected Object invoke(Exchange exchange, 
+                            Object serviceObject, 
+                            Method m, 
+                            List<Object> params) {       
+        Object result = null;
+        
+        InvocationContext invContext = exchange.get(InvocationContext.class);
+        if (invContext == null) {
+            LOG.debug("PreEJBInvoke");
+            result = preEjbInvoke(exchange, serviceObject, m, params);
+        } else {
+            LOG.debug("EJBInvoke");
+            result = ejbInvoke(exchange, serviceObject, m, params);
+        }    
+        
+        return result;
+    }
+    
+    private Object preEjbInvoke(Exchange exchange, 
+                                Object serviceObject, 
+                                Method method, 
+                                List<Object> params) {           
+        
         MessageContext ctx = ContextPropertiesMapping.createWebServiceContext(exchange);
         WebServiceContextImpl.setMessageContext(ctx);
 
-        Object[] paramArray = new Object[] {};
-        if (params != null) {
-            paramArray = params.toArray();
+        try {           
+            EJBInterceptor interceptor = new EJBInterceptor(params, method, this.endpoint,
this.bus, exchange);
+            Object[] arguments = { ctx, interceptor };
+
+            RpcContainer container = (RpcContainer) this.deploymentInfo.getContainer();
+
+            Class callInterface = this.deploymentInfo.getServiceEndpointInterface();
+            method = getMostSpecificMethod(method, callInterface);
+            Object res = container.invoke(this.deploymentInfo.getDeploymentID(), method,
arguments, null);
+
+            if (exchange.isOneWay()) {
+                return null;
+            }
+
+            List<Object> retList = new ArrayList<Object>(1);
+            if (!((Class) method.getReturnType()).getName().equals("void")) {
+                retList.add(res);
+            }
+            
+            return retList;
+        } catch (Exception e) {
+            exchange.getInMessage().put(FaultMode.class, FaultMode.UNCHECKED_APPLICATION_FAULT);
+            throw new Fault(e);
+        } finally {
+            WebServiceContextImpl.clear();
         }
-
-        insertExchange(m, paramArray, exchange);
-        
-        RpcContainer container = (RpcContainer) this.deploymentInfo.getContainer();
-        Object result = null;
+    }
+    
+    private Object ejbInvoke(Exchange exchange, 
+                             Object serviceObject, 
+                             Method m, 
+                             List<Object> params) {         
         try {
-            result = container.invoke(this.deploymentInfo.getDeploymentID(), m, paramArray,
null, null);
-        } catch (OpenEJBException e) {
-            throw new Fault(e);           
-        } catch (RuntimeException e) {
+            Object res = directEjbInvoke(exchange, m, params);
+            
+            if (exchange.isOneWay()) {
+                return null;
+            }
+            
+            List<Object> retList = new ArrayList<Object>(1);
+            if (!((Class)m.getReturnType()).getName().equals("void")) {
+                retList.add(res);
+            }
+            
+            return retList;
+        } catch (InvocationTargetException e) {
+            Throwable t = e.getCause();
+            if (t == null) {
+                t = e;
+            }
+            exchange.getInMessage().put(FaultMode.class, FaultMode.CHECKED_APPLICATION_FAULT);
+            throw new Fault(t);
+        } catch (Exception e) {
+            exchange.getInMessage().put(FaultMode.class, FaultMode.UNCHECKED_APPLICATION_FAULT);
             throw new Fault(e);
         }
-        
-        if (exchange.isOneWay()) {
-            return null;
-        }
+    }
 
-        List<Object> retList = new ArrayList<Object>(1);
-        if (!((Class) m.getReturnType()).getName().equals("void")) {
-            retList.add(result);
+    public Object directEjbInvoke(Exchange exchange, 
+                                  Method m, 
+                                  List<Object> params) throws Exception {
+        InvocationContext invContext = exchange.get(InvocationContext.class);
+        Object[] paramArray;
+        if (params != null) {
+            paramArray = params.toArray();
+        } else {
+            paramArray = new Object[]{};
         }
-
-        ContextPropertiesMapping.updateWebServiceContext(exchange, ctx);
-
-        return retList;
+                    
+        invContext.setParameters(paramArray);
+        Object res = invContext.proceed();
+        
+        ContextPropertiesMapping.updateWebServiceContext(exchange, 
+                                                         (MessageContext)invContext.getContextData());
+                
+        return res;
     }
+        
 }

Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOEndpoint.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOEndpoint.java?view=diff&rev=535062&r1=535061&r2=535062
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOEndpoint.java
(original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOEndpoint.java
Thu May  3 19:55:33 2007
@@ -19,30 +19,22 @@
 package org.apache.geronimo.cxf.pojo;
 
 import java.net.URL;
-import java.util.List;
 
 import javax.xml.ws.WebServiceException;
-import javax.xml.ws.handler.Handler;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.jaxws.JAXWSMethodInvoker;
-import org.apache.cxf.jaxws.handler.PortInfoImpl;
-import org.apache.cxf.jaxws.javaee.HandlerChainsType;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
 import org.apache.geronimo.cxf.CXFEndpoint;
-import org.apache.geronimo.cxf.CXFHandlerResolver;
 import org.apache.geronimo.cxf.CXFServiceConfiguration;
 import org.apache.geronimo.cxf.GeronimoJaxWsImplementorInfo;
 import org.apache.geronimo.jaxws.JAXWSAnnotationProcessor;
 import org.apache.geronimo.jaxws.JAXWSUtils;
 import org.apache.geronimo.jaxws.JNDIResolver;
 import org.apache.geronimo.jaxws.annotations.AnnotationException;
-import org.apache.geronimo.jaxws.annotations.AnnotationProcessor;
 
 public class POJOEndpoint extends CXFEndpoint {
-
-    private AnnotationProcessor annotationProcessor;
-
+  
     public POJOEndpoint(Bus bus, URL configurationBaseUrl, Object instance) {
         super(bus, instance);
         
@@ -79,7 +71,8 @@
     protected void init() {        
         // configure and inject handlers
         try {
-            configureHandlers();
+            initHandlers();
+            injectHandlers();
         } catch (Exception e) {
             throw new WebServiceException("Error configuring handlers", e);
         }
@@ -92,38 +85,9 @@
         }
     }
 
-    private void injectResources(Object instance) throws AnnotationException {
-        this.annotationProcessor.processAnnotations(instance);
-        this.annotationProcessor.invokePostConstruct(instance);
-    }
-
-    /*
-     * Gets the right handlers for the port/service/bindings and 
-     * performs injection.
-     */
-    protected void configureHandlers() throws Exception {        
-        HandlerChainsType handlerChains = this.portInfo.getHandlers(HandlerChainsType.class);
-        CXFHandlerResolver handlerResolver =
-            new CXFHandlerResolver(this.implementor.getClass().getClassLoader(), 
-                                   this.implementor.getClass(),
-                                   handlerChains, 
-                                   this.annotationProcessor);
-                      
-        PortInfoImpl portInfo = new PortInfoImpl(implInfo.getBindingType(), 
-                                                 serviceFactory.getEndpointName(),
-                                                 service.getName());
-        
-        List<Handler> chain = handlerResolver.getHandlerChain(portInfo);
-
-        getBinding().setHandlerChain(chain);
-    }
-
     public void stop() {
-        // call handlers preDestroy
-        List<Handler> handlers = getBinding().getHandlerChain();
-        for (Handler handler : handlers) {
-            this.annotationProcessor.invokePreDestroy(handler);
-        }
+        // call handler preDestroy
+        destroyHandlers();
 
         // call service preDestroy
         this.annotationProcessor.invokePreDestroy(this.implementor);



Mime
View raw message