bug 306971 also replaced the require-bundle by pacakge imports
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1409 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
203d692be0
commit
eceb7b6ec6
|
@ -6,8 +6,11 @@ Bundle-SymbolicName: org.eclipse.jetty.osgi.boot.jsp;singleton:=true
|
|||
Bundle-Version: 7.0.2.qualifier
|
||||
Bundle-Vendor: Mort Bay Consulting
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
Require-Bundle: org.mortbay.jetty.jsp-2.1-glassfish
|
||||
Import-Package: javax.el;version="1.0.0";resolution:=optional,
|
||||
Import-Package: com.sun.el;resolution:=optional,
|
||||
com.sun.el.lang;resolution:=optional,
|
||||
com.sun.el.parser;resolution:=optional,
|
||||
com.sun.el.util;resolution:=optional,
|
||||
javax.el;version="1.0.0";resolution:=optional,
|
||||
javax.servlet.jsp;version="2.1.0",
|
||||
javax.servlet.jsp.el;version="2.1.0",
|
||||
javax.servlet.jsp.jstl.core;version="1.2.0";resolution:=optional,
|
||||
|
@ -16,4 +19,36 @@ Import-Package: javax.el;version="1.0.0";resolution:=optional,
|
|||
javax.servlet.jsp.jstl.tlv;version="1.2.0";resolution:=optional,
|
||||
javax.servlet.jsp.resources;version="2.1",
|
||||
javax.servlet.jsp.tagext;version="2.1",
|
||||
javax.servlet.resources;version="2.5.0"
|
||||
javax.servlet.resources;version="2.5.0",
|
||||
org.apache.jasper;version="6.0.0";resolution:=optional,
|
||||
org.apache.jasper.compiler;version="6.0.0";resolution:=optional,
|
||||
org.apache.jasper.compiler.tagplugin;version="6.0.0";resolution:=optional,
|
||||
org.apache.jasper.runtime;version="6.0.0";resolution:=optional,
|
||||
org.apache.jasper.security;version="6.0.0";resolution:=optional,
|
||||
org.apache.jasper.servlet;version="6.0.0";resolution:=optional,
|
||||
org.apache.jasper.tagplugins.jstl;version="6.0.0";resolution:=optional,
|
||||
org.apache.jasper.util;version="6.0.0";resolution:=optional,
|
||||
org.apache.jasper.xmlparser;version="6.0.0";resolution:=optional,
|
||||
org.apache.taglibs.standard;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.extra.spath;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.functions;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.lang.jstl;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.lang.jstl.parser;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.lang.jstl.test;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.lang.jstl.test.beans;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.lang.support;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.resources;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tag.common.core;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tag.common.fmt;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tag.common.sql;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tag.common.xml;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tag.el.core;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tag.el.fmt;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tag.el.sql;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tag.el.xml;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tag.rt.core;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tag.rt.fmt;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tag.rt.sql;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tag.rt.xml;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tei;version="1.2.0";resolution:=optional,
|
||||
org.apache.taglibs.standard.tlv;version="1.2.0";resolution:=optional
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009-2010 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
package org.eclipse.jetty.osgi.boot.jasper;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelper;
|
||||
import org.eclipse.jetty.osgi.boot.utils.WebappRegistrationCustomizer;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
|
||||
/**
|
||||
* Plug bundles that contains tld files so that jasper will discover them
|
||||
* and set them up in jetty.
|
||||
*
|
||||
* For example: -Djetty.osgi.tldbundles=org.springframework.web.servlet,com.opensymphony.module.sitemesh
|
||||
*/
|
||||
public class PluggableWebAppRegistrationCustomizerImpl implements WebappRegistrationCustomizer
|
||||
{
|
||||
|
||||
public static final String SYS_PROP_TLD_BUNDLES = "jetty.osgi.tldbundles";
|
||||
|
||||
private static Collection<String> getTldBundles()
|
||||
{
|
||||
String sysprop = System.getProperty(SYS_PROP_TLD_BUNDLES);
|
||||
if (sysprop == null)
|
||||
{
|
||||
return Collections.emptySet();
|
||||
}
|
||||
Collection<String> tldbundles = new HashSet<String>();
|
||||
StringTokenizer tokenizer = new StringTokenizer(sysprop, ", \n\r\t", false);
|
||||
while (tokenizer.hasMoreTokens())
|
||||
{
|
||||
tldbundles.add(tokenizer.nextToken());
|
||||
}
|
||||
return tldbundles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The location of the jars that contain tld files.
|
||||
* Jasper will discover them.
|
||||
*/
|
||||
public URL[] getJarsWithTlds(BundleFileLocatorHelper locatorHelper) throws Exception
|
||||
{
|
||||
List<URL> urls = new ArrayList<URL>();
|
||||
//naive way of finding those bundles.
|
||||
//lots of assumptions: for example we assume a single version of each bundle that would contain tld files.
|
||||
//this is probably good enough as those tlds are loaded system-wide on jetty.
|
||||
//to do better than this we need to do it on a per webapp basis.
|
||||
//probably using custom properties in the ContextHandler service
|
||||
//and mirroring those in the MANIFEST.MF
|
||||
|
||||
Bundle[] bundles = FrameworkUtil.getBundle(PluggableWebAppRegistrationCustomizerImpl.class).getBundleContext().getBundles();
|
||||
Collection<String> tldbundles = getTldBundles();
|
||||
for (Bundle bundle : bundles)
|
||||
{
|
||||
if (tldbundles.contains(bundle.getSymbolicName()))
|
||||
{
|
||||
registerTldBundle(locatorHelper, bundle, urls);
|
||||
}
|
||||
}
|
||||
|
||||
return urls.toArray(new URL[urls.size()]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the bundle that contains tld files as a set of URLs that will be
|
||||
* passed to jasper as a URLClassLoader later on.
|
||||
* Usually that would be a single URL per bundle.
|
||||
* But we do some more work if there are jars embedded in the bundle.
|
||||
*
|
||||
* The jasper TldScanner expects a URLClassloader to parse a jar for the /META-INF/*.tld it may contain. We place the bundles that we know contain such
|
||||
* tag-libraries. Please note that it will work if and only if the bundle is a jar (!) Currently we just hardcode the bundle that contains the jstl
|
||||
* implemenation.
|
||||
*
|
||||
* A workaround when the tld cannot be parsed with this method is to copy and paste it inside the WEB-INF of the webapplication where it is used.
|
||||
*
|
||||
* Support only 2 types of packaging for the bundle: - the bundle is a jar (recommended for runtime.) - the bundle is a folder and contain jars in the root
|
||||
* and/or in the lib folder (nice for PDE developement situations) Unsupported: the bundle is a jar that embeds more jars.
|
||||
*
|
||||
* @param locatorHelper
|
||||
* @param bundle
|
||||
* @param urls
|
||||
* @throws Exception
|
||||
*/
|
||||
private void registerTldBundle(BundleFileLocatorHelper locatorHelper, Bundle bundle, List<URL> urls) throws Exception
|
||||
{
|
||||
File jasperLocation = locatorHelper.getBundleInstallLocation(bundle);
|
||||
if (jasperLocation.isDirectory())
|
||||
{
|
||||
for (File f : jasperLocation.listFiles())
|
||||
{
|
||||
if (f.getName().endsWith(".jar") && f.isFile())
|
||||
{
|
||||
urls.add(f.toURI().toURL());
|
||||
}
|
||||
else if (f.isDirectory() && f.getName().equals("lib"))
|
||||
{
|
||||
for (File f2 : jasperLocation.listFiles())
|
||||
{
|
||||
if (f2.getName().endsWith(".jar") && f2.isFile())
|
||||
{
|
||||
urls.add(f2.toURI().toURL());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
urls.add(jasperLocation.toURI().toURL());
|
||||
}
|
||||
else
|
||||
{
|
||||
urls.add(jasperLocation.toURI().toURL());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
// ========================================================================
|
||||
// Copyright (c) 2009 Intalio, Inc.
|
||||
// Copyright (c) 2009-2010 Intalio, Inc.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
|
@ -23,7 +23,6 @@ import javax.servlet.jsp.JspFactory;
|
|||
|
||||
import org.apache.jasper.Constants;
|
||||
import org.apache.jasper.compiler.Localizer;
|
||||
import org.apache.jasper.compiler.TldLocationsCache;
|
||||
import org.apache.jasper.xmlparser.ParserUtils;
|
||||
import org.eclipse.jetty.osgi.boot.JettyBootstrapActivator;
|
||||
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelper;
|
||||
|
@ -36,10 +35,29 @@ import org.xml.sax.SAXException;
|
|||
|
||||
/**
|
||||
* Fix various shortcomings with the way jasper parses the tld files.
|
||||
* Plugs the JSTL tlds assuming that they are packaged with the bundle that contains the JSTL classes:
|
||||
*
|
||||
*/
|
||||
public class WebappRegistrationCustomizerImpl implements WebappRegistrationCustomizer
|
||||
{
|
||||
|
||||
/**
|
||||
* Default name of a class that belongs to the jstl bundle.
|
||||
* From that class we locate the corresponding bundle and register it
|
||||
* as a bundle that contains tld files.
|
||||
*/
|
||||
private static String DEFAULT_JSTL_BUNDLE_CLASS = "org.apache.taglibs.standard.tag.el.core.WhenTag";
|
||||
//used to be "org.apache.jasper.runtime.JspFactoryImpl" but now
|
||||
//the standard tag library implementation are stored in a separate bundle.
|
||||
|
||||
/**
|
||||
* Default jsp factory implementation.
|
||||
* Idally jasper is osgified and we can use services.
|
||||
* In the mean time we statically set the jsp factory implementation.
|
||||
* bug #299733
|
||||
*/
|
||||
private static String DEFAULT_JSP_FACTORY_IMPL_CLASS = "org.apache.jasper.runtime.JspFactoryImpl";
|
||||
|
||||
public WebappRegistrationCustomizerImpl()
|
||||
{
|
||||
fixupDtdResolution();
|
||||
|
@ -66,7 +84,7 @@ public class WebappRegistrationCustomizerImpl implements WebappRegistrationCusto
|
|||
//however its bundles does not import the jasper package
|
||||
//so it fails. let's help things out:
|
||||
fact = (JspFactory)JettyBootstrapActivator.class.getClassLoader()
|
||||
.loadClass("org.apache.jasper.runtime.JspFactoryImpl").newInstance();
|
||||
.loadClass(DEFAULT_JSP_FACTORY_IMPL_CLASS).newInstance();
|
||||
JspFactory.setDefaultFactory(fact);
|
||||
}
|
||||
|
||||
|
@ -95,7 +113,14 @@ public class WebappRegistrationCustomizerImpl implements WebappRegistrationCusto
|
|||
*/
|
||||
public URL[] getJarsWithTlds(BundleFileLocatorHelper locatorHelper) throws Exception
|
||||
{
|
||||
Bundle jasperBundler = FrameworkUtil.getBundle(TldLocationsCache.class);
|
||||
|
||||
//Look for the jstl bundle
|
||||
//We assume the jstl's tlds are defined there.
|
||||
//We assume that the jstl bundle is imported by this bundle
|
||||
//So we can look for this class using this bundle's classloader:
|
||||
Class<?> jstlClass = WebappRegistrationCustomizerImpl.class.getClassLoader().loadClass(DEFAULT_JSTL_BUNDLE_CLASS);
|
||||
|
||||
Bundle jasperBundler = FrameworkUtil.getBundle(jstlClass);
|
||||
File jasperLocation = locatorHelper.getBundleInstallLocation(jasperBundler);
|
||||
if (jasperLocation.isDirectory())
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
package org.eclipse.jetty.osgi.boot.jsp;
|
||||
|
||||
import org.eclipse.jetty.osgi.boot.internal.webapp.WebappRegistrationHelper;
|
||||
import org.eclipse.jetty.osgi.boot.jasper.PluggableWebAppRegistrationCustomizerImpl;
|
||||
import org.eclipse.jetty.osgi.boot.jasper.WebappRegistrationCustomizerImpl;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
@ -36,6 +37,7 @@ public class FragmentActivator implements BundleActivator
|
|||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
WebappRegistrationHelper.JSP_REGISTRATION_HELPERS.add(new WebappRegistrationCustomizerImpl());
|
||||
WebappRegistrationHelper.JSP_REGISTRATION_HELPERS.add(new PluggableWebAppRegistrationCustomizerImpl());
|
||||
// try {
|
||||
// FragmentActivator.class.getClassLoader().loadClass("does.not.exist");
|
||||
// } catch (Throwable t) {
|
||||
|
|
Loading…
Reference in New Issue