You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/10/02 04:47:10 UTC
svn commit: r820868 - in /cxf/branches/2.2.x-fixes: ./
api/src/main/java/org/apache/cxf/annotations/
api/src/main/java/org/apache/cxf/tools/common/
rt/core/src/main/java/org/apache/cxf/service/factory/
rt/databinding/xmlbeans/src/main/java/org/apache/c...
Author: dkulp
Date: Fri Oct 2 02:47:09 2009
New Revision: 820868
URL: http://svn.apache.org/viewvc?rev=820868&view=rev
Log:
[CXF-2429] Port Databinding annotation from 2.3 to 2.2
Merged revisions 803954 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r803954 | dkulp | 2009-08-13 13:33:48 -0400 (Thu, 13 Aug 2009) | 4 lines
Add DataBinding annotation to set the databinding for a service without
needing config.
Allow wsdl2java to output DataBinding annotation if appropriate.
........
Added:
cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/annotations/
cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/annotations/DataBinding.java
- copied unchanged from r820268, cxf/trunk/api/src/main/java/org/apache/cxf/annotations/DataBinding.java
Modified:
cxf/branches/2.2.x-fixes/ (props changed)
cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java
cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java
cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf.xml
cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/model/JAnnotationElement.java
cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
cxf/branches/2.2.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/SEIGenerator.java
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct 2 02:47:09 2009
@@ -1 +1 @@
-/cxf/trunk:820391-820393
+/cxf/trunk:803954,820391-820393
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-blocked' - no diff available.
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?rev=820868&r1=820867&r2=820868&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java (original)
+++ cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java Fri Oct 2 02:47:09 2009
@@ -217,6 +217,7 @@
// Tools framework
public static final String FRONTEND_PLUGIN = "frontend";
public static final String DATABINDING_PLUGIN = "databinding";
+ public static final String RUNTIME_DATABINDING_CLASS = "databinding-class";
public static final String CFG_WSDL_VERSION = "wsdlversion";
Modified: cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java?rev=820868&r1=820867&r2=820868&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java (original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java Fri Oct 2 02:47:09 2009
@@ -54,7 +54,10 @@
}
public DataBinding getDataBinding() {
- if (dataBinding == null) {
+ return getDataBinding(true);
+ }
+ public DataBinding getDataBinding(boolean create) {
+ if (dataBinding == null && create) {
dataBinding = createDefaultDataBinding();
}
return dataBinding;
Modified: cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java?rev=820868&r1=820867&r2=820868&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java (original)
+++ cxf/branches/2.2.x-fixes/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansToolingDataBinding.java Fri Oct 2 02:47:09 2009
@@ -91,6 +91,9 @@
StscState state;
public void initialize(ToolContext context) throws ToolException {
+ context.put(ToolConstants.RUNTIME_DATABINDING_CLASS,
+ "org.apache.cxf.xmlbeans.XmlBeansDataBinding.class");
+
String wsdl = (String)context.get(ToolConstants.CFG_WSDLURL);
String catalog = (String)context.get(ToolConstants.CFG_CATALOG);
Object o = context.get(ToolConstants.CFG_BINDING);
Modified: cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java?rev=820868&r1=820867&r2=820868&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java Fri Oct 2 02:47:09 2009
@@ -75,11 +75,11 @@
}
protected void applyExtraClass() {
- DataBinding dataBinding = getServiceFactory().getDataBinding();
- if (dataBinding instanceof JAXBDataBinding) {
- Map props = this.getProperties();
- if (props != null && props.get("jaxb.additionalContextClasses") != null) {
- Class[] extraClass = (Class[])this.getProperties().get("jaxb.additionalContextClasses");
+ Map props = this.getProperties();
+ if (props != null && props.get("jaxb.additionalContextClasses") != null) {
+ Class[] extraClass = (Class[])this.getProperties().get("jaxb.additionalContextClasses");
+ DataBinding dataBinding = getServiceFactory().getDataBinding();
+ if (dataBinding instanceof JAXBDataBinding) {
((JAXBDataBinding)dataBinding).setExtraClass(extraClass);
}
}
Modified: cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java?rev=820868&r1=820867&r2=820868&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java Fri Oct 2 02:47:09 2009
@@ -201,11 +201,11 @@
}
protected void applyExtraClass() {
- DataBinding dataBinding = getServiceFactory().getDataBinding();
- if (dataBinding instanceof JAXBDataBinding) {
- Map props = this.getProperties();
- if (props != null && props.get("jaxb.additionalContextClasses") != null) {
- Class[] extraClass = (Class[])this.getProperties().get("jaxb.additionalContextClasses");
+ Map props = this.getProperties();
+ if (props != null && props.get("jaxb.additionalContextClasses") != null) {
+ Class[] extraClass = (Class[])this.getProperties().get("jaxb.additionalContextClasses");
+ DataBinding dataBinding = getServiceFactory().getDataBinding();
+ if (dataBinding instanceof JAXBDataBinding) {
((JAXBDataBinding)dataBinding).setExtraClass(extraClass);
}
}
Modified: cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=820868&r1=820867&r2=820868&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Fri Oct 2 02:47:09 2009
@@ -83,6 +83,7 @@
import org.apache.cxf.interceptor.FaultOutInterceptor;
import org.apache.cxf.jaxb.JAXBDataBinding;
import org.apache.cxf.message.Exchange;
+import org.apache.cxf.resource.ResourceManager;
import org.apache.cxf.service.Service;
import org.apache.cxf.service.ServiceImpl;
import org.apache.cxf.service.ServiceModelSchemaValidator;
@@ -185,6 +186,22 @@
protected DataBinding createDefaultDataBinding() {
+ if (getServiceClass() != null) {
+ org.apache.cxf.annotations.DataBinding db
+ = getServiceClass().getAnnotation(org.apache.cxf.annotations.DataBinding.class);
+ if (db != null) {
+ try {
+ if (!StringUtils.isEmpty(db.ref())) {
+ return getBus().getExtension(ResourceManager.class).resolveResource(db.ref(),
+ db.value());
+ }
+ return db.value().newInstance();
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, "Could not create databinding "
+ + db.value().getName(), e);
+ }
+ }
+ }
return new JAXBDataBinding(getQualifyWrapperSchema());
}
Modified: cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf.xml?rev=820868&r1=820867&r2=820868&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf.xml (original)
+++ cxf/branches/2.2.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/xmlbeans/cxf.xml Fri Oct 2 02:47:09 2009
@@ -33,9 +33,9 @@
<!-- jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties-->
- <jaxws:dataBinding>
+ <!-- jaxws:dataBinding>
<bean class="org.apache.cxf.xmlbeans.XmlBeansDataBinding"/>
- </jaxws:dataBinding>
+ </jaxws:dataBinding-->
</jaxws:client>
<jaxws:endpoint name="{http://apache.org/hello_world_soap_http/xmlbeans}SoapPort"
@@ -44,9 +44,9 @@
<jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties>
- <jaxws:dataBinding>
+ <!-- jaxws:dataBinding>
<bean class="org.apache.cxf.xmlbeans.XmlBeansDataBinding"/>
- </jaxws:dataBinding>
+ </jaxws:dataBinding-->
</jaxws:endpoint>
</beans>
Modified: cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/model/JAnnotationElement.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/model/JAnnotationElement.java?rev=820868&r1=820867&r2=820868&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/model/JAnnotationElement.java (original)
+++ cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/common/model/JAnnotationElement.java Fri Oct 2 02:47:09 2009
@@ -91,7 +91,11 @@
private void appendValue(final StringBuffer sb, final Object obj) {
if (obj instanceof String) {
- getStringValue(sb, obj);
+ if (isPrimitive) {
+ sb.append(obj);
+ } else {
+ getStringValue(sb, obj);
+ }
} else if (obj instanceof Class) {
Class clz = (Class) obj;
if (containsSameClassName(clz) && !imports.contains(clz.getName())) {
Modified: cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java?rev=820868&r1=820867&r2=820868&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java (original)
+++ cxf/branches/2.2.x-fixes/tools/common/src/main/java/org/apache/cxf/tools/util/URIParserUtil.java Fri Oct 2 02:47:09 2009
@@ -97,7 +97,8 @@
String lastToken = tokens.get(tokens.size() - 1);
idx = lastToken.lastIndexOf('.');
if (idx > 0) {
- lastToken = lastToken.substring(0, idx);
+ //lastToken = lastToken.substring(0, idx);
+ lastToken = lastToken.replace('.', '_');
tokens.set(tokens.size() - 1, lastToken);
}
}
Modified: cxf/branches/2.2.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/SEIGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/SEIGenerator.java?rev=820868&r1=820867&r2=820868&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/SEIGenerator.java (original)
+++ cxf/branches/2.2.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/SEIGenerator.java Fri Oct 2 02:47:09 2009
@@ -23,12 +23,14 @@
import javax.jws.HandlerChain;
+import org.apache.cxf.annotations.DataBinding;
import org.apache.cxf.common.i18n.Message;
import org.apache.cxf.service.model.ServiceInfo;
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.JAnnotation;
+import org.apache.cxf.tools.common.model.JAnnotationElement;
import org.apache.cxf.tools.common.model.JavaInterface;
import org.apache.cxf.tools.common.model.JavaModel;
import org.apache.cxf.tools.util.ClassCollector;
@@ -104,6 +106,15 @@
}
}
}
+ if (penv.containsKey(ToolConstants.RUNTIME_DATABINDING_CLASS)) {
+ JAnnotation ann = new JAnnotation(DataBinding.class);
+ JAnnotationElement el
+ = new JAnnotationElement(null,
+ penv.get(ToolConstants.RUNTIME_DATABINDING_CLASS),
+ true);
+ ann.addElement(el);
+ intf.addAnnotation(ann);
+ }
clearAttributes();
setAttributes("intf", intf);
setCommonAttributes();