Merge branch 'master' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project
This commit is contained in:
commit
2fa50247b7
|
@ -115,24 +115,24 @@ public class TagLibOSGiConfiguration extends TagLibConfiguration
|
|||
{
|
||||
atLeastOneTldFound = true;
|
||||
URL oriUrl = en.nextElement();
|
||||
URL url = BundleFileLocatorHelperFactory.getFactory().getHelper().getLocalURL(oriUrl);
|
||||
Resource tldResource;
|
||||
try
|
||||
{
|
||||
URL url = BundleFileLocatorHelperFactory.getFactory().getHelper().getLocalURL(oriUrl);
|
||||
Resource tldResource;
|
||||
tldResource = Resource.newResource(url);
|
||||
tlds.add(tldResource);
|
||||
}
|
||||
catch (IOException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Unable to locate the " + "tld resource in '"
|
||||
+ url.toString()
|
||||
+ "' in the bundle '"
|
||||
+ bs[0].getSymbolicName()
|
||||
+ "' while registering the "
|
||||
+ OSGiWebappConstants.REQUIRE_TLD_BUNDLE
|
||||
+ " of the manifest of "
|
||||
+ bundle.getSymbolicName(), e);
|
||||
+ oriUrl.toString()
|
||||
+ "' in the bundle '"
|
||||
+ bs[0].getSymbolicName()
|
||||
+ "' while registering the "
|
||||
+ OSGiWebappConstants.REQUIRE_TLD_BUNDLE
|
||||
+ " of the manifest of "
|
||||
+ bundle.getSymbolicName(), e);
|
||||
}
|
||||
tlds.add(tldResource);
|
||||
}
|
||||
if (!atLeastOneTldFound)
|
||||
{
|
||||
|
|
|
@ -12,6 +12,15 @@
|
|||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Arg><Ref refid="Server" /></Arg>
|
||||
<Arg name="factories">
|
||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
||||
<Arg name="config"><Ref refid="httpConfig" /></Arg>
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Arg>
|
||||
<Set name="host"><Property name="jetty.host" /></Set>
|
||||
<Set name="port"><Property name="jetty.port" default="8080"/></Set>
|
||||
<Set name="idleTimeout">300000</Set>
|
||||
|
|
|
@ -44,6 +44,17 @@
|
|||
</New>
|
||||
</Set>
|
||||
|
||||
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||
<Set name="secureScheme">https</Set>
|
||||
<Set name="securePort"><Property name="jetty.secure.port" default="8443" /></Set>
|
||||
<Set name="outputBufferSize">32768</Set>
|
||||
<Set name="requestHeaderSize">8192</Set>
|
||||
<Set name="responseHeaderSize">8192</Set>
|
||||
<Set name="sendServerVersion">true</Set>
|
||||
<Set name="sendDateHeader">false</Set>
|
||||
<Set name="headerCacheSize">512</Set>
|
||||
</New>
|
||||
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- extra options -->
|
||||
|
|
|
@ -214,7 +214,7 @@ public abstract class AbstractContextProvider extends AbstractLifeCycle implemen
|
|||
//put the server instance in
|
||||
properties.put("Server", getServerInstanceWrapper().getServer());
|
||||
//put in the location of the bundle root
|
||||
properties.put("bundle.root", rootResource.toString());
|
||||
properties.put(OSGiWebappConstants.JETTY_BUNDLE_ROOT, rootResource.toString());
|
||||
|
||||
// insert the bundle's location as a property.
|
||||
xmlConfiguration.getProperties().putAll(properties);
|
||||
|
|
|
@ -34,6 +34,8 @@ import org.eclipse.jetty.server.handler.ContextHandler;
|
|||
import org.eclipse.jetty.util.component.AbstractLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.JarResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
@ -195,7 +197,15 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
|||
? BundleFileLocatorHelperFactory.getFactory().getHelper().getBundleInstallLocation(_bundle)
|
||||
: new File(overrideBundleInstallLocation));
|
||||
URL url = null;
|
||||
|
||||
Resource rootResource = Resource.newResource(BundleFileLocatorHelperFactory.getFactory().getHelper().getLocalURL(bundleInstallLocation.toURI().toURL()));
|
||||
//try and make sure the rootResource is useable - if its a jar then make it a jar file url
|
||||
if (rootResource.exists()&& !rootResource.isDirectory() && !rootResource.toString().startsWith("jar:"))
|
||||
{
|
||||
Resource jarResource = JarResource.newJarResource(rootResource);
|
||||
if (jarResource.exists() && jarResource.isDirectory())
|
||||
rootResource = jarResource;
|
||||
}
|
||||
|
||||
//if the path wasn't set or it was ., then it is the root of the bundle's installed location
|
||||
if (_webAppPath == null || _webAppPath.length() == 0 || ".".equals(_webAppPath))
|
||||
{
|
||||
|
@ -227,6 +237,7 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
|||
+ (bundleInstallLocation != null ? bundleInstallLocation.getAbsolutePath() : "unlocated bundle '" + _bundle.getSymbolicName()+ "'"));
|
||||
}
|
||||
|
||||
//Sets the location of the war file
|
||||
// converts bundleentry: protocol if necessary
|
||||
_webApp.setWar(BundleFileLocatorHelperFactory.getFactory().getHelper().getLocalURL(url).toString());
|
||||
|
||||
|
@ -283,7 +294,7 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
|||
|
||||
// apply any META-INF/context.xml file that is found to configure
|
||||
// the webapp first
|
||||
applyMetaInfContextXml();
|
||||
applyMetaInfContextXml(rootResource);
|
||||
|
||||
// pass the value of the require tld bundle so that the TagLibOSGiConfiguration
|
||||
// can pick it up.
|
||||
|
@ -341,7 +352,7 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
|||
}
|
||||
|
||||
|
||||
protected void applyMetaInfContextXml()
|
||||
protected void applyMetaInfContextXml(Resource rootResource)
|
||||
throws Exception
|
||||
{
|
||||
if (_bundle == null) return;
|
||||
|
@ -365,6 +376,7 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement
|
|||
XmlConfiguration xmlConfiguration = new XmlConfiguration(contextXmlUrl);
|
||||
HashMap properties = new HashMap();
|
||||
properties.put("Server", getDeploymentManager().getServer());
|
||||
properties.put(OSGiWebappConstants.JETTY_BUNDLE_ROOT, rootResource.toString());
|
||||
xmlConfiguration.getProperties().putAll(properties);
|
||||
xmlConfiguration.configure(_webApp);
|
||||
}
|
||||
|
|
|
@ -79,6 +79,10 @@ public class OSGiWebappConstants
|
|||
public static final String JETTY_WAR_PATCH_FRAGMENT_FOLDER_PATH = "Jetty-WarPatchFragmentFolderPath";
|
||||
|
||||
|
||||
/** installation path of webapp bundle
|
||||
*
|
||||
*/
|
||||
public static final String JETTY_BUNDLE_ROOT = "bundle.root";
|
||||
/**
|
||||
* web app context path
|
||||
* @deprecated see RFC66_WEB_CONTEXTPATH
|
||||
|
|
|
@ -32,10 +32,13 @@ import java.util.StringTokenizer;
|
|||
import org.eclipse.jetty.osgi.boot.JettyBootstrapActivator;
|
||||
import org.eclipse.jetty.osgi.boot.OSGiServerConstants;
|
||||
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelperFactory;
|
||||
import org.eclipse.jetty.osgi.boot.utils.OSGiClassLoader;
|
||||
import org.eclipse.jetty.osgi.boot.utils.Util;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.JarResource;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
|
@ -67,7 +70,7 @@ public class DefaultJettyAtJettyHomeHelper
|
|||
/**
|
||||
* Default location within bundle of a jetty home dir.
|
||||
*/
|
||||
public static final String DEFAULT_JETTYHOME = "/jettyhome/";
|
||||
public static final String DEFAULT_JETTYHOME = "/jettyhome";
|
||||
|
||||
|
||||
|
||||
|
@ -96,9 +99,10 @@ public class DefaultJettyAtJettyHomeHelper
|
|||
{
|
||||
String jettyHomeSysProp = System.getProperty(OSGiServerConstants.JETTY_HOME);
|
||||
String jettyHomeBundleSysProp = System.getProperty(OSGiServerConstants.JETTY_HOME_BUNDLE);
|
||||
File jettyHome = null;
|
||||
File jettyHomeDir = null;
|
||||
Bundle jettyHomeBundle = null;
|
||||
|
||||
|
||||
Dictionary<String,String> properties = new Hashtable<String,String>();
|
||||
if (jettyHomeSysProp != null)
|
||||
{
|
||||
jettyHomeSysProp = Util.resolvePropertyValue(jettyHomeSysProp);
|
||||
|
@ -109,12 +113,15 @@ public class DefaultJettyAtJettyHomeHelper
|
|||
if (jettyHomeBundleSysProp != null)
|
||||
LOG.warn("Both jetty.home and jetty.home.bundle property defined: jetty.home.bundle ignored.");
|
||||
|
||||
jettyHome = new File(jettyHomeSysProp);
|
||||
if (!jettyHome.exists() || !jettyHome.isDirectory())
|
||||
jettyHomeDir = new File(jettyHomeSysProp);
|
||||
if (!jettyHomeDir.exists() || !jettyHomeDir.isDirectory())
|
||||
{
|
||||
LOG.warn("Unable to locate the jetty.home folder " + jettyHomeSysProp);
|
||||
return null;
|
||||
}
|
||||
|
||||
//set jetty.home
|
||||
Util.setProperty(properties, OSGiServerConstants.JETTY_HOME, jettyHomeDir.getAbsolutePath());
|
||||
}
|
||||
else if (jettyHomeBundleSysProp != null)
|
||||
{
|
||||
|
@ -134,33 +141,35 @@ public class DefaultJettyAtJettyHomeHelper
|
|||
}
|
||||
}
|
||||
|
||||
if (jettyHome == null && jettyHomeBundle == null)
|
||||
if (jettyHomeDir == null && jettyHomeBundle == null)
|
||||
{
|
||||
LOG.warn("No default jetty created.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//configure the server here rather than letting the JettyServerServiceTracker do it, because we want to be able to
|
||||
//configure the ThreadPool, which can only be done via the constructor, ie from within the xml configuration processing
|
||||
List<URL> configURLs = jettyHome != null ? getJettyConfigurationURLs(jettyHome) : getJettyConfigurationURLs(jettyHomeBundle);
|
||||
List<URL> configURLs = jettyHomeDir != null ? getJettyConfigurationURLs(jettyHomeDir) : getJettyConfigurationURLs(jettyHomeBundle, properties);
|
||||
|
||||
LOG.info("Configuring the default jetty server with {}",configURLs);
|
||||
LOG.info("JETTY.HOME="+properties.get(OSGiServerConstants.JETTY_HOME));
|
||||
ClassLoader contextCl = Thread.currentThread().getContextClassLoader();
|
||||
try
|
||||
{
|
||||
Thread.currentThread().setContextClassLoader(JettyBootstrapActivator.class.getClassLoader());
|
||||
|
||||
|
||||
// these properties usually are the ones passed to this type of
|
||||
// configuration.
|
||||
Dictionary<String,String> properties = new Hashtable<String,String>();
|
||||
properties.put(OSGiServerConstants.MANAGED_JETTY_SERVER_NAME, OSGiServerConstants.MANAGED_JETTY_SERVER_DEFAULT_NAME);
|
||||
Util.setProperty(properties, OSGiServerConstants.JETTY_HOME, System.getProperty(OSGiServerConstants.JETTY_HOME));
|
||||
Util.setProperty(properties, OSGiServerConstants.JETTY_HOST, System.getProperty(OSGiServerConstants.JETTY_HOST));
|
||||
Util.setProperty(properties, OSGiServerConstants.JETTY_PORT, System.getProperty(OSGiServerConstants.JETTY_PORT));
|
||||
Util.setProperty(properties, OSGiServerConstants.JETTY_PORT_SSL, System.getProperty(OSGiServerConstants.JETTY_PORT_SSL));
|
||||
|
||||
Server server = ServerInstanceWrapper.configure(null, configURLs, properties);
|
||||
//ensure jetty.home is set
|
||||
server.setAttribute(OSGiServerConstants.JETTY_HOME, properties.get(OSGiServerConstants.JETTY_HOME));
|
||||
|
||||
//Register the default Server instance as an OSGi service.
|
||||
//The JettyServerServiceTracker will notice it and set it up to deploy bundles as wars etc
|
||||
|
@ -216,8 +225,8 @@ public class DefaultJettyAtJettyHomeHelper
|
|||
* @param jettyhome
|
||||
* @return
|
||||
*/
|
||||
private static List<URL> getJettyConfigurationURLs(Bundle configurationBundle)
|
||||
throws MalformedURLException
|
||||
private static List<URL> getJettyConfigurationURLs(Bundle configurationBundle, Dictionary properties)
|
||||
throws Exception
|
||||
{
|
||||
List<URL> configURLs = new ArrayList<URL>();
|
||||
String files = System.getProperty(JETTY_ETC_FILES, DEFAULT_JETTY_ETC_FILES);
|
||||
|
@ -234,25 +243,72 @@ public class DefaultJettyAtJettyHomeHelper
|
|||
{
|
||||
Enumeration<URL> enUrls = BundleFileLocatorHelperFactory.getFactory().getHelper().findEntries(configurationBundle, etcFile);
|
||||
|
||||
String home = null;
|
||||
// default for org.eclipse.osgi.boot where we look inside
|
||||
// jettyhome/ for the default embedded configuration.
|
||||
if ((enUrls == null || !enUrls.hasMoreElements()))
|
||||
{
|
||||
home = DEFAULT_JETTYHOME;
|
||||
String tmp = DEFAULT_JETTYHOME+(DEFAULT_JETTYHOME.endsWith("/")?"":"/")+etcFile;
|
||||
enUrls = BundleFileLocatorHelperFactory.getFactory().getHelper().findEntries(configurationBundle, tmp);
|
||||
LOG.info("Configuring jetty from bundle: {} with {}", configurationBundle.getSymbolicName(),tmp);
|
||||
}
|
||||
}
|
||||
|
||||
//lazily ensure jetty.home value is set based on location of etc files
|
||||
if (properties.get(OSGiServerConstants.JETTY_HOME) == null)
|
||||
{
|
||||
Resource res = findDir(configurationBundle, home);
|
||||
if (res != null)
|
||||
properties.put(OSGiServerConstants.JETTY_HOME, res.toString());
|
||||
}
|
||||
|
||||
if (enUrls == null || !enUrls.hasMoreElements())
|
||||
throw new IllegalStateException ("Unable to locate a jetty configuration file for " + etcFile);
|
||||
|
||||
while (enUrls.hasMoreElements())
|
||||
{
|
||||
URL url = BundleFileLocatorHelperFactory.getFactory().getHelper().getFileURL(enUrls.nextElement());
|
||||
configURLs.add(url);
|
||||
}
|
||||
URL url = BundleFileLocatorHelperFactory.getFactory().getHelper().getFileURL(enUrls.nextElement());
|
||||
configURLs.add(url);
|
||||
|
||||
}
|
||||
}
|
||||
return configURLs;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Get a resource representing a directory inside a bundle. If the dir is null,
|
||||
* return a resource representing the installation location of the bundle.
|
||||
* @param bundle
|
||||
* @param dir
|
||||
* @return
|
||||
*/
|
||||
public static Resource findDir (Bundle bundle, String dir)
|
||||
{
|
||||
if (bundle == null)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
File f = BundleFileLocatorHelperFactory.getFactory().getHelper().getBundleInstallLocation(bundle);
|
||||
URL u = f.toURI().toURL();
|
||||
u = BundleFileLocatorHelperFactory.getFactory().getHelper().getLocalURL(u);
|
||||
Resource res = Resource.newResource(u);
|
||||
String s = res.toString();
|
||||
|
||||
//check if it is an unarchived bundle
|
||||
if (s.endsWith(".jar") && s.startsWith("file:"))
|
||||
res = JarResource.newJarResource(res);
|
||||
|
||||
//if looking for a directory
|
||||
if (dir != null)
|
||||
res = res.addPath(dir);
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOG.warn("Bad bundle location" , e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,7 +185,6 @@ public class ServiceWatcher implements ServiceListener
|
|||
try
|
||||
{
|
||||
added = e.getValue().serviceAdded(sr, contextHandler);
|
||||
System.err.println(serverName+" deployed "+contextHandler+": "+added);
|
||||
if (added && LOG.isDebugEnabled())
|
||||
LOG.debug("Provider "+e.getValue()+" deployed "+contextHandler);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.osgi.boot.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
|
||||
|
@ -103,7 +104,7 @@ public interface BundleFileLocatorHelper
|
|||
*
|
||||
* @return a URL to the bundle entry that uses a common protocol
|
||||
*/
|
||||
public URL getLocalURL(URL url);
|
||||
public URL getLocalURL(URL url) throws Exception;
|
||||
|
||||
/**
|
||||
* Only useful for equinox: on felix we get the file:// url already. Other
|
||||
|
@ -116,7 +117,9 @@ public interface BundleFileLocatorHelper
|
|||
* @return a URL to the content of the bundle entry that uses the file:
|
||||
* protocol
|
||||
* </p>
|
||||
* @throws IOException
|
||||
* @throws Exception
|
||||
*/
|
||||
public URL getFileURL(URL url);
|
||||
public URL getFileURL(URL url) throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class Util
|
|||
* @throws MalformedURLException
|
||||
*/
|
||||
public static List<URL> fileNamesAsURLs(String val, String delims)
|
||||
throws MalformedURLException
|
||||
throws Exception
|
||||
{
|
||||
String separators = DEFAULT_DELIMS;
|
||||
if (delims == null)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.eclipse.jetty.osgi.boot.utils.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
@ -301,25 +302,19 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
|
|||
* @return a URL to the bundle entry that uses a common protocol
|
||||
*/
|
||||
public URL getLocalURL(URL url)
|
||||
throws Exception
|
||||
{
|
||||
if ("bundleresource".equals(url.getProtocol()) || "bundleentry".equals(url.getProtocol()))
|
||||
{
|
||||
try
|
||||
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setDefaultUseCaches(Resource.getDefaultUseCaches());
|
||||
if (BUNDLE_URL_CONNECTION_getLocalURL == null && conn.getClass().getName().equals("org.eclipse.osgi.framework.internal.core.BundleURLConnection"))
|
||||
{
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setDefaultUseCaches(Resource.getDefaultUseCaches());
|
||||
if (BUNDLE_URL_CONNECTION_getLocalURL == null && conn.getClass().getName().equals("org.eclipse.osgi.framework.internal.core.BundleURLConnection"))
|
||||
{
|
||||
BUNDLE_URL_CONNECTION_getLocalURL = conn.getClass().getMethod("getLocalURL", null);
|
||||
BUNDLE_URL_CONNECTION_getLocalURL.setAccessible(true);
|
||||
}
|
||||
if (BUNDLE_URL_CONNECTION_getLocalURL != null) { return (URL) BUNDLE_URL_CONNECTION_getLocalURL.invoke(conn, null); }
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
System.err.println("Unable to locate the OSGi url: '" + url + "'.");
|
||||
t.printStackTrace();
|
||||
BUNDLE_URL_CONNECTION_getLocalURL = conn.getClass().getMethod("getLocalURL", null);
|
||||
BUNDLE_URL_CONNECTION_getLocalURL.setAccessible(true);
|
||||
}
|
||||
if (BUNDLE_URL_CONNECTION_getLocalURL != null) { return (URL) BUNDLE_URL_CONNECTION_getLocalURL.invoke(conn, null); }
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
@ -335,26 +330,23 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
|
|||
* @return a URL to the content of the bundle entry that uses the file:
|
||||
* protocol
|
||||
* </p>
|
||||
* @throws IOException
|
||||
*/
|
||||
public URL getFileURL(URL url)
|
||||
public URL getFileURL(URL url) throws Exception
|
||||
|
||||
{
|
||||
if ("bundleresource".equals(url.getProtocol()) || "bundleentry".equals(url.getProtocol()))
|
||||
{
|
||||
try
|
||||
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setDefaultUseCaches(Resource.getDefaultUseCaches());
|
||||
if (BUNDLE_URL_CONNECTION_getFileURL == null && conn.getClass().getName().equals("org.eclipse.osgi.framework.internal.core.BundleURLConnection"))
|
||||
{
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setDefaultUseCaches(Resource.getDefaultUseCaches());
|
||||
if (BUNDLE_URL_CONNECTION_getFileURL == null && conn.getClass().getName().equals("org.eclipse.osgi.framework.internal.core.BundleURLConnection"))
|
||||
{
|
||||
BUNDLE_URL_CONNECTION_getFileURL = conn.getClass().getMethod("getFileURL", null);
|
||||
BUNDLE_URL_CONNECTION_getFileURL.setAccessible(true);
|
||||
}
|
||||
if (BUNDLE_URL_CONNECTION_getFileURL != null) { return (URL) BUNDLE_URL_CONNECTION_getFileURL.invoke(conn, null); }
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
BUNDLE_URL_CONNECTION_getFileURL = conn.getClass().getMethod("getFileURL", null);
|
||||
BUNDLE_URL_CONNECTION_getFileURL.setAccessible(true);
|
||||
}
|
||||
if (BUNDLE_URL_CONNECTION_getFileURL != null) { return (URL) BUNDLE_URL_CONNECTION_getFileURL.invoke(conn, null); }
|
||||
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
|
|
@ -46,11 +46,30 @@ public class Activator implements BundleActivator
|
|||
*/
|
||||
public void start(BundleContext context) throws Exception
|
||||
{
|
||||
String serverName = "defaultJettyServer";
|
||||
|
||||
/* Uncomment to create a different server instance to deploy to. Also change
|
||||
* TestJettyOSGiBootWebAppAsService to use the port 9999
|
||||
|
||||
Server server = new Server();
|
||||
//do any setup on Server in here
|
||||
serverName = "fooServer";
|
||||
Dictionary serverProps = new Hashtable();
|
||||
//define the unique name of the server instance
|
||||
serverProps.put("managedServerName", serverName);
|
||||
serverProps.put("jetty.port", "9999");
|
||||
//let Jetty apply some configuration files to the Server instance
|
||||
serverProps.put("jetty.etc.config.urls", "file:/opt/jetty/etc/jetty.xml,file:/opt/jetty/etc/jetty-selector.xml,file:/opt/jetty/etc/jetty-deployer.xml");
|
||||
//register as an OSGi Service for Jetty to find
|
||||
context.registerService(Server.class.getName(), server, serverProps);
|
||||
*/
|
||||
|
||||
//Create a webapp context as a Service and target it at the Server created above
|
||||
WebAppContext webapp = new WebAppContext();
|
||||
Dictionary props = new Hashtable();
|
||||
props.put("war",".");
|
||||
props.put("contextPath","/acme");
|
||||
//uiProps.put(OSGiServerConstants.MANAGED_JETTY_SERVER_NAME, serverName);
|
||||
props.put("managedServerName", serverName);
|
||||
context.registerService(ContextHandler.class.getName(),webapp,props);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||
|
||||
<!-- ============================================================= -->
|
||||
<!-- Configure a HTTPS connector. -->
|
||||
<!-- This configuration must be used in conjunction with jetty.xml -->
|
||||
<!-- and jetty-ssl.xml. -->
|
||||
<!-- ============================================================= -->
|
||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Add a HTTPS Connector. -->
|
||||
<!-- Configure an o.e.j.server.ServerConnector with connection -->
|
||||
<!-- factories for TLS (aka SSL) and HTTP to provide HTTPS. -->
|
||||
<!-- All accepted TLS connections are wired to a HTTP connection.-->
|
||||
<!-- -->
|
||||
<!-- Consult the javadoc of o.e.j.server.ServerConnector, -->
|
||||
<!-- o.e.j.server.SslConnectionFactory and -->
|
||||
<!-- o.e.j.server.HttpConnectionFactory for all configuration -->
|
||||
<!-- that may be set here. -->
|
||||
<!-- =========================================================== -->
|
||||
<Call id="httpsConnector" name="addConnector">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Arg name="server"><Ref refid="Server" /></Arg>
|
||||
<Arg name="factories">
|
||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.SslConnectionFactory">
|
||||
<Arg name="next">http/1.1</Arg>
|
||||
<Arg name="sslContextFactory"><Ref refid="sslContextFactory"/></Arg>
|
||||
</New>
|
||||
</Item>
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
||||
<Arg name="config"><Ref refid="sslHttpConfig"/></Arg>
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Arg>
|
||||
<Set name="host"><Property name="jetty.host" /></Set>
|
||||
<Set name="port"><Property name="jetty.https.port" default="8443" /></Set>
|
||||
<Set name="idleTimeout">30000</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Configure>
|
|
@ -12,6 +12,15 @@
|
|||
<Arg>
|
||||
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||
<Arg><Ref refid="Server" /></Arg>
|
||||
<Arg name="factories">
|
||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||
<Item>
|
||||
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
||||
<Arg name="config"><Ref refid="httpConfig" /></Arg>
|
||||
</New>
|
||||
</Item>
|
||||
</Array>
|
||||
</Arg>
|
||||
<Set name="host"><Property name="jetty.host" /></Set>
|
||||
<Set name="port"><Property name="jetty.port" default="8080"/></Set>
|
||||
<Set name="idleTimeout">300000</Set>
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||
|
||||
<!-- ============================================================= -->
|
||||
<!-- Configure a TLS (SSL) Context Factory -->
|
||||
<!-- This configuration must be used in conjunction with jetty.xml -->
|
||||
<!-- and either jetty-https.xml or jetty-spdy.xml (but not both) -->
|
||||
<!-- ============================================================= -->
|
||||
<Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
|
||||
<Set name="KeyStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.keystore" default="etc/keystore"/></Set>
|
||||
<Set name="KeyStorePassword"><Property name="jetty.keystore.password" default="OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"/></Set>
|
||||
<Set name="KeyManagerPassword"><Property name="jetty.keymanager.password" default="OBF:1u2u1wml1z7s1z7a1wnl1u2g"/></Set>
|
||||
<Set name="TrustStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.truststore" default="etc/keystore"/></Set>
|
||||
<Set name="TrustStorePassword"><Property name="jetty.truststore.password" default="OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"/></Set>
|
||||
<Set name="EndpointIdentificationAlgorithm"></Set>
|
||||
<Set name="ExcludeCipherSuites">
|
||||
<Array type="String">
|
||||
<Item>SSL_RSA_WITH_DES_CBC_SHA</Item>
|
||||
<Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item>
|
||||
<Item>SSL_DHE_DSS_WITH_DES_CBC_SHA</Item>
|
||||
<Item>SSL_RSA_EXPORT_WITH_RC4_40_MD5</Item>
|
||||
<Item>SSL_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
|
||||
<Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item>
|
||||
<Item>SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA</Item>
|
||||
</Array>
|
||||
</Set>
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- Create a TLS specific HttpConfiguration based on the -->
|
||||
<!-- common HttpConfiguration defined in jetty.xml -->
|
||||
<!-- Add a SecureRequestCustomizer to extract certificate and -->
|
||||
<!-- session information -->
|
||||
<!-- =========================================================== -->
|
||||
<New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||
<Arg><Ref refid="httpConfig"/></Arg>
|
||||
<Call name="addCustomizer">
|
||||
<Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg>
|
||||
</Call>
|
||||
</New>
|
||||
|
||||
</Configure>
|
|
@ -44,6 +44,17 @@
|
|||
</New>
|
||||
</Set>
|
||||
|
||||
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||
<Set name="secureScheme">https</Set>
|
||||
<Set name="securePort"><Property name="jetty.secure.port" default="8443" /></Set>
|
||||
<Set name="outputBufferSize">32768</Set>
|
||||
<Set name="requestHeaderSize">8192</Set>
|
||||
<Set name="responseHeaderSize">8192</Set>
|
||||
<Set name="sendServerVersion">true</Set>
|
||||
<Set name="sendDateHeader">false</Set>
|
||||
<Set name="headerCacheSize">512</Set>
|
||||
</New>
|
||||
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- extra options -->
|
||||
|
@ -57,6 +68,20 @@
|
|||
<!-- =========================================================== -->
|
||||
<!-- jetty-jndi by default -->
|
||||
<!-- =========================================================== -->
|
||||
<Call class="org.eclipse.jetty.webapp.Configuration$ClassList" name="setServerDefault">
|
||||
<Arg><Ref refid="Server" /></Arg>
|
||||
<Call name="addAfter">
|
||||
<Arg name="afterClass">org.eclipse.jetty.webapp.FragmentConfiguration</Arg>
|
||||
<Arg>
|
||||
<Array type="String">
|
||||
<Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
|
||||
<Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
|
||||
</Array>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Call>
|
||||
|
||||
<Call class="java.lang.System" name="setProperty">
|
||||
<Arg>java.naming.factory.initial</Arg>
|
||||
<Arg><Property name="java.naming.factory.initial" default="org.eclipse.jetty.jndi.InitialContextFactory"/></Arg>
|
||||
|
|
|
@ -118,9 +118,14 @@ public class TestJettyOSGiBootWithJsp
|
|||
+ jettySelectorFileName
|
||||
+ ";"
|
||||
+ etc
|
||||
+ "/jetty-ssl.xml;"
|
||||
+ etc
|
||||
+ "/jetty-https.xml;"
|
||||
+ etc
|
||||
+ "/jetty-deployer.xml;"
|
||||
+ etc
|
||||
+ "/jetty-testrealm.xml";
|
||||
|
||||
options.add(systemProperty(OSGiServerConstants.MANAGED_JETTY_XML_CONFIG_URLS).value(xmlConfigs));
|
||||
options.add(systemProperty("jetty.port").value(String.valueOf(TestJettyOSGiBootCore.DEFAULT_JETTY_HTTP_PORT)));
|
||||
options.add(systemProperty("jetty.home").value(etcFolder.getParentFile().getAbsolutePath()));
|
||||
|
|
Loading…
Reference in New Issue