Author: ningjiang
Date: Sat Dec 17 12:30:01 2011
New Revision: 1215477
URL: http://svn.apache.org/viewvc?rev=1215477&view=rev
Log:
CAMEL-4788 Fixed the CxfRs address issue with camel properties
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.java
(with props)
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.xml
(with props)
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/testEndpoint.properties
(with props)
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerBlueprintBean.java
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsBlueprintEndpoint.java
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpoint.java
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerBlueprintBean.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerBlueprintBean.java?rev=1215477&r1=1215476&r2=1215477&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerBlueprintBean.java
(original)
+++
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/RsServerBlueprintBean.java
Sat Dec 17 12:30:01 2011
@@ -18,7 +18,6 @@ package org.apache.camel.component.cxf.b
import java.util.List;
-import org.apache.camel.RuntimeCamelException;
import org.apache.cxf.feature.AbstractFeature;
import org.apache.cxf.feature.LoggingFeature;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsBlueprintEndpoint.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsBlueprintEndpoint.java?rev=1215477&r1=1215476&r2=1215477&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsBlueprintEndpoint.java
(original)
+++
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsBlueprintEndpoint.java
Sat Dec 17 12:30:01 2011
@@ -33,7 +33,13 @@ public class CxfRsBlueprintEndpoint exte
private BlueprintContainer blueprintContainer;
private BundleContext bundleContext;
private BlueprintCamelContext blueprintCamelContext;
-
+
+ @Deprecated
+ /**
+ * It will be removed in Camel 3.0
+ * @param comp
+ * @param bean
+ */
public CxfRsBlueprintEndpoint(Component comp, AbstractJAXRSFactoryBean
bean) {
super(bean.getAddress(), comp);
this.bean = bean;
@@ -41,6 +47,15 @@ public class CxfRsBlueprintEndpoint exte
setBlueprintContainer(support.getBlueprintContainer());
setBundleContext(support.getBundleContext());
}
+
+ public CxfRsBlueprintEndpoint(Component comp, String uri,
AbstractJAXRSFactoryBean bean) {
+ super(uri, comp);
+ this.bean = bean;
+ setAddress(bean.getAddress());
+ BlueprintSupport support = (BlueprintSupport)bean;
+ setBlueprintContainer(support.getBlueprintContainer());
+ setBundleContext(support.getBundleContext());
+ }
public BlueprintContainer getBlueprintContainer() {
return blueprintContainer;
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java?rev=1215477&r1=1215476&r2=1215477&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java
(original)
+++
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java
Sat Dec 17 12:30:01 2011
@@ -54,9 +54,9 @@ public class CxfRsComponent extends Head
AbstractJAXRSFactoryBean bean =
CamelContextHelper.mandatoryLookup(getCamelContext(), beanId,
AbstractJAXRSFactoryBean.class);
if (bean instanceof BlueprintSupport) {
- answer = new CxfRsBlueprintEndpoint(this, bean);
+ answer = new CxfRsBlueprintEndpoint(this, remaining, bean);
} else {
- answer = new CxfRsSpringEndpoint(this, bean);
+ answer = new CxfRsSpringEndpoint(this, remaining, bean);
}
// Apply Spring bean properties (including # notation referenced
bean). Note that the
// Spring bean properties values can be overridden by property
defined in URI query.
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java?rev=1215477&r1=1215476&r2=1215477&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
(original)
+++
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
Sat Dec 17 12:30:01 2011
@@ -31,6 +31,7 @@ import org.apache.camel.component.cxf.Cx
import org.apache.camel.impl.DefaultEndpoint;
import org.apache.camel.spi.HeaderFilterStrategy;
import org.apache.camel.spi.HeaderFilterStrategyAware;
+import org.apache.camel.util.ObjectHelper;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.feature.LoggingFeature;
@@ -167,6 +168,19 @@ public class CxfRsEndpoint extends Defau
protected JAXRSClientFactoryBean newJAXRSClientFactoryBean() {
return new JAXRSClientFactoryBean();
}
+
+ protected String resolvePropertyPlaceholders(String str) {
+ try {
+ if (getCamelContext() != null) {
+ return getCamelContext().resolvePropertyPlaceholders(str);
+ } else {
+ return str;
+ }
+ } catch (Exception ex) {
+ throw ObjectHelper.wrapRuntimeCamelException(ex);
+ }
+ }
+
public JAXRSServerFactoryBean createJAXRSServerFactoryBean() {
JAXRSServerFactoryBean answer = newJAXRSServerFactoryBean();
@@ -216,7 +230,7 @@ public class CxfRsEndpoint extends Defau
}
public String getAddress() {
- return address;
+ return resolvePropertyPlaceholders(address);
}
public boolean isLoggingFeatureEnabled() {
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java?rev=1215477&r1=1215476&r2=1215477&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
(original)
+++
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
Sat Dec 17 12:30:01 2011
@@ -35,7 +35,6 @@ import org.apache.camel.Message;
import org.apache.camel.component.cxf.CxfEndpointUtils;
import org.apache.camel.component.cxf.CxfOperationException;
import org.apache.camel.component.cxf.common.message.CxfConstants;
-import org.apache.camel.converter.IOConverter;
import org.apache.camel.impl.DefaultProducer;
import org.apache.camel.util.IOHelper;
import org.apache.camel.util.LRUSoftCache;
Modified:
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpoint.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpoint.java?rev=1215477&r1=1215476&r2=1215477&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpoint.java
(original)
+++
camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpoint.java
Sat Dec 17 12:30:01 2011
@@ -17,28 +17,32 @@
package org.apache.camel.component.cxf.jaxrs;
-import org.apache.camel.CamelContext;
import org.apache.camel.Component;
-import org.apache.camel.component.cxf.spring.SpringJAXRSClientFactoryBean;
-import org.apache.camel.component.cxf.spring.SpringJAXRSServerFactoryBean;
-import org.apache.camel.spring.SpringCamelContext;
-import org.apache.cxf.configuration.spring.ConfigurerImpl;
import org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.AbstractApplicationContext;
public class CxfRsSpringEndpoint extends CxfRsEndpoint implements BeanIdAware {
private AbstractJAXRSFactoryBean bean;
private String beanId;
-
+ @Deprecated
+ /**
+ * It will be removed in Camel 3.0
+ * @param comp
+ * @param bean
+ */
public CxfRsSpringEndpoint(Component component, AbstractJAXRSFactoryBean
bean) throws Exception {
super(bean.getAddress(), component);
init(bean);
}
+ public CxfRsSpringEndpoint(Component component, String uri,
AbstractJAXRSFactoryBean bean) throws Exception {
+ super(uri, component);
+ setAddress(bean.getAddress());
+ init(bean);
+ }
+
private void init(AbstractJAXRSFactoryBean bean) {
this.bean = bean;
if (bean instanceof BeanIdAware) {
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.java?rev=1215477&view=auto
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.java
(added)
+++
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.java
Sat Dec 17 12:30:01 2011
@@ -0,0 +1,38 @@
+/**
+ * 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.camel.component.cxf.jaxrs;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.cxf.spring.AbstractSpringBeanTestSupport;
+import org.junit.Test;
+
+public class CxfRsEndpointWithProperties extends AbstractSpringBeanTestSupport
{
+
+ @Override
+ protected String[] getApplicationContextFiles() {
+ return new String[]
{"org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.xml"};
+ }
+
+ @Test
+ public void testCxfRsBeanWithCamelPropertiesHolder() throws Exception {
+ // get the camelContext from application context
+ CamelContext camelContext = ctx.getBean("camel", CamelContext.class);
+ CxfRsEndpoint testEndpoint =
camelContext.getEndpoint("cxfrs:bean:testEndpoint", CxfRsEndpoint.class);
+ assertEquals("Got a wrong address",
"http://localhost:9000/testEndpoint", testEndpoint.getAddress());
+ }
+
+}
Propchange:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.xml?rev=1215477&view=auto
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.xml
(added)
+++
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.xml
Sat Dec 17 12:30:01 2011
@@ -0,0 +1,39 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:cxf="http://camel.apache.org/schema/cxf"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd
+ http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+
+ <cxf:rsServer id="testEndpoint" address="{{address}}"
+
serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService"
+ loggingFeatureEnabled="true" loggingSizeLimit="200">
+ </cxf:rsServer>
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+ <propertyPlaceholder id="properties"
location="org/apache/camel/component/cxf/jaxrs/testEndpoint.properties"/>
+ </camelContext>
+
+
+
+</beans>
\ No newline at end of file
Propchange:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/testEndpoint.properties
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/testEndpoint.properties?rev=1215477&view=auto
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/testEndpoint.properties
(added)
+++
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/testEndpoint.properties
Sat Dec 17 12:30:01 2011
@@ -0,0 +1,21 @@
+#
+#
+# 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.
+#
+#
+address=http://localhost:9000/testEndpoint
Propchange:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/testEndpoint.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/testEndpoint.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/testEndpoint.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain