cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r719328 - in /cxf/branches/2.1.x-fixes: ./ common/common/ common/common/src/main/java/org/apache/cxf/common/util/ common/common/src/main/java/org/apache/cxf/jaxb/ parent/ rt/core/src/test/java/org/apache/cxf/configuration/spring/ rt/databin...
Date Thu, 20 Nov 2008 19:27:17 GMT
Author: dkulp
Date: Thu Nov 20 11:27:15 2008
New Revision: 719328

URL: http://svn.apache.org/viewvc?rev=719328&view=rev
Log:
Merged revisions 708410 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r708410 | dkulp | 2008-10-27 20:56:32 -0400 (Mon, 27 Oct 2008) | 2 lines
  
  BUNCH of updates to get all the jaxb RUNTIME parts (including DynamicClient) working with the JAXB implementationbuilt into Java6 as well as the shipped version.  tooling still requires shipped xjc/impl at this point.
........

Added:
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ReflectionInvokationHandler.java
      - copied unchanged from r708410, cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ReflectionInvokationHandler.java
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/NamespaceMapper.java
      - copied unchanged from r708410, cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/NamespaceMapper.java
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBBeanInfo.java
      - copied unchanged from r708410, cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBBeanInfo.java
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextProxy.java
      - copied unchanged from r708410, cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextProxy.java
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/common/common/pom.xml
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
    cxf/branches/2.1.x-fixes/parent/pom.xml
    cxf/branches/2.1.x-fixes/rt/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/pom.xml
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/TypeClassInitializer.java
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/resources/schemas/wsdl/http-conf.xsd
    cxf/branches/2.1.x-fixes/rt/transports/jbi/src/test/java/org/apache/cxf/transport/jbi/JBIConduitTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
    cxf/branches/2.1.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
    cxf/branches/2.1.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 20 11:27:15 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708417,708550,708554,709353-709354,709425,710076,710150,710154,71138
 8,711410,711490,711635,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281,718439,718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222,719273
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711388,711410,711490,711635,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281,718439,718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222,719273

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/common/common/pom.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/pom.xml?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/common/common/pom.xml (original)
+++ cxf/branches/2.1.x-fixes/common/common/pom.xml Thu Nov 20 11:27:15 2008
@@ -74,7 +74,7 @@
         <dependency>
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-impl</artifactId>
-            <scope>test</scope>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>

Modified: cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java (original)
+++ cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java Thu Nov 20 11:27:15 2008
@@ -122,7 +122,12 @@
     public ClassWriter createClassWriter() {
         ClassWriter newCw = null;
         if (!oldASM) {
-            Class<ClassWriter> cls = ClassWriter.class;
+            Class<ClassWriter> cls;
+            try {
+                cls = ClassWriter.class;
+            } catch (NoClassDefFoundError error) {
+                return null;
+            }
             try {
                 // ASM 1.5.x/2.x
                 Constructor<ClassWriter> cons = cls.getConstructor(new Class<?>[] {Boolean.TYPE});
@@ -182,7 +187,7 @@
             super(parent);
         }
         public Class<?> lookupDefinedClass(String name) {
-            return defined.get(name);
+            return defined.get(name.replace('/', '.'));
         }
         
         public Class<?> defineClass(String name, byte bytes[]) {
@@ -201,7 +206,7 @@
             }
             
             Class<?> ret = super.defineClass(name.replace('/', '.'), bytes, 0, bytes.length);
-            defined.put(name, ret);
+            defined.put(name.replace('/', '.'), ret);
             return ret;
         }
     }

Modified: cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java (original)
+++ cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java Thu Nov 20 11:27:15 2008
@@ -19,23 +19,57 @@
 
 package org.apache.cxf.jaxb;
 
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.Type;
 import java.net.URI;
 import java.net.URISyntaxException;
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.StringTokenizer;
-import java.util.concurrent.Future;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
-import javax.xml.ws.AsyncHandler;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.PropertyException;
+import javax.xml.bind.attachment.AttachmentMarshaller;
+import javax.xml.bind.attachment.AttachmentUnmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.stream.StreamResult;
 import javax.xml.ws.Holder;
-import javax.xml.ws.Response;
 
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.xml.sax.InputSource;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.ASMHelper;
+import org.apache.cxf.common.util.ReflectionInvokationHandler;
+import org.apache.cxf.common.util.ReflectionInvokationHandler.WrapReturn;
 import org.apache.cxf.helpers.JavaUtils;
 
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+
 public final class JAXBUtils {
     
     public enum IdentifierType {
@@ -65,7 +99,8 @@
     
     private static final Map<String, String> BUILTIN_DATATYPES_MAP;
     private static final Map<String, Class<?>> HOLDER_TYPES_MAP;
-    
+    private static final Logger LOG = LogUtils.getL7dLogger(JAXBUtils.class, "CommonUtilityMessages");
+
     static {
         BUILTIN_DATATYPES_MAP = new HashMap<String, String>();        
         BUILTIN_DATATYPES_MAP.put("string", "java.lang.String");
@@ -225,23 +260,6 @@
         return packageName.toString();
     }
     
-    public static boolean isAsync(Method method) {
-        return method.getName().endsWith("Async") 
-            && (method.getReturnType().equals(Response.class) || method.getReturnType().equals(Future.class));
-    }
-    
-    public static boolean isAsyncPolling(Method method) {
-        return method.getName().endsWith("Async") 
-            && (method.getReturnType().equals(Response.class));   
-    }
-    
-    public static boolean isAsyncCallback(Method method) {
-        Class[] paramTypes = method.getParameterTypes();
-        return method.getName().endsWith("Async") 
-            && (method.getReturnType().equals(Future.class) 
-            && AsyncHandler.class.isAssignableFrom(paramTypes[paramTypes.length - 1]));
-    }
-    
     private static String normalizePackageNamePart(String name) {
         StringBuffer sname = new StringBuffer(name.toLowerCase());
 
@@ -476,4 +494,337 @@
         return cls;
     }
 
+    public static JAXBContext createRIContext(Class<?> clss[], String defaultNS) throws JAXBException {
+        try {
+            Class<?> cls;
+            Map<String, Object> map = new HashMap<String, Object>();
+            try {
+                cls = Class.forName("com.sun.xml.bind.v2.ContextFactory");
+                if (defaultNS != null) {
+                    map.put("com.sun.xml.bind.defaultNamespaceRemap", defaultNS);
+                }
+            } catch (ClassNotFoundException e) {
+                // TODO Auto-generated catch block
+                cls = Class.forName("com.sun.xml.internal.bind.v2.ContextFactory");
+                if (defaultNS != null) {
+                    map.put("com.sun.xml.internal.bind.defaultNamespaceRemap", defaultNS);
+                }
+            }
+            Method meth = cls.getMethod("createContext", clss.getClass(), Map.class);
+            return (JAXBContext)meth.invoke(null, clss, map);
+        } catch (Exception e) {
+            throw new JAXBException(e);
+        }
+    }
+    public static void setNamespaceWrapper(final Map<String, String> nspref,
+                                           Marshaller marshaller) throws PropertyException {
+        Object mapper = null;
+        if (marshaller.getClass().getName().contains(".internal.")) {
+            mapper = createNamespaceWrapper(nspref);
+            if (mapper == null) {
+                LOG.log(Level.INFO, "Could not create namespace mapper for JDK internal"
+                        + " JAXB implementation.");
+            } else {
+                marshaller.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper",
+                                   mapper);
+            }
+        } else {
+            try {
+                Class<?> cls = Class.forName("org.apache.cxf.jaxb.NamespaceMapper");
+                mapper = cls.getConstructor(Map.class).newInstance(nspref);
+            } catch (Exception ex) {
+                LOG.log(Level.INFO, "Could not create NamespaceMapper", ex);
+            }
+            marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper",
+                                   mapper);
+        }
+    }
+    public static BridgeWrapper createBridge(Set<Class<?>> ctxClasses,
+                                      QName qname,
+                                      Class<?> refcls,
+                                      Annotation anns[]) throws JAXBException {
+        try {
+            Class<?> cls;
+            String pkg = "com.sun.xml.bind.";
+            try {
+                cls = Class.forName("com.sun.xml.bind.api.JAXBRIContext");
+            } catch (ClassNotFoundException e) {
+                // TODO Auto-generated catch block
+                cls = Class.forName("com.sun.xml.internal.bind.api.JAXBRIContext");
+                pkg = "com.sun.xml.internal.bind.";
+            }
+            Class<?> refClass = Class.forName(pkg + "api.TypeReference");
+            Object ref = refClass.getConstructor(QName.class, 
+                                                 Type.class, 
+                                                 anns.getClass()).newInstance(qname, refcls, anns);
+            List<Object> typeRefs = new ArrayList<Object>();
+            typeRefs.add(ref);
+            List<Class<?>> clses = new ArrayList<Class<?>>(ctxClasses);
+            clses.add(refClass.getField("type").get(ref).getClass());
+            clses.add(refcls);
+            
+            Object ctx = null;
+            for (Method m : cls.getDeclaredMethods()) {
+                if (m.getName().equals("newInstance")
+                    && m.getParameterTypes().length == 6) {
+                    ctx = m.invoke(null, clses.toArray(new Class[clses.size()]),
+                                         typeRefs, null, null, true, null);
+                    
+                }
+            }
+            
+            Object bridge = ctx.getClass().getMethod("createBridge", refClass).invoke(ctx, ref);
+            return ReflectionInvokationHandler.createProxyWrapper(bridge,
+                                                                  BridgeWrapper.class);
+        } catch (Exception ex) {
+            throw new JAXBException(ex);
+        }
+    }
+    public static interface BridgeWrapper {
+
+        Object unmarshal(XMLStreamReader source, AttachmentUnmarshaller am) throws JAXBException;
+
+        Object unmarshal(InputStream source) throws JAXBException;
+
+        Object unmarshal(Node source, AttachmentUnmarshaller am) throws JAXBException;
+
+        void marshal(Object elValue, XMLStreamWriter source, AttachmentMarshaller m) throws JAXBException;
+
+        void marshal(Object elValue, StreamResult s1) throws JAXBException;
+
+        void marshal(Object elValue, Node source, AttachmentMarshaller am) throws JAXBException;
+    }
+    
+    
+    public static SchemaCompiler createSchemaCompiler() throws JAXBException {
+        try {
+            Class<?> cls;
+            Object sc = null;
+            try {
+                cls = Class.forName("com.sun.tools.xjc.api.XJC");
+                sc = cls.getMethod("createSchemaCompiler").invoke(null);
+            } catch (Throwable e) {
+                // TODO Auto-generated catch block
+                cls = Class.forName("com.sun.tools.internal.xjc.api.XJC");
+                sc = cls.getMethod("createSchemaCompiler").invoke(null);
+            }
+            
+            return ReflectionInvokationHandler.createProxyWrapper(sc,
+                                                                  SchemaCompiler.class);
+        } catch (Exception ex) {
+            throw new JAXBException(ex);
+        }
+    }
+    public static Object createFileCodeWriter(File f) throws JAXBException {
+        try {
+            Class<?> cls;
+            try {
+                cls = Class.forName("com.sun.codemodel.writer.FileCodeWriter");
+            } catch (ClassNotFoundException e) {
+                // TODO Auto-generated catch block
+                cls = Class.forName("com.sun.codemodel.internal.writer.FileCodeWriter");
+            }
+            return cls.getConstructor(File.class).newInstance(f);
+        } catch (Exception ex) {
+            throw new JAXBException(ex);
+        }
+    }
+    public static Class<?> getParamClass(SchemaCompiler sc, String method) {
+        Object o = ((ReflectionInvokationHandler)Proxy.getInvocationHandler(sc)).getTarget();
+        for (Method m : o.getClass().getMethods()) {
+            if (m.getName().equals(method) && m.getParameterTypes().length == 1) {
+                return m.getParameterTypes()[0];
+            }
+        }
+        return null;
+    }
+    public static interface SchemaCompiler {
+
+        void setErrorListener(Object elForRun);
+
+        void setClassNameAllocator(Object allocator);
+
+        @WrapReturn(S2JJAXBModel.class)
+        S2JJAXBModel bind();
+
+        void parseSchema(InputSource source);
+
+        void parseSchema(String key, Element el);
+
+        @WrapReturn(Options.class)
+        Options getOptions();
+    }
+    public static interface S2JJAXBModel {
+
+        @WrapReturn(JCodeModel.class)
+        JCodeModel generateCode(Object object, Object elForRun);
+        
+        @WrapReturn(Mapping.class)
+        Mapping get(QName qn);
+
+        @WrapReturn(TypeAndAnnotation.class)
+        TypeAndAnnotation getJavaType(QName typeQName);
+    }
+    public static interface Mapping {
+        @WrapReturn(TypeAndAnnotation.class)
+        TypeAndAnnotation getType();        
+    }
+    public static interface TypeAndAnnotation {
+        @WrapReturn(JType.class)
+        JType getTypeClass();
+    }
+    public static interface JType {
+        boolean isArray();
+
+        @WrapReturn(JType.class)
+        JType elementType();
+
+        boolean isPrimitive();
+
+        String binaryName();
+
+        String fullName();
+
+        String name();
+
+        @WrapReturn(value = JType.class, iterator = true)
+        Iterator<JType> classes();
+    }
+    public static interface Options {
+
+        void addGrammar(InputSource is);
+
+        void addBindFile(InputSource is);
+
+        String getBuildID();
+    }
+    public static interface JCodeModel {
+
+        void build(Object writer) throws IOException;
+
+        @WrapReturn(value = JPackage.class, iterator = true)
+        Iterator<JPackage> packages();
+    }
+    public static interface JPackage {
+
+        String name();
+
+        @WrapReturn(value = JDefinedClass.class, iterator = true)
+        Iterator<JDefinedClass> classes();
+    }
+    public static interface JDefinedClass {
+        String name();
+
+        String fullName();
+    }
+ 
+    private static synchronized Object createNamespaceWrapper(Map<String, String> map) {
+        ASMHelper helper = new ASMHelper();
+        String className = "org.apache.cxf.jaxb.NamespaceMapperInternal";
+        Class<?> cls = helper.findClass(className, JAXBUtils.class);
+        if (cls == null) {
+            ClassWriter cw = helper.createClassWriter();
+            if (cw == null) {
+                return null;
+            }
+            cls = createNamespaceWrapperInternal(helper, cw);
+        }
+        try {
+            return cls.getConstructor(Map.class).newInstance(map);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+    private static Class<?> createNamespaceWrapperInternal(ASMHelper helper, ClassWriter cw) {
+        String className = "org.apache.cxf.jaxb.NamespaceMapperInternal";
+        FieldVisitor fv;
+        MethodVisitor mv;
+        cw.visit(Opcodes.V1_5, 
+                 Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER,
+                 "org/apache/cxf/jaxb/NamespaceMapperInternal", null,
+                 "com/sun/xml/internal/bind/marshaller/NamespacePrefixMapper", null);
+
+        cw.visitSource("NamespaceMapper.java", null);
+
+        fv = cw.visitField(Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL, 
+                           "nspref", "Ljava/util/Map;",
+                           "Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;", null);
+        fv.visitEnd();
+        
+        mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", 
+                            "(Ljava/util/Map;)V", 
+                            "(Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;)V", null);
+        mv.visitCode();
+        Label l0 = new Label();
+        mv.visitLabel(l0);
+        mv.visitLineNumber(30, l0);
+        mv.visitVarInsn(Opcodes.ALOAD, 0);
+        mv.visitMethodInsn(Opcodes.INVOKESPECIAL,
+                           "com/sun/xml/internal/bind/marshaller/NamespacePrefixMapper", "<init>", "()V");
+        Label l1 = new Label();
+        mv.visitLabel(l1);
+        mv.visitLineNumber(31, l1);
+        mv.visitVarInsn(Opcodes.ALOAD, 0);
+        mv.visitVarInsn(Opcodes.ALOAD, 1);
+        mv.visitFieldInsn(Opcodes.PUTFIELD, "org/apache/cxf/jaxb/NamespaceMapperInternal",
+                          "nspref", "Ljava/util/Map;");
+        Label l2 = new Label();
+        mv.visitLabel(l2);
+        mv.visitLineNumber(32, l2);
+        mv.visitInsn(Opcodes.RETURN);
+        Label l3 = new Label();
+        mv.visitLabel(l3);
+        mv.visitLocalVariable("this", "Lorg/apache/cxf/jaxb/NamespaceMapperInternal;", null, l0, l3, 0);
+        mv.visitLocalVariable("nspref", "Ljava/util/Map;",
+                              "Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;", 
+                              l0, l3, 1);
+        mv.visitMaxs(2, 2);
+        mv.visitEnd();
+
+        mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "getPreferredPrefix",
+                            "(Ljava/lang/String;Ljava/lang/String;Z)Ljava/lang/String;",
+                            null, null);
+        mv.visitCode();
+        l0 = new Label();
+        mv.visitLabel(l0);
+        mv.visitLineNumber(38, l0);
+        mv.visitVarInsn(Opcodes.ALOAD, 0);
+        mv.visitFieldInsn(Opcodes.GETFIELD, 
+                          "org/apache/cxf/jaxb/NamespaceMapperInternal", 
+                          "nspref", "Ljava/util/Map;");
+        mv.visitVarInsn(Opcodes.ALOAD, 1);
+        mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/Map", 
+                           "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
+        mv.visitTypeInsn(Opcodes.CHECKCAST, "java/lang/String");
+        mv.visitVarInsn(Opcodes.ASTORE, 4);
+        l1 = new Label();
+        mv.visitLabel(l1);
+        mv.visitLineNumber(39, l1);
+        mv.visitVarInsn(Opcodes.ALOAD, 4);
+        l2 = new Label();
+        mv.visitJumpInsn(Opcodes.IFNULL, l2);
+        l3 = new Label();
+        mv.visitLabel(l3);
+        mv.visitLineNumber(40, l3);
+        mv.visitVarInsn(Opcodes.ALOAD, 4);
+        mv.visitInsn(Opcodes.ARETURN);
+        mv.visitLabel(l2);
+        mv.visitLineNumber(42, l2);
+        mv.visitVarInsn(Opcodes.ALOAD, 2);
+        mv.visitInsn(Opcodes.ARETURN);
+        Label l4 = new Label();
+        mv.visitLabel(l4);
+        mv.visitLocalVariable("this", "Lorg/apache/cxf/jaxb/NamespaceMapperInternal;", null, l0, l4, 0);
+        mv.visitLocalVariable("namespaceUri", "Ljava/lang/String;", null, l0, l4, 1);
+        mv.visitLocalVariable("suggestion", "Ljava/lang/String;", null, l0, l4, 2);
+        mv.visitLocalVariable("requirePrefix", "Z", null, l0, l4, 3);
+        mv.visitLocalVariable("prefix", "Ljava/lang/String;", null, l1, l4, 4);
+        mv.visitMaxs(2, 5);
+        mv.visitEnd();
+        cw.visitEnd();
+
+        byte bts[] = cw.toByteArray();
+        return helper.loadClass(className,
+                                JAXBUtils.class, bts);
+    }
 }

Modified: cxf/branches/2.1.x-fixes/parent/pom.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/parent/pom.xml?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/parent/pom.xml (original)
+++ cxf/branches/2.1.x-fixes/parent/pom.xml Thu Nov 20 11:27:15 2008
@@ -790,6 +790,10 @@
                         <groupId>javax.xml.bind</groupId>
                         <artifactId>jsr173_api</artifactId>
                     </exclusion>
+                    <exclusion>
+                        <groupId>com.sun.xml.bind</groupId>
+                        <artifactId>jaxb-impl</artifactId>
+                    </exclusion>
                 </exclusions>
             </dependency>
             <dependency>

Modified: cxf/branches/2.1.x-fixes/rt/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/core/src/test/java/org/apache/cxf/configuration/spring/ConfigurerImplTest.java Thu Nov 20 11:27:15 2008
@@ -23,11 +23,10 @@
 import java.math.BigInteger;
 
 import javax.xml.bind.DatatypeConverter;
+import javax.xml.bind.DatatypeConverterInterface;
 import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
 import javax.xml.namespace.QName;
 
-import com.sun.xml.bind.DatatypeConverterImpl;
-
 import org.apache.cxf.bus.spring.BusApplicationContext;
 import org.apache.cxf.configuration.Configurable;
 import org.junit.Assert;
@@ -38,7 +37,19 @@
 public class ConfigurerImplTest extends Assert {
     
     static {
-        DatatypeConverter.setDatatypeConverter(DatatypeConverterImpl.theInstance);
+        Class<?> cls;
+        try {
+            try {
+                cls = Class.forName("com.sun.xml.bind.DatatypeConverterImpl");
+            } catch (ClassNotFoundException e) {
+                cls = Class.forName("com.sun.xml.internal.bind.DatatypeConverterImpl");
+            }
+            DatatypeConverterInterface convert = (DatatypeConverterInterface)cls.getField("theInstance")
+                                                                                .get(null);
+            DatatypeConverter.setDatatypeConverter(convert);
+        } catch (Exception ex) {
+            //ignore;
+        }
     }
     
     @Test

Modified: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/pom.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/jaxb/pom.xml?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/jaxb/pom.xml (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/jaxb/pom.xml Thu Nov 20 11:27:15 2008
@@ -147,11 +147,17 @@
         <dependency>
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-impl</artifactId>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-xjc</artifactId>
         </dependency>
+        <dependency>
+            <groupId>asm</groupId>
+            <artifactId>asm</artifactId>
+            <optional>true</optional>
+        </dependency>
 	 <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-jaxws_2.1_spec</artifactId>

Modified: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java Thu Nov 20 11:27:15 2008
@@ -51,21 +51,11 @@
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 
-import com.sun.codemodel.JCodeModel;
-import com.sun.codemodel.JDefinedClass;
-import com.sun.codemodel.JPackage;
-import com.sun.codemodel.writer.FileCodeWriter;
-import com.sun.tools.xjc.Options;
-import com.sun.tools.xjc.api.ClassNameAllocator;
-import com.sun.tools.xjc.api.ErrorListener;
-import com.sun.tools.xjc.api.S2JJAXBModel;
-import com.sun.tools.xjc.api.SchemaCompiler;
-import com.sun.tools.xjc.api.XJC;
-
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.CXFBusFactory;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.ReflectionInvokationHandler;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.ClientImpl;
@@ -73,6 +63,12 @@
 import org.apache.cxf.endpoint.SimpleEndpointImplFactory;
 import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.jaxb.JAXBDataBinding;
+import org.apache.cxf.jaxb.JAXBUtils;
+import org.apache.cxf.jaxb.JAXBUtils.JCodeModel;
+import org.apache.cxf.jaxb.JAXBUtils.JDefinedClass;
+import org.apache.cxf.jaxb.JAXBUtils.JPackage;
+import org.apache.cxf.jaxb.JAXBUtils.S2JJAXBModel;
+import org.apache.cxf.jaxb.JAXBUtils.SchemaCompiler;
 import org.apache.cxf.resource.URIResolver;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.ServiceConstructionException;
@@ -200,12 +196,21 @@
         //all SI's should have the same schemas
         Collection<SchemaInfo> schemas = svc.getServiceInfos().get(0).getSchemas();
 
-        SchemaCompiler compiler = XJC.createSchemaCompiler();
-        ErrorListener elForRun = new InnerErrorListener(wsdlUrl);
+        SchemaCompiler compiler;
+        try {
+            compiler = JAXBUtils.createSchemaCompiler();
+        } catch (JAXBException e1) {
+            throw new IllegalStateException("Unable to create schema compiler", e1);
+        }
+        Object elForRun = ReflectionInvokationHandler
+            .createProxyWrapper(new InnerErrorListener(wsdlUrl),
+                                JAXBUtils.getParamClass(compiler, "setErrorListener"));
+        
         compiler.setErrorListener(elForRun);
         
-        ClassNameAllocator allocator 
-            = new ClassNameAllocatorImpl();
+        Object allocator = ReflectionInvokationHandler
+            .createProxyWrapper(new ClassNameAllocatorImpl(),
+                                JAXBUtils.getParamClass(compiler, "setClassNameAllocator"));
 
         compiler.setClassNameAllocator(allocator);
 
@@ -239,9 +244,9 @@
             throw new IllegalStateException("Unable to create working directory " + src.getPath());
         }
         try {
-            FileCodeWriter writer = new FileCodeWriter(src);
+            Object writer = JAXBUtils.createFileCodeWriter(src);
             codeModel.build(writer);
-        } catch (IOException e) {
+        } catch (Exception e) {
             throw new IllegalStateException("Unable to write generated Java files for schemas: "
                                             + e.getMessage(), e);
         }
@@ -303,7 +308,6 @@
         return client;
     }
 
-    @SuppressWarnings("deprecation")
     private void addBindingFiles(List<String> bindingFiles, SchemaCompiler compiler) {
         if (bindingFiles != null) {
             for (String s : bindingFiles) {
@@ -366,7 +370,6 @@
         
     }
 
-    @SuppressWarnings("deprecation")
     private void addSchemas(String wsdlUrl, Collection<SchemaInfo> schemas, SchemaCompiler compiler) {
         int num = 1;
         for (SchemaInfo schema : schemas) {
@@ -386,7 +389,7 @@
             num++;
         }
         
-        if (simpleBindingEnabled && isJaxb21()) {
+        if (simpleBindingEnabled && isJaxb21(compiler)) {
             String id = "/org/apache/cxf/endpoint/dynamic/simple-binding.xjb";
             LOG.info("Loading the JAXB 2.1 simple binding for client.");
             InputSource source = new InputSource(getClass().getResourceAsStream(id));
@@ -395,8 +398,8 @@
         }
     }
     
-    private boolean isJaxb21() {
-        String id = Options.getBuildID();
+    private boolean isJaxb21(SchemaCompiler sc) {
+        String id = sc.getOptions().getBuildID();
         StringTokenizer st = new StringTokenizer(id, ".");
         String minor = null;
         
@@ -537,7 +540,7 @@
         }
     }
 
-    private class InnerErrorListener implements ErrorListener {
+    private class InnerErrorListener {
 
         private String url;
 
@@ -605,7 +608,7 @@
     
     
     
-    private static class ClassNameAllocatorImpl implements ClassNameAllocator {
+    public static class ClassNameAllocatorImpl {
         private final Set<String> typesClassNames = new HashSet<String>();
 
         public ClassNameAllocatorImpl() {

Modified: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/TypeClassInitializer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/TypeClassInitializer.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/TypeClassInitializer.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/TypeClassInitializer.java Thu Nov 20 11:27:15 2008
@@ -19,20 +19,19 @@
 package org.apache.cxf.endpoint.dynamic;
 
 import java.lang.reflect.Array;
+import java.util.Iterator;
 import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
 
-import com.sun.codemodel.JDefinedClass;
-import com.sun.codemodel.JType;
-import com.sun.tools.xjc.api.Mapping;
-import com.sun.tools.xjc.api.S2JJAXBModel;
-import com.sun.tools.xjc.api.TypeAndAnnotation;
-
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PrimitiveUtils;
+import org.apache.cxf.jaxb.JAXBUtils.JType;
+import org.apache.cxf.jaxb.JAXBUtils.Mapping;
+import org.apache.cxf.jaxb.JAXBUtils.S2JJAXBModel;
+import org.apache.cxf.jaxb.JAXBUtils.TypeAndAnnotation;
 import org.apache.cxf.service.ServiceModelVisitor;
 import org.apache.cxf.service.factory.ServiceConstructionException;
 import org.apache.cxf.service.model.MessagePartInfo;
@@ -92,21 +91,24 @@
                 mapping = model.get(op.getOutput().getMessagePart(0).getElementQName());
             }
             if (mapping != null) {
-                jType = mapping.getType().getTypeClass();  
-                if (jType instanceof JDefinedClass) {
-                    JDefinedClass jdType = (JDefinedClass)jType;
-                    for (JType jt : jdType.listClasses()) {
+                jType = mapping.getType().getTypeClass();
+                try {
+                    Iterator<JType> i = jType.classes();
+                    while (i.hasNext()) {
+                        JType jt = i.next();
                         if (jt.name().equalsIgnoreCase(part.getElementQName().getLocalPart())) {
                             jType = jt;
                         }
                     }
+                } catch (Throwable t) {
+                    //ignore, JType is a type that doesn't have a classes method
                 }
             }
             
         }
         
         if (jType == null) {
-            throw new ServiceConstructionException(new Message("NO_JAXB_CLASS", LOG, name));
+            throw new ServiceConstructionException(new Message("NO_JAXB_CLASSMapping", LOG, name));
         }
             
         Class cls;

Modified: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java Thu Nov 20 11:27:15 2008
@@ -58,10 +58,6 @@
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 
-import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
-import com.sun.xml.bind.v2.ContextFactory;
-import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
-
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.CacheMap;
@@ -184,27 +180,6 @@
         context = ctx;
     }
 
-    public NamespacePrefixMapper getNamespacePrefixMapper() {
-        Map<String, String> mappings = getDeclaredNamespaceMappings();
-        if (mappings == null) {
-            mappings = Collections.emptyMap();
-        }
-
-        final Map<String, String> closedMappings = mappings;
-
-        NamespacePrefixMapper mapper = new NamespacePrefixMapper() {
-            @Override
-            public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {
-                String prefix = closedMappings.get(namespaceUri);
-                if (prefix != null) {
-                    return prefix;
-                }
-                return suggestion;
-            }
-        };
-        return mapper;
-    }
-
     @SuppressWarnings("unchecked")
     public <T> DataWriter<T> createWriter(Class<T> c) {
 
@@ -344,14 +319,14 @@
                                   r.getSystemId());
             }
 
-            JAXBContextImpl riContext;
-            if (context instanceof JAXBContextImpl) {
-                riContext = (JAXBContextImpl)context;
+            JAXBContext riContext;
+            if (context.getClass().getName().contains("com.sun.xml.")) {
+                riContext = context;
             } else {
                 // fall back if we're using another jaxb implementation
                 try {
-                    riContext = (JAXBContextImpl)ContextFactory.createContext(contextClasses
-                        .toArray(new Class[contextClasses.size()]), null);
+                    riContext = JAXBUtils.createRIContext(contextClasses
+                        .toArray(new Class[contextClasses.size()]), tns);
                 } catch (JAXBException e) {
                     throw new ServiceConstructionException(e);
                 }
@@ -424,7 +399,55 @@
             }
         }
 
-        // try and read any jaxb.index files that are with the other classes.
+        scanPackages(classes);
+        addWsAddressingTypes(classes);
+
+        for (Class<?> clz : classes) {
+            if (clz.getName().endsWith("ObjectFactory")
+                && checkObjectFactoryNamespaces(clz)) {
+                // kind of a hack, but ObjectFactories may be created with empty
+                // namespaces
+                defaultNs = null;
+            }
+        }
+
+        Map<String, Object> map = new HashMap<String, Object>();
+        if (defaultNs != null) {
+            map.put("com.sun.xml.bind.defaultNamespaceRemap", defaultNs);
+        }
+
+        if (contextProperties != null) {
+            // add any specified context properties into the properties map
+            map.putAll(contextProperties);
+        }
+
+        CachedContextAndSchemas cachedContextAndSchemas = null;
+        synchronized (JAXBCONTEXT_CACHE) {
+            cachedContextAndSchemas = JAXBCONTEXT_CACHE.get(classes);
+        }
+        if (cachedContextAndSchemas == null) {
+            JAXBContext ctx;
+            try {
+                ctx = JAXBContext.newInstance(classes.toArray(new Class[classes.size()]), map);
+            } catch (JAXBException ex) {
+                if (map.containsKey("com.sun.xml.bind.defaultNamespaceRemap")) {
+                    map.put("com.sun.xml.internal.bind.defaultNamespaceRemap",
+                            map.remove("com.sun.xml.bind.defaultNamespaceRemap"));
+                    ctx = JAXBContext.newInstance(classes.toArray(new Class[classes.size()]), map);
+                } else {
+                    throw ex;
+                }
+            }
+            cachedContextAndSchemas = new CachedContextAndSchemas(ctx);
+            synchronized (JAXBCONTEXT_CACHE) {
+                JAXBCONTEXT_CACHE.put(classes, cachedContextAndSchemas);
+            }
+        }
+
+        return cachedContextAndSchemas;
+    }
+    private void scanPackages(Set<Class<?>> classes) {
+     // try and read any jaxb.index files that are with the other classes.
         // This should
         // allow loading of extra classes (such as subclasses for inheritance
         // reasons)
@@ -503,40 +526,6 @@
             }
         }
         classes.addAll(objectFactories);
-        addWsAddressingTypes(classes);
-
-        for (Class<?> clz : classes) {
-            if (clz.getName().endsWith("ObjectFactory")
-                && checkObjectFactoryNamespaces(clz)) {
-                // kind of a hack, but ObjectFactories may be created with empty
-                // namespaces
-                defaultNs = null;
-            }
-        }
-
-        Map<String, Object> map = new HashMap<String, Object>();
-        if (defaultNs != null) {
-            map.put("com.sun.xml.bind.defaultNamespaceRemap", defaultNs);
-        }
-
-        if (contextProperties != null) {
-            // add any specified context properties into the properties map
-            map.putAll(contextProperties);
-        }
-
-        CachedContextAndSchemas cachedContextAndSchemas = null;
-        synchronized (JAXBCONTEXT_CACHE) {
-            cachedContextAndSchemas = JAXBCONTEXT_CACHE.get(classes);
-        }
-        if (cachedContextAndSchemas == null) {
-            JAXBContext ctx = JAXBContext.newInstance(classes.toArray(new Class[classes.size()]), map);
-            cachedContextAndSchemas = new CachedContextAndSchemas(ctx);
-            synchronized (JAXBCONTEXT_CACHE) {
-                JAXBCONTEXT_CACHE.put(classes, cachedContextAndSchemas);
-            }
-        }
-
-        return cachedContextAndSchemas;
     }
 
     private boolean checkObjectFactoryNamespaces(Class<?> clz) {

Modified: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java Thu Nov 20 11:27:15 2008
@@ -21,6 +21,7 @@
 
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
@@ -58,10 +59,6 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
-import com.sun.xml.bind.api.Bridge;
-import com.sun.xml.bind.api.JAXBRIContext;
-import com.sun.xml.bind.api.TypeReference;
-
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.helpers.CastUtils;
@@ -180,22 +177,17 @@
         }
     }
     //TODO: cache the JAXBRIContext
-    @SuppressWarnings("unchecked")
-    public static void marshalWithBridge(TypeReference ref,
+    public static void marshalWithBridge(QName qname,
+                                         Class<?> cls,
+                                         Annotation anns[],
                                          Set<Class<?>> ctxClasses,
                                          Object elValue,
                                          Object source, AttachmentMarshaller am) {
-        List<TypeReference> typeRefs = new ArrayList<TypeReference>();
-        typeRefs.add(ref);
-        List<Class<?>> clses = new ArrayList<Class<?>>(ctxClasses);
-        clses.add(ref.type.getClass());
         try {
-            JAXBRIContext riContext = JAXBRIContext.newInstance(clses.toArray(new Class[clses.size()]),
-                                                                    typeRefs, null, null, true, null);
-            Bridge bridge = riContext.createBridge(ref);
+            JAXBUtils.BridgeWrapper bridge = JAXBUtils.createBridge(ctxClasses, qname, cls, anns);
 
             if (source instanceof XMLStreamWriter) {
-                bridge.marshal(elValue, (XMLStreamWriter)source);
+                bridge.marshal(elValue, (XMLStreamWriter)source, am);
             } else if (source instanceof OutputStream) {
                 //the namespace is missing when marshal the xsd:QName type 
                 //to the OutputStream directly 
@@ -204,7 +196,7 @@
                 bridge.marshal(elValue, s1);
                 ((OutputStream)source).write(sw.toString().getBytes());
             } else if (source instanceof Node) {
-                bridge.marshal(elValue, (Node)source);
+                bridge.marshal(elValue, (Node)source, am);
             } else {
                 throw new Fault(new Message("UNKNOWN_SOURCE", LOG, source.getClass().getName()));
             }
@@ -223,22 +215,19 @@
     }
     
 //  TODO: cache the JAXBRIContext
-    public static Object unmarshalWithBridge(TypeReference ref,
+    public static Object unmarshalWithBridge(QName qname,
+                                             Class<?> cls,
+                                             Annotation anns[],
                                              Set<Class<?>> ctxClasses,
                                              Object source,
                                              AttachmentUnmarshaller am) {
-        List<TypeReference> typeRefs = new ArrayList<TypeReference>();
-        typeRefs.add(ref);
-        List<Class<?>> clses = new ArrayList<Class<?>>(ctxClasses);
-        clses.add(ref.type.getClass());
+        
         try {
-            JAXBRIContext riContext = JAXBRIContext.newInstance(clses.toArray(new Class[clses.size()]),
-                                                                    typeRefs, null, null, true, null);
-            Bridge bridge = riContext.createBridge(ref);
+            JAXBUtils.BridgeWrapper bridge = JAXBUtils.createBridge(ctxClasses, qname, cls, anns);
            
             if (source instanceof XMLStreamReader) {
                 //DOMUtils.writeXml(StaxUtils.read((XMLStreamReader)source), System.out);
-                return bridge.unmarshal((XMLStreamReader)source);               
+                return bridge.unmarshal((XMLStreamReader)source, am);               
             } else if (source instanceof InputStream) {
                 return bridge.unmarshal((InputStream)source);
             } else if (source instanceof Node) {

Modified: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java Thu Nov 20 11:27:15 2008
@@ -27,17 +27,16 @@
 import java.util.Iterator;
 import java.util.logging.Logger;
 
+import javax.xml.bind.JAXBContext;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import javax.xml.namespace.QName;
 
-import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
-import com.sun.xml.bind.v2.runtime.JaxBeanInfo;
-
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.ReflectionInvokationHandler;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
 import org.apache.cxf.common.xmlschema.XmlSchemaTools;
 import org.apache.cxf.interceptor.Fault;
@@ -62,19 +61,29 @@
     private static final Logger LOG = LogUtils.getLogger(JAXBSchemaInitializer.class);
 
     private SchemaCollection schemas;
-    private JAXBContextImpl context;
+    private JAXBContextProxy context;
     private final boolean qualifiedSchemas;
     
     public JAXBSchemaInitializer(ServiceInfo serviceInfo, 
                                  SchemaCollection col, 
-                                 JAXBContextImpl context, 
+                                 JAXBContext context, 
                                  boolean q) {
         super(serviceInfo);
         schemas = col;
-        this.context = context;
+        this.context = ReflectionInvokationHandler.createProxyWrapper(context, JAXBContextProxy.class);
         this.qualifiedSchemas = q;
     }
 
+    public JAXBBeanInfo getBeanInfo(Class<?> cls) {
+        return getBeanInfo(context, cls);
+    }
+    public static JAXBBeanInfo getBeanInfo(JAXBContextProxy context, Class<?> cls) {
+        Object o = context.getBeanInfo(cls);
+        if (o == null) {
+            return null;
+        }
+        return ReflectionInvokationHandler.createProxyWrapper(o, JAXBBeanInfo.class);
+    }
     @Override
     public void begin(MessagePartInfo part) {
         // Check to see if the WSDL information has been filled in for us.
@@ -93,7 +102,7 @@
             clazz = clazz.getComponentType();
         }
 
-        JaxBeanInfo<?> beanInfo = context.getBeanInfo(clazz);
+        JAXBBeanInfo beanInfo = getBeanInfo(clazz);
         if (beanInfo == null) {
             Annotation[] anns = (Annotation[])part.getProperty("parameter.annotations");
             XmlJavaTypeAdapter jta = findFromTypeAdapter(clazz, anns);
@@ -159,7 +168,7 @@
     }
 
     private XmlJavaTypeAdapter findFromTypeAdapter(Class<?> clazz, Annotation[] anns) {
-        JaxBeanInfo<?> ret = null;
+        JAXBBeanInfo ret = null;
         if (anns != null) {
             for (Annotation a : anns) {
                 if (XmlJavaTypeAdapter.class.isAssignableFrom(a.annotationType())) {
@@ -180,7 +189,7 @@
         return null;
     }
 
-    private JaxBeanInfo<?> findFromTypeAdapter(Class<? extends XmlAdapter> aclass) {
+    private JAXBBeanInfo findFromTypeAdapter(Class<? extends XmlAdapter> aclass) {
         Class<?> c2 = aclass;
         Type sp = c2.getGenericSuperclass();
         while (!XmlAdapter.class.equals(c2) && c2 != null) {
@@ -190,13 +199,13 @@
         if (sp instanceof ParameterizedType) {
             Type tp = ((ParameterizedType)sp).getActualTypeArguments()[0];
             if (tp instanceof Class) {
-                return context.getBeanInfo((Class<?>)tp);
+                return getBeanInfo((Class<?>)tp);
             }
         }
         return null;
     }
 
-    private QName getTypeName(JaxBeanInfo<?> beanInfo) {
+    private QName getTypeName(JAXBBeanInfo beanInfo) {
         Iterator<QName> itr = beanInfo.getTypeNames().iterator();
         if (!itr.hasNext()) {
             return null;
@@ -218,7 +227,7 @@
                 if (isFromWrapper && clazz.isArray() && !Byte.TYPE.equals(clazz.getComponentType())) {
                     clazz = clazz.getComponentType();
                 }
-                JaxBeanInfo<?> beanInfo = context.getBeanInfo(clazz);
+                JAXBBeanInfo beanInfo = getBeanInfo(clazz);
                 if (beanInfo == null) {
                     if (Exception.class.isAssignableFrom(clazz)) {
                         QName name = (QName)part.getMessageInfo().getProperty("elementName");
@@ -290,7 +299,7 @@
         if (cls != cl2) {            
             QName name = (QName)fault.getProperty("elementName");
             part.setElementQName(name);           
-            JaxBeanInfo<?> beanInfo = context.getBeanInfo(cls);
+            JAXBBeanInfo beanInfo = getBeanInfo(cls);
             if (beanInfo == null) {
                 throw new Fault(new Message("NO_BEAN_INFO", LOG, cls.getName()));
             }
@@ -353,7 +362,7 @@
                         m.getDeclaringClass().getMethod("set" + m.getName().substring(beginIdx),
                                                         m.getReturnType());
                         
-                        JaxBeanInfo<?> beanInfo = context.getBeanInfo(m.getReturnType());
+                        JAXBBeanInfo beanInfo = getBeanInfo(m.getReturnType());
                         if (beanInfo != null) {
                             el = new XmlSchemaElement();
                             el.setName(m.getName().substring(beginIdx));
@@ -443,7 +452,7 @@
         for (Field f : cls.getDeclaredFields()) {
             if (JAXBContextInitializer.isFieldAccepted(f, accessType)) {
                 //map field
-                JaxBeanInfo<?> beanInfo = context.getBeanInfo(f.getType());
+                JAXBBeanInfo beanInfo = getBeanInfo(f.getType());
                 if (beanInfo != null) {
                     addElement(seq, beanInfo, new QName(namespace, f.getName()));
                 }                
@@ -452,7 +461,7 @@
         for (Method m : cls.getMethods()) {
             if (JAXBContextInitializer.isMethodAccepted(m, accessType)) {
                 //map field
-                JaxBeanInfo<?> beanInfo = context.getBeanInfo(m.getReturnType());
+                JAXBBeanInfo beanInfo = getBeanInfo(m.getReturnType());
                 if (beanInfo != null) {
                     int idx = m.getName().startsWith("get") ? 3 : 2;
                     String name = m.getName().substring(idx);
@@ -464,7 +473,7 @@
         part.setProperty(JAXBDataBinding.class.getName() + ".CUSTOM_EXCEPTION", Boolean.TRUE);
     }
     
-    public void addElement(XmlSchemaSequence seq, JaxBeanInfo<?> beanInfo, QName name) {    
+    public void addElement(XmlSchemaSequence seq, JAXBBeanInfo beanInfo, QName name) {    
         XmlSchemaElement el = new XmlSchemaElement();
         el.setName(name.getLocalPart());
         XmlSchemaTools.setElementQName(el, name);

Modified: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java Thu Nov 20 11:27:15 2008
@@ -29,8 +29,6 @@
 import javax.xml.bind.Unmarshaller;
 import javax.xml.namespace.QName;
 
-import com.sun.xml.bind.api.TypeReference;
-
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.databinding.DataReader;
@@ -98,8 +96,10 @@
             //annotated with @XmlList,@XmlAttachmentRef,@XmlJavaTypeAdapter
             //TODO:Cache the JAXBRIContext
             QName qname = new QName(null, part.getConcreteName().getLocalPart());
-            TypeReference typeReference = new TypeReference(qname, part.getTypeClass(), anns);
-            return JAXBEncoderDecoder.unmarshalWithBridge(typeReference, 
+
+            return JAXBEncoderDecoder.unmarshalWithBridge(qname,
+                                                          part.getTypeClass(),
+                                                          anns, 
                                                           databinding.getContextClasses(),
                                                           reader,
                                                           getAttachmentUnmarshaller());

Modified: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java Thu Nov 20 11:27:15 2008
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.jaxb.io;
 
+
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Array;
 import java.util.Collection;
@@ -34,8 +35,6 @@
 import javax.xml.bind.attachment.AttachmentMarshaller;
 import javax.xml.namespace.QName;
 
-import com.sun.xml.bind.api.TypeReference;
-
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.databinding.DataWriter;
@@ -43,6 +42,7 @@
 import org.apache.cxf.jaxb.JAXBDataBase;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.jaxb.JAXBEncoderDecoder;
+import org.apache.cxf.jaxb.JAXBUtils;
 import org.apache.cxf.jaxb.attachment.JAXBAttachmentMarshaller;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.ws.commons.schema.XmlSchemaElement;
@@ -107,8 +107,11 @@
             if (databinding.getValidationEventHandler() != null) {
                 marshaller.setEventHandler(databinding.getValidationEventHandler());
             }
-            marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper",
-                                   databinding.getNamespacePrefixMapper());
+            
+            final Map<String, String> nspref = databinding.getDeclaredNamespaceMappings();
+            if (nspref != null) {
+                JAXBUtils.setNamespaceWrapper(nspref, marshaller);
+            }
             if (databinding.getMarshallerProperties() != null) {
                 for (Map.Entry<String, Object> propEntry 
                     : databinding.getMarshallerProperties().entrySet()) {
@@ -169,9 +172,10 @@
                     //annotated with @XmlList,@XmlAttachmentRef,@XmlJavaTypeAdapter
                     //TODO:Cache the JAXBRIContext
                     QName qname = new QName(null, part.getConcreteName().getLocalPart());
-                    TypeReference typeReference = new TypeReference(qname, part.getTypeClass(), anns);
                     
-                    JAXBEncoderDecoder.marshalWithBridge(typeReference, 
+                    JAXBEncoderDecoder.marshalWithBridge(qname,
+                                                         part.getTypeClass(),
+                                                         anns, 
                                                          databinding.getContextClasses(), 
                                                          obj, 
                                                          output, 

Modified: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBDataBindingTest.java Thu Nov 20 11:27:15 2008
@@ -43,12 +43,10 @@
 
 import org.w3c.dom.Node;
 
-import com.sun.xml.bind.api.JAXBRIContext;
-import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
-
 import org.apache.cxf.Bus;
 import org.apache.cxf.binding.BindingFactoryManager;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.ReflectionInvokationHandler;
 import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.databinding.DataWriter;
 import org.apache.cxf.helpers.CastUtils;
@@ -183,17 +181,15 @@
         Set<Class<?>> classes = new HashSet<Class<?>>();
         classes.add(ObjectFactory.class);
         JAXBContext ctx = db.createJAXBContext(classes);
-        if (ctx instanceof JAXBContextImpl) {
-            JAXBContextImpl rictx = (JAXBContextImpl)ctx;
-            assertNotNull(rictx.getBeanInfo(TestJAXBClass.class));
-        }
+        JAXBContextProxy ctxp = ReflectionInvokationHandler.createProxyWrapper(ctx, JAXBContextProxy.class);
+        assertNotNull(JAXBSchemaInitializer.getBeanInfo(ctxp, TestJAXBClass.class));
     }
     
     @Test 
     public void testContextProperties() throws Exception {
         JAXBDataBinding db = new JAXBDataBinding();
         Map<String, Object> contextProperties = new HashMap<String, Object>();
-        contextProperties.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, "uri:ultima:thule");
+        contextProperties.put("com.sun.xml.bind.defaultNamespaceRemap", "uri:ultima:thule");
         db.setContextProperties(contextProperties);
         Set<Class<?>> classes = new HashSet<Class<?>>();
         classes.add(UnqualifiedBean.class);
@@ -217,7 +213,7 @@
         nsMap.put("uri:ultima:thule", "greenland");
         db.setNamespaceMap(nsMap);
         Map<String, Object> contextProperties = new HashMap<String, Object>();
-        contextProperties.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, "uri:ultima:thule");
+        contextProperties.put("com.sun.xml.bind.defaultNamespaceRemap", "uri:ultima:thule");
         db.setContextProperties(contextProperties);
         Set<Class<?>> classes = new HashSet<Class<?>>();
         classes.add(QualifiedBean.class);

Modified: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java Thu Nov 20 11:27:15 2008
@@ -25,6 +25,8 @@
 import java.io.StringWriter;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.xml.XMLConstants;
 import javax.xml.bind.JAXBContext;
@@ -46,8 +48,6 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
-import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
-
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxb_form.ObjectWithQualifiedElementElement;
@@ -182,18 +182,9 @@
     
     @Test
     public void testCustomNamespaces() throws Exception {
-        NamespacePrefixMapper mapper = new NamespacePrefixMapper() {
-
-            @Override
-            public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {
-                if ("http://apache.org/hello_world_soap_http/types".equals(namespaceUri)) {
-                    return "Omnia";
-                } else if ("http://cxf.apache.org/jaxb_form".equals(namespaceUri)) {
-                    return "Gallia";
-                }
-                return suggestion;
-            } 
-        };
+        Map<String, String> mapper = new HashMap<String, String>();
+        mapper.put("http://apache.org/hello_world_soap_http/types", "Omnia");
+        mapper.put("http://cxf.apache.org/jaxb_form", "Gallia");
         ObjectWithQualifiedElementElement testObject = new ObjectWithQualifiedElementElement();
         testObject.setString1("twine");
         testObject.setString2("cord");
@@ -209,8 +200,7 @@
         opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
         XMLEventWriter writer = opFactory.createXMLEventWriter(stringWriter);
         Marshaller m = context.createMarshaller();
-        m.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper);
-        
+        JAXBUtils.setNamespaceWrapper(mapper, m);
         JAXBEncoderDecoder.marshall(m, testObject, part, writer);
         writer.flush();
         writer.close();

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java Thu Nov 20 11:27:15 2008
@@ -92,7 +92,6 @@
         return PF;
     }
 
-    @SuppressWarnings("unchecked")
     public <T> ContextResolver<T> createContextResolver(Type contextType, Message m) {
         for (ProviderInfo<ContextResolver> cr : userContextResolvers) {
             Type[] types = cr.getProvider().getClass().getGenericInterfaces();

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/SwAOutInterceptor.java Thu Nov 20 11:27:15 2008
@@ -30,7 +30,9 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Logger;
 
 import javax.activation.DataHandler;
@@ -46,9 +48,6 @@
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
 
-import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
-import com.sun.xml.bind.v2.util.DataSourceSource;
-
 import org.apache.cxf.attachment.AttachmentImpl;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
@@ -72,18 +71,8 @@
 
 public class SwAOutInterceptor extends AbstractSoapInterceptor {
     private static final Logger LOG = LogUtils.getL7dLogger(SwAOutInterceptor.class);
-    private static final boolean HAS_SWA_REF_METHOD;
-    static {
-        Class<?> cls = JAXBContextImpl.class;
-        Method m = null;
-        try {
-            m = cls.getMethod("hasSwaRef", new Class[0]);
-        } catch (Exception e) {
-            //ignore
-        }
-        HAS_SWA_REF_METHOD = m != null;
-    }
     
+    private static final Map<String, Method> SWA_REF_METHOD = new ConcurrentHashMap<String, Method>();
     
     AttachmentOutInterceptor attachOut = new AttachmentOutInterceptor();
     
@@ -92,6 +81,23 @@
         addAfter(HolderOutInterceptor.class.getName());
         addBefore(WrapperClassOutInterceptor.class.getName());
     }
+    
+    private boolean callSWARefMethod(JAXBContext ctx) {
+        Method m = SWA_REF_METHOD.get(ctx.getClass().getName());
+        if (m == null && !SWA_REF_METHOD.containsKey(ctx.getClass().getName())) {
+            try {
+                m = ctx.getClass().getMethod("hasSwaRef", new Class[0]);
+            } catch (Exception e) {
+                //ignore
+            }
+            SWA_REF_METHOD.put(ctx.getClass().getName(), m);
+        }
+        try {
+            return (Boolean)m.invoke(ctx);
+        } catch (Exception e) {
+            return false;
+        }
+    }
 
     public void handleMessage(SoapMessage message) throws Fault {
         Exchange ex = message.getExchange();
@@ -206,20 +212,13 @@
     }
     private boolean hasSwaRef(JAXBDataBinding db) {
         JAXBContext context = db.getContext();
-        if (HAS_SWA_REF_METHOD
-            && context instanceof JAXBContextImpl) {
-            return ((JAXBContextImpl)context).hasSwaRef();
-        }
-        
-        return false;
+        return callSWARefMethod(context);
     }
 
     private DataSource createDataSource(Source o, String ct) {
         DataSource ds = null;
         
-        if (o instanceof DataSourceSource) {
-            ds = (DataSource) o;
-        } else if (o instanceof StreamSource) {
+        if (o instanceof StreamSource) {
             StreamSource src = (StreamSource)o;
             try {
                 if (src.getInputStream() != null) {

Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/main/resources/schemas/wsdl/http-conf.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/main/resources/schemas/wsdl/http-conf.xsd?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/main/resources/schemas/wsdl/http-conf.xsd (original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/main/resources/schemas/wsdl/http-conf.xsd Thu Nov 20 11:27:15 2008
@@ -81,7 +81,7 @@
                         after each reply is sent, even if the client requests the server to keep 
                         the connection alive.  Keep-Alive improves performance for the client 
                         requesting such behavior, but can limit overall scalability of the server 
-                        for handling many clients. The Default is false.
+                        for handling many clients. The Default is true.
                         </xs:documentation>
                     </xs:annotation>      
                 </xs:attribute>

Modified: cxf/branches/2.1.x-fixes/rt/transports/jbi/src/test/java/org/apache/cxf/transport/jbi/JBIConduitTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/jbi/src/test/java/org/apache/cxf/transport/jbi/JBIConduitTest.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/jbi/src/test/java/org/apache/cxf/transport/jbi/JBIConduitTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/transports/jbi/src/test/java/org/apache/cxf/transport/jbi/JBIConduitTest.java Thu Nov 20 11:27:15 2008
@@ -23,7 +23,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.util.logging.Logger;
 
@@ -68,13 +67,10 @@
         LOG.info("test send");
         JBIConduit conduit = setupJBIConduit(true, false); 
         Message message = new MessageImpl();
-        Member method = control.createMock(Member.class);
-        message.put(Method.class.getName(), method);
-                
-        EasyMock.expect(method.getDeclaringClass()).andStubReturn(
-                                        (Class<?>)org.apache.hello_world_soap_http.Greeter.class);
-        
-                
+
+        Class<org.apache.hello_world_soap_http.Greeter> greeterCls 
+            = org.apache.hello_world_soap_http.Greeter.class;
+        message.put(Method.class.getName(), greeterCls.getMethod("sayHi"));
         
         Exchange exchange = new ExchangeImpl();
         exchange.setOneWay(false);

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java Thu Nov 20 11:27:15 2008
@@ -51,8 +51,6 @@
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 
-import com.sun.xml.bind.api.JAXBRIContext;
-
 import org.apache.cxf.Bus;
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.bus.CXFBusFactory;
@@ -900,7 +898,7 @@
         // that would actually notice the difference. At least it ensures that 
         // specifying the property does not explode.
         Map<String, Object> jaxbContextProperties = new HashMap<String, Object>();
-        jaxbContextProperties.put(JAXBRIContext.DEFAULT_NAMESPACE_REMAP, "uri:ultima:thule");
+        jaxbContextProperties.put("com.sun.xml.bind.defaultNamespaceRemap", "uri:ultima:thule");
         dcf.setJaxbContextProperties(jaxbContextProperties);
         client = dcf.createClient(wsdlUrl, serviceName, portName);
         client.invoke("greetMe", "test");        

Modified: cxf/branches/2.1.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java (original)
+++ cxf/branches/2.1.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java Thu Nov 20 11:27:15 2008
@@ -62,9 +62,9 @@
 import com.sun.tools.xjc.api.Mapping;
 import com.sun.tools.xjc.api.Property;
 import com.sun.tools.xjc.api.S2JJAXBModel;
+import com.sun.tools.xjc.api.SchemaCompiler;
 import com.sun.tools.xjc.api.TypeAndAnnotation;
 import com.sun.tools.xjc.api.XJC;
-import com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl;
 
 
 import org.apache.cxf.common.i18n.Message;
@@ -128,7 +128,7 @@
     public void initialize(ToolContext c) throws ToolException {
         this.context = c;
         
-        SchemaCompilerImpl schemaCompiler = (SchemaCompilerImpl)XJC.createSchemaCompiler();
+        SchemaCompiler schemaCompiler = XJC.createSchemaCompiler();
         ClassCollector classCollector = context.get(ClassCollector.class);
         
         ClassNameAllocatorImpl allocator 
@@ -237,7 +237,7 @@
         initialized = true;
     }
 
-    private void addSchemas(Options opts, SchemaCompilerImpl schemaCompiler,
+    private void addSchemas(Options opts, SchemaCompiler schemaCompiler,
                             Map<String, Element> schemaLists) {
         for (String key : schemaLists.keySet()) {
             Element ele = schemaLists.get(key);
@@ -268,7 +268,7 @@
 
     // TODO  this can be repaced with schemaCompiler.getOptions() once we
     // move to a version => 2.0.3 for jaxb-xjc
-    private Options getOptions(SchemaCompilerImpl schemaCompiler) throws ToolException {
+    private Options getOptions(SchemaCompiler schemaCompiler) throws ToolException {
         try {
             Field delegateField = schemaCompiler.getClass().getDeclaredField("opts");
             delegateField.setAccessible(true);

Modified: cxf/branches/2.1.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java?rev=719328&r1=719327&r2=719328&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java (original)
+++ cxf/branches/2.1.x-fixes/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/AbstractWSDLToProcessor.java Thu Nov 20 11:27:15 2008
@@ -45,7 +45,7 @@
 import org.apache.cxf.wsdl.WSDLManager;
 import org.apache.cxf.wsdl11.WSDLDefinitionBuilder;
 
-public class AbstractWSDLToProcessor implements Processor, com.sun.tools.xjc.api.ErrorListener {
+public class AbstractWSDLToProcessor implements Processor {
     protected static final Logger LOG = LogUtils.getL7dLogger(AbstractWSDLToProcessor.class);
     protected static final String WSDL_FILE_NAME_EXT = ".wsdl";
 



Mime
View raw message