bug 317231 ability to define the jety configuration in a fragment that contains an etc/jetty.xml file

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2024 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Hugues Malphettes 2010-06-18 01:30:15 +00:00
parent b1a9027c2b
commit 1a82b62179
2 changed files with 22 additions and 4 deletions

View File

@ -25,6 +25,7 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -199,7 +200,25 @@ public class WebappRegistrationHelper
*/
public void setup(BundleContext context, Map<String, String> configProperties) throws Exception
{
File _installLocation = BUNDLE_FILE_LOCATOR_HELPER.getBundleInstallLocation(context.getBundle());
Enumeration<?> enUrls = context.getBundle().findEntries("/etc", "jetty.xml", false);System.err.println();
if (enUrls.hasMoreElements())
{
URL url = (URL) enUrls.nextElement();
if (url != null)
{
//bug 317231: there is a fragment that defines the jetty configuration file.
//let's use that as the jetty home.
url = DefaultFileLocatorHelper.getLocalURL(url);
if (url.getProtocol().equals("file"))
{
//ok good.
File jettyxml = new File(url.toURI());
File jettyhome = jettyxml.getParentFile().getParentFile();
System.setProperty("jetty.home", jettyhome.getAbsolutePath());
}
}
}
File _installLocation = BUNDLE_FILE_LOCATOR_HELPER.getBundleInstallLocation(context.getBundle());
// debug:
// new File("~/proj/eclipse-install/eclipse-3.5.1-SDK-jetty7/" +
// "dropins/jetty7/plugins/org.eclipse.jetty.osgi.boot_0.0.1.001-SNAPSHOT.jar");
@ -232,7 +251,6 @@ public class WebappRegistrationHelper
String install = _installLocation != null?_installLocation.getCanonicalPath():" unresolved_install_location";
throw new IllegalArgumentException("The system property -Djetty.home" + " must be set to a directory or the bundle "
+ context.getBundle().getSymbolicName() + " installed here " + install + " must be unjarred.");
}
try
{

View File

@ -225,7 +225,7 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
* @return a URL to the bundle entry that uses a common protocol
*/
public static URL getLocalURL(URL url) {
if ("bundleresource".equals(url.getProtocol())) {
if ("bundleresource".equals(url.getProtocol()) || "bundleentry".equals(url.getProtocol())) {
try {
URLConnection conn = url.openConnection();
if (BUNDLE_URL_CONNECTION_getLocalURL == null &&
@ -255,7 +255,7 @@ public class DefaultFileLocatorHelper implements BundleFileLocatorHelper
*/
public static URL getFileURL(URL url)
{
if ("bundleresource".equals(url.getProtocol()))
if ("bundleresource".equals(url.getProtocol()) || "bundleentry".equals(url.getProtocol()))
{
try
{