Repository: cxf-dosgi Updated Branches: refs/heads/master 628a128b6 -> bec022021
[DOSGI-257] Add ability to set bus properties via service properties of the form cxf.bus.prop.<key>=<value> Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/d785e345 Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/d785e345 Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/d785e345 Branch: refs/heads/master Commit: d785e345d39d91d89e9be57eea8799d4d54d691e Parents: 628a128 Author: Amichai Rothman <[email protected]> Authored: Thu Feb 9 16:09:24 2017 +0200 Committer: Amichai Rothman <[email protected]> Committed: Fri Feb 10 11:02:25 2017 +0200 ---------------------------------------------------------------------- .../cxf/dosgi/dsw/handlers/rest/RsProvider.java | 21 +++++++++++++++----- .../cxf/dosgi/dsw/handlers/ws/WsProvider.java | 12 ++++++++--- 2 files changed, 25 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/d785e345/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java ---------------------------------------------------------------------- diff --git a/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java b/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java index 5ef58d2..1c5e2f9 100644 --- a/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java +++ b/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java @@ -138,10 +138,7 @@ public class RsProvider implements DistributionProvider { final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID); Set<String> intentNames = intentManager.getExported(endpointProps); List<Object> intents = intentManager.getRequiredIntents(intentNames); - Bus bus = BusFactory.newInstance().createBus(); - if (contextRoot != null) { - httpServiceManager.registerServlet(bus, contextRoot, callingContext, sid); - } + Bus bus = createBus(sid, callingContext, contextRoot, endpointProps); LOG.info("Creating JAXRS endpoint for " + iClass.getName() + " with address " + address); JAXRSServerFactoryBean factory = createServerFactory(callingContext, endpointProps, @@ -154,7 +151,21 @@ public class RsProvider implements DistributionProvider { intentNames); return createServerFromFactory(factory, epd); } - + + protected Bus createBus(Long sid, BundleContext callingContext, String contextRoot, + Map<String, Object> endpointProps) { + Bus bus = BusFactory.newInstance().createBus(); + for (Map.Entry<String, Object> prop : endpointProps.entrySet()) { + if (prop.getKey().startsWith("cxf.bus.prop.")) { + bus.setProperty(prop.getKey().substring("cxf.bus.prop.".length()), prop.getValue()); + } + } + if (contextRoot != null) { + httpServiceManager.registerServlet(bus, contextRoot, callingContext, sid); + } + return bus; + } + private void applyIntents(List<Object> intents, AbstractJAXRSFactoryBean factory) { List<Feature> features = intentManager.getIntents(Feature.class, intents); factory.setFeatures(features); http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/d785e345/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java ---------------------------------------------------------------------- diff --git a/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java b/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java index 27fe72b..c13c93d 100644 --- a/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java +++ b/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java @@ -169,7 +169,7 @@ public class WsProvider implements DistributionProvider { final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID); Set<String> intentNames = intentManager.getExported(endpointProps); List<Object> intents = intentManager.getRequiredIntents(intentNames); - Bus bus = createBus(sid, serviceContext, contextRoot); + Bus bus = createBus(sid, serviceContext, contextRoot, endpointProps); factory.setDataBinding(getDataBinding(endpointProps, iClass)); factory.setBindingConfig(new SoapBindingConfiguration()); factory.setBus(bus); @@ -247,9 +247,15 @@ public class WsProvider implements DistributionProvider { String address = getClientAddress(sd); return address == null ? httpServiceManager.getDefaultAddress(iClass) : address; } - - protected Bus createBus(Long sid, BundleContext callingContext, String contextRoot) { + + protected Bus createBus(Long sid, BundleContext callingContext, String contextRoot, + Map<String, Object> endpointProps) { Bus bus = BusFactory.newInstance().createBus(); + for (Map.Entry<String, Object> prop : endpointProps.entrySet()) { + if (prop.getKey().startsWith("cxf.bus.prop.")) { + bus.setProperty(prop.getKey().substring("cxf.bus.prop.".length()), prop.getValue()); + } + } if (contextRoot != null) { httpServiceManager.registerServlet(bus, contextRoot, callingContext, sid); }
