You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bi...@apache.org on 2009/03/12 01:58:31 UTC

svn commit: r752734 - in /cxf/trunk/rt/databinding/aegis/src: main/java/org/apache/cxf/aegis/ main/java/org/apache/cxf/aegis/databinding/ main/java/org/apache/cxf/aegis/type/ test/java/org/apache/cxf/aegis/custom/

Author: bimargulies
Date: Thu Mar 12 00:58:31 2009
New Revision: 752734

URL: http://svn.apache.org/viewvc?rev=752734&view=rev
Log:
This is a part of CXF-2093. Allow the app to grab the type mapping before service initialization without
causing all the automatically mapped types to fall into the XSD namespace.

Added:
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/InconsistentInitializationException.java   (with props)
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomBeansTest.java   (with props)
Modified:
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeMapping.java

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java?rev=752734&r1=752733&r2=752734&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java Thu Mar 12 00:58:31 2009
@@ -45,7 +45,6 @@
 import org.apache.cxf.aegis.type.basic.BeanType;
 import org.apache.cxf.aegis.type.java5.Java5TypeCreator;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.common.util.SOAPConstants;
 import org.apache.cxf.common.xmlschema.XmlSchemaUtils;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.ws.commons.schema.XmlSchema;
@@ -144,9 +143,8 @@
             TypeMapping baseTM = DefaultTypeMapping.createDefaultTypeMapping(defaultNillable, 
                                                                              mtomUseXmime, 
                                                                              enableJDOMMappings);
-            // The use of the XSD URI in the mapping is, MAGIC.
             if (mappingNamespaceURI == null) {
-                mappingNamespaceURI = SOAPConstants.XSD;
+                mappingNamespaceURI = DefaultTypeMapping.DEFAULT_MAPPING_URI;
             }
             DefaultTypeMapping defaultTypeMapping = new DefaultTypeMapping(mappingNamespaceURI, baseTM);
             defaultTypeMapping.setTypeCreator(createTypeCreator());
@@ -463,6 +461,9 @@
 
     public void setMappingNamespaceURI(String mappingNamespaceURI) {
         this.mappingNamespaceURI = mappingNamespaceURI;
+        if (typeMapping != null) {
+            typeMapping.setMappingIdentifierURI(mappingNamespaceURI);
+        }
     }
 
     public boolean isEnableJDOMMappings() {

Added: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/InconsistentInitializationException.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/InconsistentInitializationException.java?rev=752734&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/InconsistentInitializationException.java (added)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/InconsistentInitializationException.java Thu Mar 12 00:58:31 2009
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.aegis.databinding;
+
+/**
+ * 
+ */
+public class InconsistentInitializationException extends RuntimeException {
+
+    public InconsistentInitializationException() {
+        super();
+    }
+
+    public InconsistentInitializationException(String message) {
+        super(message);
+    }
+
+}

Propchange: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/InconsistentInitializationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/InconsistentInitializationException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java?rev=752734&r1=752733&r2=752734&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java Thu Mar 12 00:58:31 2009
@@ -76,6 +76,7 @@
  * Contains type mappings for java/qname pairs.
  */
 public class DefaultTypeMapping implements TypeMapping {
+    public  static final String DEFAULT_MAPPING_URI = "urn:org.apache.cxf.aegis.types";
     private static final Log LOG = LogFactory.getLog(DefaultTypeMapping.class);
     private Map<Class, Type> class2Type;
     private Map<QName, Type> xml2Type;
@@ -91,7 +92,7 @@
     }
     
     public DefaultTypeMapping() {
-        this(SOAPConstants.XSD);
+        this(DEFAULT_MAPPING_URI);
     }
 
     public DefaultTypeMapping(String identifierURI) {
@@ -414,4 +415,9 @@
     public String getMappingIdentifierURI() {
         return identifierURI;
     }
+
+    public void setMappingIdentifierURI(String uri) {
+        identifierURI = uri;
+        
+    }
 }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeMapping.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeMapping.java?rev=752734&r1=752733&r2=752734&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeMapping.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeMapping.java Thu Mar 12 00:58:31 2009
@@ -73,4 +73,9 @@
      * @return the URI.
      */
     String getMappingIdentifierURI();
+    /**
+     * This exists only to deal with an initialization order problem.
+     * @param uri
+     */
+    void setMappingIdentifierURI(String uri);
 }

Added: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomBeansTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomBeansTest.java?rev=752734&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomBeansTest.java (added)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomBeansTest.java Thu Mar 12 00:58:31 2009
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.aegis.custom;
+
+import org.apache.cxf.aegis.custom.service.Service;
+import org.apache.cxf.aegis.custom.types.NoDefaultConstructorBeanKeyTypeRegistrar;
+import org.apache.cxf.aegis.custom.types.NoDefaultConstructorBeanTypeRegistrar;
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.aegis.type.DefaultTypeMapping;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotSame;
+
+/**
+ * 
+ */
+public class CustomBeansTest {
+
+    // CXF-2093 reports an explosion with this case.
+    @Test
+    public void testClientSetup() throws Exception {
+
+        JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
+        clientFactory.setAddress("local:not-really");
+        clientFactory.setServiceClass(Service.class);
+
+        AegisDatabinding dataBinding = new AegisDatabinding();
+
+        NoDefaultConstructorBeanTypeRegistrar beanRegistrar 
+            = new NoDefaultConstructorBeanTypeRegistrar();
+        beanRegistrar.setDataBinding(dataBinding);
+        beanRegistrar.register();
+
+        NoDefaultConstructorBeanKeyTypeRegistrar beanKeyRegistrar 
+            = new NoDefaultConstructorBeanKeyTypeRegistrar();
+        beanKeyRegistrar.setDataBinding(dataBinding);
+        beanKeyRegistrar.register();
+
+        clientFactory.setDataBinding(dataBinding);
+
+        clientFactory.create();
+        String uri = dataBinding.getAegisContext().getTypeMapping().getMappingIdentifierURI();
+        assertNotSame(DefaultTypeMapping.DEFAULT_MAPPING_URI, uri);
+    }
+
+}

Propchange: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomBeansTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomBeansTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date