tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r591858 [11/13] - in /openejb/trunk/openejb3: ./ assembly/openejb-tomcat/ assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/ container/openejb-core/ container/openejb-core/src/main/java/org/apache/openejb/ container/openejb-co...
Date Sun, 04 Nov 2007 22:42:06 GMT
Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfEndpoint.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfEndpoint.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfEndpoint.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfEndpoint.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,214 @@
+/**
+ *
+ * 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.openejb.server.cxf;
+
+import org.apache.cxf.Bus;
+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.support.JaxWsEndpointImpl;
+import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.cxf.service.Service;
+import org.apache.openejb.core.webservices.HandlerResolverImpl;
+import org.apache.openejb.core.webservices.PortData;
+
+import javax.xml.transform.Source;
+import javax.xml.ws.Binding;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.http.HTTPBinding;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.naming.Context;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executor;
+
+public abstract class CxfEndpoint extends Endpoint {
+    protected Bus bus;
+
+    protected PortData port;
+
+    protected Context context;
+
+    protected Object implementor;
+
+    protected Server server;
+
+    protected Service service;
+
+    protected JaxWsImplementorInfo implInfo;
+
+    protected JaxWsServiceFactoryBean serviceFactory;
+
+    protected HandlerResolverImpl handlerResolver;
+
+    public CxfEndpoint(Bus bus, PortData port, Context context, Object implementor) {
+        this.bus = bus;
+        this.port = port;
+        this.implementor = implementor;
+        this.context = context;
+    }
+
+    protected URL getWsdlURL(URL configurationBaseUrl, String wsdlFile) {
+        URL wsdlURL = null;
+        if (wsdlFile != null && wsdlFile.trim().length() > 0) {
+            wsdlFile = wsdlFile.trim();
+            try {
+                wsdlURL = new URL(wsdlFile);
+            } catch (MalformedURLException e) {
+                // Not a URL, try as a resource
+                wsdlURL = getImplementorClass().getResource("/" + wsdlFile);
+
+                if (wsdlURL == null && configurationBaseUrl != null) {
+                    // Cannot get it as a resource, try with
+                    // configurationBaseUrl
+                    try {
+                        wsdlURL = new URL(configurationBaseUrl, wsdlFile);
+                    } catch (MalformedURLException ee) {
+                        // ignore
+                    }
+                }
+            }
+        }
+        return wsdlURL;
+    }
+
+    protected Class getImplementorClass() {
+        return this.implementor.getClass();
+    }
+
+    protected org.apache.cxf.endpoint.Endpoint getEndpoint() {
+        return getServer().getEndpoint();
+    }
+
+    public boolean isSOAP11() {
+        return SOAPBinding.SOAP11HTTP_BINDING.equals(implInfo.getBindingType()) ||
+                SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(implInfo.getBindingType());
+    }
+
+    public ServerImpl getServer() {
+        return (ServerImpl) server;
+    }
+
+    public Binding getBinding() {
+        return ((JaxWsEndpointImpl) getEndpoint()).getJaxwsBinding();
+    }
+
+    public void setExecutor(Executor executor) {
+        service.setExecutor(executor);
+    }
+
+    public Executor getExecutor() {
+        return service.getExecutor();
+    }
+
+    public Object getImplementor() {
+        return implementor;
+    }
+
+    public List<Source> getMetadata() {
+        return null;
+    }
+
+    public Map<String, Object> getProperties() {
+        return null;
+    }
+
+    public boolean isPublished() {
+        return server != null;
+    }
+
+    public void publish(Object arg0) {
+    }
+
+    public void publish(String address) {
+        doPublish(address);
+    }
+
+    public void setMetadata(List<Source> arg0) {
+    }
+
+    public void setProperties(Map<String, Object> arg0) {
+    }
+
+    private static class NoInitJaxWsServerFactoryBean extends JaxWsServerFactoryBean {
+        public NoInitJaxWsServerFactoryBean() {
+            // disable CXF resource injection
+            doInit = false;
+        }
+    }
+
+    protected void doPublish(String address) {
+        JaxWsServerFactoryBean svrFactory = new NoInitJaxWsServerFactoryBean();
+        svrFactory.setBus(bus);
+        svrFactory.setAddress(address);
+        svrFactory.setServiceFactory(serviceFactory);
+        svrFactory.setStart(false);
+        svrFactory.setServiceBean(implementor);
+
+        if (HTTPBinding.HTTP_BINDING.equals(implInfo.getBindingType())) {
+            svrFactory.setTransportId("http://cxf.apache.org/bindings/xformat");
+        }
+
+        server = svrFactory.create();
+
+        init();
+
+        // todo do we need to call this?
+        getEndpoint();
+
+        if (getBinding() instanceof SOAPBinding) {
+            ((SOAPBinding) getBinding()).setMTOMEnabled(port.isMtomEnabled());
+        }
+
+        server.start();
+    }
+
+    protected void init() {
+    }
+
+    /**
+     * Set appropriate handlers for the port/service/bindings.
+     */
+    protected void initHandlers() throws Exception {
+        PortInfoImpl portInfo = new PortInfoImpl(implInfo.getBindingType(), serviceFactory.getEndpointName(), service.getName());
+
+        handlerResolver = new HandlerResolverImpl(port.getHandlerChains(), port.getInjections(), context);
+        List<Handler> chain = handlerResolver.getHandlerChain(portInfo);
+
+        getBinding().setHandlerChain(chain);
+    }
+
+    protected void destroyHandlers() {
+        if (this.handlerResolver != null) {
+            handlerResolver.destroyHandlers();
+            handlerResolver = null;
+        }
+    }
+
+    public void stop() {
+        // shutdown server
+        if (this.server != null) {
+            this.server.stop();
+        }
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfService.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,75 @@
+/**
+ *
+ * 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.openejb.server.cxf;
+
+import org.apache.cxf.Bus;
+import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.core.webservices.PortData;
+import org.apache.openejb.server.cxf.ejb.EjbWsContainer;
+import org.apache.openejb.server.cxf.pojo.PojoWsContainer;
+import org.apache.openejb.server.httpd.HttpListener;
+import org.apache.openejb.server.webservices.WsService;
+
+import javax.naming.Context;
+import java.net.URL;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class CxfService extends WsService {
+    private final Map<String, CxfWsContainer> wsContainers = new TreeMap<String, CxfWsContainer>();
+
+    public String getName() {
+        return "cxf";
+    }
+
+    protected HttpListener createEjbWsContainer(URL moduleBaseUrl, PortData port, DeploymentInfo deploymentInfo) {
+        Bus bus = CxfWsContainer.getBus();
+
+        CxfCatalogUtils.loadOASISCatalog(bus, moduleBaseUrl, "META-INF/jax-ws-catalog.xml");
+
+        EjbWsContainer container = new EjbWsContainer(bus, port, deploymentInfo);
+        container.start();
+        wsContainers.put(deploymentInfo.getDeploymentID().toString(), container);
+        return container;
+    }
+
+    protected void destroyEjbWsContainer(String deploymentId) {
+        CxfWsContainer container = wsContainers.remove(deploymentId);
+        if (container != null) {
+            container.destroy();
+        }
+    }
+
+    protected HttpListener createPojoWsContainer(URL moduleBaseUrl, PortData port, String serviceId, Class target, Context context, String contextRoot) {
+        Bus bus = CxfWsContainer.getBus();
+
+        CxfCatalogUtils.loadOASISCatalog(bus, moduleBaseUrl, "META-INF/jax-ws-catalog.xml");
+
+        PojoWsContainer container = new PojoWsContainer(bus, port, context, target);
+        container.start();
+        wsContainers.put(serviceId, container);
+        return container;
+    }
+
+    protected void destroyPojoWsContainer(String serviceId) {
+        CxfWsContainer container = wsContainers.remove(serviceId);
+        if (container != null) {
+            container.destroy();
+        }
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfServiceConfiguration.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfServiceConfiguration.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfServiceConfiguration.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfServiceConfiguration.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,58 @@
+/**
+ *
+ * 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.openejb.server.cxf;
+
+import org.apache.cxf.service.factory.AbstractServiceConfiguration;
+import org.apache.openejb.core.webservices.PortData;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Used to overwrite serviceName and portName values of WebService annotation.
+ */
+public class CxfServiceConfiguration extends AbstractServiceConfiguration {
+    private PortData port;
+
+    public CxfServiceConfiguration(PortData portData) {
+        this.port = portData;
+    }
+
+    public String getServiceName() {
+        if (port.getWsdlService() != null) {
+            return port.getWsdlService().getLocalPart();
+        } else {
+            return null;
+        }
+    }
+
+    public String getServiceNamespace() {
+        if (port.getWsdlService() != null) {
+            return port.getWsdlService().getNamespaceURI();
+        } else {
+            return null;
+        }
+    }
+
+    public QName getEndpointName() {
+        return this.port.getWsdlPort();
+    }
+
+    public String getWsdlURL() {
+        return (port.getWsdlUrl() == null) ? null : port.getWsdlUrl().toString();
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/CxfWsContainer.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,152 @@
+/**
+ *
+ * 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.openejb.server.cxf;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.extension.ExtensionManagerBus;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.openejb.core.webservices.PortData;
+import org.apache.openejb.server.httpd.HttpRequest;
+import org.apache.openejb.server.httpd.HttpResponse;
+import org.apache.openejb.server.httpd.HttpListener;
+import org.apache.openejb.server.webservices.saaj.SaajUniverse;
+
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class CxfWsContainer implements HttpListener {
+    protected final Bus bus;
+    protected final PortData port;
+    protected HttpDestination destination;
+    protected CxfEndpoint endpoint;
+
+
+    public CxfWsContainer(Bus bus, PortData port) {
+        this.bus = bus;
+        this.port = port;
+
+        List<String> ids = new ArrayList<String>();
+        ids.add("http://schemas.xmlsoap.org/wsdl/soap/");
+
+        DestinationFactoryManager factoryManager = bus.getExtension(DestinationFactoryManager.class);
+        HttpTransportFactory factory = new HttpTransportFactory(bus);
+        factory.setTransportIds(ids);
+
+        factoryManager.registerDestinationFactory("http://cxf.apache.org/transports/http/configuration", factory);
+        factoryManager.registerDestinationFactory("http://cxf.apache.org/bindings/xformat", factory);
+        factoryManager.registerDestinationFactory("http://www.w3.org/2003/05/soap/bindings/HTTP/", factory);
+        factoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", factory);
+        factoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/http/", factory);
+        factoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", factory);
+    }
+
+    public void start() {
+        endpoint = createEndpoint();
+        endpoint.publish("http://nopath");
+        destination = (HttpDestination) endpoint.getServer().getDestination();
+    }
+
+    protected abstract CxfEndpoint createEndpoint();
+
+    public void destroy() {
+        if (endpoint != null) {
+            endpoint.stop();
+            endpoint = null;
+        }
+        // if (destination != null) {
+        //    destination.shutdown();
+        //    destination = null;
+        // }
+    }
+
+    public void onMessage(HttpRequest request, HttpResponse response) throws Exception {
+        if (request.getMethod() == HttpRequest.GET) {
+            processGET(request, response);
+        } else {
+            processPOST(request, response);
+        }
+    }
+
+    protected void processGET(HttpRequest request, HttpResponse response) throws Exception {
+        boolean wsdlRequest = request.getParameter("wsdl") != null ||
+                request.getParameter("WSDL") != null ||
+                request.getParameter("xsd") != null ||
+                request.getParameter("XSD") != null;
+
+        if (wsdlRequest) {
+            getWsdl(request, response);
+        } else if (endpoint.isSOAP11()) {
+            EndpointInfo ei = this.destination.getEndpointInfo();
+            response.setContentType("text/html");
+            PrintWriter pw = new PrintWriter(response.getOutputStream());
+            pw.write("<html><title>Web Service</title><body>");
+            pw.write("Hi, this is '" + ei.getService().getName().getLocalPart() + "' web service.");
+            pw.write("</body></html>");
+            pw.flush();
+        } else {
+            processPOST(request, response);
+        }
+    }
+
+    protected void processPOST(HttpRequest request, HttpResponse response) throws Exception {
+        SaajUniverse universe = new SaajUniverse();
+        universe.set(SaajUniverse.DEFAULT);
+        try {
+            destination.invoke(request, response);
+        } finally {
+            universe.unset();
+        }
+    }
+
+    private void getWsdl(HttpRequest request, HttpResponse response) throws Exception {
+        WsdlQueryHandler queryHandler = new WsdlQueryHandler(this.bus);
+        String requestUri = request.getURI().toString();
+        EndpointInfo ei = this.destination.getEndpointInfo();
+        OutputStream out = response.getOutputStream();
+        response.setContentType("text/xml");
+        queryHandler.writeResponse(requestUri, null, ei, out);
+    }
+
+    /*
+     * Ensure the bus created is unqiue and non-shared.
+     * The very first bus created is set as a default bus which then can
+     * be (re)used in other places.
+     */
+    public static Bus getBus() {
+        getDefaultBus();
+        return new ExtensionManagerBus();
+    }
+
+    /*
+     * Ensure the Spring bus is initialized with the CXF module classloader
+     * instead of the application classloader.
+     */
+    public static Bus getDefaultBus() {
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(CxfEndpoint.class.getClassLoader());
+        try {
+            return BusFactory.getDefaultBus();
+        } finally {
+            Thread.currentThread().setContextClassLoader(cl);
+        }
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpDestination.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpDestination.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpDestination.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpDestination.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,361 @@
+/**
+ *
+ * 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.openejb.server.cxf;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.security.SecurityContext;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.ConduitInitiator;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.openejb.server.webservices.WsConstants;
+import org.apache.openejb.server.httpd.HttpRequest;
+import org.apache.openejb.server.httpd.HttpResponse;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.ws.handler.MessageContext;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+public class HttpDestination extends AbstractHTTPDestination {
+    private MessageObserver messageObserver;
+    private boolean passSecurityContext = false;
+
+    public HttpDestination(Bus bus, ConduitInitiator conduitInitiator, EndpointInfo endpointInfo) throws IOException {
+        super(bus, conduitInitiator, endpointInfo, true);
+    }
+
+    public void setPassSecurityContext(boolean passSecurityContext) {
+        this.passSecurityContext = passSecurityContext;
+    }
+
+    public boolean getPassSecurityContext() {
+        return this.passSecurityContext;
+    }
+
+    public EndpointInfo getEndpointInfo() {
+        return this.endpointInfo;
+    }
+
+    public void invoke(HttpRequest request, HttpResponse response) throws Exception {
+        MessageImpl message = new MessageImpl();
+        message.setContent(InputStream.class, request.getInputStream());
+        message.setDestination(this);
+
+        message.put(HttpRequest.class, request);
+        message.put(HttpResponse.class, response);
+
+        final HttpServletRequest servletRequest = (HttpServletRequest) request.getAttribute(WsConstants.SERVLET_REQUEST);
+        message.put(MessageContext.SERVLET_REQUEST, servletRequest);
+
+        HttpServletResponse servletResponse = (HttpServletResponse) request.getAttribute(WsConstants.SERVLET_RESPONSE);
+        message.put(MessageContext.SERVLET_RESPONSE, servletResponse);
+
+        ServletContext servletContext = (ServletContext) request.getAttribute(WsConstants.SERVLET_CONTEXT);
+        message.put(MessageContext.SERVLET_CONTEXT, servletContext);
+
+        if (this.passSecurityContext) {
+            message.put(SecurityContext.class, new SecurityContext() {
+                public Principal getUserPrincipal() {
+                    return servletRequest.getUserPrincipal();
+                }
+
+                public boolean isUserInRole(String role) {
+                    return servletRequest.isUserInRole(role);
+                }
+            });
+        }
+
+        // this calls copyRequestHeaders()
+        setHeaders(message);
+
+        message.put(Message.HTTP_REQUEST_METHOD, servletRequest.getMethod());
+        message.put(Message.PATH_INFO, servletRequest.getPathInfo());
+        message.put(Message.QUERY_STRING, servletRequest.getQueryString());
+        message.put(Message.CONTENT_TYPE, servletRequest.getContentType());
+        message.put(Message.ENCODING, getCharacterEncoding(servletRequest.getCharacterEncoding()));
+
+        getMessageObserver().onMessage(message);
+    }
+
+    private static String getCharacterEncoding(String encoding) {
+        if (encoding != null) {
+            encoding = encoding.trim();
+            // work around a bug with Jetty which results in the character
+            // encoding not being trimmed correctly:
+            // http://jira.codehaus.org/browse/JETTY-302
+            if (encoding.endsWith("\"")) {
+                encoding = encoding.substring(0, encoding.length() - 1);
+            }
+        }
+        return encoding;
+    }
+
+    protected void copyRequestHeaders(Message message, Map<String, List<String>> headers) {
+        HttpServletRequest servletRequest = (HttpServletRequest) message.get(MessageContext.SERVLET_REQUEST);
+        if (servletRequest != null) {
+            Enumeration names = servletRequest.getHeaderNames();
+            while (names.hasMoreElements()) {
+                String name = (String) names.nextElement();
+
+                List<String> headerValues = headers.get(name);
+                if (headerValues == null) {
+                    headerValues = new ArrayList<String>();
+                    headers.put(name, headerValues);
+                }
+
+                Enumeration values = servletRequest.getHeaders(name);
+                while (values.hasMoreElements()) {
+                    String value = (String) values.nextElement();
+                    headerValues.add(value);
+                }
+            }
+        }
+    }
+
+    public Logger getLogger() {
+        return Logger.getLogger(HttpDestination.class.getName());
+    }
+
+    public Conduit getInbuiltBackChannel(Message inMessage) {
+        return new BackChannelConduit(null, inMessage);
+    }
+
+    public Conduit getBackChannel(Message inMessage, Message partialResponse, EndpointReferenceType address) throws IOException {
+        Conduit backChannel = null;
+        if (address == null) {
+            backChannel = new BackChannelConduit(address, inMessage);
+        } else {
+            if (partialResponse != null) {
+                // setup the outbound message to for 202 Accepted
+                partialResponse.put(Message.RESPONSE_CODE, HttpURLConnection.HTTP_ACCEPTED);
+                backChannel = new BackChannelConduit(address, inMessage);
+            } else {
+                backChannel = conduitInitiator.getConduit(endpointInfo, address);
+                // ensure decoupled back channel input stream is closed
+                backChannel.setMessageObserver(new MessageObserver() {
+                    public void onMessage(Message m) {
+                        if (m.getContentFormats().contains(InputStream.class)) {
+                            InputStream is = m.getContent(InputStream.class);
+                            try {
+                                is.close();
+                            } catch (Exception e) {
+                                // ignore
+                            }
+                        }
+                    }
+                });
+            }
+        }
+        return backChannel;
+    }
+
+    public void shutdown() {
+    }
+
+    public synchronized MessageObserver getMessageObserver() {
+        return messageObserver;
+    }
+
+    public synchronized void setMessageObserver(MessageObserver messageObserver) {
+        this.messageObserver = messageObserver;
+    }
+
+    protected class BackChannelConduit implements Conduit {
+
+        protected Message request;
+        protected EndpointReferenceType target;
+
+        BackChannelConduit(EndpointReferenceType target, Message request) {
+            this.target = target;
+            this.request = request;
+        }
+
+        public void close(Message msg) throws IOException {
+            msg.getContent(OutputStream.class).close();
+        }
+
+        /**
+         * Register a message observer for incoming messages.
+         *
+         * @param observer the observer to notify on receipt of incoming
+         */
+        public void setMessageObserver(MessageObserver observer) {
+            // shouldn't be called for a back channel conduit
+        }
+
+        public void prepare(Message message) throws IOException {
+            send(message);
+        }
+
+        /**
+         * Send an outbound message, assumed to contain all the name-value
+         * mappings of the corresponding input message (if any).
+         *
+         * @param message the message to be sent.
+         */
+        public void send(Message message) throws IOException {
+            HttpResponse response = request.get(HttpResponse.class);
+
+            // handle response headers
+            updateResponseHeaders(message);
+
+            Map<String, List<String>> protocolHeaders = getProtocolHeaders(message);
+
+            // set headers of the HTTP response object
+            for (Map.Entry<String, List<String>> entry : protocolHeaders.entrySet()) {
+                String headerName = entry.getKey();
+                String headerValue = getHeaderValue(entry.getValue());
+                response.setHeader(headerName, headerValue);
+            }
+
+            message.setContent(OutputStream.class, new WrappedOutputStream(message, response));
+        }
+
+        /**
+         * @return the reference associated with the target Destination
+         */
+        public EndpointReferenceType getTarget() {
+            return target;
+        }
+
+        /**
+         * Retreive the back-channel Destination.
+         *
+         * @return the backchannel Destination (or null if the backchannel is
+         *         built-in)
+         */
+        public Destination getBackChannel() {
+            return null;
+        }
+
+        /**
+         * Close the conduit
+         */
+        public void close() {
+        }
+    }
+
+    private String getHeaderValue(List<String> values) {
+        Iterator iter = values.iterator();
+        StringBuffer buf = new StringBuffer();
+        while (iter.hasNext()) {
+            buf.append(iter.next());
+            if (iter.hasNext()) {
+                buf.append(", ");
+            }
+        }
+        return buf.toString();
+    }
+
+    protected void setContentType(Message message, HttpResponse response) {
+        Map<String, List<String>> protocolHeaders = getProtocolHeaders(message);
+
+        if (protocolHeaders == null || !protocolHeaders.containsKey(Message.CONTENT_TYPE)) {
+            String ct = (String) message.get(Message.CONTENT_TYPE);
+            String enc = (String) message.get(Message.ENCODING);
+
+            if (null != ct) {
+                if (enc != null && ct.indexOf("charset=") == -1) {
+                    ct = ct + "; charset=" + enc;
+                }
+                response.setContentType(ct);
+            } else if (enc != null) {
+                response.setContentType("text/xml; charset=" + enc);
+            }
+        }
+    }
+
+    @SuppressWarnings({"unchecked"})
+    private Map<String, List<String>> getProtocolHeaders(Message message) {
+        Map<String, List<String>> protocolHeaders = (Map<String, List<String>>) message.get(Message.PROTOCOL_HEADERS);
+        return protocolHeaders;
+    }
+
+    private class WrappedOutputStream extends OutputStream {
+
+        private Message message;
+        private HttpResponse response;
+        private OutputStream rawOutputStream;
+
+        WrappedOutputStream(Message message, HttpResponse response) {
+            this.message = message;
+            this.response = response;
+        }
+
+        public void write(int b) throws IOException {
+            flushHeaders();
+            this.rawOutputStream.write(b);
+        }
+
+        public void write(byte b[]) throws IOException {
+            flushHeaders();
+            this.rawOutputStream.write(b);
+        }
+
+        public void write(byte b[], int off, int len) throws IOException {
+            flushHeaders();
+            this.rawOutputStream.write(b, off, len);
+        }
+
+        public void flush() throws IOException {
+            flushHeaders();
+            this.rawOutputStream.flush();
+        }
+
+        public void close() throws IOException {
+            flushHeaders();
+            this.rawOutputStream.close();
+        }
+
+        protected void flushHeaders() throws IOException {
+            if (this.rawOutputStream != null) {
+                return;
+            }
+
+            // set response code
+            Integer i = (Integer) this.message.get(Message.RESPONSE_CODE);
+            if (i != null) {
+                this.response.setStatusCode(i.intValue());
+            }
+
+            // set content-type
+            setContentType(this.message, this.response);
+
+            this.rawOutputStream = this.response.getOutputStream();
+        }
+
+    }
+
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpTransportFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpTransportFactory.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpTransportFactory.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/HttpTransportFactory.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,41 @@
+/**
+ *
+ * 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.openejb.server.cxf;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.http.AbstractHTTPTransportFactory;
+
+import java.io.IOException;
+
+public class HttpTransportFactory extends AbstractHTTPTransportFactory {
+    public HttpTransportFactory() {
+    }
+
+    public HttpTransportFactory(Bus bus) {
+        setBus(bus);
+    }
+
+    public Destination getDestination(EndpointInfo endpointInfo) throws IOException {
+        HttpDestination destination = new HttpDestination(getBus(), this, endpointInfo);
+        configure(destination);
+        return destination;
+    }
+
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/JaxWsImplementorInfoImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/JaxWsImplementorInfoImpl.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/JaxWsImplementorInfoImpl.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/JaxWsImplementorInfoImpl.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,40 @@
+/**
+ *
+ * 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.openejb.server.cxf;
+
+import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
+
+/**
+ * Override the binding type uri.
+ */
+public class JaxWsImplementorInfoImpl extends JaxWsImplementorInfo {
+    private final String bindingURI;
+
+    public JaxWsImplementorInfoImpl(Class clazz, String bindingURI) {
+        super(clazz);
+        this.bindingURI = bindingURI;
+    }
+
+    public String getBindingType() {
+        if (this.bindingURI != null) {
+            return this.bindingURI;
+        } else {
+            return super.getBindingType();
+        }
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ResourceManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ResourceManager.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ResourceManager.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ResourceManager.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,29 @@
+/**
+ *
+ * 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.openejb.server.cxf;
+
+import org.apache.cxf.bus.resource.ResourceManagerImpl;
+import org.apache.cxf.resource.ResourceResolver;
+
+import java.util.List;
+
+public class ResourceManager extends ResourceManagerImpl {
+    public ResourceManager(List<ResourceResolver> r) {
+        super(r);
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/WsdlQueryHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/WsdlQueryHandler.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/WsdlQueryHandler.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/WsdlQueryHandler.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,127 @@
+/**
+ *
+ * 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.openejb.server.cxf;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.tools.common.extensions.soap.SoapAddress;
+import org.apache.cxf.tools.util.SOAPBindingUtil;
+import org.apache.cxf.transport.http.WSDLQueryHandler;
+import org.apache.openejb.util.Logger;
+import org.apache.openejb.util.LogCategory;
+import org.xmlsoap.schemas.wsdl.http.AddressType;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.schema.SchemaReference;
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+public class WsdlQueryHandler extends WSDLQueryHandler {
+    private static final Logger logger = Logger.getInstance(LogCategory.CXF, WsdlQueryHandler.class);
+
+    public WsdlQueryHandler(Bus bus) {
+        super(bus);
+    }
+
+    protected void updateDefinition(Definition def, Map<String, Definition> done, Map<String, SchemaReference> doneSchemas, String base, EndpointInfo ei) {
+        if (done.get("") == def) {
+            QName serviceName = ei.getService().getName();
+            String portName = ei.getName().getLocalPart();
+            updateServices(serviceName, portName, def, base);
+        }
+        super.updateDefinition(def, done, doneSchemas, base, ei);
+    }
+
+    private void updateServices(QName serviceName, String portName, Definition def, String baseUri) {
+        boolean updated = false;
+        Map services = def.getServices();
+        if (services != null) {
+            ArrayList<QName> servicesToRemove = new ArrayList<QName>();
+
+            Iterator serviceIterator = services.entrySet().iterator();
+            while (serviceIterator.hasNext()) {
+                Map.Entry serviceEntry = (Map.Entry) serviceIterator.next();
+                QName currServiceName = (QName) serviceEntry.getKey();
+                if (currServiceName.equals(serviceName)) {
+                    Service service = (Service) serviceEntry.getValue();
+                    updatePorts(portName, service, baseUri);
+                    updated = true;
+                } else {
+                    servicesToRemove.add(currServiceName);
+                }
+            }
+
+            for (QName serviceToRemove : servicesToRemove) {
+                def.removeService(serviceToRemove);
+            }
+        }
+        if (!updated) {
+            logger.warning("WSDL '" + serviceName.getLocalPart() + "' service not found.");
+        }
+    }
+
+    private void updatePorts(String portName, Service service, String baseUri) {
+        boolean updated = false;
+        Map ports = service.getPorts();
+        if (ports != null) {
+            ArrayList<String> portsToRemove = new ArrayList<String>();
+
+            Iterator portIterator = ports.entrySet().iterator();
+            while (portIterator.hasNext()) {
+                Map.Entry portEntry = (Map.Entry) portIterator.next();
+                String currPortName = (String) portEntry.getKey();
+                if (currPortName.equals(portName)) {
+                    Port port = (Port) portEntry.getValue();
+                    updatePortLocation(port, baseUri);
+                    updated = true;
+                } else {
+                    portsToRemove.add(currPortName);
+                }
+            }
+
+            for (String portToRemove : portsToRemove) {
+                service.removePort(portToRemove);
+            }
+        }
+        if (!updated) {
+            logger.warning("WSDL '" + portName + "' port not found.");
+        }
+    }
+
+    private void updatePortLocation(Port port, String baseUri) {
+        List<?> exts = port.getExtensibilityElements();
+        if (exts != null && exts.size() > 0) {
+            ExtensibilityElement el = (ExtensibilityElement) exts.get(0);
+            if (SOAPBindingUtil.isSOAPAddress(el)) {
+                SoapAddress add = SOAPBindingUtil.getSoapAddress(el);
+                add.setLocationURI(baseUri);
+            }
+            if (el instanceof AddressType) {
+                AddressType add = (AddressType) el;
+                add.setLocation(baseUri);
+            }
+        }
+    }
+
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajInFaultInterceptor.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajInFaultInterceptor.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajInFaultInterceptor.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajInFaultInterceptor.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,36 @@
+/**
+ *  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.openejb.server.cxf.client;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.openejb.server.webservices.saaj.SaajUniverse;
+
+public class SaajInFaultInterceptor extends SaajInterceptor {
+    public SaajInFaultInterceptor(SaajUniverse universe) {
+        super(Phase.RECEIVE, universe);
+    }
+
+    public void handleMessage(Message arg0) throws Fault {
+    }
+
+    public void handleFault(Message msg) {
+        this.universe.unset();
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajInInterceptor.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajInInterceptor.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajInInterceptor.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajInInterceptor.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,33 @@
+/**
+ *  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.openejb.server.cxf.client;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.openejb.server.webservices.saaj.SaajUniverse;
+
+public class SaajInInterceptor extends SaajInterceptor {
+    public SaajInInterceptor(SaajUniverse universe) {
+        super(Phase.POST_INVOKE, universe);
+    }
+    
+    public void handleMessage(Message msg) throws Fault {
+        this.universe.unset();
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajInterceptor.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajInterceptor.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajInterceptor.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajInterceptor.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,45 @@
+/**
+ *  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.openejb.server.cxf.client;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.openejb.server.webservices.saaj.SaajUniverse;
+
+public abstract class SaajInterceptor extends AbstractPhaseInterceptor<Message> {
+    private static boolean interceptorsRegistered = false;
+    protected SaajUniverse universe;
+
+    public SaajInterceptor(String phase, SaajUniverse universe) {
+        super(phase);
+        this.universe = universe;
+    }
+    
+    public static synchronized void registerInterceptors() {
+        if (!interceptorsRegistered) {
+            Bus bus = BusFactory.getDefaultBus();
+            SaajUniverse universe = new SaajUniverse();
+            bus.getOutInterceptors().add(new SaajOutInterceptor(universe));
+            bus.getInInterceptors().add(new SaajInInterceptor(universe));
+            bus.getInInterceptors().add(new SaajInFaultInterceptor(universe));
+            interceptorsRegistered = true;
+        }
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajOutInterceptor.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajOutInterceptor.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajOutInterceptor.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/client/SaajOutInterceptor.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,37 @@
+/**
+ *  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.openejb.server.cxf.client;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.openejb.server.webservices.saaj.SaajUniverse;
+
+public class SaajOutInterceptor extends SaajInterceptor {
+    public SaajOutInterceptor(SaajUniverse universe) {
+        super(Phase.SETUP, universe);
+    }
+    
+    public void handleMessage(Message msg) throws Fault {
+        this.universe.set(SaajUniverse.DEFAULT);
+    }
+    
+    public void handleFault(Message msg) {
+        this.universe.unset();
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbEndpoint.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,106 @@
+/**
+ *
+ * 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.openejb.server.cxf.ejb;
+
+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.logical.LogicalHandlerInInterceptor;
+import org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor;
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.core.webservices.JaxWsUtils;
+import org.apache.openejb.core.webservices.PortData;
+import org.apache.openejb.server.cxf.CxfEndpoint;
+import org.apache.openejb.server.cxf.CxfServiceConfiguration;
+import org.apache.openejb.server.cxf.JaxWsImplementorInfoImpl;
+
+import javax.xml.ws.WebServiceException;
+import java.util.List;
+
+/**
+ * A web service endpoint which invokes an EJB container.
+ */
+public class EjbEndpoint extends CxfEndpoint {
+    private final DeploymentInfo deploymentInfo;
+
+    public EjbEndpoint(Bus bus, PortData portData, DeploymentInfo deploymentInfo) {
+        super(bus, portData, deploymentInfo.getJndiEnc(), deploymentInfo.getBeanClass());
+        this.deploymentInfo = deploymentInfo;
+
+        String bindingURI = JaxWsUtils.getBindingURI(portData.getBindingID());
+        implInfo = new JaxWsImplementorInfoImpl((Class) implementor, bindingURI);
+
+        serviceFactory = new JaxWsServiceFactoryBean(implInfo);
+        serviceFactory.setBus(bus);
+
+        // install as first to overwrite annotations (wsdl-file, wsdl-port, wsdl-service)
+        CxfServiceConfiguration configuration = new CxfServiceConfiguration(portData);
+        serviceFactory.getConfigurations().add(0, configuration);
+
+        service = serviceFactory.create();
+    }
+
+    protected Class getImplementorClass() {
+        return (Class) this.implementor;
+    }
+
+    protected void init() {
+        // configure handlers
+        try {
+            initHandlers();
+        } catch (Exception e) {
+            throw new WebServiceException("Error configuring handlers", e);
+        }
+
+        // Set service to invoke the target ejb
+        service.setInvoker(new EjbMethodInvoker(this.bus, deploymentInfo));
+
+        // Remove interceptors that perform handler processing since
+        // handler processing must happen within the EJB container.
+        Endpoint endpoint = getEndpoint();
+        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 LogicalHandlerInInterceptor || interceptor instanceof SOAPHandlerInterceptor) {
+                interceptors.remove(interceptor);
+            }
+        }
+    }
+
+    public void stop() {
+        // call handler preDestroy
+        destroyHandlers();
+
+        // shutdown server
+        super.stop();
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbInterceptor.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbInterceptor.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbInterceptor.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbInterceptor.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,174 @@
+/**
+ *
+ * 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.openejb.server.cxf.ejb;
+
+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.logical.LogicalHandlerInInterceptor;
+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.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
+
+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 java.lang.reflect.Method;
+import java.util.List;
+
+public class EjbInterceptor {
+    private static final Logger log = Logger.getInstance(LogCategory.CXF, EjbInterceptor.class);
+
+    private Exchange exchange;
+    private Bus bus;
+    private List<Object> params;
+    private Method method;
+
+    public EjbInterceptor(List<Object> params, Method method, Bus bus, Exchange exchange) {
+        this.params = params;
+        this.method = method;
+        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.");
+
+            Message inMessage = exchange.getInMessage();
+            PhaseInterceptorChain chain = new PhaseInterceptorChain(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 LogicalHandlerInInterceptor(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;
+        }
+
+        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);
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbMethodInvoker.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbMethodInvoker.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbMethodInvoker.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbMethodInvoker.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,145 @@
+/**
+ *
+ * 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.openejb.server.cxf.ejb;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.interceptor.Fault;
+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.RpcContainer;
+import org.apache.openejb.util.LogCategory;
+import org.apache.openejb.util.Logger;
+
+import javax.interceptor.InvocationContext;
+import javax.xml.ws.handler.MessageContext;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+public class EjbMethodInvoker extends AbstractInvoker {
+    private static final Logger log = Logger.getInstance(LogCategory.CXF, EjbMethodInvoker.class);
+
+    private DeploymentInfo deploymentInfo;
+    private Bus bus;
+
+    public EjbMethodInvoker(Bus bus, DeploymentInfo deploymentInfo) {
+        this.bus = bus;
+        this.deploymentInfo = deploymentInfo;
+    }
+
+    public Object getServiceObject(Exchange context) {
+        return null;
+    }
+
+    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, m, params);
+        } else {
+            log.debug("EJBInvoke");
+            result = ejbInvoke(exchange, m, params);
+        }
+
+        return result;
+    }
+
+    private Object preEjbInvoke(Exchange exchange, Method method, List<Object> params) {
+
+        MessageContext ctx = ContextPropertiesMapping.createWebServiceContext(exchange);
+        WebServiceContextImpl.setMessageContext(ctx);
+
+        try {
+            EjbInterceptor interceptor = new EjbInterceptor(params, method, 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(), callInterface, method, arguments, null);
+
+            if (exchange.isOneWay()) {
+                return null;
+            }
+
+            List<Object> retList = new ArrayList<Object>(1);
+            if (!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();
+        }
+    }
+
+    private Object ejbInvoke(Exchange exchange, Method m, List<Object> params) {
+        try {
+            Object res = directEjbInvoke(exchange, m, params);
+
+            if (exchange.isOneWay()) {
+                return null;
+            }
+
+            List<Object> retList = new ArrayList<Object>(1);
+            if (!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);
+        }
+    }
+
+    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[]{};
+        }
+
+        invContext.setParameters(paramArray);
+        Object res = invContext.proceed();
+
+        ContextPropertiesMapping.updateWebServiceContext(exchange, (MessageContext) invContext.getContextData());
+
+        return res;
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/ejb/EjbWsContainer.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,38 @@
+/**
+ *
+ * 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.openejb.server.cxf.ejb;
+
+import org.apache.cxf.Bus;
+import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.core.webservices.PortData;
+import org.apache.openejb.server.cxf.CxfWsContainer;
+
+public class EjbWsContainer extends CxfWsContainer {
+    private final DeploymentInfo deploymentInfo;
+
+    public EjbWsContainer(Bus bus, PortData port, DeploymentInfo deploymentInfo) {
+        super(bus, port);
+        if (deploymentInfo == null) throw new NullPointerException("deploymentInfo is null");
+        this.deploymentInfo = deploymentInfo;
+    }
+
+    protected EjbEndpoint createEndpoint() {
+        EjbEndpoint ep = new EjbEndpoint(bus, port, deploymentInfo);
+        return ep;
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoEndpoint.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoEndpoint.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoEndpoint.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoEndpoint.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,88 @@
+/**
+ *
+ * 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.openejb.server.cxf.pojo;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.jaxws.JAXWSMethodInvoker;
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.apache.openejb.InjectionProcessor;
+import org.apache.openejb.core.webservices.JaxWsUtils;
+import org.apache.openejb.core.webservices.PortData;
+import org.apache.openejb.server.cxf.CxfEndpoint;
+import org.apache.openejb.server.cxf.CxfServiceConfiguration;
+import org.apache.openejb.server.cxf.JaxWsImplementorInfoImpl;
+
+import javax.naming.Context;
+import javax.xml.ws.WebServiceException;
+
+public class PojoEndpoint extends CxfEndpoint {
+    private InjectionProcessor<Object> injectionProcessor;
+
+    public PojoEndpoint(Bus bus, PortData port, Context context, Class<?> instance) {
+        super(bus, port, context, instance);
+
+        String bindingURI = null;
+        if (port.getBindingID() != null) {
+            bindingURI = JaxWsUtils.getBindingURI(port.getBindingID());
+        }
+        implInfo = new JaxWsImplementorInfoImpl(instance, bindingURI);
+
+        serviceFactory = new JaxWsServiceFactoryBean(implInfo);
+        serviceFactory.setBus(bus);
+
+        // install as first to overwrite annotations (wsdl-file, wsdl-port, wsdl-service)
+        CxfServiceConfiguration configuration = new CxfServiceConfiguration(port);
+        serviceFactory.getConfigurations().add(0, configuration);
+
+        service = serviceFactory.create();
+
+        // instantiate and inject resources into service
+        try {
+            injectionProcessor = new InjectionProcessor<Object>(instance, port.getInjections(), null, null, context);
+            injectionProcessor.createInstance();
+            injectionProcessor.postConstruct();
+            implementor = injectionProcessor.getInstance();
+        } catch (Exception e) {
+            throw new WebServiceException("Service resource injection failed", e);
+        }
+
+        service.setInvoker(new JAXWSMethodInvoker(implementor));
+    }
+
+    protected void init() {
+        // configure and inject handlers
+        try {
+            initHandlers();
+        } catch (Exception e) {
+            throw new WebServiceException("Error configuring handlers", e);
+        }
+    }
+
+    public void stop() {
+        // call handler preDestroy
+        destroyHandlers();
+
+        // call service preDestroy
+        if (injectionProcessor != null) {
+            injectionProcessor.preDestroy();
+        }
+
+        // shutdown server
+        super.stop();
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/java/org/apache/openejb/server/cxf/pojo/PojoWsContainer.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,46 @@
+/**
+ *
+ * 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.openejb.server.cxf.pojo;
+
+import org.apache.cxf.Bus;
+import org.apache.openejb.core.webservices.PortData;
+import org.apache.openejb.server.cxf.CxfWsContainer;
+
+import javax.naming.Context;
+
+public class PojoWsContainer extends CxfWsContainer {
+    private final Context context;
+    private final Class target;
+
+    public PojoWsContainer(Bus bus, PortData port, Context context, Class target) {
+        super(bus, port);
+        if (target == null) throw new NullPointerException("target is null");
+        this.context = context;
+        this.target = target;
+    }
+
+    protected PojoEndpoint createEndpoint() {
+        PojoEndpoint ep = new PojoEndpoint(bus, port, context, target);
+        return ep;
+    }
+
+    public void start() {
+        super.start();
+        this.destination.setPassSecurityContext(true);
+    }
+}

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/cxf-extension-openejb.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/cxf-extension-openejb.xml?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/cxf-extension-openejb.xml (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/cxf-extension-openejb.xml Sun Nov  4 14:41:49 2007
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:foo="http://cxf.apache.org/configuration/foo"
+       xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <bean id="org.apache.cxf.resource.ResourceManager" class="org.apache.openejb.server.cxf.ResourceManager">
+       <constructor-arg>
+            <list>
+                <bean class="org.apache.cxf.resource.ClasspathResolver"/>
+                <bean class="org.apache.cxf.resource.ClassLoaderResolver"/>
+            </list>
+       </constructor-arg>
+       <property name="bus" ref="cxf"/>
+    </bean>
+
+    <bean class="org.apache.openejb.server.cxf.HttpTransportFactory" lazy-init="true">
+        <property name="bus" ref="cxf"/>
+        <property name="transportIds">
+            <list>
+                <value>http://schemas.xmlsoap.org/soap/http</value>
+                <value>http://schemas.xmlsoap.org/wsdl/http/</value>
+                <value>http://schemas.xmlsoap.org/wsdl/soap/http</value>
+                <value>http://www.w3.org/2003/05/soap/bindings/HTTP/</value>
+                <value>http://cxf.apache.org/transports/http/configuration</value>
+                <value>http://cxf.apache.org/bindings/xformat</value>
+            </list>
+        </property>
+    </bean>
+
+</beans>

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/cxf.extension
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/cxf.extension?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/cxf.extension (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/cxf.extension Sun Nov  4 14:41:49 2007
@@ -0,0 +1 @@
+META-INF/cxf/cxf-extension-openejb.xml
\ No newline at end of file

Added: openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/org.apache.openejb.server.ServerService/cxf
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/org.apache.openejb.server.ServerService/cxf?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/org.apache.openejb.server.ServerService/cxf (added)
+++ openejb/trunk/openejb3/server/openejb-cxf/src/main/resources/META-INF/org.apache.openejb.server.ServerService/cxf Sun Nov  4 14:41:49 2007
@@ -0,0 +1,13 @@
+server      = org.apache.openejb.server.cxf.CxfService
+
+# realmName   =
+
+# NONE, INTEGRAL or CONFIDENTIAL
+transportGuarantee = NONE
+
+#  NONE, BASIC, DIGEST or CLIENT-CERT
+authMethod  = NONE
+
+# virtualHost =
+
+disabled    = false



Mime
View raw message