Rename some jetty-osgi classes, add comments, organize imports.
This commit is contained in:
parent
6783975707
commit
8a0ba267c1
|
@ -52,8 +52,7 @@ public abstract class AbstractContextProvider extends AbstractLifeCycle implemen
|
||||||
{
|
{
|
||||||
private static final Logger LOG = Log.getLogger(AbstractContextProvider.class);
|
private static final Logger LOG = Log.getLogger(AbstractContextProvider.class);
|
||||||
|
|
||||||
private DeploymentManager _deploymentManager;
|
private DeploymentManager _deploymentManager;
|
||||||
|
|
||||||
|
|
||||||
private ServerInstanceWrapper _serverWrapper;
|
private ServerInstanceWrapper _serverWrapper;
|
||||||
|
|
||||||
|
@ -62,7 +61,7 @@ public abstract class AbstractContextProvider extends AbstractLifeCycle implemen
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* BundleApp
|
* OSGiApp
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -26,16 +26,11 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.jetty.deploy.App;
|
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.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.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
import org.osgi.framework.FrameworkUtil;
|
import org.osgi.framework.FrameworkUtil;
|
||||||
import org.osgi.framework.ServiceReference;
|
|
||||||
import org.osgi.framework.ServiceRegistration;
|
import org.osgi.framework.ServiceRegistration;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.jetty.deploy.App;
|
import org.eclipse.jetty.deploy.App;
|
||||||
import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper;
|
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.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
|
|
|
@ -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.DefaultJettyAtJettyHomeHelper;
|
||||||
import org.eclipse.jetty.osgi.boot.internal.serverfactory.JettyServerServiceTracker;
|
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.BundleWatcher;
|
||||||
import org.eclipse.jetty.osgi.boot.internal.webapp.WebBundleTrackerCustomizer;
|
import org.eclipse.jetty.osgi.boot.internal.webapp.ServiceWatcher;
|
||||||
import org.eclipse.jetty.osgi.boot.utils.internal.PackageAdminServiceTracker;
|
import org.eclipse.jetty.osgi.boot.utils.internal.PackageAdminServiceTracker;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
|
@ -56,7 +56,7 @@ public class JettyBootstrapActivator implements BundleActivator
|
||||||
|
|
||||||
private ServiceRegistration _registeredServer;
|
private ServiceRegistration _registeredServer;
|
||||||
|
|
||||||
private JettyContextHandlerServiceTracker _jettyContextHandlerTracker;
|
private ServiceWatcher _jettyContextHandlerTracker;
|
||||||
|
|
||||||
private PackageAdminServiceTracker _packageAdminServiceTracker;
|
private PackageAdminServiceTracker _packageAdminServiceTracker;
|
||||||
|
|
||||||
|
@ -65,7 +65,10 @@ public class JettyBootstrapActivator implements BundleActivator
|
||||||
private BundleContext _bundleContext;
|
private BundleContext _bundleContext;
|
||||||
|
|
||||||
private JettyServerServiceTracker _jettyServerServiceTracker;
|
private JettyServerServiceTracker _jettyServerServiceTracker;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* Setup a new jetty Server, registers it as a service. Setup the Service
|
* 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
|
* 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() + ")");
|
context.addServiceListener(_jettyServerServiceTracker, "(objectclass=" + Server.class.getName() + ")");
|
||||||
|
|
||||||
// track ContextHandler class instances and deploy them to one of the known Servers
|
// 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() + ")");
|
context.addServiceListener(_jettyContextHandlerTracker, "(objectclass=" + ContextHandler.class.getName() + ")");
|
||||||
|
|
||||||
// Create a default jetty instance right now.
|
// Create a default jetty instance right now.
|
||||||
Server defaultServer = DefaultJettyAtJettyHomeHelper.startJettyAtJettyHome(context);
|
Server defaultServer = DefaultJettyAtJettyHomeHelper.startJettyAtJettyHome(context);
|
||||||
|
|
||||||
//Create a bundle tracker to help deploy webapps and ContextHandlers
|
//Create a bundle tracker to help deploy webapps and ContextHandlers
|
||||||
WebBundleTrackerCustomizer bundleTrackerCustomizer = new WebBundleTrackerCustomizer();
|
BundleWatcher bundleTrackerCustomizer = new BundleWatcher();
|
||||||
bundleTrackerCustomizer.setWaitForDefaultServer(defaultServer != null);
|
bundleTrackerCustomizer.setWaitForDefaultServer(defaultServer != null);
|
||||||
_webBundleTracker = new BundleTracker(context, Bundle.ACTIVE | Bundle.STOPPING, bundleTrackerCustomizer);
|
_webBundleTracker = new BundleTracker(context, Bundle.ACTIVE | Bundle.STOPPING, bundleTrackerCustomizer);
|
||||||
bundleTrackerCustomizer.setBundleTracker(_webBundleTracker);
|
bundleTrackerCustomizer.setBundleTracker(_webBundleTracker);
|
||||||
bundleTrackerCustomizer.open();
|
bundleTrackerCustomizer.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* Stop the activator.
|
* Stop the activator.
|
||||||
*
|
*
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
||||||
|
|
||||||
public static final String CONTAINER_BUNDLE_PATTERN = "org.eclipse.jetty.server.webapp.containerIncludeBundlePattern";
|
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
|
* 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.
|
* 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.
|
* Consider the fragment bundles associated with the bundle of the webapp being deployed.
|
||||||
*
|
*
|
||||||
|
@ -148,7 +148,7 @@ public class OSGiWebInfConfiguration extends WebInfConfiguration
|
||||||
return mergedResources;
|
return mergedResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* Allow fragments to supply some resources that are added to the baseResource of the webapp.
|
* 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();
|
resources[resources.length-1] = context.getBaseResource();
|
||||||
context.setBaseResource(new ResourceCollection(resources));
|
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
|
* 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.
|
* embedded in the bundle.
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.osgi.util.tracker.BundleTrackerCustomizer;
|
||||||
import org.osgi.util.tracker.ServiceTracker;
|
import org.osgi.util.tracker.ServiceTracker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WebBundleTrackerCustomizer
|
* BundleWatcher
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Tracks the installation and removal of Bundles in the OSGi environment. Any bundles
|
* 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
|
* @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<TldBundleDiscoverer> JSP_REGISTRATION_HELPERS = new ArrayList<TldBundleDiscoverer>();
|
public static Collection<TldBundleDiscoverer> JSP_REGISTRATION_HELPERS = new ArrayList<TldBundleDiscoverer>();
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class WebBundleTrackerCustomizer implements BundleTrackerCustomizer
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public WebBundleTrackerCustomizer() throws Exception
|
public BundleWatcher() throws Exception
|
||||||
{
|
{
|
||||||
_bundle = FrameworkUtil.getBundle(this.getClass());
|
_bundle = FrameworkUtil.getBundle(this.getClass());
|
||||||
//Track all BundleProviders (Jetty DeploymentManager Providers that can deploy bundles)
|
//Track all BundleProviders (Jetty DeploymentManager Providers that can deploy bundles)
|
|
@ -39,7 +39,7 @@ import org.osgi.framework.ServiceReference;
|
||||||
import org.osgi.util.tracker.ServiceTracker;
|
import org.osgi.util.tracker.ServiceTracker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JettyContextHandlerServiceTracker
|
* ServiceWatcher
|
||||||
*
|
*
|
||||||
* When a {@link ContextHandler} is activated as an osgi service we find a jetty deployer
|
* 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
|
* 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
|
* osgi services. Instead, they can be deployed via manifest headers inside bundles. See
|
||||||
* {@link WebBundleTrackerCustomizer}.
|
* {@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() + ")";
|
public static final String FILTER = "(objectclass=" + ServiceProvider.class.getName() + ")";
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public class JettyContextHandlerServiceTracker implements ServiceListener
|
||||||
/**
|
/**
|
||||||
* @param registry
|
* @param registry
|
||||||
*/
|
*/
|
||||||
public JettyContextHandlerServiceTracker() throws Exception
|
public ServiceWatcher() throws Exception
|
||||||
{
|
{
|
||||||
//track all instances of deployers of webapps
|
//track all instances of deployers of webapps
|
||||||
Bundle myBundle = FrameworkUtil.getBundle(this.getClass());
|
Bundle myBundle = FrameworkUtil.getBundle(this.getClass());
|
|
@ -31,8 +31,8 @@ import java.util.zip.ZipFile;
|
||||||
|
|
||||||
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelper;
|
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelper;
|
||||||
import org.eclipse.jetty.util.URIUtil;
|
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.FileResource;
|
||||||
|
import org.eclipse.jetty.util.resource.Resource;
|
||||||
import org.osgi.framework.Bundle;
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue