geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r582070 - in /geronimo/server/trunk/modules: geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/ geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/ geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ ger...
Date Fri, 05 Oct 2007 03:49:47 GMT
Author: gawor
Date: Thu Oct  4 20:49:46 2007
New Revision: 582070

URL: http://svn.apache.org/viewvc?rev=582070&view=rev
Log:
got ridd of initContextRoot() method that wasn't thread safe (GERONIMO-3495)

Modified:
    geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
    geronimo/server/trunk/modules/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
    geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java
    geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java
    geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java

Modified: geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java?rev=582070&r1=582069&r2=582070&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
Thu Oct  4 20:49:46 2007
@@ -32,12 +32,10 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.axis2.pojo.POJOWebServiceContainerFactoryGBean;
 import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.j2ee.deployment.Module;
-import org.apache.geronimo.j2ee.deployment.WebModule;
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.jaxws.JAXWSUtils;
@@ -181,32 +179,6 @@
         }
     }
 
-    public boolean configurePOJO(GBeanData targetGBean,
-                                 String servletName,
-                                 Module module,
-                                 String seiClassName,
-                                 DeploymentContext context)
-        throws DeploymentException {
-                
-        boolean status = super.configurePOJO(targetGBean, servletName, module, seiClassName,
context);
-        if(!status) {
-            return false;
-        }       
-                
-        //change the URL
-        Map sharedContext = ((WebModule) module).getSharedContext();
-        String contextRoot = ((WebModule) module).getContextRoot();
-        Map portInfoMap = (Map) sharedContext.get(getKey());
-        PortInfo portInfo;
-        
-        if(portInfoMap != null && portInfoMap.get(servletName) != null){
-            portInfo = (PortInfo) portInfoMap.get(servletName);
-            processURLPattern(contextRoot, portInfo);
-        }
-        
-        return status;
-    }
-
     private static String getString(String in) {
         if (in != null) {
             in = in.trim();
@@ -216,34 +188,7 @@
         }
         return in;
     }
-
-    private void processURLPattern(String contextRoot, PortInfo portInfo) throws DeploymentException
{
-        //if the user specifies a url-pattern, set it here. 
-        String oldup = portInfo.getLocation();
-        if (oldup == null || oldup.length() == 0) { 
-            //if we cannot grab a valid urlpattern, default it to the port-component-name.
-            oldup = portInfo.getPortName();   
-        } else {
-            int i = oldup.indexOf(contextRoot);
-            oldup = oldup.substring(i + contextRoot.length() + 1);
-            oldup = oldup.trim();
-            if (oldup.indexOf("*") > 0) {
-                //uncomment this before we fix this issue.  workarond by assuming * is at
the end.
-                //throw new DeploymentException("Per JSR 109, the url-pattern should not
contain an asterisk.");
-                oldup = oldup.substring(0, oldup.length() - 1);
-            } 
-            //trim the forward slashes at the beginning or end.
-            if (oldup.substring(0, 1).equalsIgnoreCase("/")) {
-                oldup = oldup.substring(1);
-            } 
-            if (oldup.substring(oldup.length()-1).equalsIgnoreCase("/")) {
-                oldup = oldup.substring(0, oldup.length() - 1);
-            }
-        
-        } 
-        portInfo.setLocation(oldup);
-    }
-        
+   
     @Override
     protected void initialize(GBeanData targetGBean, Class serviceClass, PortInfo portInfo,
Module module) 
         throws DeploymentException {

Modified: geronimo/server/trunk/modules/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java?rev=582070&r1=582069&r2=582070&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
Thu Oct  4 20:49:46 2007
@@ -38,7 +38,6 @@
  */
 public class EJBWebServiceContainer extends Axis2WebServiceContainer {
 
-    private String contextRoot = null;
     private DeploymentInfo deploymnetInfo;
     
     public EJBWebServiceContainer(PortInfo portInfo,
@@ -55,6 +54,23 @@
     public void init() throws Exception { 
         super.init();
         
+        String rootContext = null;
+        String servicePath = null;
+        String location = trimContext(this.portInfo.getLocation());
+        int pos = location.indexOf('/');     
+        if (pos > 0) {
+            rootContext = location.substring(0, pos);
+            servicePath = location.substring(pos + 1);
+        } else {
+            rootContext = "/";
+            servicePath = location;
+        }
+              
+        this.configurationContext.setServicePath(servicePath);
+        //need to setContextRoot after servicePath as cachedServicePath is only built 
+        //when setContextRoot is called.
+        this.configurationContext.setContextRoot(rootContext); 
+        
         // configure handlers
         try {
             configureHandlers();
@@ -71,40 +87,7 @@
         serviceGenerator.setMessageReceiver(messageReceiver);
         return serviceGenerator;
     }
-    
-    @Override
-    protected void initContextRoot(Request request) {       
-        String servicePath = portInfo.getLocation();
         
-        if (contextRoot == null || "".equals(contextRoot)) {
-            String[] parts = JavaUtils.split(request.getContextPath(), '/');
-            if (parts != null) {
-                for (int i = 0; i < parts.length; i++) {
-                    if (parts[i].length() > 0) {
-                        contextRoot = parts[i];
-                        break;
-                    }
-                }
-            }
-            if (contextRoot == null || request.getContextPath().equals("/")) {
-                contextRoot = "/";
-            } else { //when contextRoot is not "/"
-                //set the servicePath here for EJB.
-                //check if portInfo.getLocation() contains contextRoot, if so, strip it.
-                int i = servicePath.indexOf(contextRoot);
-                if (i > -1) {
-                    servicePath = servicePath.substring(i + contextRoot.length() + 1);
-                    servicePath.trim();
-                }
-            }
-            configurationContext.setServicePath(servicePath);
-            
-            //need to setContextRoot after servicePath as cachedServicePath is only built

-            //when setContextRoot is called.
-            configurationContext.setContextRoot(contextRoot);  
-        } 
-    }
-    
     public synchronized void injectHandlers() {
         if (this.annotationProcessor != null) {
             // assume injection was already done

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java?rev=582070&r1=582069&r2=582070&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
Thu Oct  4 20:49:46 2007
@@ -172,7 +172,6 @@
 
     protected void doService(final Request request, final Response response)
             throws Exception {        
-        initContextRoot(request);
 
         if (LOG.isDebugEnabled()) {
             LOG.debug("Target URI: " + request.getURI());
@@ -236,8 +235,26 @@
 
     }
 
-    protected abstract void initContextRoot(Request request);
-
+    protected String getServicePath(String contextRoot) {
+        String location = this.portInfo.getLocation();
+        if (location != null && location.startsWith(contextRoot)) {
+            return location.substring(contextRoot.length());
+        }
+        return null;
+    }
+    
+    public static String trimContext(String contextPath) {
+        if (contextPath != null) {
+            if (contextPath.startsWith("/")) {
+                contextPath = contextPath.substring(1);
+            }
+            if (contextPath.endsWith("/")) {
+                contextPath = contextPath.substring(0, contextPath.length() - 1);
+            }
+        }
+        return contextPath;
+    }
+    
     public void doService2(Request request,
                            Response response,
                            MessageContext msgContext) throws Exception {

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java?rev=582070&r1=582069&r2=582070&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
Thu Oct  4 20:49:46 2007
@@ -30,7 +30,6 @@
 import org.apache.axis2.jaxws.server.endpoint.lifecycle.factory.EndpointLifecycleManagerFactory;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HTTPTransportUtils;
-import org.apache.axis2.util.JavaUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.axis2.Axis2WebServiceContainer;
@@ -46,7 +45,7 @@
     private static final Log LOG = LogFactory.getLog(POJOWebServiceContainer.class);
     
     private Object endpointInstance;
-    private String contextRoot = null;
+    private String contextRoot;
     private AnnotationHolder holder;
     
     public POJOWebServiceContainer(PortInfo portInfo,
@@ -54,9 +53,11 @@
                                    ClassLoader classLoader,
                                    Context context,
                                    URL configurationBaseUrl,
-                                   AnnotationHolder holder) {
+                                   AnnotationHolder holder,
+                                   String contextRoot) {
         super(portInfo, endpointClassName, classLoader, context, configurationBaseUrl);
         this.holder = holder;
+        this.contextRoot = contextRoot;
     }
     
     @Override
@@ -69,8 +70,13 @@
          */
         FactoryRegistry.setFactory(EndpointLifecycleManagerFactory.class, 
                                    new POJOEndpointLifecycleManagerFactory());
-                       
-        this.configurationContext.setServicePath(this.portInfo.getLocation());
+                                      
+        String servicePath = trimContext(getServicePath(this.contextRoot));
+        this.configurationContext.setServicePath(servicePath);
+        //need to setContextRoot after servicePath as cachedServicePath is only built 
+        //when setContextRoot is called.
+        String rootContext = trimContext(this.contextRoot);
+        this.configurationContext.setContextRoot(rootContext); 
         
         // instantiate and inject resources into service
         try {
@@ -123,27 +129,7 @@
             POJOWebServiceContext.clear();
         } 
     }
-    
-    protected void initContextRoot(Request request) {
-        if (contextRoot == null || "".equals(contextRoot)) {
-            String[] parts = JavaUtils.split(request.getContextPath(), '/');
-            if (parts != null) {
-                for (int i = 0; i < parts.length; i++) {
-                    if (parts[i].length() > 0) {
-                        contextRoot = parts[i];
-                        break;
-                    }
-                }
-            }
-            if (contextRoot == null || request.getContextPath().equals("/")) {
-                contextRoot = "/";
-            }
-            //need to setContextRoot after servicePath as cachedServicePath is only built

-            //when setContextRoot is called.
-            configurationContext.setContextRoot(contextRoot);  
-        }
-    }     
-    
+         
     @Override
     public void destroy() {
         // call handler preDestroy

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java?rev=582070&r1=582069&r2=582070&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
Thu Oct  4 20:49:46 2007
@@ -50,6 +50,7 @@
     private URL configurationBaseUrl;
     private Context context;
     private AnnotationHolder holder;
+    private String contextRoot;
 
     public POJOWebServiceContainerFactoryGBean(org.apache.geronimo.jaxws.PortInfo portInfo,
                                                String endpointClassName,
@@ -58,7 +59,8 @@
                                                Kernel kernel,
                                                TransactionManager transactionManager,
                                                URL configurationBaseUrl,
-                                               AnnotationHolder holder)
+                                               AnnotationHolder holder,
+                                               String contextRoot)
         throws InstantiationException, IllegalAccessException, ClassNotFoundException {
         
         if (componentContext != null) {
@@ -76,16 +78,18 @@
                 LOG.warn("Failed to create naming context", e);
             }
         }
-
+        
         this.portInfo = portInfo;
         this.classLoader = classLoader;
         this.endpointClassName = endpointClassName;
         this.configurationBaseUrl = configurationBaseUrl;   
         this.holder = holder;
+        this.contextRoot = contextRoot;
     }
 
     public WebServiceContainer getWebServiceContainer() {
-        POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName,
classLoader, context, configurationBaseUrl, holder);
+        POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName,
classLoader, 
+                                                                        context, configurationBaseUrl,
holder, contextRoot);
         try {
             container.init();
         } catch (Exception e) {
@@ -112,9 +116,20 @@
         infoBuilder.addReference("TransactionManager", TransactionManager.class, NameFactory.TRANSACTION_MANAGER);
         infoBuilder.addAttribute("configurationBaseUrl", URL.class, true);
         infoBuilder.addAttribute("holder", AnnotationHolder.class, true);
+        infoBuilder.addAttribute("contextRoot", String.class, true, true);
 
-        infoBuilder.setConstructor(new String[]{"portInfo", "endpointClassName", "classLoader",
-                "componentContext", "kernel", "TransactionManager", "configurationBaseUrl",
"holder"});
+        infoBuilder.setConstructor(new String[]{
+                "portInfo", 
+                "endpointClassName", 
+                "classLoader",
+                "componentContext", 
+                "kernel", 
+                "TransactionManager", 
+                "configurationBaseUrl", 
+                "holder", 
+                "contextRoot"
+        });
+        
         GBEAN_INFO = infoBuilder.getBeanInfo();
     }
 

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java?rev=582070&r1=582069&r2=582070&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java
Thu Oct  4 20:49:46 2007
@@ -58,7 +58,7 @@
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
 
         PortInfo portInfo = new PortInfo();
-        portInfo.setLocation("HelloWorld");
+        portInfo.setLocation("/axis2/HelloWorld");
         portInfo.setServiceEndpointInterfaceName("org.apache.geronimo.axis2.testdata.simple.HelloWorld");
 
         Axis2Request req = new Axis2Request(504,
@@ -73,7 +73,7 @@
         Axis2Response res = new Axis2Response("text/xml; charset=utf-8", "127.0.0.1", null,
null, 8080, out);
         
         String endpointClassName = "org.apache.geronimo.axis2.testdata.simple.HelloWorld";
-        POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName,
cl, null, null, AnnotationHolder.EMPTY);
+        POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName,
cl, null, null, AnnotationHolder.EMPTY, "/axis2");
         container.init();
         container.invoke(req, res);
         out.flush();
@@ -129,7 +129,7 @@
             request = new ByteArrayInputStream(envelope.toString().getBytes("UTF-8"));
         	
             PortInfo portInfo = new PortInfo();
-            portInfo.setLocation(serviceName);
+            portInfo.setLocation("/axis2/" + serviceName);
             
             File wsdlFile = new File(RESOURCE_PATH + wsdl);
             portInfo.setWsdlFile(wsdlFile.toURL().toString());
@@ -147,7 +147,7 @@
                 ByteArrayOutputStream out = new ByteArrayOutputStream();
                 Axis2Response res = new Axis2Response("text/xml; charset=utf-8", "127.0.0.1",
null, null, 8080, out);
 
-                POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo,
endPointClassName, cl, null, null, AnnotationHolder.EMPTY);
+                POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo,
endPointClassName, cl, null, null, AnnotationHolder.EMPTY, "/axis2");
                 container.init();
                 container.invoke(req, res);
                 System.out.println("Response "+out);

Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java?rev=582070&r1=582069&r2=582070&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java
(original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/pojo/POJOWebServiceContainerFactoryGBean.java
Thu Oct  4 20:49:46 2007
@@ -62,7 +62,8 @@
                                                Kernel kernel,
                                                TransactionManager transactionManager,
                                                URL configurationBaseUrl,
-                                               AnnotationHolder holder)
+                                               AnnotationHolder holder,
+                                               String contextRoot)
             throws ClassNotFoundException, 
                    IllegalAccessException,
                    InstantiationException {
@@ -122,6 +123,7 @@
         infoBuilder.addReference("TransactionManager", TransactionManager.class, NameFactory.TRANSACTION_MANAGER);
         infoBuilder.addAttribute("configurationBaseUrl", URL.class, true);
         infoBuilder.addAttribute("holder", AnnotationHolder.class, true);
+        infoBuilder.addAttribute("contextRoot", String.class, true, true);
 
         infoBuilder.setConstructor(new String[]{
                 "portInfo", 
@@ -131,7 +133,8 @@
                 "kernel", 
                 "TransactionManager", 
                 "configurationBaseUrl",
-                "holder"
+                "holder",
+                "contextRoot"
         });
         
         GBEAN_INFO = infoBuilder.getBeanInfo();

Modified: geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java?rev=582070&r1=582069&r2=582070&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
Thu Oct  4 20:49:46 2007
@@ -156,6 +156,7 @@
         containerFactoryData.setAttribute("endpointClassName", servletClassName);
         containerFactoryData.setAttribute("componentContext", componentContext);
         containerFactoryData.setAttribute("holder", serviceHolder);
+        containerFactoryData.setAttribute("contextRoot", ((WebModule) module).getContextRoot());
         try {
             context.addGBean(containerFactoryData);
         } catch (GBeanAlreadyExistsException e) {



Mime
View raw message