Author: cziegeler
Date: Mon Sep 19 06:37:28 2016
New Revision: 1761386

URL: http://svn.apache.org/viewvc?rev=1761386&view=rev
Log:
FELIX-5349 : add ManagedServiceFactory to HTTP service. Cleaning up code, 
logging errors

Modified:
    
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConnectorFactoryTracker.java
    
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
    
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedService.java
    
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedServiceFactory.java
    
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
    
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyServiceStarter.java
    
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/MBeanServerTracker.java
    
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/WebAppBundleContext.java

Modified: 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConnectorFactoryTracker.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConnectorFactoryTracker.java?rev=1761386&r1=1761385&r2=1761386&view=diff
==============================================================================
--- 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConnectorFactoryTracker.java
 (original)
+++ 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/ConnectorFactoryTracker.java
 Mon Sep 19 06:37:28 2016
@@ -26,13 +26,13 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.util.tracker.ServiceTracker;
 
-public class ConnectorFactoryTracker extends ServiceTracker
+public class ConnectorFactoryTracker extends ServiceTracker<ConnectorFactory, 
Connector>
 {
     private final Server server;
 
     public ConnectorFactoryTracker(final BundleContext context, final Server 
server)
     {
-        super(context, ConnectorFactory.class.getName(), null);
+        super(context, ConnectorFactory.class, null);
         this.server = server;
     }
 
@@ -48,7 +48,7 @@ public class ConnectorFactoryTracker ext
     }
 
     @Override
-    public Object addingService(ServiceReference reference)
+    public Connector addingService(ServiceReference<ConnectorFactory> 
reference)
     {
         ConnectorFactory factory = (ConnectorFactory) 
super.addingService(reference);
         Connector connector = factory.createConnector(server);
@@ -68,9 +68,9 @@ public class ConnectorFactoryTracker ext
     }
 
     @Override
-    public void removedService(ServiceReference reference, Object service)
+    public void removedService(ServiceReference<ConnectorFactory> reference, 
Connector service)
     {
-        Connector connector = (Connector) service;
+        Connector connector = service;
         if (connector.isStarted())
         {
             try

Modified: 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java?rev=1761386&r1=1761385&r2=1761386&view=diff
==============================================================================
--- 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
 (original)
+++ 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
 Mon Sep 19 06:37:28 2016
@@ -25,7 +25,6 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Properties;
 
 import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.osgi.framework.BundleContext;
@@ -137,13 +136,13 @@ public final class JettyConfig
 
     /** Felix specific property to control whether to enable Proxy/Load 
Balancer Connection */
     public static final String FELIX_PROXY_LOAD_BALANCER_CONNECTION_ENABLE = 
"org.apache.felix.proxy.load.balancer.connection.enable";
-    
+
     /** Felix specific property to configure the session cookie httpOnly flag 
*/
     public static final String FELIX_JETTY_SESSION_COOKIE_HTTP_ONLY = 
"org.apache.felix.https.jetty.session.cookie.httpOnly";
-    
+
     /** Felix specific property to configure the session cookie secure flag */
     public static final String FELIX_JETTY_SESSION_COOKIE_SECURE = 
"org.apache.felix.https.jetty.session.cookie.secure";
-    
+
     /** Felix specific property to configure session id path parameter*/
     public static final String 
FELIX_JETTY_SERVLET_SESSION_ID_PATH_PARAMETER_NAME = 
"org.eclipse.jetty.servlet.SessionIdPathParameterName";
 
@@ -197,9 +196,9 @@ public final class JettyConfig
      * This map is indexed by String objects (the property names) and
      * the values are just objects as provided by the configuration.
      */
-    private volatile Dictionary config;
+    private volatile Dictionary<String, ?> config;
 
-    public JettyConfig(BundleContext context)
+    public JettyConfig(final BundleContext context)
     {
         this.context = context;
         reset();
@@ -408,7 +407,7 @@ public final class JettyConfig
         boolean useHttps = getBooleanProperty(FELIX_HTTPS_ENABLE, 
getBooleanProperty(OSCAR_HTTPS_ENABLE, false));
         return useHttps && getHttpsPort() > 0;
     }
-    
+
     public boolean isProxyLoadBalancerConnection()
     {
         return getBooleanProperty(FELIX_PROXY_LOAD_BALANCER_CONNECTION_ENABLE, 
false);
@@ -446,15 +445,15 @@ public final class JettyConfig
      * @param props the dictionary with the new configuration values, can be 
<code>null</code> to reset this configuration to its defaults.
      * @return <code>true</code> if the configuration was updated due to a 
changed value, or <code>false</code> if no change was found.
      */
-    public boolean update(Dictionary props)
+    public boolean update(Dictionary<String, ?> props)
     {
         if (props == null)
         {
-            props = new Properties();
+            props = new Hashtable<>();
         }
 
         // FELIX-4312 Check whether there's something changed in our 
configuration...
-        Dictionary currentConfig = this.config;
+        Dictionary<String, ?> currentConfig = this.config;
         if (currentConfig == null || !props.equals(currentConfig))
         {
             this.config = props;
@@ -579,9 +578,9 @@ public final class JettyConfig
         return port;
     }
 
-    private Object getProperty(String name)
+    private Object getProperty(final String name)
     {
-        Dictionary conf = this.config;
+        Dictionary<String, ?> conf = this.config;
         Object value = (conf != null) ? conf.get(name) : null;
         if (value == null)
         {

Modified: 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedService.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedService.java?rev=1761386&r1=1761385&r2=1761386&view=diff
==============================================================================
--- 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedService.java
 (original)
+++ 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedService.java
 Mon Sep 19 06:37:28 2016
@@ -36,12 +36,12 @@ public class JettyManagedService impleme
     }
 
     @Override
-    public ManagedService getService(Bundle bundle, ServiceRegistration 
registration)
+    public ManagedService getService(Bundle bundle, 
ServiceRegistration<ManagedService> registration)
     {
         return new ManagedService()
         {
             @Override
-            public void updated(Dictionary properties)
+            public void updated(Dictionary<String, ?> properties)
             {
                 jettyService.updated(properties);
             }
@@ -49,7 +49,7 @@ public class JettyManagedService impleme
     }
 
     @Override
-    public void ungetService(Bundle bundle, ServiceRegistration registration, 
ManagedService service)
+    public void ungetService(Bundle bundle, 
ServiceRegistration<ManagedService> registration, ManagedService service)
     {
         // just have the reference dropped, nothing to cleanup
     }

Modified: 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedServiceFactory.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedServiceFactory.java?rev=1761386&r1=1761385&r2=1761386&view=diff
==============================================================================
--- 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedServiceFactory.java
 (original)
+++ 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyManagedServiceFactory.java
 Mon Sep 19 06:37:28 2016
@@ -25,6 +25,7 @@ import java.util.Hashtable;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
@@ -35,24 +36,23 @@ public class JettyManagedServiceFactory
 {
        private final Map<String, JettyServiceStarter> services = new 
HashMap<>();
        private final BundleContext context;
-       private ServiceRegistration<?> serviceReg;
+       private final ServiceRegistration<?> serviceReg;
 
-       JettyManagedServiceFactory(BundleContext context)
+       JettyManagedServiceFactory(final BundleContext context)
        {
                this.context = context;
-               
-               Dictionary<String, Object> props = new Hashtable<String, 
Object>();
+
+               final Dictionary<String, Object> props = new Hashtable<String, 
Object>();
         props.put(Constants.SERVICE_PID, JettyService.PID);
         this.serviceReg = 
context.registerService(ManagedServiceFactory.class.getName(), this, props);
        }
-       
+
        public synchronized void stop()
        {
                this.serviceReg.unregister();
-               this.serviceReg = null;
 
                Set<String> pids = new HashSet<>(services.keySet());
-               for (String pid : pids)
+               for (final String pid : pids)
                {
                        deleted(pid);
                }
@@ -65,7 +65,7 @@ public class JettyManagedServiceFactory
        }
 
        @Override
-       public synchronized void updated(String pid, Dictionary<String, ?> 
properties) throws ConfigurationException
+       public synchronized void updated(final String pid, final 
Dictionary<String, ?> properties) throws ConfigurationException
        {
                JettyServiceStarter jetty = services.get(pid);
 
@@ -81,9 +81,9 @@ public class JettyManagedServiceFactory
                                jetty.updated(properties);
                        }
                }
-               catch (Exception e)
+               catch (final Exception e)
                {
-                       throw new ConfigurationException(null, "Failed to start 
Http Jetty pid=" + pid, e);
+            SystemLogger.error("Failed to start Http Jetty pid=" + pid, e);
                }
        }
 
@@ -100,7 +100,7 @@ public class JettyManagedServiceFactory
                        }
                        catch (Exception e)
                        {
-                               throw new RuntimeException("Faiiled to stop 
Http Jetty pid=" + pid, e);
+                           SystemLogger.error("Faiiled to stop Http Jetty 
pid=" + pid, e);
                        }
                }
 

Modified: 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java?rev=1761386&r1=1761385&r2=1761386&view=diff
==============================================================================
--- 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
 (original)
+++ 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
 Mon Sep 19 06:37:28 2016
@@ -39,8 +39,6 @@ import javax.servlet.ServletContext;
 import javax.servlet.SessionCookieConfig;
 import javax.servlet.SessionTrackingMode;
 
-import org.apache.felix.http.base.internal.DispatcherServlet;
-import org.apache.felix.http.base.internal.EventDispatcher;
 import org.apache.felix.http.base.internal.HttpServiceController;
 import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.eclipse.jetty.http.HttpVersion;
@@ -77,7 +75,7 @@ import org.osgi.util.tracker.BundleTrack
 import org.osgi.util.tracker.ServiceTracker;
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
-public final class JettyService extends 
AbstractLifeCycle.AbstractLifeCycleListener implements BundleTrackerCustomizer, 
ServiceTrackerCustomizer
+public final class JettyService extends 
AbstractLifeCycle.AbstractLifeCycleListener
 {
     /** PID for configuration of the HTTP service. */
     public static final String PID = "org.apache.felix.http";
@@ -91,22 +89,20 @@ public final class JettyService extends
 
     private final JettyConfig config;
     private final BundleContext context;
-    private final DispatcherServlet dispatcher;
     private final HttpServiceController controller;
     private final Map<String, Deployment> deployments;
     private final ExecutorService executor;
 
-    private ServiceRegistration<?> configServiceReg;
-    private Server server;
-    private ContextHandlerCollection parent;
-    private EventDispatcher eventDispatcher;
-    private MBeanServerTracker mbeanServerTracker;
-    private BundleTracker bundleTracker;
-    private ServiceTracker eventAdmintTracker;
-    private ServiceTracker connectorTracker;
-    private ServiceTracker loadBalancerCustomizerTracker;
-    private CustomizerWrapper customizerWrapper;
-    private EventAdmin eventAdmin;
+    private volatile ServiceRegistration<?> configServiceReg;
+    private volatile Server server;
+    private volatile ContextHandlerCollection parent;
+    private volatile MBeanServerTracker mbeanServerTracker;
+    private volatile BundleTracker<Deployment> bundleTracker;
+    private volatile ServiceTracker<EventAdmin, EventAdmin> eventAdmintTracker;
+    private volatile ConnectorFactoryTracker connectorTracker;
+    private volatile LoadBalancerCustomizerFactoryTracker 
loadBalancerCustomizerTracker;
+    private volatile CustomizerWrapper customizerWrapper;
+    private volatile EventAdmin eventAdmin;
     private boolean registerManagedService = true;
 
     public JettyService(final BundleContext context,
@@ -114,8 +110,6 @@ public final class JettyService extends
     {
         this.context = context;
         this.config = new JettyConfig(this.context);
-        this.dispatcher = controller.getDispatcherServlet();
-        this.eventDispatcher = controller.getEventDispatcher();
         this.controller = controller;
         this.deployments = new LinkedHashMap<String, Deployment>();
         this.executor = Executors.newSingleThreadExecutor(new ThreadFactory()
@@ -145,15 +139,86 @@ public final class JettyService extends
         startJetty();
 
         if (this.registerManagedService) {
-                       Dictionary<String, Object> props = new 
Hashtable<String, Object>();
+                       final Dictionary<String, Object> props = new 
Hashtable<String, Object>();
                        props.put(Constants.SERVICE_PID, PID);
-                       this.configServiceReg = 
this.context.registerService("org.osgi.service.cm.ManagedService", new 
JettyManagedService(this), props);
+                       this.configServiceReg = 
this.context.registerService("org.osgi.service.cm.ManagedService",
+                               new JettyManagedService(this), props);
         }
 
-        this.eventAdmintTracker = new ServiceTracker(this.context, 
EventAdmin.class.getName(), this);
+        this.eventAdmintTracker = new ServiceTracker<EventAdmin, 
EventAdmin>(this.context, EventAdmin.class,
+                new ServiceTrackerCustomizer<EventAdmin, EventAdmin>()
+        {
+            @Override
+            public EventAdmin addingService(final ServiceReference<EventAdmin> 
reference)
+            {
+                EventAdmin service = context.getService(reference);
+                modifiedService(reference, service);
+                return service;
+            }
+
+            @Override
+            public void modifiedService(final ServiceReference<EventAdmin> 
reference, final EventAdmin service)
+            {
+                eventAdmin = service;
+            }
+
+            @Override
+            public void removedService(final ServiceReference<EventAdmin> 
reference, final EventAdmin service)
+            {
+                context.ungetService(reference);
+                eventAdmin = null;
+            }
+        });
         this.eventAdmintTracker.open();
 
-        this.bundleTracker = new BundleTracker(this.context, Bundle.ACTIVE | 
Bundle.STARTING, this);
+        this.bundleTracker = new BundleTracker<Deployment>(this.context, 
Bundle.ACTIVE | Bundle.STARTING,
+                new BundleTrackerCustomizer<Deployment>() {
+
+            @Override
+            public Deployment addingBundle(Bundle bundle, BundleEvent event)
+            {
+                return detectWebAppBundle(bundle);
+            }
+
+            @Override
+            public void modifiedBundle(Bundle bundle, BundleEvent event, 
Deployment object)
+            {
+                detectWebAppBundle(bundle);
+            }
+
+            private Deployment detectWebAppBundle(Bundle bundle)
+            {
+                if (bundle.getState() == Bundle.ACTIVE || (bundle.getState() 
== Bundle.STARTING && 
"Lazy".equals(bundle.getHeaders().get(HEADER_ACTIVATION_POLICY))))
+                {
+
+                    String contextPath = 
bundle.getHeaders().get(HEADER_WEB_CONTEXT_PATH);
+                    if (contextPath != null)
+                    {
+                        return startWebAppBundle(bundle, contextPath);
+                    }
+                }
+                return null;
+            }
+
+            @Override
+            public void removedBundle(Bundle bundle, BundleEvent event, 
Deployment object)
+            {
+                String contextPath = 
bundle.getHeaders().get(HEADER_WEB_CONTEXT_PATH);
+                if (contextPath == null)
+                {
+                    return;
+                }
+
+                Deployment deployment = deployments.remove(contextPath);
+                if (deployment != null && deployment.getContext() != null)
+                {
+                    // remove registration, since bundle is already stopping
+                    deployment.setRegistration(null);
+                    undeploy(deployment, deployment.getContext());
+                }
+            }
+
+                });
         this.bundleTracker.open();
     }
 
@@ -197,7 +262,7 @@ public final class JettyService extends
         return props;
     }
 
-    public void updated(Dictionary props)
+    public void updated(final Dictionary<String, ?> props)
     {
         if (this.config.update(props))
         {
@@ -223,7 +288,7 @@ public final class JettyService extends
     {
         if (this.server != null)
         {
-            this.eventDispatcher.setActive(false);
+            this.controller.getEventDispatcher().setActive(false);
             if (this.connectorTracker != null)
             {
                 this.connectorTracker.close();
@@ -276,10 +341,10 @@ public final class JettyService extends
             ServletContextHandler context = new 
ServletContextHandler(this.parent, this.config.getContextPath(), 
ServletContextHandler.SESSIONS);
 
             configureSessionManager(context);
-            this.eventDispatcher.setActive(true);
-            context.addEventListener(eventDispatcher);
-            context.getSessionHandler().addEventListener(eventDispatcher);
-            final ServletHolder holder = new ServletHolder(this.dispatcher);
+            this.controller.getEventDispatcher().setActive(true);
+            context.addEventListener(controller.getEventDispatcher());
+            
context.getSessionHandler().addEventListener(controller.getEventDispatcher());
+            final ServletHolder holder = new 
ServletHolder(this.controller.getDispatcherServlet());
             holder.setAsyncSupported(true);
             context.addServlet(holder, "/*");
             context.setMaxFormContentSize(this.config.getMaxFormSize());
@@ -328,6 +393,7 @@ public final class JettyService extends
                 }
                 Connector connector = this.server.getConnectors()[0];
                 if (connector instanceof ServerConnector) {
+                    @SuppressWarnings("resource")
                     ServerConnector serverConnector = (ServerConnector) 
connector;
                     
message.append("acceptors=").append(serverConnector.getAcceptors()).append(",");
                     
message.append("selectors=").append(serverConnector.getSelectorManager().getSelectorCount());
@@ -353,8 +419,8 @@ public final class JettyService extends
     private String fixJettyVersion()
     {
         // FELIX-4311: report the real version of Jetty...
-        Dictionary headers = this.context.getBundle().getHeaders();
-        String version = (String) headers.get("X-Jetty-Version");
+        Dictionary<String, String> headers = 
this.context.getBundle().getHeaders();
+        String version = headers.get("X-Jetty-Version");
         if (version != null)
         {
             System.setProperty("jetty.version", version);
@@ -754,7 +820,7 @@ public final class JettyService extends
                     props.put(WEB_SYMBOLIC_NAME, 
webAppBundle.getSymbolicName());
                     props.put(WEB_VERSION, webAppBundle.getVersion());
                     props.put(WEB_CONTEXT_PATH, deployment.getContextPath());
-                    
deployment.setRegistration(webAppBundle.getBundleContext().registerService(ServletContext.class.getName(),
 context.getServletContext(), props));
+                    
deployment.setRegistration(webAppBundle.getBundleContext().registerService(ServletContext.class,
 context.getServletContext(), props));
 
                     postEvent(WebEvent.DEPLOYED(webAppBundle, extenderBundle));
                 }
@@ -791,7 +857,7 @@ public final class JettyService extends
 
                     
context.getServletContext().removeAttribute(OSGI_BUNDLE_CONTEXT);
 
-                    ServiceRegistration registration = 
deployment.getRegistration();
+                    ServiceRegistration<ServletContext> registration = 
deployment.getRegistration();
                     if (registration != null)
                     {
                         registration.unregister();
@@ -812,71 +878,6 @@ public final class JettyService extends
         });
     }
 
-    @Override
-    public Object addingBundle(Bundle bundle, BundleEvent event)
-    {
-        return detectWebAppBundle(bundle);
-    }
-
-    @Override
-    public void modifiedBundle(Bundle bundle, BundleEvent event, Object object)
-    {
-        detectWebAppBundle(bundle);
-    }
-
-    private Object detectWebAppBundle(Bundle bundle)
-    {
-        if (bundle.getState() == Bundle.ACTIVE || (bundle.getState() == 
Bundle.STARTING && 
"Lazy".equals(bundle.getHeaders().get(HEADER_ACTIVATION_POLICY))))
-        {
-
-            String contextPath = 
bundle.getHeaders().get(HEADER_WEB_CONTEXT_PATH);
-            if (contextPath != null)
-            {
-                return startWebAppBundle(bundle, contextPath);
-            }
-        }
-        return null;
-    }
-
-    @Override
-    public void removedBundle(Bundle bundle, BundleEvent event, Object object)
-    {
-        String contextPath = bundle.getHeaders().get(HEADER_WEB_CONTEXT_PATH);
-        if (contextPath == null)
-        {
-            return;
-        }
-
-        Deployment deployment = this.deployments.remove(contextPath);
-        if (deployment != null && deployment.getContext() != null)
-        {
-            // remove registration, since bundle is already stopping
-            deployment.setRegistration(null);
-            undeploy(deployment, deployment.getContext());
-        }
-    }
-
-    @Override
-    public Object addingService(ServiceReference reference)
-    {
-        Object service = this.context.getService(reference);
-        modifiedService(reference, service);
-        return service;
-    }
-
-    @Override
-    public void modifiedService(ServiceReference reference, Object service)
-    {
-        this.eventAdmin = (EventAdmin) service;
-    }
-
-    @Override
-    public void removedService(ServiceReference reference, Object service)
-    {
-        this.context.ungetService(reference);
-        this.eventAdmin = null;
-    }
-
     private void postEvent(Event event)
     {
         if (this.eventAdmin != null)
@@ -919,7 +920,7 @@ public final class JettyService extends
         private String contextPath;
         private Bundle bundle;
         private WebAppBundleContext context;
-        private ServiceRegistration registration;
+        private ServiceRegistration<ServletContext> registration;
 
         public Deployment(String contextPath, Bundle bundle)
         {
@@ -947,12 +948,12 @@ public final class JettyService extends
             this.context = context;
         }
 
-        public ServiceRegistration getRegistration()
+        public ServiceRegistration<ServletContext> getRegistration()
         {
             return this.registration;
         }
 
-        public void setRegistration(ServiceRegistration registration)
+        public void setRegistration(ServiceRegistration<ServletContext> 
registration)
         {
             this.registration = registration;
         }

Modified: 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyServiceStarter.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyServiceStarter.java?rev=1761386&r1=1761385&r2=1761386&view=diff
==============================================================================
--- 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyServiceStarter.java
 (original)
+++ 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyServiceStarter.java
 Mon Sep 19 06:37:28 2016
@@ -27,15 +27,13 @@ public class JettyServiceStarter
 {
 
        private final HttpServiceController controller;
-       private final Dictionary<String, ?> props;
     private final JettyService jetty;
 
-    JettyServiceStarter(BundleContext context, Dictionary<String, ?> 
properties)
+    public JettyServiceStarter(final BundleContext context, final 
Dictionary<String, ?> properties)
     throws Exception
     {
        this.controller = new HttpServiceController(context);
-               this.props = properties;
-        this.jetty = new JettyService(context, this.controller, props);
+        this.jetty = new JettyService(context, this.controller, properties);
         this.jetty.start();
     }
 
@@ -45,7 +43,7 @@ public class JettyServiceStarter
        this.controller.stop();
     }
 
-    public void updated(Dictionary<String, ?> properties) throws Exception
+    public void updated(final Dictionary<String, ?> properties) throws 
Exception
     {
        this.jetty.updated(properties);
     }

Modified: 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/MBeanServerTracker.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/MBeanServerTracker.java?rev=1761386&r1=1761385&r2=1761386&view=diff
==============================================================================
--- 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/MBeanServerTracker.java
 (original)
+++ 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/MBeanServerTracker.java
 Mon Sep 19 06:37:28 2016
@@ -26,31 +26,41 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.util.tracker.ServiceTracker;
 
-public class MBeanServerTracker extends ServiceTracker
+public class MBeanServerTracker extends ServiceTracker<MBeanServer, 
MBeanContainer>
 {
 
     private final Server server;
 
     public MBeanServerTracker(final BundleContext context, final Server server)
     {
-        super(context, MBeanServer.class.getName(), null);
+        super(context, MBeanServer.class, null);
         this.server = server;
     }
 
     @Override
-    public Object addingService(ServiceReference reference)
+    public MBeanContainer addingService(ServiceReference<MBeanServer> 
reference)
     {
         MBeanServer server = (MBeanServer) super.addingService(reference);
-        MBeanContainer mBeanContainer = new MBeanContainer(server);
-        this.server.addEventListener(mBeanContainer);
-        return mBeanContainer;
+        if ( server != null )
+        {
+            MBeanContainer mBeanContainer = new MBeanContainer(server);
+            this.server.addEventListener(mBeanContainer);
+            return mBeanContainer;
+        }
+        else
+        {
+            super.removedService(reference, null);
+        }
+        return null;
     }
 
     @Override
-    public void removedService(ServiceReference reference, Object service)
+    public void removedService(ServiceReference<MBeanServer> reference, 
MBeanContainer service)
     {
-        MBeanContainer mBeanContainer = (MBeanContainer) service;
-        this.server.removeEventListener(mBeanContainer);
-        super.removedService(reference, mBeanContainer.getMBeanServer());
+        if ( service != null )
+        {
+            this.server.removeEventListener(service);
+            super.removedService(reference, service);
+        }
     }
 }

Modified: 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/WebAppBundleContext.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/WebAppBundleContext.java?rev=1761386&r1=1761385&r2=1761386&view=diff
==============================================================================
--- 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/WebAppBundleContext.java
 (original)
+++ 
felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/WebAppBundleContext.java
 Mon Sep 19 06:37:28 2016
@@ -16,18 +16,18 @@
  */
 package org.apache.felix.http.jetty.internal;
 
-import org.eclipse.jetty.util.URIUtil;
-import org.eclipse.jetty.util.resource.Resource;
-import org.eclipse.jetty.util.resource.URLResource;
-import org.eclipse.jetty.webapp.WebAppContext;
-import org.osgi.framework.Bundle;
-
 import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Enumeration;
 
+import org.eclipse.jetty.util.URIUtil;
+import org.eclipse.jetty.util.resource.Resource;
+import org.eclipse.jetty.util.resource.URLResource;
+import org.eclipse.jetty.webapp.WebAppContext;
+import org.osgi.framework.Bundle;
+
 class WebAppBundleContext extends WebAppContext
 {
     public WebAppBundleContext(String contextPath, final Bundle bundle, final 
ClassLoader parent)
@@ -70,13 +70,12 @@ class WebAppBundleContext extends WebApp
             }
 
             @Override
-            @SuppressWarnings({ "unchecked" })
             protected Enumeration<URL> findResources(String name) throws 
IOException
             {
                 // Don't try to load resources from the bundle when it is not 
active
                 if (bundle.getState() == Bundle.ACTIVE)
                 {
-                    Enumeration<URL> urls = (Enumeration<URL>) 
bundle.getResources(name);
+                    Enumeration<URL> urls = bundle.getResources(name);
                     if (urls != null)
                     {
                         return urls;


Reply via email to