Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 37352 invoked from network); 13 Jun 2007 09:53:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Jun 2007 09:53:22 -0000 Received: (qmail 84352 invoked by uid 500); 13 Jun 2007 09:53:26 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 84240 invoked by uid 500); 13 Jun 2007 09:53:25 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 84226 invoked by uid 99); 13 Jun 2007 09:53:25 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jun 2007 02:53:25 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jun 2007 02:53:21 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id C315D1A981A; Wed, 13 Jun 2007 02:53:00 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r546794 - in /incubator/cxf/trunk/rt/frontend: jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java Date: Wed, 13 Jun 2007 09:53:00 -0000 To: cxf-commits@incubator.apache.org From: jliu@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070613095300.C315D1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jliu Date: Wed Jun 13 02:52:59 2007 New Revision: 546794 URL: http://svn.apache.org/viewvc?view=rev&rev=546794 Log: CXF-717: Refactor EndpointImpl and JaxWsServerFactoryBean so that EndpointImpl becomes a pure wrapper on top of JaxWsServerFactoryBean. Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?view=diff&rev=546794&r1=546793&r2=546794 ============================================================================== --- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java (original) +++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java Wed Jun 13 02:52:59 2007 @@ -25,19 +25,14 @@ import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Executor; -import java.util.logging.Logger; import javax.xml.namespace.QName; import javax.xml.transform.Source; import javax.xml.ws.Binding; -import javax.xml.ws.WebServiceException; import javax.xml.ws.WebServicePermission; -import javax.xml.ws.handler.Handler; import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; -import org.apache.cxf.common.injection.ResourceInjector; -import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.configuration.Configurable; import org.apache.cxf.configuration.Configurer; import org.apache.cxf.endpoint.Server; @@ -45,14 +40,9 @@ import org.apache.cxf.feature.AbstractFeature; import org.apache.cxf.interceptor.Interceptor; import org.apache.cxf.interceptor.InterceptorProvider; -import org.apache.cxf.jaxws.context.WebServiceContextResourceResolver; -import org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder; 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.resource.DefaultResourceManager; -import org.apache.cxf.resource.ResourceManager; -import org.apache.cxf.resource.ResourceResolver; import org.apache.cxf.service.Service; public class EndpointImpl extends javax.xml.ws.Endpoint @@ -65,12 +55,9 @@ public static final String CHECK_PUBLISH_ENDPOINT_PERMISSON_PROPERTY = "org.apache.cxf.jaxws.checkPublishEndpointPermission"; - private static final Logger LOG = LogUtils.getL7dLogger(EndpointImpl.class); - private static final WebServicePermission PUBLISH_PERMISSION = new WebServicePermission("publishEndpoint"); - protected boolean doInit; private Bus bus; private Object implementor; private Server server; @@ -102,8 +89,6 @@ this.bus = b; this.serverFactory = sf; this.implementor = implementor; - - doInit = true; } /** @@ -120,8 +105,6 @@ this.bindingUri = bindingUri; wsdlLocation = wsdl == null ? null : new String(wsdl); serverFactory = new JaxWsServerFactoryBean(); - - doInit = true; } @@ -215,27 +198,7 @@ server.stop(); } } - - /** - * inject resources into servant. The resources are injected - * according to @Resource annotations. See JSR 250 for more - * information. - */ - /** - * @param instance - */ - protected void injectResources(Object instance) { - if (instance != null) { - ResourceManager resourceManager = bus.getExtension(ResourceManager.class); - List resolvers = resourceManager.getResourceResolvers(); - resourceManager = new DefaultResourceManager(resolvers); - resourceManager.addResourceResolver(new WebServiceContextResourceResolver()); - ResourceInjector injector = new ResourceInjector(resourceManager); - injector.inject(instance); - } - } - - + public String getBeanName() { return endpointName.toString() + ".jaxws-endpoint"; } @@ -313,8 +276,6 @@ server = serverFactory.create(); - init(); - org.apache.cxf.endpoint.Endpoint endpoint = getEndpoint(); if (getInInterceptors() != null) { endpoint.getInInterceptors().addAll(getInInterceptors()); @@ -353,38 +314,6 @@ if (null != configurer) { configurer.configureBean(instance); } - } - - - private synchronized void init() { - if (doInit) { - try { - injectResources(implementor); - buildHandlerChain(); - } catch (Exception ex) { - if (ex instanceof WebServiceException) { - throw (WebServiceException)ex; - } - throw new WebServiceException("Creation of Endpoint failed", ex); - } - } - doInit = false; - } - - /** - * Obtain handler chain from annotations. - * - */ - private void buildHandlerChain() { - LOG.fine("loading handler chain for endpoint"); - AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder(); - - List chain = builder.buildHandlerChainFromClass(getImplementorClass(), endpointName); - for (Handler h : chain) { - injectResources(h); - } - - getBinding().setHandlerChain(chain); } protected void checkPublishPermission() { Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java?view=diff&rev=546794&r1=546793&r2=546794 ============================================================================== --- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java (original) +++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java Wed Jun 13 02:52:59 2007 @@ -19,17 +19,30 @@ package org.apache.cxf.jaxws; + +import java.util.List; + import javax.xml.soap.SOAPMessage; +import javax.xml.ws.WebServiceException; +import javax.xml.ws.handler.Handler; import javax.xml.ws.soap.SOAPBinding; import org.apache.cxf.binding.AbstractBindingFactory; import org.apache.cxf.binding.soap.Soap12; import org.apache.cxf.binding.soap.SoapBindingFactory; import org.apache.cxf.binding.soap.model.SoapBindingInfo; +import org.apache.cxf.common.injection.ResourceInjector; +import org.apache.cxf.endpoint.Server; import org.apache.cxf.frontend.ServerFactoryBean; import org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration; +import org.apache.cxf.jaxws.context.WebServiceContextResourceResolver; +import org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder; +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.resource.DefaultResourceManager; +import org.apache.cxf.resource.ResourceManager; +import org.apache.cxf.resource.ResourceResolver; import org.apache.cxf.service.invoker.Invoker; import org.apache.cxf.service.model.BindingInfo; @@ -44,8 +57,11 @@ * This will start a server for you and register it with the ServerManager. */ public class JaxWsServerFactoryBean extends ServerFactoryBean { + protected boolean doInit; + public JaxWsServerFactoryBean() { this(new JaxWsServiceFactoryBean()); + doInit = true; } public JaxWsServerFactoryBean(JaxWsServiceFactoryBean serviceFactory) { setServiceFactory(serviceFactory); @@ -54,6 +70,7 @@ = new JaxWsSoapBindingConfiguration(serviceFactory); setBindingConfig(defConfig); + doInit = true; } @Override @@ -121,5 +138,60 @@ return bindingInfo; } + public Server create() { + Server server = super.create(); + init(); + return server; + } + + private synchronized void init() { + if (doInit) { + try { + injectResources(getServiceBean()); + buildHandlerChain(); + } catch (Exception ex) { + if (ex instanceof WebServiceException) { + throw (WebServiceException)ex; + } + throw new WebServiceException("Creation of Endpoint failed", ex); + } + } + doInit = false; + } + + /** + * Obtain handler chain from annotations. + * + */ + private void buildHandlerChain() { + AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder(); + + List chain = builder.buildHandlerChainFromClass(getServiceBean().getClass(), + getEndpointName()); + for (Handler h : chain) { + injectResources(h); + } + + ((JaxWsEndpointImpl)getServer().getEndpoint()).getJaxwsBinding().setHandlerChain(chain); + } + + /** + * inject resources into servant. The resources are injected + * according to @Resource annotations. See JSR 250 for more + * information. + */ + /** + * @param instance + */ + protected void injectResources(Object instance) { + if (instance != null) { + ResourceManager resourceManager = getBus().getExtension(ResourceManager.class); + List resolvers = resourceManager.getResourceResolvers(); + resourceManager = new DefaultResourceManager(resolvers); + resourceManager.addResourceResolver(new WebServiceContextResourceResolver()); + ResourceInjector injector = new ResourceInjector(resourceManager); + injector.inject(instance); + } + } } Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java?view=diff&rev=546794&r1=546793&r2=546794 ============================================================================== --- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java (original) +++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java Wed Jun 13 02:52:59 2007 @@ -155,6 +155,9 @@ } public Object getServiceBean() { + if (serviceBean == null) { + return getServiceFactory().getServiceClass(); + } return serviceBean; }