camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject svn commit: r738346 - in /camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf: CxfComponent.java CxfEndpoint.java CxfSpringEndpoint.java DefaultCxfBinding.java
Date Wed, 28 Jan 2009 02:57:56 GMT
Author: wtam
Date: Wed Jan 28 02:57:56 2009
New Revision: 738346

URL: http://svn.apache.org/viewvc?rev=738346&view=rev
Log:
minor code cleanup to camel-cxf

Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java?rev=738346&r1=738345&r2=738346&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
Wed Jan 28 02:57:56 2009
@@ -59,7 +59,7 @@
             CxfEndpointBean bean = CamelContextHelper.mandatoryLookup(getCamelContext(),
beanId, 
                     CxfEndpointBean.class);
 
-            result = new CxfSpringEndpoint(this, beanId, bean);
+            result = new CxfSpringEndpoint(this, bean);
             
         } else {
             // endpoint URI does not specify a bean

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=738346&r1=738345&r2=738346&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
Wed Jan 28 02:57:56 2009
@@ -52,6 +52,7 @@
 import org.apache.cxf.headers.Header;
 import org.apache.cxf.jaxws.JaxWsClientFactoryBean;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.message.Message;
 
 /**
@@ -76,8 +77,6 @@
     private Bus bus;
     private CxfBinding cxfBinding;
     private HeaderFilterStrategy headerFilterStrategy;
-    private boolean hasWSProviderAnnotation;
-    private boolean hasWebServiceAnnotation;
     private AtomicBoolean cxfBindingInitialized = new AtomicBoolean(false);
     private AtomicBoolean getBusHasBeenCalled = new AtomicBoolean(false);
     private boolean isSetDefaultBus;
@@ -111,8 +110,6 @@
      * Populate server factory bean
      */
     protected void setupServerFactoryBean(ServerFactoryBean sfb, Class<?> cls) {
-        hasWSProviderAnnotation = CxfEndpointUtils.hasAnnotation(cls, 
-                WebServiceProvider.class);
         
         // address
         sfb.setAddress(getEndpointUri());
@@ -136,7 +133,7 @@
         }
 
         // apply feature here
-        if (!webServiceProviderAnnotated()) {
+        if (!CxfEndpointUtils.hasAnnotation(cls, WebServiceProvider.class)) {
             if (getDataFormat() == DataFormat.PAYLOAD) {
                 sfb.getFeatures().add(new PayLoadDataFormatFeature());
             } else if (getDataFormat() == DataFormat.MESSAGE) {
@@ -162,8 +159,7 @@
         // quick null point check for serviceClass
         ObjectHelper.notNull(cls, "Please provide endpoint service interface class");
         
-        hasWebServiceAnnotation = CxfEndpointUtils.hasWebServiceAnnotation(cls);
-        if (hasWebServiceAnnotation) {
+        if (CxfEndpointUtils.hasWebServiceAnnotation(cls)) {
             return new JaxWsProxyFactoryBean(new JaxWsClientFactoryBean() {
                 @Override
                 protected void createClient(Endpoint ep) {
@@ -256,21 +252,20 @@
         Class<?> cls = ClassLoaderUtils.loadClass(getServiceClass(), getClass());
         
         // create server factory bean
-        ServerFactoryBean answer = CxfEndpointUtils.getServerFactoryBean(cls);
+        // Shouldn't use CxfEndpointUtils.getServerFactoryBean(cls) as it is for
+        // CxfSoapComponent
+        ServerFactoryBean answer = null;
+        if (CxfEndpointUtils.hasWebServiceAnnotation(cls)) {
+            answer = new JaxWsServerFactoryBean();
+        } else {
+            answer = new ServerFactoryBean();
+        }
         
         // setup server factory bean
         setupServerFactoryBean(answer, cls);
         return answer;
     }
     
-    boolean webServiceProviderAnnotated() {
-        return hasWSProviderAnnotation;
-    }
-    
-    boolean webServiceAnnotated() {
-        return hasWebServiceAnnotation;
-    }
-    
     // Properties
     // -------------------------------------------------------------------------
 

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java?rev=738346&r1=738345&r2=738346&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSpringEndpoint.java
Wed Jan 28 02:57:56 2009
@@ -35,6 +35,7 @@
 import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 
 /**
  * Defines the <a href="http://activemq.apache.org/camel/cxf.html">CXF Endpoint</a>
@@ -51,11 +52,18 @@
     private String endpointLocalName;
     private String endpointNamespace;
     
-    public CxfSpringEndpoint(CamelContext context, String beanId,
-            CxfEndpointBean bean) throws Exception {
-        
+    public CxfSpringEndpoint(CamelContext context, CxfEndpointBean bean) throws Exception
{
         super(bean.getAddress(), context);
-        this.beanId = beanId;
+        init(bean);
+    }
+    
+    public CxfSpringEndpoint(CxfComponent component, CxfEndpointBean bean) throws Exception
{
+        super(bean.getAddress(), component);
+        init(bean);
+    }
+    
+
+    private void init(CxfEndpointBean bean) throws Exception {
         this.bean = bean;
         
         // set properties from bean which can be overridden by endpoint URI
@@ -65,15 +73,6 @@
         configurer = new ConfigurerImpl(((SpringCamelContext)getCamelContext())
             .getApplicationContext());
     }
-    
-    public CxfSpringEndpoint(CxfComponent component, String beanId,
-            CxfEndpointBean bean) throws Exception {
-        this(component.getCamelContext(), beanId, bean);
-    }
-    
-    public CxfSpringEndpoint(CamelContext context, CxfEndpointBean bean) throws Exception
{
-        this(context, "", bean);
-    }
 
     /**
      * Read properties from the CxfEndpointBean and copy them to the 
@@ -174,7 +173,15 @@
         ObjectHelper.notNull(cls, CxfConstants.SERVICE_CLASS);
         
         // create server factory bean
-        ServerFactoryBean answer = CxfEndpointUtils.getServerFactoryBean(cls);
+        // create server factory bean
+        // Shouldn't use CxfEndpointUtils.getServerFactoryBean(cls) as it is for
+        // CxfSoapComponent
+        ServerFactoryBean answer = null;
+        if (CxfEndpointUtils.hasWebServiceAnnotation(cls)) {
+            answer = new JaxWsServerFactoryBean();
+        } else {
+            answer = new ServerFactoryBean();
+        }
 
         // configure server factory bean by CXF configurer
         configure(answer);

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java?rev=738346&r1=738345&r2=738346&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
Wed Jan 28 02:57:56 2009
@@ -241,7 +241,7 @@
         
         if (outBody != null) {
             if (dataFormat == DataFormat.PAYLOAD) {
-                CxfPayload<?> payload = (CxfPayload)outBody;
+                CxfPayload<?> payload = (CxfPayload<?>)outBody;
                 outMessage.put(List.class, payload.getBody());
                 outMessage.put(Header.HEADER_LIST, payload.getHeaders());
             } else {
@@ -249,7 +249,7 @@
                 if (outBody instanceof MessageContentsList) {
                     resList = (MessageContentsList)outBody;
                 } else if (outBody instanceof List) {
-                    resList = new MessageContentsList((List)outBody);
+                    resList = new MessageContentsList((List<?>)outBody);
                 } else if (outBody.getClass().isArray()) {
                     resList = new MessageContentsList((Object[])outBody);
                 } else {
@@ -339,8 +339,7 @@
     protected void propagateHeadersFromCxfToCamel(Message cxfMessage,
             org.apache.camel.Message camelMessage) {
         
-        Map<String, List<String>> cxfHeaders =
-            CastUtils.cast((Map)cxfMessage.get(Message.PROTOCOL_HEADERS));
+        Map<String, List<String>> cxfHeaders = (Map)cxfMessage.get(Message.PROTOCOL_HEADERS);
         Map<String, Object> camelHeaders = camelMessage.getHeaders();
 
         if (cxfHeaders != null) {



Mime
View raw message