Repository: cxf Updated Branches: refs/heads/3.1.x-fixes 4c97b1134 -> 9f91f73f9
[CXF-7125] Expose Logging feature as DOSGi intent named logging by default Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/9f91f73f Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/9f91f73f Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/9f91f73f Branch: refs/heads/3.1.x-fixes Commit: 9f91f73f9c829595e40688ccb4afde39376b9d4f Parents: 4c97b11 Author: Christian Schneider <[email protected]> Authored: Fri Nov 4 11:55:07 2016 +0100 Committer: Christian Schneider <[email protected]> Committed: Fri Nov 4 11:55:41 2016 +0100 ---------------------------------------------------------------------- .../apache/cxf/ext/logging/osgi/Activator.java | 37 ++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/9f91f73f/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/osgi/Activator.java ---------------------------------------------------------------------- diff --git a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/osgi/Activator.java b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/osgi/Activator.java index 6d45a28..814de9a 100644 --- a/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/osgi/Activator.java +++ b/rt/features/logging/src/main/java/org/apache/cxf/ext/logging/osgi/Activator.java @@ -22,6 +22,7 @@ import java.util.Dictionary; import java.util.Hashtable; import org.apache.cxf.ext.logging.LoggingFeature; +import org.apache.cxf.feature.AbstractFeature; import org.apache.cxf.feature.Feature; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -51,6 +52,7 @@ public class Activator implements BundleActivator { private final class ConfigUpdater implements ManagedService { private BundleContext bundleContext; private ServiceRegistration serviceReg; + private ServiceRegistration intentReg; private LoggingFeature logging; ConfigUpdater(BundleContext bundleContext) { @@ -63,23 +65,30 @@ public class Activator implements BundleActivator { public void updated(Dictionary config) throws ConfigurationException { boolean enabled = Boolean.valueOf(getValue(config, "enabled", "false")); LOG.info("CXF message logging feature " + (enabled ? "enabled" : "disabled")); - if (enabled) { - Integer limit = Integer.valueOf(getValue(config, "limit", "65536")); - Boolean pretty = Boolean.valueOf(getValue(config, "pretty", "false")); - Long inMemThreshold = Long.valueOf(getValue(config, "inMemThresHold", "-1")); + Integer limit = Integer.valueOf(getValue(config, "limit", "65536")); + Boolean pretty = Boolean.valueOf(getValue(config, "pretty", "false")); + Long inMemThreshold = Long.valueOf(getValue(config, "inMemThresHold", "-1")); - if (limit != null) { - logging.setLimit(limit); - } - if (inMemThreshold != null) { - logging.setInMemThreshold(inMemThreshold); - } - if (pretty != null) { - logging.setPrettyLogging(pretty); - } + if (limit != null) { + logging.setLimit(limit); + } + if (inMemThreshold != null) { + logging.setInMemThreshold(inMemThreshold); + } + if (pretty != null) { + logging.setPrettyLogging(pretty); + } + + if (intentReg == null) { Dictionary<String, Object> properties = new Hashtable<>(); - properties.put("name", "logging"); + properties.put("org.apache.cxf.dosgi.IntentName", "logging"); + bundleContext.registerService(AbstractFeature.class.getName(), logging, properties); + } + + if (enabled) { if (serviceReg == null) { + Dictionary<String, Object> properties = new Hashtable<>(); + properties.put("name", "logging"); serviceReg = bundleContext.registerService(Feature.class.getName(), logging, properties); } } else {
