From 8a0ba267c16f3f1fc7f90dadb2d6d2898b2f8fa8 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Thu, 11 Apr 2013 15:07:50 +1000 Subject: [PATCH] Rename some jetty-osgi classes, add comments, organize imports. --- .../osgi/boot/AbstractContextProvider.java | 5 ++--- .../osgi/boot/BundleContextProvider.java | 5 ----- .../jetty/osgi/boot/BundleWebAppProvider.java | 1 - .../osgi/boot/JettyBootstrapActivator.java | 20 ++++++++++++------- .../osgi/boot/OSGiWebInfConfiguration.java | 9 ++++----- ...ckerCustomizer.java => BundleWatcher.java} | 8 ++++---- ...erviceTracker.java => ServiceWatcher.java} | 8 ++++---- .../internal/DefaultFileLocatorHelper.java | 2 +- 8 files changed, 28 insertions(+), 30 deletions(-) rename jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/{WebBundleTrackerCustomizer.java => BundleWatcher.java} (97%) rename jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/{JettyContextHandlerServiceTracker.java => ServiceWatcher.java} (96%) diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractContextProvider.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractContextProvider.java index afb831361fd..5d801c614eb 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractContextProvider.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractContextProvider.java @@ -52,8 +52,7 @@ public abstract class AbstractContextProvider extends AbstractLifeCycle implemen { private static final Logger LOG = Log.getLogger(AbstractContextProvider.class); - private DeploymentManager _deploymentManager; - + private DeploymentManager _deploymentManager; private ServerInstanceWrapper _serverWrapper; @@ -62,7 +61,7 @@ public abstract class AbstractContextProvider extends AbstractLifeCycle implemen /* ------------------------------------------------------------ */ /** - * BundleApp + * OSGiApp * * */ diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/BundleContextProvider.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/BundleContextProvider.java index 6ec082e9038..92dcbd45c28 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/BundleContextProvider.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/BundleContextProvider.java @@ -26,16 +26,11 @@ import java.util.List; import java.util.Map; import org.eclipse.jetty.deploy.App; -import org.eclipse.jetty.deploy.DeploymentManager; import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper; -import org.eclipse.jetty.osgi.boot.utils.EventSender; -import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -import org.eclipse.jetty.webapp.WebAppContext; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/BundleWebAppProvider.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/BundleWebAppProvider.java index 2a5e6e3cd0d..ab38f29ac67 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/BundleWebAppProvider.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/BundleWebAppProvider.java @@ -25,7 +25,6 @@ import java.util.Map; import org.eclipse.jetty.deploy.App; import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper; -import org.eclipse.jetty.osgi.boot.utils.EventSender; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.osgi.framework.Bundle; diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/JettyBootstrapActivator.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/JettyBootstrapActivator.java index 91fb3a388a7..8763ece7b9d 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/JettyBootstrapActivator.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/JettyBootstrapActivator.java @@ -20,8 +20,8 @@ package org.eclipse.jetty.osgi.boot; import org.eclipse.jetty.osgi.boot.internal.serverfactory.DefaultJettyAtJettyHomeHelper; import org.eclipse.jetty.osgi.boot.internal.serverfactory.JettyServerServiceTracker; -import org.eclipse.jetty.osgi.boot.internal.webapp.JettyContextHandlerServiceTracker; -import org.eclipse.jetty.osgi.boot.internal.webapp.WebBundleTrackerCustomizer; +import org.eclipse.jetty.osgi.boot.internal.webapp.BundleWatcher; +import org.eclipse.jetty.osgi.boot.internal.webapp.ServiceWatcher; import org.eclipse.jetty.osgi.boot.utils.internal.PackageAdminServiceTracker; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.ContextHandler; @@ -56,7 +56,7 @@ public class JettyBootstrapActivator implements BundleActivator private ServiceRegistration _registeredServer; - private JettyContextHandlerServiceTracker _jettyContextHandlerTracker; + private ServiceWatcher _jettyContextHandlerTracker; private PackageAdminServiceTracker _packageAdminServiceTracker; @@ -65,7 +65,10 @@ public class JettyBootstrapActivator implements BundleActivator private BundleContext _bundleContext; private JettyServerServiceTracker _jettyServerServiceTracker; - + + + + /* ------------------------------------------------------------ */ /** * Setup a new jetty Server, registers it as a service. Setup the Service * tracker for the jetty ContextHandlers that are in charge of deploying the @@ -88,20 +91,23 @@ public class JettyBootstrapActivator implements BundleActivator context.addServiceListener(_jettyServerServiceTracker, "(objectclass=" + Server.class.getName() + ")"); // track ContextHandler class instances and deploy them to one of the known Servers - _jettyContextHandlerTracker = new JettyContextHandlerServiceTracker(); + _jettyContextHandlerTracker = new ServiceWatcher(); context.addServiceListener(_jettyContextHandlerTracker, "(objectclass=" + ContextHandler.class.getName() + ")"); // Create a default jetty instance right now. Server defaultServer = DefaultJettyAtJettyHomeHelper.startJettyAtJettyHome(context); //Create a bundle tracker to help deploy webapps and ContextHandlers - WebBundleTrackerCustomizer bundleTrackerCustomizer = new WebBundleTrackerCustomizer(); + BundleWatcher bundleTrackerCustomizer = new BundleWatcher(); bundleTrackerCustomizer.setWaitForDefaultServer(defaultServer != null); _webBundleTracker = new BundleTracker(context, Bundle.ACTIVE | Bundle.STOPPING, bundleTrackerCustomizer); bundleTrackerCustomizer.setBundleTracker(_webBundleTracker); bundleTrackerCustomizer.open(); } - + + + + /* ------------------------------------------------------------ */ /** * Stop the activator. * diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiWebInfConfiguration.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiWebInfConfiguration.java index 988ebb244f2..76eb8ade44d 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiWebInfConfiguration.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiWebInfConfiguration.java @@ -52,7 +52,7 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration public static final String CONTAINER_BUNDLE_PATTERN = "org.eclipse.jetty.server.webapp.containerIncludeBundlePattern"; - + /* ------------------------------------------------------------ */ /** * Check to see if there have been any bundle symbolic names added of bundles that should be * regarded as being on the container classpath, and scanned for fragments, tlds etc etc. @@ -120,7 +120,7 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration } - + /* ------------------------------------------------------------ */ /** * Consider the fragment bundles associated with the bundle of the webapp being deployed. * @@ -148,7 +148,7 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration return mergedResources; } - + /* ------------------------------------------------------------ */ /** * Allow fragments to supply some resources that are added to the baseResource of the webapp. * @@ -227,11 +227,10 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration resources[resources.length-1] = context.getBaseResource(); context.setBaseResource(new ResourceCollection(resources)); } - } - + /* ------------------------------------------------------------ */ /** * Resolves the bundle. Usually that would be a single URL per bundle. But we do some more work if there are jars * embedded in the bundle. diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebBundleTrackerCustomizer.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/BundleWatcher.java similarity index 97% rename from jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebBundleTrackerCustomizer.java rename to jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/BundleWatcher.java index ab0c32b9159..74622c36b12 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebBundleTrackerCustomizer.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/BundleWatcher.java @@ -40,7 +40,7 @@ import org.osgi.util.tracker.BundleTrackerCustomizer; import org.osgi.util.tracker.ServiceTracker; /** - * WebBundleTrackerCustomizer + * BundleWatcher * * * Tracks the installation and removal of Bundles in the OSGi environment. Any bundles @@ -49,9 +49,9 @@ import org.osgi.util.tracker.ServiceTracker; * * @author hmalphettes */ -public class WebBundleTrackerCustomizer implements BundleTrackerCustomizer +public class BundleWatcher implements BundleTrackerCustomizer { - private static final Logger LOG = Log.getLogger(WebBundleTrackerCustomizer.class); + private static final Logger LOG = Log.getLogger(BundleWatcher.class); public static Collection JSP_REGISTRATION_HELPERS = new ArrayList(); @@ -69,7 +69,7 @@ public class WebBundleTrackerCustomizer implements BundleTrackerCustomizer /** * @throws Exception */ - public WebBundleTrackerCustomizer() throws Exception + public BundleWatcher() throws Exception { _bundle = FrameworkUtil.getBundle(this.getClass()); //Track all BundleProviders (Jetty DeploymentManager Providers that can deploy bundles) diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/JettyContextHandlerServiceTracker.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/ServiceWatcher.java similarity index 96% rename from jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/JettyContextHandlerServiceTracker.java rename to jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/ServiceWatcher.java index 83dc00d265b..08dbd4a9025 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/JettyContextHandlerServiceTracker.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/ServiceWatcher.java @@ -39,7 +39,7 @@ import org.osgi.framework.ServiceReference; import org.osgi.util.tracker.ServiceTracker; /** - * JettyContextHandlerServiceTracker + * ServiceWatcher * * When a {@link ContextHandler} is activated as an osgi service we find a jetty deployer * for it. The ContextHandler could be either a WebAppContext or any other derivative of @@ -49,9 +49,9 @@ import org.osgi.util.tracker.ServiceTracker; * osgi services. Instead, they can be deployed via manifest headers inside bundles. See * {@link WebBundleTrackerCustomizer}. */ -public class JettyContextHandlerServiceTracker implements ServiceListener +public class ServiceWatcher implements ServiceListener { - private static Logger LOG = Log.getLogger(JettyContextHandlerServiceTracker.class); + private static Logger LOG = Log.getLogger(ServiceWatcher.class); public static final String FILTER = "(objectclass=" + ServiceProvider.class.getName() + ")"; @@ -65,7 +65,7 @@ public class JettyContextHandlerServiceTracker implements ServiceListener /** * @param registry */ - public JettyContextHandlerServiceTracker() throws Exception + public ServiceWatcher() throws Exception { //track all instances of deployers of webapps Bundle myBundle = FrameworkUtil.getBundle(this.getClass()); diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultFileLocatorHelper.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultFileLocatorHelper.java index eb23d5924bf..7349cd08bb6 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultFileLocatorHelper.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultFileLocatorHelper.java @@ -31,8 +31,8 @@ import java.util.zip.ZipFile; import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelper; import org.eclipse.jetty.util.URIUtil; -import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.FileResource; +import org.eclipse.jetty.util.resource.Resource; import org.osgi.framework.Bundle; /**