Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jetty-osgi/jetty-osgi-boot-jsp')
-rw-r--r--jetty-osgi/jetty-osgi-boot-jsp/pom.xml2
-rw-r--r--jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/ContainerTldBundleDiscoverer.java (renamed from jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/PluggableWebAppRegistrationCustomizerImpl.java)100
-rw-r--r--jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/JSTLBundleDiscoverer.java (renamed from jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/WebappRegistrationCustomizerImpl.java)17
-rw-r--r--jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jsp/FragmentActivator.java47
4 files changed, 67 insertions, 99 deletions
diff --git a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml
index 325448d0d6..a7e5645b29 100644
--- a/jetty-osgi/jetty-osgi-boot-jsp/pom.xml
+++ b/jetty-osgi/jetty-osgi-boot-jsp/pom.xml
@@ -2,7 +2,7 @@
<parent>
<groupId>org.eclipse.jetty.osgi</groupId>
<artifactId>jetty-osgi-project</artifactId>
- <version>9.0.1-SNAPSHOT</version>
+ <version>9.0.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-osgi-boot-jsp</artifactId>
diff --git a/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/PluggableWebAppRegistrationCustomizerImpl.java b/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/ContainerTldBundleDiscoverer.java
index 2521ed186d..f9c212a516 100644
--- a/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/PluggableWebAppRegistrationCustomizerImpl.java
+++ b/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/ContainerTldBundleDiscoverer.java
@@ -21,8 +21,6 @@ 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.Set;
@@ -32,67 +30,48 @@ import java.util.regex.Pattern;
import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.osgi.boot.OSGiWebInfConfiguration;
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelper;
-import org.eclipse.jetty.osgi.boot.utils.WebappRegistrationCustomizer;
+import org.eclipse.jetty.osgi.boot.utils.TldBundleDiscoverer;
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.
+ * ContainerTldBundleDiscoverer
+ *
+ *
+ * Use a System property to define bundles that contain tlds that need to
+ * be treated by jasper as if they were on the jetty container's classpath.
+ *
+ * The value of the property is evaluated against the DeploymentManager
+ * context attribute "org.eclipse.jetty.server.webapp.containerIncludeBundlePattern",
+ * which defines a pattern of matching bundle names.
+ *
+ * The bundle locations are converted to URLs for jasper's use.
+ *
+ * Eg:
+ * -Dorg.eclipse.jetty.osgi.tldbundles=org.springframework.web.servlet,com.opensymphony.module.sitemesh
*
- * For example:
- * -Dorg.eclipse.jetty.osgi.tldbundles=org.springframework.web.servlet
- * ,com.opensymphony.module.sitemesh Otherwise use an attribute to the
- * WebAppDeployer &lt;New
- * class="org.eclipse.jetty.deploy.providers.WebAppProvider"&gt; .... &lt;Set
- * name="tldBundles"&gt;&ltProperty name="org.eclipse.jetty.osgi.tldsbundles"
- * default="" /&gt;&lt;/Set&gt; &lt;New&gt;
*/
-public class PluggableWebAppRegistrationCustomizerImpl implements WebappRegistrationCustomizer
+public class ContainerTldBundleDiscoverer implements TldBundleDiscoverer
{
/**
- * To plug into jasper bundles that contain tld files please use a list of
- * bundle's symbolic names:
- * -Djetty.osgi.tldbundles=org.springframework.web.servlet
- * ,com.opensymphony.module.sitemesh
+ * Comma separated list of names of bundles that contain tld files that should be
+ * discoved by jasper as if they were on the container's classpath.
+ * Eg:
+ * -Djetty.osgi.tldbundles=org.springframework.web.servlet,com.opensymphony.module.sitemesh
*/
public static final String SYS_PROP_TLD_BUNDLES = "org.eclipse.jetty.osgi.tldbundles";
- /**
- * Union of the tld bundles defined system wide and the one defines as an
- * attribute of the AppProvider.
- *
- * @param provider
- * @return
- */
- private static Collection<String> getTldBundles(DeploymentManager deploymentManager)
- {
- String sysprop = System.getProperty(SYS_PROP_TLD_BUNDLES);
- String att = (String) deploymentManager.getContextAttribute(OSGiWebInfConfiguration.CONTAINER_BUNDLE_PATTERN);
- if (sysprop == null && att == null) { return Collections.emptySet(); }
- if (att == null)
- {
- att = sysprop;
- }
- else if (sysprop != null)
- {
- att = att + "," + sysprop;
- }
- Collection<String> tldbundles = new HashSet<String>();
- StringTokenizer tokenizer = new StringTokenizer(att, ", \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.
+ * Check the System property "org.eclipse.jetty.osgi.tldbundles" for names of
+ * bundles that contain tlds and convert to URLs.
+ *
+ * @return The location of the jars that contain tld files as URLs.
*/
- public URL[] getJarsWithTlds(DeploymentManager deploymentManager, BundleFileLocatorHelper locatorHelper) throws Exception
+ public URL[] getUrlsForBundlesWithTlds(DeploymentManager deploymentManager, BundleFileLocatorHelper locatorHelper) throws Exception
{
// naive way of finding those bundles.
// lots of assumptions: for example we assume a single version of each
@@ -103,7 +82,7 @@ public class PluggableWebAppRegistrationCustomizerImpl implements WebappRegistra
// probably using custom properties in the ContextHandler service
// and mirroring those in the MANIFEST.MF
- Bundle[] bundles = FrameworkUtil.getBundle(PluggableWebAppRegistrationCustomizerImpl.class).getBundleContext().getBundles();
+ Bundle[] bundles = FrameworkUtil.getBundle(ContainerTldBundleDiscoverer.class).getBundleContext().getBundles();
HashSet<URL> urls = new HashSet<URL>();
String tmp = System.getProperty(SYS_PROP_TLD_BUNDLES); //comma separated exact names
List<String> sysNames = new ArrayList<String>();
@@ -118,10 +97,10 @@ public class PluggableWebAppRegistrationCustomizerImpl implements WebappRegistra
for (Bundle bundle : bundles)
{
if (sysNames.contains(bundle.getSymbolicName()))
- registerTldBundle(locatorHelper, bundle, urls);
+ convertBundleLocationToURL(locatorHelper, bundle, urls);
if (pattern != null && pattern.matcher(bundle.getSymbolicName()).matches())
- registerTldBundle(locatorHelper, bundle, urls);
+ convertBundleLocationToURL(locatorHelper, bundle, urls);
}
return urls.toArray(new URL[urls.size()]);
@@ -129,19 +108,8 @@ public class PluggableWebAppRegistrationCustomizerImpl implements WebappRegistra
}
/**
- * 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.
+ * Resolves a bundle that contains tld files as a URL. The URLs are
+ * used by jasper to discover the tld files.
*
* 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
@@ -153,7 +121,7 @@ public class PluggableWebAppRegistrationCustomizerImpl implements WebappRegistra
* @param urls
* @throws Exception
*/
- private void registerTldBundle(BundleFileLocatorHelper locatorHelper, Bundle bundle, Set<URL> urls) throws Exception
+ private void convertBundleLocationToURL(BundleFileLocatorHelper locatorHelper, Bundle bundle, Set<URL> urls) throws Exception
{
File jasperLocation = locatorHelper.getBundleInstallLocation(bundle);
if (jasperLocation.isDirectory())
@@ -181,7 +149,5 @@ public class PluggableWebAppRegistrationCustomizerImpl implements WebappRegistra
{
urls.add(jasperLocation.toURI().toURL());
}
-
}
-
} \ No newline at end of file
diff --git a/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/WebappRegistrationCustomizerImpl.java b/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/JSTLBundleDiscoverer.java
index 7b744b99cd..23628c39e7 100644
--- a/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/WebappRegistrationCustomizerImpl.java
+++ b/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jasper/JSTLBundleDiscoverer.java
@@ -34,7 +34,7 @@ import org.apache.jasper.xmlparser.ParserUtils;
import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.osgi.boot.JettyBootstrapActivator;
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelper;
-import org.eclipse.jetty.osgi.boot.utils.WebappRegistrationCustomizer;
+import org.eclipse.jetty.osgi.boot.utils.TldBundleDiscoverer;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.osgi.framework.Bundle;
@@ -44,17 +44,20 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
+ *
+ * JSTLBundleDiscoverer
+ *
* 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.
* <p>
* Pluggable tlds at the server level are handled by
- * {@link PluggableWebAppRegistrationCustomizerImpl}.
+ * {@link ContainerTldBundleDiscoverer}.
* </p>
*/
-public class WebappRegistrationCustomizerImpl implements WebappRegistrationCustomizer
+public class JSTLBundleDiscoverer implements TldBundleDiscoverer
{
- private static final Logger LOG = Log.getLogger(WebappRegistrationCustomizerImpl.class);
+ private static final Logger LOG = Log.getLogger(JSTLBundleDiscoverer.class);
/**
@@ -83,7 +86,7 @@ public class WebappRegistrationCustomizerImpl implements WebappRegistrationCusto
*/
private static String DEFAULT_JSP_FACTORY_IMPL_CLASS = "org.apache.jasper.runtime.JspFactoryImpl";
- public WebappRegistrationCustomizerImpl()
+ public JSTLBundleDiscoverer()
{
fixupDtdResolution();
@@ -136,7 +139,7 @@ public class WebappRegistrationCustomizerImpl implements WebappRegistrationCusto
* @return array of URLs
* @throws Exception
*/
- public URL[] getJarsWithTlds(DeploymentManager deployer, BundleFileLocatorHelper locatorHelper) throws Exception
+ public URL[] getUrlsForBundlesWithTlds(DeploymentManager deployer, BundleFileLocatorHelper locatorHelper) throws Exception
{
ArrayList<URL> urls = new ArrayList<URL>();
@@ -148,7 +151,7 @@ public class WebappRegistrationCustomizerImpl implements WebappRegistrationCusto
// So we can look for this class using this bundle's classloader:
try
{
- Class<?> jstlClass = WebappRegistrationCustomizerImpl.class.getClassLoader().loadClass(DEFAULT_JSTL_BUNDLE_CLASS);
+ Class<?> jstlClass = JSTLBundleDiscoverer.class.getClassLoader().loadClass(DEFAULT_JSTL_BUNDLE_CLASS);
classesToAddToTheTldBundles.add(jstlClass);
}
diff --git a/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jsp/FragmentActivator.java b/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jsp/FragmentActivator.java
index 9741d21c7d..b17270224f 100644
--- a/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jsp/FragmentActivator.java
+++ b/jetty-osgi/jetty-osgi-boot-jsp/src/main/java/org/eclipse/jetty/osgi/boot/jsp/FragmentActivator.java
@@ -19,21 +19,26 @@
package org.eclipse.jetty.osgi.boot.jsp;
import org.eclipse.jetty.osgi.boot.BundleWebAppProvider;
-import org.eclipse.jetty.osgi.boot.internal.webapp.WebBundleTrackerCustomizer;
-import org.eclipse.jetty.osgi.boot.jasper.PluggableWebAppRegistrationCustomizerImpl;
-import org.eclipse.jetty.osgi.boot.jasper.WebappRegistrationCustomizerImpl;
+import org.eclipse.jetty.osgi.boot.internal.serverfactory.ServerInstanceWrapper;
+import org.eclipse.jetty.osgi.boot.jasper.ContainerTldBundleDiscoverer;
+import org.eclipse.jetty.osgi.boot.jasper.JSTLBundleDiscoverer;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
/**
- * Pseudo fragment activator. Called by the main org.eclipse.jetty.osgi.boot
- * bundle. Please note: this is not a real BundleActivator. Simply something
- * called back by the host bundle.
- * <p>
- * It must be placed in the org.eclipse.jetty.osgi.boot.jsp package: this is
- * because org.eclipse.jetty.osgi.boot.jsp is the symbolic-name of this
- * fragment. From that name, the PackageadminTracker will call this class. IN a
- * different package it won't be called.
+ * FragmentActivator
+ *
+ * Sets up support for jsp. All relevant jsp jars must also be installed
+ * into the osgi environment.
+ * <p>
+ * Note that as this is part of a bundle fragment, this activator is NOT
+ * called by the OSGi environment. Instead, the org.eclipse.jetty.osgi.boot.utils.internal.PackageAdminTracker
+ * simulates fragment activation and causes this class's start() method to
+ * be called.
+ * </p>
+ * <p>
+ * The package of this class MUST match the Bundle-SymbolicName of this fragment
+ * in order for the PackageAdminTracker to find it.
* </p>
*/
public class FragmentActivator implements BundleActivator
@@ -43,12 +48,14 @@ public class FragmentActivator implements BundleActivator
*/
public void start(BundleContext context) throws Exception
{
+ //jsr199 compilation does not work in osgi
System.setProperty("org.apache.jasper.compiler.disablejsr199", Boolean.TRUE.toString());
- WebBundleTrackerCustomizer.JSP_REGISTRATION_HELPERS.add(new WebappRegistrationCustomizerImpl());
- WebBundleTrackerCustomizer.JSP_REGISTRATION_HELPERS.add(new PluggableWebAppRegistrationCustomizerImpl());
- //Put in the support for the tag libs
- addTagLibSupport();
-
+
+ //set up some classes that will look for bundles with tlds that must be converted
+ //to urls and treated as if they are on the Jetty container's classpath so that
+ //jasper can deal with them
+ ServerInstanceWrapper.addContainerTldBundleDiscoverer(new JSTLBundleDiscoverer());
+ ServerInstanceWrapper.addContainerTldBundleDiscoverer(new ContainerTldBundleDiscoverer());
}
/**
@@ -58,12 +65,4 @@ public class FragmentActivator implements BundleActivator
{
}
-
- public void addTagLibSupport ()
- {
- String[] defaultConfigurations = new String[BundleWebAppProvider.getDefaultConfigurations().length+1];
- System.arraycopy(BundleWebAppProvider.getDefaultConfigurations(), 0, defaultConfigurations, 0, BundleWebAppProvider.getDefaultConfigurations().length);
- defaultConfigurations[defaultConfigurations.length-1] = "org.eclipse.jetty.osgi.boot.jsp.TagLibOSGiConfiguration";
- BundleWebAppProvider.setDefaultConfigurations(defaultConfigurations);
- }
}

Back to the top