Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 2592 invoked from network); 17 Jun 2008 03:36:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Jun 2008 03:36:43 -0000 Received: (qmail 12066 invoked by uid 500); 17 Jun 2008 03:36:45 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 11969 invoked by uid 500); 17 Jun 2008 03:36:44 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 11960 invoked by uid 500); 17 Jun 2008 03:36:44 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 11957 invoked by uid 99); 17 Jun 2008 03:36:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jun 2008 20:36:44 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jun 2008 03:36:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A130E23889F3; Mon, 16 Jun 2008 20:35:51 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r668384 - in /webservices/axis2/trunk/java/modules: jaxws-integration/test/org/apache/axis2/jaxws/type_substitution/tests/ jaxws/src/org/apache/axis2/datasource/jaxb/ jaxws/src/org/apache/axis2/jaxws/marshaller/factory/ jaxws/src/org/apache... Date: Tue, 17 Jun 2008 03:35:50 -0000 To: axis2-cvs@ws.apache.org From: gawor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080617033551.A130E23889F3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gawor Date: Mon Jun 16 20:35:50 2008 New Revision: 668384 URL: http://svn.apache.org/viewvc?rev=668384&view=rev Log: set default namespace property on JAXBContext (AXIS2-3854) Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/type_substitution/tests/TypeSubstitutionTests.java webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.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/message/databinding/JAXBContextFromClasses.java webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/type_substitution/tests/TypeSubstitutionTests.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/type_substitution/tests/TypeSubstitutionTests.java?rev=668384&r1=668383&r2=668384&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/type_substitution/tests/TypeSubstitutionTests.java (original) +++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/type_substitution/tests/TypeSubstitutionTests.java Mon Jun 16 20:35:50 2008 @@ -70,9 +70,8 @@ TestLogger.logger.debug(">> Response [" + body + "]"); - // XXX: the xsi:type attribute values should have namespace apparently - QName expectedXsiType1 = new QName(/*NS,*/ "fuji"); - QName expectedXsiType2 = new QName(/*NS,*/ "freyburg"); + QName expectedXsiType1 = new QName(NS, "fuji"); + QName expectedXsiType2 = new QName(NS, "freyburg"); Iterator iter; SOAPElement element; Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java?rev=668384&r1=668383&r2=668384&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java (original) +++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java Mon Jun 16 20:35:50 2008 @@ -50,6 +50,8 @@ import java.lang.reflect.Method; import java.security.PrivilegedAction; import java.text.ParseException; +import java.util.HashMap; +import java.util.Map; import java.util.TreeSet; /* @@ -84,6 +86,7 @@ // Please don't use "by java type" processing to get around errors. private Class processType = null; private boolean isxmlList =false; + private String defaultNamespace; /** * Full Constructor JAXBDSContext (most performant) @@ -158,8 +161,13 @@ } Holder constructType = new Holder(); + Map properties = null; + if (this.defaultNamespace != null) { + properties = new HashMap(); + properties.put("com.sun.xml.bind.defaultNamespaceRemap", this.defaultNamespace); + } jc = - JAXBUtils.getJAXBContext(contextPackages, constructType, contextPackagesKey, cl); + JAXBUtils.getJAXBContext(contextPackages, constructType, contextPackagesKey, cl, properties); constructionType = constructType.value; autoJAXBContext = new WeakReference(jc); } else { @@ -170,6 +178,14 @@ return jc; } + public void setDefaultNamespace(String namespace) { + this.defaultNamespace = namespace; + } + + public String getDefaultNamespace() { + return this.defaultNamespace; + } + /** @return RPC Declared Type */ public Class getProcessType() { return processType; Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java?rev=668384&r1=668383&r2=668384&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java (original) +++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/factory/MethodMarshallerFactory.java Mon Jun 16 20:35:50 2008 @@ -209,7 +209,7 @@ Holder holder = new Holder(); try { JAXBContext context = JAXBUtils.getJAXBContext(marshalDesc.getPackages(), holder, - marshalDesc.getPackagesKey(), cl); + marshalDesc.getPackagesKey(), cl, null); } catch (JAXBException e) { throw ExceptionFactory.makeWebServiceException(e); } 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?rev=668384&r1=668383&r2=668384&view=diff ============================================================================== --- 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 Jun 16 20:35:50 2008 @@ -108,6 +108,7 @@ // In usage=WRAPPED, there will be a single JAXB block inside the body. // Get this block JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey); + blockContext.setDefaultNamespace(ed.getTargetNamespace()); JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class); Block block = message.getBodyBlock(blockContext, factory); @@ -226,6 +227,7 @@ // In usage=WRAPPED, there will be a single JAXB block inside the body. // Get this block JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey); + blockContext.setDefaultNamespace(ed.getTargetNamespace()); JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class); Block block = message.getBodyBlock(blockContext, factory); @@ -389,9 +391,10 @@ // Put the object into the message JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class); - + JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey); + blockContext.setDefaultNamespace(ed.getTargetNamespace()); Block block = factory.createFrom(object, - new JAXBBlockContext(packages, packagesKey), + blockContext, wrapperQName); m.setBodyBlock(block); @@ -489,9 +492,10 @@ // Put the object into the message JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class); - + JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey); + blockContext.setDefaultNamespace(ed.getTargetNamespace()); Block block = factory.createFrom(object, - new JAXBBlockContext(packages, packagesKey), + blockContext, wrapperQName); m.setBodyBlock(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?rev=668384&r1=668383&r2=668384&view=diff ============================================================================== --- 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 Jun 16 20:35:50 2008 @@ -149,6 +149,7 @@ // In usage=WRAPPED, there will be a single JAXB block inside the body. // Get this block JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey); + blockContext.setDefaultNamespace(ed.getTargetNamespace()); JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class); Block block = message.getBodyBlock(blockContext, factory); @@ -310,7 +311,8 @@ // In usage=WRAPPED, there will be a single JAXB block inside the body. // Get this block - JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey); + JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey); + blockContext.setDefaultNamespace(ed.getTargetNamespace()); JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class); Block block = message.getBodyBlock(blockContext, factory); @@ -545,9 +547,10 @@ // Put the object into the message JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class); - + JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey); + blockContext.setDefaultNamespace(ed.getTargetNamespace()); Block block = factory.createFrom(object, - new JAXBBlockContext(packages, packagesKey), + blockContext, wrapperQName); // The factory will get the qname from the value m.setBodyBlock(block); @@ -673,8 +676,10 @@ // Put the object into the message JAXBBlockFactory factory = (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class); + JAXBBlockContext blockContext = new JAXBBlockContext(packages, packagesKey); + blockContext.setDefaultNamespace(ed.getTargetNamespace()); Block block = factory.createFrom(object, - new JAXBBlockContext(packages, packagesKey), + blockContext, wrapperQName); // The factory will get the qname from the value m.setBodyBlock(block); Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java?rev=668384&r1=668383&r2=668384&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java (original) +++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java Mon Jun 16 20:35:50 2008 @@ -39,6 +39,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.List; +import java.util.Map; /** * This class provides a utility method, newInstance, which @@ -69,7 +70,8 @@ * @throws JAXBException */ public static JAXBContext newInstance(Class[] classArray, - ClassLoader cl) + ClassLoader cl, + Map properties) throws JAXBException { JAXBContext jaxbContext = null; try { @@ -81,7 +83,7 @@ " input classes."); } } - jaxbContext = _newInstance(classArray, cl); + jaxbContext = _newInstance(classArray, cl, properties); } catch (Throwable t) { // Try finding the best set of classes ArrayList original = new ArrayList(); @@ -89,7 +91,7 @@ original.add(classArray[i]); } ArrayList best = new ArrayList(); - jaxbContext = findBestSet(original, cl, best); + jaxbContext = findBestSet(original, cl, best, properties); } @@ -106,7 +108,8 @@ * @throws Throwable */ private static JAXBContext _newInstance(final Class[] classArray, - final ClassLoader cl) + final ClassLoader cl, + final Map properties) throws Throwable { JAXBContext jaxbContext; try { @@ -120,7 +123,7 @@ ClassLoader savedClassLoader = currentThread.getContextClassLoader(); try { currentThread.setContextClassLoader(cl); - return JAXBContext.newInstance(classArray); + return JAXBContext.newInstance(classArray, properties); } finally { currentThread.setContextClassLoader(savedClassLoader); } @@ -179,7 +182,8 @@ */ static JAXBContext findBestSet(List original, ClassLoader cl, - List best) { + List best, + Map properties) { JAXBContext jc = null; Class[] clsArray = new Class[0]; @@ -194,7 +198,7 @@ best.addAll(primary); if (best.size() > 0) { try { - jc = _newInstance(best.toArray(clsArray), cl); + jc = _newInstance(best.toArray(clsArray), cl, properties); } catch (Throwable t) { return null; } @@ -212,7 +216,7 @@ Class cls = secondary.get(i); best.add(cls); try { - jc = _newInstance(best.toArray(clsArray), cl); + jc = _newInstance(best.toArray(clsArray), cl, properties); } catch (Throwable t) { if (log.isDebugEnabled()) { log.debug("The following class is not a JAXB class: " + 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?rev=668384&r1=668383&r2=668384&view=diff ============================================================================== --- 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 Jun 16 20:35:50 2008 @@ -105,7 +105,7 @@ */ public static JAXBContext getJAXBContext(TreeSet contextPackages) throws JAXBException { return getJAXBContext(contextPackages, new Holder(), - contextPackages.toString(), null); + contextPackages.toString(), null, null); } /** @@ -123,14 +123,14 @@ public static JAXBContext getJAXBContext(TreeSet contextPackages, ClassLoader cacheKey) throws JAXBException { return getJAXBContext(contextPackages, new Holder(), - contextPackages.toString(), cacheKey); + contextPackages.toString(), cacheKey, null); } public static JAXBContext getJAXBContext(TreeSet contextPackages, Holder constructionType, String key) throws JAXBException { - return getJAXBContext(contextPackages, constructionType, key, null); + return getJAXBContext(contextPackages, constructionType, key, null, null); } /** @@ -148,7 +148,8 @@ public static JAXBContext getJAXBContext(TreeSet contextPackages, Holder constructionType, String key, - ClassLoader cacheKey) + ClassLoader cacheKey, + Map properties) throws JAXBException { // JAXBContexts for the same class can be reused and are supposed to be thread-safe if (log.isDebugEnabled()) { @@ -221,13 +222,13 @@ TreeSet validContextPackages = new TreeSet(contextPackages); ClassLoader tryCl = cl; - contextValue = createJAXBContextValue(validContextPackages, cl); + contextValue = createJAXBContextValue(validContextPackages, cl, properties); // If we don't get all the classes, try the cached classloader if (cacheKey != null && validContextPackages.size() != contextPackages.size()) { tryCl = cacheKey; validContextPackages = new TreeSet(contextPackages); - contextValue = createJAXBContextValue(validContextPackages, cacheKey); + contextValue = createJAXBContextValue(validContextPackages, cacheKey, properties); } synchronized (jaxbMap) { // Add the context value with the original package set @@ -287,7 +288,8 @@ * @throws JAXBException */ private static JAXBContextValue createJAXBContextValue(TreeSet contextPackages, - ClassLoader cl) throws JAXBException { + ClassLoader cl, + Map properties) throws JAXBException { JAXBContextValue contextValue = null; if (log.isDebugEnabled()) { @@ -436,7 +438,7 @@ //Lets add all common array classes addCommonArrayClasses(fullList); Class[] classArray = fullList.toArray(new Class[0]); - JAXBContext context = JAXBContext_newInstance(classArray, cl); + JAXBContext context = JAXBContext_newInstance(classArray, cl, properties); if (context != null) { contextValue = new JAXBContextValue(context, CONSTRUCTION_TYPE.BY_CLASS_ARRAY); } @@ -1028,7 +1030,8 @@ * @throws Exception */ private static JAXBContext JAXBContext_newInstance(final Class[] classArray, - final ClassLoader cl) + final ClassLoader cl, + Map properties) throws JAXBException { // NOTE: This method must remain private because it uses AccessController JAXBContext jaxbContext = null; @@ -1043,7 +1046,7 @@ } // Get JAXBContext from classes - jaxbContext = JAXBContextFromClasses.newInstance(classArray, cl); + jaxbContext = JAXBContextFromClasses.newInstance(classArray, cl, properties); return jaxbContext; }