bug 346027 support for META-INF/web-fragment.xml and META-INF/resources/ inside fragments of a web-bundle
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3200 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
d6639b77b5
commit
2585b4cd94
|
@ -26,7 +26,7 @@ Import-Package: javax.mail;version="1.4.0";resolution:=optional,
|
|||
org.xml.sax,
|
||||
org.xml.sax.helpers
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Bundle-Classpath: .,target/classes
|
||||
Bundle-Classpath: .
|
||||
Require-Bundle: org.eclipse.jetty.ajp;bundle-version="[7.0,8)";resolution:=optional,
|
||||
org.eclipse.jetty.annotations;bundle-version="[7.0,8)";resolution:=optional,
|
||||
org.eclipse.jetty.client;bundle-version="[7.0,8)";resolution:=optional,
|
||||
|
|
|
@ -44,6 +44,8 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.resource.ResourceCollection;
|
||||
import org.eclipse.jetty.webapp.FragmentConfiguration;
|
||||
import org.eclipse.jetty.webapp.TagLibConfiguration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.webapp.WebInfConfiguration;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
|
@ -541,12 +543,80 @@ public class WebBundleDeployerHelper implements IWebBundleDeployerHelper
|
|||
patchResourcesPath.put(key + ";" + frag.getSymbolicName(), Resource.newResource(patchFragUrl));
|
||||
}
|
||||
}
|
||||
if (!appendedResourcesPath.isEmpty()) {
|
||||
if (!appendedResourcesPath.isEmpty())
|
||||
{
|
||||
wah.setAttribute(WebInfConfiguration.RESOURCE_URLS, new ArrayList<Resource>(appendedResourcesPath.values()));
|
||||
}
|
||||
if (!patchResourcesPath.isEmpty()) {
|
||||
if (!patchResourcesPath.isEmpty())
|
||||
{
|
||||
wah.setAttribute(WebInfConfiguration.RESOURCE_URLS + ".patch", new ArrayList<Resource>(patchResourcesPath.values()));
|
||||
}
|
||||
|
||||
if (wah instanceof WebAppContext)
|
||||
{
|
||||
//This is the equivalent of what MetaInfConfiguration does. For OSGi bundles without the JarScanner
|
||||
WebAppContext webappCtxt = (WebAppContext)wah;
|
||||
//take care of the web-fragments, meta-inf resources and tld resources:
|
||||
//similar to what MetaInfConfiguration does.
|
||||
List<Resource> frags = (List<Resource>)wah.getAttribute(FragmentConfiguration.FRAGMENT_RESOURCES);
|
||||
List<Resource> resfrags = (List<Resource>)wah.getAttribute(WebInfConfiguration.RESOURCE_URLS);
|
||||
List<Resource> tldfrags = (List<Resource>)wah.getAttribute(TagLibConfiguration.TLD_RESOURCES);
|
||||
for (Bundle frag : fragments)
|
||||
{
|
||||
URL webFrag = frag.getEntry("/META-INF/web-fragment.xml");
|
||||
Enumeration<URL> resEnum = frag.findEntries("/META-INF/resources", "*", true);
|
||||
Enumeration<URL> tldEnum = frag.findEntries("/META-INF", "*.tld", false);
|
||||
if (webFrag != null || (resEnum != null && resEnum.hasMoreElements())
|
||||
|| (tldEnum != null && tldEnum.hasMoreElements()))
|
||||
{
|
||||
try
|
||||
{
|
||||
File fragFile = BUNDLE_FILE_LOCATOR_HELPER.getBundleInstallLocation(frag);
|
||||
//add it to the webinf jars collection:
|
||||
//no need to check that it was not there yet: it was not there yet for sure.
|
||||
Resource fragFileAsResource = Resource.newResource(fragFile.toURI());
|
||||
webappCtxt.getMetaData().addWebInfJar(fragFileAsResource);
|
||||
|
||||
if (webFrag != null)
|
||||
{
|
||||
if (frags == null)
|
||||
{
|
||||
frags = new ArrayList<Resource>();
|
||||
wah.setAttribute(FragmentConfiguration.FRAGMENT_RESOURCES, frags);
|
||||
}
|
||||
frags.add(fragFileAsResource);
|
||||
}
|
||||
if (resEnum != null && resEnum.hasMoreElements())
|
||||
{
|
||||
if (resfrags == null)
|
||||
{
|
||||
resfrags = new ArrayList<Resource>();
|
||||
wah.setAttribute(WebInfConfiguration.RESOURCE_URLS, resfrags);
|
||||
}
|
||||
resfrags.add(Resource.newResource(
|
||||
DefaultFileLocatorHelper.getLocalURL(frag.getEntry("/META-INF/resources"))));
|
||||
}
|
||||
if (tldEnum != null && tldEnum.hasMoreElements())
|
||||
{
|
||||
if (tldfrags == null)
|
||||
{
|
||||
tldfrags = new ArrayList<Resource>();
|
||||
wah.setAttribute(TagLibConfiguration.TLD_RESOURCES, tldfrags);
|
||||
}
|
||||
while (tldEnum.hasMoreElements())
|
||||
{
|
||||
tldfrags.add(Resource.newResource(
|
||||
DefaultFileLocatorHelper.getLocalURL(tldEnum.nextElement())));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
__logger.warn("Unable to locate the bundle " + frag.getBundleId(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue