diff options
author | Hugues Malphettes | 2011-05-18 03:55:13 +0000 |
---|---|---|
committer | Hugues Malphettes | 2011-05-18 03:55:13 +0000 |
commit | 2585b4cd9485ad9bb074b80b69707e5631f286ac (patch) | |
tree | bb19edcc0e244a867c9e2554958cf53aa6dcc055 | |
parent | d6639b77b5c6fc635b8c6b3f4ecadbdd1eee7b62 (diff) | |
download | org.eclipse.jetty.project-2585b4cd9485ad9bb074b80b69707e5631f286ac.tar.gz org.eclipse.jetty.project-2585b4cd9485ad9bb074b80b69707e5631f286ac.tar.xz org.eclipse.jetty.project-2585b4cd9485ad9bb074b80b69707e5631f286ac.zip |
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
-rw-r--r-- | jetty-osgi/jetty-osgi-boot/META-INF/MANIFEST.MF | 2 | ||||
-rw-r--r-- | jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebBundleDeployerHelper.java | 74 |
2 files changed, 73 insertions, 3 deletions
diff --git a/jetty-osgi/jetty-osgi-boot/META-INF/MANIFEST.MF b/jetty-osgi/jetty-osgi-boot/META-INF/MANIFEST.MF index dbc515fd33..54da97ddcb 100644 --- a/jetty-osgi/jetty-osgi-boot/META-INF/MANIFEST.MF +++ b/jetty-osgi/jetty-osgi-boot/META-INF/MANIFEST.MF @@ -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, diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebBundleDeployerHelper.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebBundleDeployerHelper.java index 91564f6472..7ae65b966d 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebBundleDeployerHelper.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/webapp/WebBundleDeployerHelper.java @@ -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); + } + } + } + } } |