axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r503860 - in /webservices/axis2/trunk/java/modules: jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/ jaxws/src/org/apache/axis2/jaxws/message/databinding/ jaxws/test/org/apache/axis2/jaxws/framework/ jaxws/test/org/apache/axis2/jaxws/m...
Date Mon, 05 Feb 2007 20:38:09 GMT
Author: scheu
Date: Mon Feb  5 12:38:08 2007
New Revision: 503860

URL: http://svn.apache.org/viewvc?view=rev&rev=503860
Log:
AXIS2-2114
Contributor: Rich Scheuerle (Discussed With Nikhil Thaker)
Changes to the JAXBUtils pooling code added small test

Added:
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java?view=diff&rev=503860&r1=503859&r2=503860
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitBareMethodMarshaller.java
Mon Feb  5 12:38:08 2007
@@ -19,7 +19,7 @@
 package org.apache.axis2.jaxws.marshaller.impl.alt;
 
 import java.util.List;
-import java.util.Set;
+import java.util.TreeSet;
 
 import javax.xml.ws.WebServiceException;
 
@@ -68,7 +68,7 @@
             //   4) The type of the data block is defined by schema; thus in most cases
             //      an xsi:type will not be present
             ParameterDescription[] pds =operationDesc.getParameterDescriptions();
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
               
             // Get the return value.
             Class returnType = operationDesc.getResultActualType();
@@ -116,7 +116,7 @@
             //   4) The type of the data block (data:foo) is defined by schema (and probably
             //      is not present in the message
             ParameterDescription[] pds =operationDesc.getParameterDescriptions();
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
             
             
             // Unmarshal the ParamValues from the message
@@ -165,7 +165,7 @@
             
             // Get the operation information
             ParameterDescription[] pds =operationDesc.getParameterDescriptions();
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
             
             // Create the message 
             MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
@@ -221,7 +221,7 @@
             
             // Get the operation information
             ParameterDescription[] pds =operationDesc.getParameterDescriptions();
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
             
             // Create the message 
             MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java?view=diff&rev=503860&r1=503859&r2=503860
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedMethodMarshaller.java
Mon Feb  5 12:38:08 2007
@@ -19,10 +19,10 @@
 package org.apache.axis2.jaxws.marshaller.impl.alt;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
-import java.util.HashMap;
+import java.util.TreeSet;
 
 import javax.jws.WebParam.Mode;
 import javax.xml.bind.JAXBElement;
@@ -32,7 +32,6 @@
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.EndpointInterfaceDescription;
 import org.apache.axis2.jaxws.description.OperationDescription;
-import org.apache.axis2.jaxws.description.OperationDescriptionJava;
 import org.apache.axis2.jaxws.description.ParameterDescription;
 import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
@@ -83,7 +82,7 @@
             //   4) The type of the data block is defined by schema; thus in most cases
             //      an xsi:type will not be present
             ParameterDescription[] pds =operationDesc.getParameterDescriptions();
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
             
             // Determine if a returnValue is expected.
             // The return value may be an child element
@@ -193,7 +192,7 @@
             //   4) The type of the data block (data:foo) is defined by schema (and probably
             //      is not present in the message
             ParameterDescription[] pds =operationDesc.getParameterDescriptions();
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
                         
             // In usage=WRAPPED, there will be a single JAXB block inside the body.
             // Get this block

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java?view=diff&rev=503860&r1=503859&r2=503860
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/DocLitWrappedPlusMethodMarshaller.java
Mon Feb  5 12:38:08 2007
@@ -22,8 +22,8 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.HashMap;
+import java.util.TreeSet;
 
 import javax.jws.WebMethod;
 import javax.jws.WebParam;
@@ -130,7 +130,7 @@
             //   4) The type of the data block is defined by schema; thus in most cases
             //      an xsi:type will not be present
             ParameterDescription[] pds =operationDesc.getParameterDescriptions();
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
             
             // Determine if a returnValue is expected.
             // The return value may be an child element
@@ -270,7 +270,7 @@
             //   4) The type of the data block (data:foo) is defined by schema (and probably
             //      is not present in the message
             ParameterDescription[] pds =operationDesc.getParameterDescriptions();
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
                         
             // In usage=WRAPPED, there will be a single JAXB block inside the body.
             // Get this block
@@ -381,7 +381,7 @@
             
             // Get the operation information
             ParameterDescription[] pds =operationDesc.getParameterDescriptions();
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
             
             // Create the message 
             MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
@@ -569,7 +569,7 @@
             // Put the object into the message
             JAXBBlockFactory factory = 
                 (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
             Block block = factory.createFrom(object, 
                     new JAXBBlockContext(packages), 
                     null);  // The factory will get the qname from the value

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java?view=diff&rev=503860&r1=503859&r2=503860
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
Mon Feb  5 12:38:08 2007
@@ -25,7 +25,7 @@
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
+import java.util.TreeSet;
 
 import javax.jws.WebParam.Mode;
 import javax.jws.soap.SOAPBinding.Style;
@@ -164,7 +164,7 @@
      */
     static List<PDElement> getPDElements(ParameterDescription[] params, 
             Message message, 
-            Set<String> packages, 
+            TreeSet<String> packages, 
             boolean isInput) throws XMLStreamException {
         
         List<PDElement> pdeList = new ArrayList<PDElement>();
@@ -357,7 +357,7 @@
      * @param isRPC 
      * @throws MessageException
      */
-    static void toMessage(List<PDElement> pdeList, Message message, Set<String>
packages, boolean isRPC) throws WebServiceException {
+    static void toMessage(List<PDElement> pdeList, Message message, TreeSet<String>
packages, boolean isRPC) throws WebServiceException {
         
         int totalBodyBlocks = 0;
         for (int i=0; i<pdeList.size(); i++) {
@@ -421,7 +421,7 @@
             Class returnType, 
             String returnNS, 
             String returnLocalPart, 
-            Set<String> packages, 
+            TreeSet<String> packages, 
             Message message, 
             boolean isRPC,
             boolean isHeader)
@@ -464,7 +464,7 @@
      * @throws WebService
      * @throws XMLStreamException
      */
-    static Object getReturnValue(Set<String> packages, 
+    static Object getReturnValue(TreeSet<String> packages, 
             Message message, 
             Class rpcType,
             boolean isHeader,
@@ -503,7 +503,7 @@
      */
     static void marshalFaultResponse(Throwable throwable, 
             OperationDescription operationDesc,  
-            Set<String> packages, 
+            TreeSet<String> packages, 
             Message message, 
             boolean isRPC) {
         // Get the root cause of the throwable object
@@ -695,7 +695,7 @@
      * @throws InvocationTargetException
      * @throws NoSuchMethodException
      */
-    static Throwable demarshalFaultResponse(OperationDescription operationDesc, Set<String>
packages,Message message, boolean isRPC) 
+    static Throwable demarshalFaultResponse(OperationDescription operationDesc, TreeSet<String>
packages,Message message, boolean isRPC) 
         throws WebServiceException, ClassNotFoundException, IllegalAccessException,
                InstantiationException, XMLStreamException, InvocationTargetException, NoSuchMethodException
{
         

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java?view=diff&rev=503860&r1=503859&r2=503860
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/RPCLitMethodMarshaller.java
Mon Feb  5 12:38:08 2007
@@ -19,7 +19,7 @@
 package org.apache.axis2.jaxws.marshaller.impl.alt;
 
 import java.util.List;
-import java.util.Set;
+import java.util.TreeSet;
 
 import javax.jws.soap.SOAPBinding.Style;
 import javax.xml.namespace.QName;
@@ -85,7 +85,7 @@
             
             // Get the operation information
             ParameterDescription[] pds =operationDesc.getParameterDescriptions();
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
             
             // TODO This needs more work.  We need to check inside holders of input params.
 We also
             // may want to exclude header params from this check
@@ -161,7 +161,7 @@
             //   5) We always send an xsi:type, but other vendor's may not.
             // Get the operation information
             ParameterDescription[] pds =operationDesc.getParameterDescriptions();
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
             
             // Indicate that the style is RPC.  This is important so that the message understands
             // that the data blocks are underneath the operation element
@@ -236,7 +236,7 @@
             
             // Get the operation information
             ParameterDescription[] pds =operationDesc.getParameterDescriptions();
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
             
             // Create the message 
             MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
@@ -330,7 +330,7 @@
             //   5) We always send an xsi:type, but other vendor's may not.
             // Get the operation information
             ParameterDescription[] pds =operationDesc.getParameterDescriptions();
-            Set<String> packages = endpointDesc.getPackages();
+            TreeSet<String> packages = endpointDesc.getPackages();
             
             // Indicate that the style is RPC.  This is important so that the message understands
             // that the data blocks are underneath the operation element

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java?view=diff&rev=503860&r1=503859&r2=503860
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java
Mon Feb  5 12:38:08 2007
@@ -16,8 +16,7 @@
  */
 package org.apache.axis2.jaxws.message.databinding;
 
-import java.util.HashSet;
-import java.util.Set;
+import java.util.TreeSet;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
@@ -36,7 +35,7 @@
     
     private static final Log log = LogFactory.getLog(JAXBBlockContext.class);
     
-	private Set<String> contextPackages;  // List of packages needed by the context
+	private TreeSet<String> contextPackages;  // List of packages needed by the context
 	private JAXBContext jaxbContext = null;
     
     // For RPC processing only
@@ -52,7 +51,7 @@
 	 * Normal Constructor JAXBBlockContext
 	 * @param packages Set of packages needed by the JAXBContext.
 	 */
-	public JAXBBlockContext(Set<String> packages) {
+	public JAXBBlockContext(TreeSet<String> packages) {
         this.contextPackages = packages;
 	}
     
@@ -62,7 +61,7 @@
      * @deprecated
      */
     public JAXBBlockContext(String contextPackage) {
-        this.contextPackages = new HashSet();
+        this.contextPackages = new TreeSet();
         this.contextPackages.add(contextPackage);
     }
 
@@ -79,7 +78,7 @@
 	/**
 	 * @return Class representing type of the element
 	 */
-	public Set<String> getContextPackages() {
+	public TreeSet<String> getContextPackages() {
 		return contextPackages;
 	}
     

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java?view=diff&rev=503860&r1=503859&r2=503860
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java
Mon Feb  5 12:38:08 2007
@@ -26,11 +26,10 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
+import java.util.TreeSet;
 import java.util.WeakHashMap;
 
 import javax.xml.bind.JAXBContext;
@@ -61,8 +60,8 @@
     
 	// Create a synchronized map to get the JAXBObject: keys are ClassLoader and Set<String>.
     // TODO We should change the key from Set<String> to an actual package ContextPath
-    private static Map<ClassLoader, Map<Set<String>, JAXBContext> > jaxbMap
=
-			Collections.synchronizedMap(new WeakHashMap<ClassLoader, Map<Set<String>,
JAXBContext> >());
+    private static Map<ClassLoader, Map<String, JAXBContext> > jaxbMap =
+			Collections.synchronizedMap(new WeakHashMap<ClassLoader, Map<String, JAXBContext>
>());
 	private static JAXBContext genericJAXBContext = null;
 	
 	private static Map<JAXBContext,Unmarshaller> umap = 
@@ -90,7 +89,7 @@
 	 * @return JAXBContext
 	 * @throws JAXBException
 	 */
-	public static JAXBContext getJAXBContext(Set<String> contextPackages) throws JAXBException
{
+	public static JAXBContext getJAXBContext(TreeSet<String> contextPackages) throws JAXBException
{
 		// JAXBContexts for the same class can be reused and are supposed to be thread-safe
         if(log.isDebugEnabled()){
         	log.debug("Following packages are in this batch of getJAXBContext() :");
@@ -102,23 +101,31 @@
         ClassLoader cl = getContextClassLoader();
         
         // Get the innerMap 
-        Map<Set<String>, JAXBContext> innerMap = jaxbMap.get(cl);
+        Map<String, JAXBContext> innerMap = jaxbMap.get(cl);
         if (innerMap == null) {
             synchronized(jaxbMap) {
-                innerMap = new WeakHashMap<Set<String>, JAXBContext>();
+                innerMap = new WeakHashMap<String, JAXBContext>();
                 jaxbMap.put(cl, Collections.synchronizedMap(innerMap));
             }
         }
         
         if (contextPackages == null) {
-            contextPackages = new HashSet<String>();
+            contextPackages = new TreeSet<String>();
         }
         
-		JAXBContext context = innerMap.get(contextPackages);
+		JAXBContext context = innerMap.get(contextPackages.toString());
 		if (context == null) {
             synchronized(innerMap) {
+                // A pooled context was not found, so create one and put it in the map.
+                
+                // A copy is made of the original list of packages because createJAXBContext
may 
+                // prune the list.
+                TreeSet<String> origContextPackages = new TreeSet<String>(contextPackages);
                 context = createJAXBContext(contextPackages, cl);
-                innerMap.put(contextPackages, context);	
+                
+                // Put the new context in the map keyed by both the original and current
list of packages
+                innerMap.put(origContextPackages.toString(), context);
+                innerMap.put(contextPackages.toString(), context);	
                 if (log.isDebugEnabled()) {
                     log.debug("JAXBContext [created] for " + contextPackages.toString());
                 }
@@ -138,7 +145,7 @@
      * @return JAXBContext
      * @throws JAXBException
      */
-    private static JAXBContext createJAXBContext(Set<String> contextPackages, ClassLoader
cl) throws JAXBException {
+    private static JAXBContext createJAXBContext(TreeSet<String> contextPackages, ClassLoader
cl) throws JAXBException {
 
        JAXBContext context = null;
        if(log.isDebugEnabled()){
@@ -148,7 +155,7 @@
        	}
        }
         // The contextPackages is a set of package names that are constructed using PackageSetBuilder.
-        // PackageSetBuilder gets the packages names from the following sources.
+        // PackageSetBuilder gets the packages names from various sources.
         //   a) It walks the various annotations on the WebService collecting package names.
         //   b) It walks the wsdl/schemas and builds package names for each target namespace.
         //
@@ -231,6 +238,19 @@
             }
         }
         
+        // The code above may have removed some packages from the list. 
+        // Retry our lookup with the updated list
+        Map<String, JAXBContext> innerMap = jaxbMap.get(cl);
+        if (innerMap != null) {
+            context = innerMap.get(contextPackages.toString());
+            if (context != null) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Successfully found JAXBContext with updated context list:"
+ context.toString());
+                }
+                return context;
+            }
+        }
+        
         // CONTEXT construction
         if (contextConstruction) {
             context = createJAXBContextUsingContextPath(contextPackages, cl);
@@ -291,7 +311,9 @@
         if (log.isDebugEnabled()) {
             log.debug("Unmarshaller placed back into pool");
         }
-		umap.put(context, unmarshaller);
+        if (ENABLE_ADV_POOLING) {
+            umap.put(context, unmarshaller);
+        }
 	}
 	
 	/**
@@ -335,7 +357,9 @@
         if (log.isDebugEnabled()) {
             log.debug("Marshaller placed back into pool");
         }
-        mmap.put(context, marshaller);
+        if (ENABLE_ADV_POOLING) {
+            mmap.put(context, marshaller);
+        }
 	}
 	
 	/**
@@ -378,7 +402,9 @@
         if (log.isDebugEnabled()) {
             log.debug("JAXBIntrospector placed back into pool");
         }
-        imap.put(context, introspector);
+        if (ENABLE_ADV_POOLING) {
+            imap.put(context, introspector);
+        }
 	}
     
     /**
@@ -409,7 +435,7 @@
 	    }
 	    
         try {
-            Class cls = Class.forName(p + ".package-info",false, cl);
+            Class cls = forName(p + ".package-info",false, cl);
             if (cls != null) {
                 return true;
             }
@@ -432,7 +458,7 @@
      * @param cl ClassLoader
      * @return JAXBContext or null if unsuccessful
      */
-    private static JAXBContext createJAXBContextUsingContextPath(Set<String> packages,
ClassLoader cl) {
+    private static JAXBContext createJAXBContextUsingContextPath(TreeSet<String> packages,
ClassLoader cl) {
         JAXBContext context = null;
         String contextpath = "";
         
@@ -490,7 +516,7 @@
         	 }          
         }
         try {
-           //If Calsses not found in directory then look for jar that has these classes
+           //If Clases not found in directory then look for jar that has these classes
         	if(classes.size() <=0){
         		//This will load classes from jar file.
         		ClassFinderFactory cff = (ClassFinderFactory)FactoryRegistry.getFactory(ClassFinderFactory.class);
@@ -689,6 +715,13 @@
         // NOTE: This method must remain private because it uses AccessController
         JAXBContext jaxbContext = null;
         try {
+            if (log.isDebugEnabled()) {
+                if (context== null || context.length() == 0) {
+                    log.debug("JAXBContext is constructed without a context String.");
+                } else {
+                    log.debug("JAXBContext is constructed with a context of:" + context);
+                }
+            }
             jaxbContext = (JAXBContext) AccessController.doPrivileged(
                     new PrivilegedExceptionAction() {
                         public Object run() throws JAXBException {
@@ -716,6 +749,13 @@
         // NOTE: This method must remain private because it uses AccessController
         JAXBContext jaxbContext = null;
         try {
+            if (log.isDebugEnabled()) {
+                if (classArray== null || classArray.length == 0) {
+                    log.debug("JAXBContext is constructed with 0 input classes.");
+                } else {
+                    log.debug("JAXBContext is constructed with " + classArray.length + "
input classes.");
+                }
+            }
             jaxbContext = (JAXBContext) AccessController.doPrivileged(
                     new PrivilegedExceptionAction() {
                         public Object run() throws JAXBException {

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?view=diff&rev=503860&r1=503859&r2=503860
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
Mon Feb  5 12:38:08 2007
@@ -46,6 +46,7 @@
 import org.apache.axis2.jaxws.message.SAAJConverterTests;
 import org.apache.axis2.jaxws.message.SOAP12Tests;
 import org.apache.axis2.jaxws.message.XMLStreamReaderSplitterTests;
+import org.apache.axis2.jaxws.misc.JAXBContextTest;
 import org.apache.axis2.jaxws.misc.NS2PkgTest;
 import org.apache.axis2.jaxws.nonanonymous.complextype.NonAnonymousComplexTypeTests;
 import org.apache.axis2.jaxws.polymorphic.shape.tests.PolymorphicTests;
@@ -148,6 +149,7 @@
         suite.addTestSuite(AnyTypeTests.class);
         suite.addTestSuite(PolymorphicTests.class);
         suite.addTestSuite(NS2PkgTest.class);
+        suite.addTestSuite(JAXBContextTest.class);
         // Start (and stop) the server only once for all the tests
         TestSetup testSetup = new TestSetup(suite) {
             public void setUp() {

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java?view=auto&rev=503860
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java
(added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/misc/JAXBContextTest.java
Mon Feb  5 12:38:08 2007
@@ -0,0 +1,84 @@
+/**
+ * 
+ */
+package org.apache.axis2.jaxws.misc;
+
+import java.util.TreeSet;
+import java.util.Set;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.apache.axis2.jaxws.message.databinding.JAXBUtils;
+import org.apache.axis2.jaxws.util.JavaUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests Namespace to Package Algorithmh
+ *
+ */
+public class JAXBContextTest extends TestCase {
+
+    /**
+     * Test basic functionality of JAXBUtils pooling
+     * @throws Exception
+     */
+    public void test01() throws JAXBException {
+        
+        // Get a JAXBContext
+        TreeSet<String> context1 = new TreeSet<String>();
+        context1.add("org.test.addnumbers");
+        context1.add("org.test.anytype");
+        
+        JAXBContext jaxbContext1 = JAXBUtils.getJAXBContext(context1);
+        
+        // Assert that the JAXBContext was found and the context contains the two valid packages
+        assertTrue(jaxbContext1 != null);
+        assertTrue(context1.contains("org.test.addnumbers"));
+        assertTrue(context1.contains("org.test.anytype"));
+        
+        // Repeat with the same packages
+        TreeSet<String> context2 = new TreeSet<String>();
+        context2.add("org.test.addnumbers");
+        context2.add("org.test.anytype");
+        
+        JAXBContext jaxbContext2 = JAXBUtils.getJAXBContext(context2);
+        
+        // The following assertion is probably true,but GC may have wiped out the weak reference
+        //assertTrue(jaxbContext2 == jaxbContext1);
+        assertTrue(jaxbContext2 != null);
+        assertTrue(jaxbContext2.toString().equals(jaxbContext1.toString()));
+        assertTrue(context2.contains("org.test.addnumbers"));
+        assertTrue(context2.contains("org.test.anytype"));
+        
+        // Repeat with the same packages + an invalid package
+        TreeSet<String> context3 = new TreeSet<String>();
+        context3.add("org.test.addnumbers");
+        context3.add("org.test.anytype");
+        context3.add("my.grandma.loves.jaxws");
+        
+        JAXBContext jaxbContext3 = JAXBUtils.getJAXBContext(context3);
+        
+        // The following assertion is probably true,but GC may have wiped out the weak reference
+        //assertTrue(jaxbContext3 == jaxbContext1);
+        assertTrue(jaxbContext3 != null);
+        assertTrue(jaxbContext1.toString().equals(jaxbContext1.toString()));
+        assertTrue(context3.contains("org.test.addnumbers"));
+        assertTrue(context3.contains("org.test.anytype")); 
+        assertTrue(!context3.contains("my.grandma.loves.jaxws"));  // invalid package should
be silently removed
+        
+        // Repeat with a subset of packages
+        TreeSet<String> context4 = new TreeSet<String>();
+        context4.add("org.test.addnumbers");
+        
+        
+        JAXBContext jaxbContext4 = JAXBUtils.getJAXBContext(context4);
+        
+        assertTrue(jaxbContext4 != null);
+        assertTrue(jaxbContext4 != jaxbContext3);
+        assertTrue(context4.contains("org.test.addnumbers"));
+        
+       
+    }
+}

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java?view=diff&rev=503860&r1=503859&r2=503860
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java
Mon Feb  5 12:38:08 2007
@@ -19,7 +19,7 @@
 package org.apache.axis2.jaxws.description;
 
 import java.util.List;
-import java.util.Set;
+import java.util.TreeSet;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.Service;
@@ -116,7 +116,7 @@
      * JAXBContext.
      * @return Set<Package>
      */
-    public Set<String> getPackages();
+    public TreeSet<String> getPackages();
     
     public QName getPortType();
 }

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?view=diff&rev=503860&r1=503859&r2=503860
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
Mon Feb  5 12:38:08 2007
@@ -22,6 +22,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeSet;
 
 import javax.jws.WebService;
 import javax.wsdl.Binding;
@@ -110,7 +111,7 @@
     DescriptionBuilderComposite composite = null;
  
     // Set of packages that are needed to marshal/unmashal data (used to set JAXBContext)
-    Set<String> packages = null;
+    TreeSet<String> packages = null;
     
     // The JAX-WS Handler port information corresponding to this endpoint
     private PortInfo portInfo;
@@ -1223,7 +1224,7 @@
      * JAXBContext.
      * @return Set<Package>
      */
-    public Set<String> getPackages() {
+    public TreeSet<String> getPackages() {
         // @REVIEW Currently the package set is stored on the
         // EndpointDescription.  We may consider moving this to 
         // ServiceDescription. 
@@ -1240,7 +1241,7 @@
                 // So for now we will do both.
                 boolean doSchemaWalk = true;
                 boolean doAnnotationWalk = true;
-                packages = new HashSet<String>();
+                packages = new TreeSet<String>();
                 if (doSchemaWalk) {
                     packages.addAll(PackageSetBuilder.getPackagesFromSchema(this.getServiceDescription()));
                 }

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java?view=diff&rev=503860&r1=503859&r2=503860
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/PackageSetBuilder.java
Mon Feb  5 12:38:08 2007
@@ -21,8 +21,8 @@
 import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.HashSet;
 import java.util.Set;
+import java.util.TreeSet;
 
 import javax.wsdl.Definition;
 import javax.wsdl.WSDLException;
@@ -86,9 +86,9 @@
      * @param serviceDesc ServiceDescription
      * @return Set of Packages
      */
-    public static Set<String> getPackagesFromSchema(ServiceDescription serviceDesc)
{
+    public static TreeSet<String> getPackagesFromSchema(ServiceDescription serviceDesc)
{
     	boolean annotationWalking = true;
-    	Set<String> set = new HashSet<String>();
+    	TreeSet<String> set = new TreeSet<String>();
     	//If we are on client side we will get wsdl definition from ServiceDescription. If we
are on server side we will have to 
     	//read wsdlLocation from @WebService Annotation.
     	ServiceDescriptionWSDL sdw = (ServiceDescriptionWSDL) serviceDesc;
@@ -133,8 +133,8 @@
      * @param serviceDescription ServiceDescription
      * @return Set of Packages
      */
-    public static Set<String> getPackagesFromAnnotations(ServiceDescription serviceDesc)
{
-        HashSet<String> set = new HashSet<String>();
+    public static TreeSet<String> getPackagesFromAnnotations(ServiceDescription serviceDesc)
{
+        TreeSet<String> set = new TreeSet<String>();
         EndpointDescription[] endpointDescs = serviceDesc.getEndpointDescriptions();
         
         // Build a set of packages from all of the endpoints
@@ -150,11 +150,11 @@
      * @param endpointDesc EndpointDescription
      * @return Set of Packages
      */
-    public static Set<String> getPackagesFromAnnotations(EndpointDescription endpointDesc)
{
+    public static TreeSet<String> getPackagesFromAnnotations(EndpointDescription endpointDesc)
{
         EndpointInterfaceDescription endpointInterfaceDesc = 
             endpointDesc.getEndpointInterfaceDescription();
         if (endpointInterfaceDesc == null) {
-            return new HashSet<String>(); 
+            return new TreeSet<String>(); 
         } else {
             return getPackagesFromAnnotations(endpointInterfaceDesc);
         }
@@ -164,8 +164,8 @@
      * @param endpointInterfaceDescription EndpointInterfaceDescription
      * @return Set of Packages
      */
-    public static Set<String> getPackagesFromAnnotations(EndpointInterfaceDescription
endpointInterfaceDesc) {
-        HashSet<String> set = new HashSet<String>();
+    public static TreeSet<String> getPackagesFromAnnotations(EndpointInterfaceDescription
endpointInterfaceDesc) {
+        TreeSet<String> set = new TreeSet<String>();
         OperationDescription[] opDescs = endpointInterfaceDesc.getOperations();
         
         // Build a set of packages from all of the opertions
@@ -182,7 +182,7 @@
      * @param opDesc OperationDescription
      * @param set Set<Package> that is updated
      */
-    private static void getPackagesFromAnnotations(OperationDescription opDesc, Set<String>
set) {
+    private static void getPackagesFromAnnotations(OperationDescription opDesc, TreeSet<String>
set) {
        
        // Walk the parameter information
        ParameterDescription[] parameterDescs = opDesc.getParameterDescriptions();
@@ -235,7 +235,7 @@
      * @param paramDesc ParameterDesc
      * @param set Set<Package> that is updated
      */
-    private static void getPackagesFromAnnotations(ParameterDescription paramDesc, Set<String>
set) {
+    private static void getPackagesFromAnnotations(ParameterDescription paramDesc, TreeSet<String>
set) {
        
        // Get the type that defines the actual data.  (this is never a holder )
        Class paramClass = paramDesc.getParameterActualType();
@@ -251,7 +251,7 @@
      * @param faultDesc FaultDescription
      * @param set Set<Package> that is updated
      */
-    private static void getPackagesFromAnnotations(FaultDescription faultDesc, Set<String>
set) {
+    private static void getPackagesFromAnnotations(FaultDescription faultDesc, TreeSet<String>
set) {
       
       Class faultBean = loadClass(faultDesc.getFaultBean());  
       if (faultBean != null) {
@@ -266,7 +266,7 @@
      * @param localPart of the element
      * @param set with both type and element packages set
      */
-    private static void setTypeAndElementPackages(Class cls, String namespace, String localPart,
Set<String> set) {
+    private static void setTypeAndElementPackages(Class cls, String namespace, String localPart,
TreeSet<String> set) {
         
         // Get the element and type classes
         Class eClass = getElement(cls);



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message