cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject git commit: Update the JAXWS/Simple ServerFactoryBean's to not hold onto the Server objects and "reset" after create. Thus, multiple "create" calls should result in actual "clean" Server's without sharing a bunch of things like EndpointInfo and such tha
Date Fri, 24 Oct 2014 20:27:37 GMT
Repository: cxf
Updated Branches:
  refs/heads/master d5433bd96 -> b54fe0dfd


Update the JAXWS/Simple ServerFactoryBean's to not hold onto the Server objects and "reset"
after create.  Thus, multiple "create" calls should result in actual "clean" Server's without
sharing a bunch of things like EndpointInfo and such that could result in state being shared
across services when they shouldn't.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/b54fe0df
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/b54fe0df
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/b54fe0df

Branch: refs/heads/master
Commit: b54fe0dfdf3c3d76df1e07fb3686d5d8a1061d48
Parents: d5433bd
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri Oct 24 16:26:02 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Oct 24 16:26:02 2014 -0400

----------------------------------------------------------------------
 .../spring/AbstractBeanDefinitionParser.java    | 52 +++++++++++---------
 .../cxf/jaxws/JaxWsServerFactoryBean.java       | 18 ++++---
 .../cxf/jaxws/spring/NamespaceHandler.java      | 17 +++++--
 .../cxf/jaxws/SchemaFirstXmlConfigTest.java     |  1 +
 .../service/AnnotationInterceptorTest.java      | 39 ++++++++-------
 .../apache/cxf/frontend/ServerFactoryBean.java  | 50 ++++++-------------
 .../ServerFactoryBeanDefinitionParser.java      | 32 +++++++++++-
 .../cxf/javascript/JavascriptRhinoTest.java     |  2 +-
 .../apache/cxf/javascript/QueryHandlerTest.java |  6 +--
 9 files changed, 124 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b54fe0df/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
b/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
index 7fcc99f..3e02b51 100644
--- a/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
+++ b/core/src/main/java/org/apache/cxf/configuration/spring/AbstractBeanDefinitionParser.java
@@ -83,32 +83,38 @@ public abstract class AbstractBeanDefinitionParser
         boolean setBus = false;
         for (int i = 0; i < atts.getLength(); i++) {
             Attr node = (Attr) atts.item(i);
-            String val = node.getValue();
-            String pre = node.getPrefix();
-            String name = node.getLocalName();
-            String prefix = node.getPrefix();
             
-            // Don't process namespaces
-            if (isNamespace(name, prefix)) {
-                continue;
-            }
-            
-            if ("createdFromAPI".equals(name)) {
-                bean.setAbstract(true);
-            } else if ("abstract".equals(name)) {
-                bean.setAbstract(true);
-            } else if ("depends-on".equals(name)) {
-                bean.addDependsOn(val);
-            } else if ("name".equals(name)) {
-                processNameAttribute(element, ctx, bean, val);
-            } else if ("bus".equals(name)) {
-                setBus = processBusAttribute(element, ctx, bean, val);
-            } else if (!"id".equals(name) && isAttribute(pre, name)) {
-                mapAttribute(bean, element, name, val);
-            }
-        } 
+            setBus |= parseAttribute(element, node, ctx, bean);
+        }
         return setBus;
     }
+    protected boolean parseAttribute(Element element, Attr node, 
+                                     ParserContext ctx, BeanDefinitionBuilder bean) {
+        String val = node.getValue();
+        String pre = node.getPrefix();
+        String name = node.getLocalName();
+        String prefix = node.getPrefix();
+        
+        // Don't process namespaces
+        if (isNamespace(name, prefix)) {
+            return false;
+        }
+        
+        if ("createdFromAPI".equals(name)) {
+            bean.setAbstract(true);
+        } else if ("abstract".equals(name)) {
+            bean.setAbstract(true);
+        } else if ("depends-on".equals(name)) {
+            bean.addDependsOn(val);
+        } else if ("name".equals(name)) {
+            processNameAttribute(element, ctx, bean, val);
+        } else if ("bus".equals(name)) {
+            return processBusAttribute(element, ctx, bean, val);
+        } else if (!"id".equals(name) && isAttribute(pre, name)) {
+            mapAttribute(bean, element, name, val);
+        }
+        return false;
+    }
 
     
     protected boolean processBusAttribute(Element element, ParserContext ctx, 

http://git-wip-us.apache.org/repos/asf/cxf/blob/b54fe0df/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
index 5713bbd..49ea9b9 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
@@ -209,7 +209,7 @@ public class JaxWsServerFactoryBean extends ServerFactoryBean {
             }
 
             Server server = super.create();
-            initializeResourcesAndHandlerChain();
+            initializeResourcesAndHandlerChain(server);
             checkPrivateEndpoint(server.getEndpoint());
             
             return server;
@@ -220,11 +220,11 @@ public class JaxWsServerFactoryBean extends ServerFactoryBean {
         }
     }
     
-    private synchronized void initializeResourcesAndHandlerChain() {
+    private synchronized void initializeResourcesAndHandlerChain(Server server) {
         if (doInit) {
             try {
                 injectResources(getServiceBean());
-                buildHandlerChain();
+                buildHandlerChain(server);
             } catch (Exception ex) {
                 if (ex instanceof WebServiceException) { 
                     throw (WebServiceException)ex; 
@@ -238,20 +238,22 @@ public class JaxWsServerFactoryBean extends ServerFactoryBean {
     
     /**
      * Obtain handler chain from annotations.
+     * @param server 
      *
      */
-    private void buildHandlerChain() {
+    private void buildHandlerChain(Server server) {
         AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder();
-        JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean)getServiceFactory(); 
         @SuppressWarnings("rawtypes")
         List<Handler> chain = new ArrayList<Handler>(handlers);
         
-        chain.addAll(builder.buildHandlerChainFromClass(getServiceBeanClass(), sf.getEndpointInfo()
-            .getName(), sf.getServiceQName(), this.getBindingId()));
+        chain.addAll(builder.buildHandlerChainFromClass(getServiceBeanClass(),
+                                                        server.getEndpoint().getEndpointInfo().getName(),
+                                                        server.getEndpoint().getService().getName(),
+                                                        this.getBindingId()));
         for (Handler<?> h : chain) {
             injectResources(h);
         }
-        ((JaxWsEndpointImpl)getServer().getEndpoint()).getJaxwsBinding().setHandlerChain(chain);
+        ((JaxWsEndpointImpl)server.getEndpoint()).getJaxwsBinding().setHandlerChain(chain);
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/cxf/blob/b54fe0df/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java
index 8f874e8..882d469 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java
@@ -21,6 +21,7 @@ package org.apache.cxf.jaxws.spring;
 import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
 import org.apache.cxf.configuration.spring.StringBeanDefinitionParser;
+import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.spring.ServerFactoryBeanDefinitionParser;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
@@ -44,16 +45,26 @@ public class NamespaceHandler extends NamespaceHandlerSupport {
     public static class SpringServerFactoryBean extends JaxWsServerFactoryBean
         implements ApplicationContextAware {
 
+        Server server;
         public SpringServerFactoryBean() {
             super();
         }
         public SpringServerFactoryBean(JaxWsServiceFactoryBean fact) {
             super(fact);
         }
+        public Server getServer() {
+            return server;
+        }
+        public Server create() {
+            if (server == null) {
+                server = super.create();
+            }
+            return server;
+        }
         public void destroy() {
-            if (getServer() != null) {
-                getServer().destroy();
-                setServer(null);
+            if (server != null) {
+                server.destroy();
+                server = null;
             }
         }
         public void setApplicationContext(ApplicationContext ctx) throws BeansException {

http://git-wip-us.apache.org/repos/asf/cxf/blob/b54fe0df/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SchemaFirstXmlConfigTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SchemaFirstXmlConfigTest.java
b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SchemaFirstXmlConfigTest.java
index 6de432a..471f2a8 100644
--- a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SchemaFirstXmlConfigTest.java
+++ b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/SchemaFirstXmlConfigTest.java
@@ -47,6 +47,7 @@ public class SchemaFirstXmlConfigTest extends AbstractJaxWsTest {
 
         JaxWsServerFactoryBean serverFB = (JaxWsServerFactoryBean) ctx.getBean("helloServer");
 
+        assertNotNull(serverFB.getServer());
         Document d = getWSDLDocument(serverFB.getServer());
 
         //XMLUtils.printDOM(d);

http://git-wip-us.apache.org/repos/asf/cxf/blob/b54fe0df/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
index 5569ebc..b55e9d7 100644
--- a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
+++ b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
@@ -23,6 +23,7 @@ import java.util.List;
 
 import javax.jws.WebService;
 
+import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.feature.Feature;
 import org.apache.cxf.feature.Features;
 import org.apache.cxf.frontend.ServerFactoryBean;
@@ -41,8 +42,10 @@ import org.junit.Test;
 public class AnnotationInterceptorTest extends AbstractJaxWsTest {
      
     private ServerFactoryBean fb;
+    private Server server;
     
     private JaxWsServerFactoryBean jfb;
+    private Server jserver;
     
     @Before
     public void setUp() {
@@ -60,15 +63,15 @@ public class AnnotationInterceptorTest extends AbstractJaxWsTest {
         fb.setServiceClass(HelloService.class);        
         HelloService hello = new HelloServiceImpl();
         fb.setServiceBean(hello);
-        fb.create();
+        server = fb.create();
         
         List<Interceptor<? extends Message>> interceptors 
-            = fb.getServer().getEndpoint().getInInterceptors();
+            = server.getEndpoint().getInInterceptors();
         assertTrue(hasTestInterceptor(interceptors));
         assertFalse(hasTest2Interceptor(interceptors));
         
         List<Interceptor<? extends Message>> outFaultInterceptors
-            = fb.getServer().getEndpoint().getOutFaultInterceptors();
+            = server.getEndpoint().getOutFaultInterceptors();
         assertTrue(hasTestInterceptor(outFaultInterceptors));
         assertTrue(hasTest2Interceptor(outFaultInterceptors));
     }
@@ -78,7 +81,7 @@ public class AnnotationInterceptorTest extends AbstractJaxWsTest {
         fb.setServiceClass(HelloService.class);
         HelloService hello = new HelloServiceImpl();
         fb.setServiceBean(hello);
-        fb.create();
+        server = fb.create();
         
         List<Feature> features = fb.getFeatures();
         assertTrue(hasAnnotationFeature(features));
@@ -89,9 +92,9 @@ public class AnnotationInterceptorTest extends AbstractJaxWsTest {
         fb.setServiceClass(HelloService.class);        
         HelloService hello = new HelloServiceImplNoAnnotation();
         fb.setServiceBean(hello);
-        fb.create();
+        server = fb.create();
         
-        List<Interceptor<? extends Message>> interceptors = fb.getServer().getEndpoint().getInInterceptors();
+        List<Interceptor<? extends Message>> interceptors = server.getEndpoint().getInInterceptors();
         assertFalse(hasTestInterceptor(interceptors));
         
         List<Feature> features = fb.getFeatures();
@@ -104,8 +107,8 @@ public class AnnotationInterceptorTest extends AbstractJaxWsTest {
         jfb.setServiceClass(SayHi.class);
         jfb.setServiceBean(new SayHiNoInterceptor());
         
-        jfb.create();
-        List<Interceptor<? extends Message>> interceptors = jfb.getServer().getEndpoint().getInInterceptors();
+        jserver = jfb.create();
+        List<Interceptor<? extends Message>> interceptors = jserver.getEndpoint().getInInterceptors();
         assertFalse(hasTestInterceptor(interceptors));
         
         List<Feature> features = fb.getFeatures();
@@ -118,12 +121,12 @@ public class AnnotationInterceptorTest extends AbstractJaxWsTest {
         SayHi implementor = new SayHiImplementation();
         jfb.setServiceBean(implementor);
         
-        jfb.create();
-        List<Interceptor<? extends Message>> interceptors = jfb.getServer().getEndpoint().getInInterceptors();
+        jserver = jfb.create();
+        List<Interceptor<? extends Message>> interceptors = jserver.getEndpoint().getInInterceptors();
         assertTrue(hasTestInterceptor(interceptors));
         
         List<Interceptor<? extends Message>> inFaultInterceptors 
-            = jfb.getServer().getEndpoint().getInFaultInterceptors();
+            = jserver.getEndpoint().getInFaultInterceptors();
         assertFalse(hasTestInterceptor(inFaultInterceptors));
         assertTrue(hasTest2Interceptor(inFaultInterceptors));
         
@@ -137,13 +140,13 @@ public class AnnotationInterceptorTest extends AbstractJaxWsTest {
         SayHi implementor = new SayHiImplementation();
         jfb.setServiceBean(implementor);
         
-        jfb.create();
+        jserver = jfb.create();
         List<Interceptor<? extends Message>> interceptors 
-            = jfb.getServer().getEndpoint().getInInterceptors();
+            = jserver.getEndpoint().getInInterceptors();
         assertTrue(hasAnnotationFeatureInterceptor(interceptors));
         
         List<Interceptor<? extends Message>> outInterceptors 
-            = jfb.getServer().getEndpoint().getOutInterceptors();
+            = jserver.getEndpoint().getOutInterceptors();
         assertTrue(hasAnnotationFeatureInterceptor(outInterceptors));
     }
     
@@ -151,9 +154,9 @@ public class AnnotationInterceptorTest extends AbstractJaxWsTest {
     public void testJaxWsFrontendWithAnnotationInSEI() throws Exception {
         jfb.setServiceClass(SayHiInterfaceImpl.class);
         jfb.setServiceBean(new SayHiInterfaceImpl());
-        jfb.create();
+        jserver = jfb.create();
         
-        List<Interceptor<? extends Message>> interceptors = jfb.getServer().getEndpoint().getInInterceptors();
+        List<Interceptor<? extends Message>> interceptors = jserver.getEndpoint().getInInterceptors();
         assertTrue(hasTestInterceptor(interceptors));
         
         List<Feature> features = jfb.getFeatures();
@@ -164,9 +167,9 @@ public class AnnotationInterceptorTest extends AbstractJaxWsTest {
     public void testJaxWsFrontendWithAnnotationInSEIAndImpl() throws Exception {
         jfb.setServiceClass(SayHiInterface.class);
         jfb.setServiceBean(new SayHiInterfaceImpl2());
-        jfb.create();
+        jserver = jfb.create();
         
-        List<Interceptor<? extends Message>> interceptors = jfb.getServer().getEndpoint().getInInterceptors();
+        List<Interceptor<? extends Message>> interceptors = jserver.getEndpoint().getInInterceptors();
         assertFalse(hasTestInterceptor(interceptors));
         assertTrue(hasTest2Interceptor(interceptors));
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/b54fe0df/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
----------------------------------------------------------------------
diff --git a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
index cd54fe6..3d82657 100644
--- a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
+++ b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
@@ -75,7 +75,6 @@ import org.apache.cxf.wsdl11.WSDLEndpointFactory;
  * </pre>
  */
 public class ServerFactoryBean extends AbstractWSDLBasedEndpointFactory {
-    private Server server;
     private boolean start = true;
     private Object serviceBean;
     private List<String> schemaLocations;
@@ -129,10 +128,20 @@ public class ServerFactoryBean extends AbstractWSDLBasedEndpointFactory
{
         return null;
     }
     
+    /**
+     * For subclasses that hold onto the created Server, this will return the singleton server.
+     * Default returns null as the default factories do not hold onto the server and will
+     * create a new one for each call to create();
+     * @return
+     */
+    public Server getServer() {
+        return null;
+    }
 
     public Server create() {
         ClassLoaderHolder orig = null;
         try {
+            Server server = null;
             try {
                 if (bus != null) {
                     ClassLoader loader = bus.getExtension(ClassLoader.class);
@@ -199,7 +208,7 @@ public class ServerFactoryBean extends AbstractWSDLBasedEndpointFactory
{
                 initializeAnnotationInterceptors(server.getEndpoint(), getServiceClass());
             }
     
-            applyFeatures();
+            applyFeatures(server);
    
             getServiceFactory().sendEvent(FactoryBeanListener.Event.SERVER_CREATED, server,
serviceBean,
                                           serviceBean == null 
@@ -218,6 +227,8 @@ public class ServerFactoryBean extends AbstractWSDLBasedEndpointFactory
{
                     throw re;
                 }
             }
+            getServiceFactory().reset();
+
             return server;
         } finally {
             if (orig != null) {
@@ -225,39 +236,14 @@ public class ServerFactoryBean extends AbstractWSDLBasedEndpointFactory
{
             }
         }            
     }
-    public void init() {
-        if (getServer() == null) {
-            ClassLoaderHolder orig = null;
-            try {
-                if (bus != null) {
-                    ClassLoader loader = bus.getExtension(ClassLoader.class);
-                    if (loader != null) {
-                        orig = ClassLoaderUtils.setThreadContextClassloader(loader);
-                    }
-                }
-                create();
-            } finally {
-                if (orig != null) {
-                    orig.reset();
-                }
-            }
-        }
-    }
     
-    public void destroy() {
-        if (getServer() != null) {
-            getServer().destroy();
-            setServer(null);
-        }
-    }
-
     @Override
     protected void initializeServiceFactory() {
         super.initializeServiceFactory();
         getServiceFactory().setSchemaLocations(schemaLocations);
     }
 
-    protected void applyFeatures() {
+    protected void applyFeatures(Server server) {
         if (getFeatures() != null) {
             for (Feature feature : getFeatures()) {
                 feature.initialize(server, getBus());
@@ -272,14 +258,6 @@ public class ServerFactoryBean extends AbstractWSDLBasedEndpointFactory
{
         return new BeanInvoker(getServiceBean());
     }
 
-    public Server getServer() {
-        return server;
-    }
-
-    public void setServer(Server server) {
-        this.server = server;
-    }
-
     /**
      * Whether or not the Server should be started upon creation.
      *

http://git-wip-us.apache.org/repos/asf/cxf/blob/b54fe0df/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
index 81edf64..9c664ac 100644
--- a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
+++ b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
@@ -23,15 +23,16 @@ import java.util.Map;
 
 import javax.xml.namespace.QName;
 
+import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
 
 import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
+import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean;
-
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
@@ -58,6 +59,13 @@ public class ServerFactoryBeanDefinitionParser extends AbstractBeanDefinitionPar
             mapToProperty(bean, name, val);
         }
     }
+    protected boolean parseAttribute(Element element, Attr node, 
+                                     ParserContext ctx, BeanDefinitionBuilder bean) {
+        if (!node.getSpecified() && "start".equals(node.getLocalName())) {
+            return false;
+        }
+        return super.parseAttribute(element, node, ctx, bean);
+    }
 
     @Override
     protected void mapElement(ParserContext ctx, BeanDefinitionBuilder bean, Element el,
String name) {
@@ -114,12 +122,34 @@ public class ServerFactoryBeanDefinitionParser extends AbstractBeanDefinitionPar
     public static class SpringServerFactoryBean extends ServerFactoryBean
         implements ApplicationContextAware {
 
+        private Server server;
+
         public SpringServerFactoryBean() {
             super();
         }
         public SpringServerFactoryBean(ReflectionServiceFactoryBean fact) {
             super(fact);
         }
+        public Server getServer() {
+            return server;
+        }
+        
+        public void init() {
+            create();
+        }
+        @Override
+        public Server create() {
+            if (server == null) {
+                server = super.create();
+            }
+            return server;
+        }
+        public void destroy() {
+            if (server != null) {
+                server.destroy();
+                server = null;
+            }
+        }
 
         public void setApplicationContext(ApplicationContext ctx) throws BeansException {
             if (bus == null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/b54fe0df/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java
----------------------------------------------------------------------
diff --git a/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java
b/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java
index 1fa1f8b..7bcff7a 100644
--- a/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java
+++ b/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JavascriptRhinoTest.java
@@ -49,7 +49,7 @@ public abstract class JavascriptRhinoTest extends AbstractCXFSpringTest
{
         testUtilities.setBus(getBean(Bus.class, "cxf"));
         testUtilities.initializeRhino();
         serverFactoryBean = getBean(ServerFactoryBean.class, serviceEndpointBean);
-        endpoint = serverFactoryBean.getServer().getEndpoint();
+        endpoint = serverFactoryBean.create().getEndpoint();
         // we need to find the implementor.
         rawImplementor = serverFactoryBean.getServiceBean();
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/b54fe0df/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/QueryHandlerTest.java
----------------------------------------------------------------------
diff --git a/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/QueryHandlerTest.java
b/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/QueryHandlerTest.java
index ea132e3..1f4ded9 100644
--- a/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/QueryHandlerTest.java
+++ b/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/QueryHandlerTest.java
@@ -71,11 +71,11 @@ public class QueryHandlerTest extends AbstractCXFSpringTest {
     @Before
     public void before() {
         ServerFactoryBean serverFactoryBean = getBean(ServerFactoryBean.class, "hw-service-endpoint");
-        hwEndpoint = serverFactoryBean.getServer().getEndpoint();
+        hwEndpoint = serverFactoryBean.create().getEndpoint();
         serverFactoryBean = getBean(ServerFactoryBean.class, "hwg-service-endpoint");
-        hwgEndpoint = serverFactoryBean.getServer().getEndpoint();
+        hwgEndpoint = serverFactoryBean.create().getEndpoint();
         serverFactoryBean = getBean(ServerFactoryBean.class, "dlb-service-endpoint");
-        dlbEndpoint = serverFactoryBean.getServer().getEndpoint();
+        dlbEndpoint = serverFactoryBean.create().getEndpoint();
     }
     
     private String getStringFromURL(URL url) throws IOException {


Mime
View raw message