Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2014-09-11 08:56:55 -0400
committerJoakim Erdfelt2014-09-11 08:56:55 -0400
commit2755746def43c28ffdf44ecfc568fb98f66eb1cc (patch)
tree00969c5d3da12805e16c62edf7e410150bf711c6 /jetty-osgi/jetty-osgi-boot/src
parent3e4c9909e0b74f9abeb24398b8e9b1de11052bbf (diff)
parent15781da7557f73d76935e1e5734c45c2a469b17c (diff)
downloadorg.eclipse.jetty.project-2755746def43c28ffdf44ecfc568fb98f66eb1cc.tar.gz
org.eclipse.jetty.project-2755746def43c28ffdf44ecfc568fb98f66eb1cc.tar.xz
org.eclipse.jetty.project-2755746def43c28ffdf44ecfc568fb98f66eb1cc.zip
Merge branch 'jetty-http2'
Diffstat (limited to 'jetty-osgi/jetty-osgi-boot/src')
-rw-r--r--jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiServerConstants.java3
-rw-r--r--jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/DefaultJettyAtJettyHomeHelper.java18
-rw-r--r--jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java78
-rw-r--r--jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/utils/internal/DefaultFileLocatorHelper.java5
4 files changed, 55 insertions, 49 deletions
diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiServerConstants.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiServerConstants.java
index b16eff92e2..4e6247dc3a 100644
--- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiServerConstants.java
+++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/OSGiServerConstants.java
@@ -30,6 +30,7 @@ public class OSGiServerConstants
* configuration.
*/
public static final String JETTY_HOME = "jetty.home";
+ public static final String JETTY_BASE = "jetty.base";
/**
* System property to point to a bundle that embeds a jetty configuration
@@ -54,7 +55,7 @@ public class OSGiServerConstants
* Usual system property used as the port for https for a typical jetty
* configuration.
*/
- public static final String JETTY_PORT_SSL = "jetty.port.ssl";
+ public static final String JETTY_PORT_SSL = "ssl.port";
//for managed jetty instances, name of the configuration parameters
diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/DefaultJettyAtJettyHomeHelper.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/DefaultJettyAtJettyHomeHelper.java
index 8f22f9768d..1347c65563 100644
--- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/DefaultJettyAtJettyHomeHelper.java
+++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/DefaultJettyAtJettyHomeHelper.java
@@ -154,7 +154,12 @@ public class DefaultJettyAtJettyHomeHelper
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));
+ String home=properties.get(OSGiServerConstants.JETTY_HOME);
+ String base=properties.get(OSGiServerConstants.JETTY_BASE);
+ if (base==null)
+ base=home;
+ LOG.info("JETTY.HOME="+home);
+ LOG.info("JETTY.BASE="+base);
ClassLoader contextCl = Thread.currentThread().getContextClassLoader();
try
{
@@ -166,10 +171,10 @@ public class DefaultJettyAtJettyHomeHelper
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));
-
+ Util.setProperty(properties, OSGiServerConstants.JETTY_HOME, home);
+ Util.setProperty(properties, OSGiServerConstants.JETTY_BASE, base);
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
@@ -177,6 +182,11 @@ public class DefaultJettyAtJettyHomeHelper
LOG.info("Default jetty server configured");
return server;
}
+ catch (Exception e)
+ {
+ LOG.warn(e);
+ throw e;
+ }
finally
{
Thread.currentThread().setContextClassLoader(contextCl);
diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java
index c4bc8c529c..dc94d6d2f5 100644
--- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java
+++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/serverfactory/ServerInstanceWrapper.java
@@ -147,47 +147,42 @@ public class ServerInstanceWrapper
for (URL jettyConfiguration : jettyConfigurations)
{
- InputStream is = null;
- try
- {
- // Execute a Jetty configuration file
- Resource r = Resource.newResource(jettyConfiguration);
- if (!r.exists())
- {
- LOG.warn("File does not exist "+r);
- throw new IllegalStateException("No such jetty server config file: "+r);
- }
- is = r.getInputStream();
- XmlConfiguration config = new XmlConfiguration(is);
- config.getIdMap().putAll(id_map);
- config.getProperties().putAll(properties);
-
- // #334062 compute the URL of the folder that contains the
- // conf file and set it as a property so we can compute relative paths
- // from it.
- String urlPath = jettyConfiguration.toString();
- int lastSlash = urlPath.lastIndexOf('/');
- if (lastSlash > 4)
- {
- urlPath = urlPath.substring(0, lastSlash);
- config.getProperties().put(PROPERTY_THIS_JETTY_XML_FOLDER_URL, urlPath);
- }
-
- Object o = config.configure();
- if (server == null)
- server = (Server)o;
-
- id_map = config.getIdMap();
- }
- catch (SAXParseException saxparse)
- {
- LOG.warn("Unable to configure the jetty/etc file " + jettyConfiguration, saxparse);
- throw saxparse;
- }
- finally
- {
- IO.close(is);
- }
+ try(Resource r = Resource.newResource(jettyConfiguration))
+ {
+ // Execute a Jetty configuration file
+ if (!r.exists())
+ {
+ LOG.warn("File does not exist "+r);
+ throw new IllegalStateException("No such jetty server config file: "+r);
+ }
+
+ XmlConfiguration config = new XmlConfiguration(r.getURL());
+
+ config.getIdMap().putAll(id_map);
+ config.getProperties().putAll(properties);
+
+ // #334062 compute the URL of the folder that contains the
+ // conf file and set it as a property so we can compute relative paths
+ // from it.
+ String urlPath = jettyConfiguration.toString();
+ int lastSlash = urlPath.lastIndexOf('/');
+ if (lastSlash > 4)
+ {
+ urlPath = urlPath.substring(0, lastSlash);
+ config.getProperties().put(PROPERTY_THIS_JETTY_XML_FOLDER_URL, urlPath);
+ }
+
+ Object o = config.configure();
+ if (server == null)
+ server = (Server)o;
+
+ id_map = config.getIdMap();
+ }
+ catch (Exception e)
+ {
+ LOG.warn("Configuration error in " + jettyConfiguration);
+ throw e;
+ }
}
return server;
@@ -250,7 +245,6 @@ public class ServerInstanceWrapper
return _ctxtCollection;
}
-
/* ------------------------------------------------------------ */
public void start(Server server, Dictionary props) throws Exception
{
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 fed6f8b6cf..35eb00b697 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
@@ -33,6 +33,7 @@ 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.FileResource;
+import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.util.resource.Resource;
import org.osgi.framework.Bundle;
@@ -100,10 +101,10 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
if (url.getProtocol().equals("file"))
{
- // some osgi frameworks do use the file protocole directly in some
+ // some osgi frameworks do use the file protocol directly in some
// situations. Do use the FileResource to transform the URL into a
// File: URL#toURI is broken
- return new FileResource(url).getFile().getParentFile().getParentFile();
+ return new PathResource(url).getFile().getParentFile().getParentFile();
}
else if (url.getProtocol().equals("bundleentry"))
{

Back to the top