Author: bimargulies
Date: Wed Feb 25 03:07:25 2009
New Revision: 747648
URL: http://svn.apache.org/viewvc?rev=747648&view=rev
Log:
CXF-2057. (re) implement type='aegis type class' as an option in a .aegis.xml
file.
Added:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.aegis.xml
(with props)
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.java
(with props)
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/TestDateMapping.java
(with props)
Modified:
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/basic/XMLBeanTypeInfo.java
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/Echo.aegis.xml
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=747648&r1=747647&r2=747648&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
Wed Feb 25 03:07:25 2009
@@ -262,6 +262,8 @@
defaultRegister(tm, defaultNillable, java.sql.Date.class,
XMLSchemaQNames.XSD_DATETIME,
new SqlDateType());
+ defaultRegister(tm, defaultNillable, java.sql.Date.class,
XMLSchemaQNames.XSD_DATE,
+ new SqlDateType());
QName mtomBase64 = XMLSchemaQNames.XSD_BASE64;
if (enableMtomXmime) {
Modified:
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java?rev=747648&r1=747647&r2=747648&view=diff
==============================================================================
---
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
(original)
+++
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
Wed Feb 25 03:07:25 2009
@@ -31,7 +31,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.Type;
import org.apache.cxf.aegis.util.NamespaceHelper;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.helpers.DOMUtils;
public class XMLBeanTypeInfo extends BeanTypeInfo {
@@ -102,6 +104,23 @@
}
if (e != null) {
+
+ String explicitTypeName = DOMUtils.getAttributeValueEmptyNull(e,
"type");
+ if (explicitTypeName != null) {
+ try {
+ Class<?> typeClass =
+ ClassLoaderUtils.loadClass(explicitTypeName,
XMLBeanTypeInfo.class);
+ Type typeObject = (Type) typeClass.newInstance();
+ mapType(mappedName, typeObject);
+ } catch (ClassNotFoundException e1) {
+ //
+ } catch (InstantiationException e2) {
+ //
+ } catch (IllegalAccessException e3) {
+ //
+ }
+ }
+
QName mappedType = NamespaceHelper.createQName(e,
DOMUtils.getAttributeValueEmptyNull(e, "typeName"),
getDefaultNamespace());
Modified:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/Echo.aegis.xml
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/Echo.aegis.xml?rev=747648&r1=747647&r2=747648&view=diff
==============================================================================
---
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/Echo.aegis.xml
(original)
+++
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/client/Echo.aegis.xml
Wed Feb 25 03:07:25 2009
@@ -1,4 +1,22 @@
-<mappings>
+<!--
+ * 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.
+ * -->
+ <mappings>
<mapping>
<method name="echo" xmlns:e="urn:echo:header">
<parameter index="1" componentType="java.lang.String"/>
Added:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.aegis.xml
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.aegis.xml?rev=747648&view=auto
==============================================================================
---
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.aegis.xml
(added)
+++
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.aegis.xml
Wed Feb 25 03:07:25 2009
@@ -0,0 +1,23 @@
+<!--
+ * 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.
+ * -->
+<mappings xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <mapping>
+ <property name="fig"
type="org.apache.cxf.aegis.type.basic.DateType" typeName="xsd:date" />
+ </mapping>
+</mappings>
\ No newline at end of file
Propchange:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.aegis.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.aegis.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.aegis.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.java?rev=747648&view=auto
==============================================================================
---
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.java
(added)
+++
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.java
Wed Feb 25 03:07:25 2009
@@ -0,0 +1,36 @@
+/**
+ * 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.date;
+
+/**
+ * class used to test remapping the schema type of date.
+ */
+public class BeanWithDate {
+ private java.util.Date fig;
+
+ public java.util.Date getFig() {
+ return fig;
+ }
+
+ public void setFig(java.util.Date fig) {
+ this.fig = fig;
+ }
+
+}
Propchange:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/BeanWithDate.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/TestDateMapping.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/TestDateMapping.java?rev=747648&view=auto
==============================================================================
---
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/TestDateMapping.java
(added)
+++
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/TestDateMapping.java
Wed Feb 25 03:07:25 2009
@@ -0,0 +1,69 @@
+/**
+ * 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.date;
+
+import java.io.StringWriter;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.cxf.aegis.AegisContext;
+import org.apache.cxf.aegis.AegisWriter;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.test.TestUtilities;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestDateMapping {
+ private AegisContext context;
+ private TestUtilities testUtilities;
+ private XMLOutputFactory xmlOutputFactory;
+
+ @Before
+ public void before() {
+ testUtilities = new TestUtilities(getClass());
+ testUtilities.addNamespace("test", "urn:test");
+ xmlOutputFactory = XMLOutputFactory.newInstance();
+ }
+
+ @Test
+ public void testWriteSqlDateAsDate() throws Exception {
+ context = new AegisContext();
+ Set<Class<?>> rootClasses = new HashSet<Class<?>>();
+ rootClasses.add(BeanWithDate.class);
+ context.setRootClasses(rootClasses);
+ context.initialize();
+ BeanWithDate bean = new BeanWithDate();
+ java.sql.Date date = new java.sql.Date(0);
+ bean.setFig(date);
+ Type sbType = context.getTypeMapping().getType(bean.getClass());
+ AegisWriter<XMLStreamWriter> writer = context.createXMLStreamWriter();
+ StringWriter stringWriter = new StringWriter();
+ XMLStreamWriter xmlWriter =
xmlOutputFactory.createXMLStreamWriter(stringWriter);
+ writer.write(bean, new QName("urn:test", "beanWithDate"),
+ false, xmlWriter, sbType);
+ xmlWriter.close();
+ // an absence of exception is success here.
+ }
+
+}
Propchange:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/TestDateMapping.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/TestDateMapping.java
------------------------------------------------------------------------------
svn:keywords = Rev Date