Repository: camel Updated Branches: refs/heads/master 55e924a98 -> 327987348
CAMEL-9629: camel-cxfrs - Allow to configure providers easily from endpoint Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/32798734 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/32798734 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/32798734 Branch: refs/heads/master Commit: 32798734811680b8844c0dbee4d9b22749b716b8 Parents: 55e924a Author: Claus Ibsen <davscl...@apache.org> Authored: Sat Feb 20 18:06:28 2016 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sat Feb 20 18:06:28 2016 +0100 ---------------------------------------------------------------------- .../component/cxf/jaxrs/CxfRsEndpoint.java | 56 +++++++++++++------- 1 file changed, 37 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/32798734/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java index c907be1..96885ba 100644 --- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java +++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java @@ -37,6 +37,7 @@ import org.apache.camel.spi.HeaderFilterStrategyAware; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriPath; +import org.apache.camel.util.EndpointHelper; import org.apache.camel.util.ObjectHelper; import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; @@ -63,8 +64,8 @@ import org.slf4j.LoggerFactory; public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware, Service { private static final Logger LOG = LoggerFactory.getLogger(CxfRsEndpoint.class); - - @UriPath + + @UriParam(label = "advanced") protected Bus bus; private final InterceptorHolder interceptorHolder = new InterceptorHolder(); @@ -80,25 +81,26 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate private List<Class<?>> resourceClasses; @UriParam private String modelRef; - @UriParam(defaultValue = "Default") + @UriParam(label = "consumer", defaultValue = "Default") private BindingStyle bindingStyle = BindingStyle.Default; - @UriParam + @UriParam(label = "advanced") private HeaderFilterStrategy headerFilterStrategy; - @UriParam + @UriParam(label = "advanced") private CxfRsBinding binding; - @UriParam + @UriParam(javaType = "java.lang.String") private List<Object> providers = new LinkedList<Object>(); + private String providersRef; @UriParam private List<String> schemaLocations; @UriParam private List<Feature> features = new ModCountCopyOnWriteArrayList<Feature>(); - @UriParam(defaultValue = "true") + @UriParam(label = "producer,advanced", defaultValue = "true") private boolean httpClientAPI = true; - @UriParam + @UriParam(label = "producer,advanced") private boolean ignoreDeleteMethodMessageBody; - @UriParam(defaultValue = "true") + @UriParam(label = "producer", defaultValue = "true") private boolean throwExceptionOnFailure = true; - @UriParam(defaultValue = "10") + @UriParam(label = "producer,advanced", defaultValue = "10") private int maxClientCacheSize = 10; @UriParam private boolean loggingFeatureEnabled; @@ -106,13 +108,13 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate private int loggingSizeLimit; @UriParam private boolean skipFaultLogging; - @UriParam(defaultValue = "30000") + @UriParam(label = "advanced", defaultValue = "30000") private long continuationTimeout = 30000; - @UriParam + @UriParam(label = "advanced") private boolean defaultBus; - @UriParam + @UriParam(label = "advanced") private boolean performInvocation; - @UriParam + @UriParam(label = "advanced") private boolean propagateContexts; public CxfRsEndpoint() { @@ -241,13 +243,13 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate // Currently a CXF model document is the only possible source // of the model. Other sources will be supported going forward if (modelRef != null) { - + List<UserResource> resources = ResourceUtils.getUserResources(modelRef, sfb.getBus()); - + processUserResources(sfb, resources); } } - + /* * Prepare model beans and set them on the factory. * The model beans can be created from a variety of sources such as @@ -264,7 +266,7 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate // the model info (when a given model does provide this info) as opposed // to a matched method which is of no real use with a default handler. sfb.setModelBeans(resources); - + } protected void setupJAXRSClientFactoryBean(JAXRSClientFactoryBean cfb, String address) { @@ -406,7 +408,7 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate /** * This option is used to specify the model file which is useful for the resource class without annotation. - * When using this option, then the service class can be omitted, to emulate document-only endpoints + * When using this option, then the service class can be omitted, to emulate document-only endpoints */ public void setModelRef(String ref) { this.modelRef = ref; @@ -508,12 +510,20 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate /** * Set custom JAX-RS provider(s) list to the CxfRs endpoint. + * You can specify a string with a list of providers to lookup in the registy separated by comma. */ public void setProviders(List<?> providers) { this.providers.addAll(providers); } /** + * Set custom JAX-RS provider(s) list which is looked up in the registry. Multiple entries can be separated by comma. + */ + public void setProviders(String providers) { + this.providersRef = providers; + } + + /** * Set custom JAX-RS provider to the CxfRs endpoint. */ public void setProvider(Object provider) { @@ -660,6 +670,14 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate if (binding instanceof HeaderFilterStrategyAware) { ((HeaderFilterStrategyAware) binding).setHeaderFilterStrategy(getHeaderFilterStrategy()); } + + if (providersRef != null) { + String[] names = providersRef.split(","); + for (String name : names) { + Object provider = EndpointHelper.resolveReferenceParameter(getCamelContext(), name, Object.class, true); + setProvider(provider); + } + } } @Override