You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2016/11/30 17:20:41 UTC
aries-jax-rs-whiteboard git commit: Extract RuntimeDelegate init
Repository: aries-jax-rs-whiteboard
Updated Branches:
refs/heads/master bb42cc1a8 -> d442835ef
Extract RuntimeDelegate init
Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/d442835e
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/d442835e
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/d442835e
Branch: refs/heads/master
Commit: d442835eff13e9e7bf80f00e7cdfe97975d10447
Parents: bb42cc1
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Wed Nov 30 18:20:26 2016 +0100
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Wed Nov 30 18:20:26 2016 +0100
----------------------------------------------------------------------
.../activator/CXFJaxRsBundleActivator.java | 53 +++++++-------------
1 file changed, 18 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/d442835e/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
index 6c98993..918b619 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
@@ -17,14 +17,9 @@
package org.apache.aries.jax.rs.whiteboard.activator;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
import javax.ws.rs.ext.RuntimeDelegate;
import org.apache.cxf.Bus;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
@@ -42,58 +37,46 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
@Override
public void start(BundleContext bundleContext) throws Exception {
- Thread thread = Thread.currentThread();
-
- ClassLoader contextClassLoader = thread.getContextClassLoader();
-
- Bundle bundle = bundleContext.getBundle();
-
- BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
-
- thread.setContextClassLoader(bundleWiring.getClassLoader());
-
- try {
-
- // Initialize instance so it is never looked up again
-
- RuntimeDelegate.getInstance();
- }
- finally {
- thread.setContextClassLoader(contextClassLoader);
- }
-
- Dictionary<String, Object> runtimeProperties = new Hashtable<>();
-
- runtimeProperties.put("endpoints", new ArrayList<String>());
+ initRuntimeDelegate(bundleContext);
// TODO make the context path of the JAX-RS Whiteboard configurable.
-
_servicesRegistrator = new ServicesRegistrator(bundleContext);
-
_servicesRegistrator.start();
_busServiceTracker = new ServiceTracker<>(
bundleContext, Bus.class,
new BusServiceTrackerCustomizer(bundleContext));
-
_busServiceTracker.open();
Filter filter = bundleContext.createFilter(
"(jaxrs.application.select=*)");
-
_singletonsTracker = new ServiceTracker<>(
bundleContext, filter,
new ServicesServiceTrackerCustomizer(bundleContext));
-
_singletonsTracker.open();
}
+ /**
+ * Initialize instance so it is never looked up again
+ * @param bundleContext
+ */
+ private void initRuntimeDelegate(BundleContext bundleContext) {
+ Thread thread = Thread.currentThread();
+ ClassLoader oldClassLoader = thread.getContextClassLoader();
+ BundleWiring bundleWiring = bundleContext.getBundle().adapt(BundleWiring.class);
+ thread.setContextClassLoader(bundleWiring.getClassLoader());
+ try {
+ RuntimeDelegate.getInstance();
+ }
+ finally {
+ thread.setContextClassLoader(oldClassLoader);
+ }
+ }
+
@Override
public void stop(BundleContext context) throws Exception {
_busServiceTracker.close();
-
_singletonsTracker.close();
-
_servicesRegistrator.stop();
}