You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2014/01/28 08:26:25 UTC
svn commit: r1561957 -
/sling/whiteboard/fmeschbe/featureflags/feature-flags/src/main/java/org/apache/sling/featureflags/impl/FeatureManager.java
Author: fmeschbe
Date: Tue Jan 28 07:26:24 2014
New Revision: 1561957
URL: http://svn.apache.org/r1561957
Log:
For now only register the Sling filter to have a predefined SlingContext for requests
process by the SlingMainServlet
Alos keep the service registrations in a list to simplify cleanup (and to prevent
getting an ever growing list of service registration fields)
Modified:
sling/whiteboard/fmeschbe/featureflags/feature-flags/src/main/java/org/apache/sling/featureflags/impl/FeatureManager.java
Modified: sling/whiteboard/fmeschbe/featureflags/feature-flags/src/main/java/org/apache/sling/featureflags/impl/FeatureManager.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/featureflags/feature-flags/src/main/java/org/apache/sling/featureflags/impl/FeatureManager.java?rev=1561957&r1=1561956&r2=1561957&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/featureflags/feature-flags/src/main/java/org/apache/sling/featureflags/impl/FeatureManager.java (original)
+++ sling/whiteboard/fmeschbe/featureflags/feature-flags/src/main/java/org/apache/sling/featureflags/impl/FeatureManager.java Tue Jan 28 07:26:24 2014
@@ -68,69 +68,43 @@ public class FeatureManager {
private Map<String, FeatureDescription> activeFeatures = new TreeMap<String, FeatureDescription>();
- private ServiceRegistration featuresService;
-
- private ServiceRegistration resourceDecorator;
-
- private ServiceRegistration featureWebConsolePlugin;
- private ServiceRegistration featureGlobalFilter;
- private ServiceRegistration featureSlingFilter;
+ private List<ServiceRegistration> services;
@SuppressWarnings("serial")
@Activate
private void activate(BundleContext bundleContext) {
- this.featuresService = bundleContext.registerService(Features.class.getName(), new FeaturesImpl(this), null);
- this.resourceDecorator = bundleContext.registerService(ResourceDecorator.class.getName(),
- new FeatureResourceDecorator(this), null);
- this.featureWebConsolePlugin = bundleContext.registerService(Servlet.class.getName(),
- new FeatureWebConsolePlugin(this), new Hashtable<String, Object>() {
+ ArrayList<ServiceRegistration> services = new ArrayList<ServiceRegistration>();
+ services.add(bundleContext.registerService(Features.class.getName(), new FeaturesImpl(this), null));
+ services.add(bundleContext.registerService(ResourceDecorator.class.getName(),
+ new FeatureResourceDecorator(this), null));
+ services.add(bundleContext.registerService(Servlet.class.getName(), new FeatureWebConsolePlugin(this),
+ new Hashtable<String, Object>() {
{
put("felix.webconsole.label", "features");
put("felix.webconsole.title", "Features");
put("felix.webconsole.category", "Sling");
}
- });
- this.featureGlobalFilter = bundleContext.registerService(Filter.class.getName(),
- new CurrentClientContextFilter(this), new Hashtable<String, Object>() {
- {
- put("pattern", "/.*");
- put("service.ranking", Integer.MIN_VALUE);
- }
- });
- this.featureGlobalFilter = bundleContext.registerService(Filter.class.getName(),
- new CurrentClientContextFilter(this), new Hashtable<String, Object>() {
- {
- put("sling.filter.scope", "REQUEST");
- put("service.ranking", Integer.MIN_VALUE);
- }
- });
+ }));
+ services.add(bundleContext.registerService(Filter.class.getName(), new CurrentClientContextFilter(this),
+ new Hashtable<String, Object>() {
+ {
+ put("sling.filter.scope", "REQUEST");
+ put("service.ranking", Integer.MIN_VALUE);
+ }
+ }));
+ this.services = services;
}
@Deactivate
private void deactivate() {
- if (this.featureWebConsolePlugin != null) {
- this.featureWebConsolePlugin.unregister();
- this.featureWebConsolePlugin = null;
- }
-
- if (this.featureSlingFilter != null) {
- this.featureSlingFilter.unregister();
- this.featureSlingFilter = null;
- }
-
- if (this.featureGlobalFilter != null) {
- this.featureGlobalFilter.unregister();
- this.featureGlobalFilter = null;
- }
-
- if (this.featuresService != null) {
- this.featuresService.unregister();
- this.featuresService = null;
- }
-
- if (this.resourceDecorator != null) {
- this.resourceDecorator.unregister();
- this.resourceDecorator = null;
+ if (this.services != null) {
+ for (ServiceRegistration service : this.services) {
+ if (service != null) {
+ service.unregister();
+ }
+ }
+ this.services.clear();
+ this.services = null;
}
}