Author: dkulp
Date: Wed Oct 26 23:43:50 2011
New Revision: 1189538
URL: http://svn.apache.org/viewvc?rev=1189538&view=rev
Log:
[CXF-3885] Add options to wsdl2java for various SourceDataBinding usage
Added:
cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/databinding/
cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/databinding/source/
cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/databinding/source/SourceDatabindingProfile.java
(with props)
cxf/trunk/tools/wsdlto/core/src/main/resources/META-INF/
cxf/trunk/tools/wsdlto/core/src/main/resources/META-INF/tools-plugin.xml
(with props)
Modified:
cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSProfileTest.java
cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/core/PluginLoaderTest.java
Added:
cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/databinding/source/SourceDatabindingProfile.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/databinding/source/SourceDatabindingProfile.java?rev=1189538&view=auto
==============================================================================
---
cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/databinding/source/SourceDatabindingProfile.java
(added)
+++
cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/databinding/source/SourceDatabindingProfile.java
Wed Oct 26 23:43:50 2011
@@ -0,0 +1,89 @@
+/**
+ * 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.tools.wsdlto.databinding.source;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+
+import org.apache.cxf.databinding.source.SourceDataBinding;
+import org.apache.cxf.staxutils.StaxSource;
+import org.apache.cxf.tools.common.ToolConstants;
+import org.apache.cxf.tools.common.ToolContext;
+import org.apache.cxf.tools.common.ToolException;
+import org.apache.cxf.tools.common.model.DefaultValueWriter;
+import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
+
+/**
+ *
+ */
+public class SourceDatabindingProfile implements DataBindingProfile {
+ Class<? extends Source> cls;
+
+
+ /** {@inheritDoc}*/
+ public void generate(ToolContext context) throws ToolException {
+ //nothing to generate
+ }
+
+ /** {@inheritDoc}*/
+ public void initialize(ToolContext c) throws ToolException {
+ //nothing really to do
+ c.put(ToolConstants.RUNTIME_DATABINDING_CLASS,
SourceDataBinding.class.getName() + ".class");
+
+ String s = (String)c.get(ToolConstants.CFG_DATABINDING);
+ if ("source".equalsIgnoreCase(s)) {
+ cls = Source.class;
+ } else if ("domsource".equalsIgnoreCase(s)) {
+ cls = DOMSource.class;
+ } else if ("staxsource".equalsIgnoreCase(s)) {
+ cls = StaxSource.class;
+ } else if ("saxsource".equalsIgnoreCase(s)) {
+ cls = SAXSource.class;
+ } else {
+ cls = Source.class;
+ }
+ }
+
+ /** {@inheritDoc}*/
+ public String getType(QName qn, boolean element) {
+ return cls.getName();
+ }
+
+ /** {@inheritDoc}*/
+ public String getWrappedElementType(QName wrapperElement, QName item) {
+ //return null, cannot unwrap
+ return null;
+ }
+
+ /** {@inheritDoc}*/
+ public DefaultValueWriter createDefaultValueWriter(QName qn, boolean
element) {
+ //won't support this for now
+ return null;
+ }
+
+ /** {@inheritDoc}*/
+ public DefaultValueWriter createDefaultValueWriterForWrappedElement(QName
wrapperElement, QName qn) {
+ //return null, cannot unwrap
+ return null;
+ }
+
+}
Propchange:
cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/databinding/source/SourceDatabindingProfile.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/databinding/source/SourceDatabindingProfile.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/tools/wsdlto/core/src/main/resources/META-INF/tools-plugin.xml
URL:
http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/main/resources/META-INF/tools-plugin.xml?rev=1189538&view=auto
==============================================================================
--- cxf/trunk/tools/wsdlto/core/src/main/resources/META-INF/tools-plugin.xml
(added)
+++ cxf/trunk/tools/wsdlto/core/src/main/resources/META-INF/tools-plugin.xml
Wed Oct 26 23:43:50 2011
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+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.
+-->
+
+<plugin name="source" version="" provider="cxf.apache.org"
xmlns="http://cxf.apache.org/tools/plugin">
+ <databinding name="source"
package="org.apache.cxf.tools.wsdlto.databinding.source"
profile="SourceDatabindingProfile"/>
+ <databinding name="domsource"
package="org.apache.cxf.tools.wsdlto.databinding.source"
profile="SourceDatabindingProfile"/>
+ <databinding name="staxsource"
package="org.apache.cxf.tools.wsdlto.databinding.source"
profile="SourceDatabindingProfile"/>
+ <databinding name="saxsource"
package="org.apache.cxf.tools.wsdlto.databinding.source"
profile="SourceDatabindingProfile"/>
+</plugin>
\ No newline at end of file
Propchange:
cxf/trunk/tools/wsdlto/core/src/main/resources/META-INF/tools-plugin.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
cxf/trunk/tools/wsdlto/core/src/main/resources/META-INF/tools-plugin.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
cxf/trunk/tools/wsdlto/core/src/main/resources/META-INF/tools-plugin.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified:
cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSProfileTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSProfileTest.java?rev=1189538&r1=1189537&r2=1189538&view=diff
==============================================================================
---
cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSProfileTest.java
(original)
+++
cxf/trunk/tools/wsdlto/frontend/jaxws/src/test/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/JAXWSProfileTest.java
Wed Oct 26 23:43:50 2011
@@ -42,8 +42,15 @@ public class JAXWSProfileTest extends As
loader.loadPlugin("/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-plugin.xml");
- assertEquals(2, loader.getPlugins().size());
- Plugin plugin = getPlugin(loader, 1);
+ assertEquals(3, loader.getPlugins().size());
+
+ Plugin plugin = null;
+ for (Plugin p : loader.getPlugins().values()) {
+ if (p.getName().contains("jaxws")) {
+ plugin = p;
+ }
+ }
+ assertNotNull(plugin);
assertEquals("tools-jaxws-frontend", plugin.getName());
assertEquals("2.0", plugin.getVersion());
assertEquals("apache cxf", plugin.getProvider());
Modified:
cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/core/PluginLoaderTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/core/PluginLoaderTest.java?rev=1189538&r1=1189537&r2=1189538&view=diff
==============================================================================
---
cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/core/PluginLoaderTest.java
(original)
+++
cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/core/PluginLoaderTest.java
Wed Oct 26 23:43:50 2011
@@ -34,7 +34,7 @@ public class PluginLoaderTest extends As
@Test
public void testLoadPlugins() throws Exception {
PluginLoader loader = PluginLoader.getInstance();
- assertEquals(3, loader.getPlugins().size());
+ assertEquals(4, loader.getPlugins().size());
Plugin plugin = getPlugin(loader, 0);
assertNotNull(plugin.getName());
@@ -59,9 +59,10 @@ public class PluginLoaderTest extends As
Map<String, DataBinding> databindings = loader.getDataBindings();
assertNotNull(databindings);
- assertEquals(2, databindings.size());
+ assertEquals(6, databindings.size());
- DataBinding databinding = getDataBinding(databindings, 0);
+ DataBinding databinding = databindings.get("jaxb");
+ assertNotNull(databinding);
assertEquals("jaxb", databinding.getName());
assertEquals("org.apache.cxf.tools.wsdlto.databinding.jaxb",
databinding.getPackage());
assertEquals("JAXBDataBinding", databinding.getProfile());