459681 Remove dead code after removal of glassfish jasper support
This commit is contained in:
parent
adaa520cc9
commit
b494fc36c5
|
@ -19,19 +19,13 @@
|
|||
package org.eclipse.jetty.osgi.boot.jasper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.jsp.JspContext;
|
||||
import javax.servlet.jsp.JspFactory;
|
||||
|
||||
import org.apache.jasper.Constants;
|
||||
import org.apache.jasper.compiler.Localizer;
|
||||
import org.eclipse.jetty.deploy.DeploymentManager;
|
||||
import org.eclipse.jetty.osgi.boot.JettyBootstrapActivator;
|
||||
import org.eclipse.jetty.osgi.boot.utils.BundleFileLocatorHelper;
|
||||
|
@ -40,9 +34,6 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.xml.sax.EntityResolver;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -68,17 +59,7 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
*/
|
||||
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.
|
||||
|
||||
// DISABLED please use the tld bundle argument for the OSGiAppProvider
|
||||
// /**
|
||||
// * Default name of a class that belongs to the bundle where the Java
|
||||
// server Faces tld files are defined.
|
||||
// * This is the sun's reference implementation.
|
||||
// */
|
||||
// private static String DEFAUT_JSF_IMPL_CLASS =
|
||||
// "com.sun.faces.config.ConfigureListener";
|
||||
|
||||
|
||||
/**
|
||||
* Default jsp factory implementation. Idally jasper is osgified and we can
|
||||
|
@ -91,8 +72,6 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
|
||||
public JSTLBundleDiscoverer()
|
||||
{
|
||||
//fixupDtdResolution();
|
||||
|
||||
try
|
||||
{
|
||||
// sanity check:
|
||||
|
@ -168,8 +147,6 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
Bundle tldBundle = FrameworkUtil.getBundle(jstlClass);
|
||||
File tldBundleLocation = locatorHelper.getBundleInstallLocation(tldBundle);
|
||||
|
||||
System.err.println("jstl bundle: "+tldBundle);
|
||||
System.err.println("jstl bundle location: "+tldBundleLocation);
|
||||
if (tldBundleLocation != null && tldBundleLocation.isDirectory())
|
||||
{
|
||||
// try to find the jar files inside this folder
|
||||
|
@ -177,7 +154,6 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
{
|
||||
if (f.getName().endsWith(".jar") && f.isFile())
|
||||
{
|
||||
System.err.println("Tld jar in dir: "+f.toURI());
|
||||
urls.add(f.toURI().toURL());
|
||||
}
|
||||
else if (f.isDirectory() && f.getName().equals("lib"))
|
||||
|
@ -186,7 +162,6 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
{
|
||||
if (f2.getName().endsWith(".jar") && f2.isFile())
|
||||
{
|
||||
System.err.println("Tld jar in lib dir: "+f2.toURI());
|
||||
urls.add(f2.toURI().toURL());
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +171,6 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
}
|
||||
else if (tldBundleLocation != null)
|
||||
{
|
||||
System.err.println("Tld bundle uri: "+tldBundleLocation.toURI());
|
||||
urls.add(tldBundleLocation.toURI().toURL());
|
||||
|
||||
String pattern = (String)deployer.getContextAttribute("org.eclipse.jetty.server.webapp.containerIncludeBundlePattern");
|
||||
|
@ -206,90 +180,10 @@ public class JSTLBundleDiscoverer implements TldBundleDiscoverer
|
|||
pattern += "|"+tldBundle.getSymbolicName();
|
||||
deployer.setContextAttribute("org.eclipse.jetty.server.webapp.containerIncludeBundlePattern", pattern);
|
||||
}
|
||||
System.err.println("PATTERN: "+pattern);
|
||||
}
|
||||
}
|
||||
|
||||
return urls.toArray(new URL[urls.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Jasper resolves the dtd when it parses a taglib descriptor. It uses this
|
||||
* code to do that:
|
||||
* ParserUtils.getClass().getResourceAsStream(resourcePath); where
|
||||
* resourcePath is for example:
|
||||
* /javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd Unfortunately, the
|
||||
* dtd file is not in the exact same classloader as ParserUtils class and
|
||||
* the dtds are packaged in 2 separate bundles. OSGi does not look in the
|
||||
* dependencies' classloader when a resource is searched.
|
||||
* <p>
|
||||
* The workaround consists of setting the entity resolver. That is a patch
|
||||
* added to the version of glassfish-jasper-jetty. IT is also present in the
|
||||
* latest version of glassfish jasper. Could not use introspection to set
|
||||
* new value on a static friendly field :(
|
||||
* </p>
|
||||
*/
|
||||
void fixupDtdResolution()
|
||||
{
|
||||
try
|
||||
{
|
||||
// ParserUtils.setEntityResolver(new MyFixedupEntityResolver());
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instead of using the ParserUtil's classloader, we use a class that is
|
||||
* indeed next to the resource for sure.
|
||||
*/
|
||||
//static class MyFixedupEntityResolver implements EntityResolver
|
||||
//{
|
||||
/**
|
||||
* Same values than in ParserUtils...
|
||||
*/
|
||||
/* static final String[] CACHED_DTD_PUBLIC_IDS = { Constants.TAGLIB_DTD_PUBLIC_ID_11, Constants.TAGLIB_DTD_PUBLIC_ID_12,
|
||||
Constants.WEBAPP_DTD_PUBLIC_ID_22, Constants.WEBAPP_DTD_PUBLIC_ID_23, };
|
||||
|
||||
static final String[] CACHED_DTD_RESOURCE_PATHS = { Constants.TAGLIB_DTD_RESOURCE_PATH_11, Constants.TAGLIB_DTD_RESOURCE_PATH_12,
|
||||
Constants.WEBAPP_DTD_RESOURCE_PATH_22, Constants.WEBAPP_DTD_RESOURCE_PATH_23, };
|
||||
|
||||
static final String[] CACHED_SCHEMA_RESOURCE_PATHS = { Constants.TAGLIB_SCHEMA_RESOURCE_PATH_20, Constants.TAGLIB_SCHEMA_RESOURCE_PATH_21,
|
||||
Constants.WEBAPP_SCHEMA_RESOURCE_PATH_24, Constants.WEBAPP_SCHEMA_RESOURCE_PATH_25, };*/
|
||||
|
||||
/* public InputSource resolveEntity(String publicId, String systemId) throws SAXException
|
||||
{
|
||||
for (int i = 0; i < CACHED_DTD_PUBLIC_IDS.length; i++)
|
||||
{
|
||||
String cachedDtdPublicId = CACHED_DTD_PUBLIC_IDS[i];
|
||||
if (cachedDtdPublicId.equals(publicId))
|
||||
{
|
||||
String resourcePath = CACHED_DTD_RESOURCE_PATHS[i];
|
||||
InputStream input = null;
|
||||
input = Servlet.class.getResourceAsStream(resourcePath);
|
||||
if (input == null)
|
||||
{
|
||||
input = JspContext.class.getResourceAsStream(resourcePath);
|
||||
if (input == null)
|
||||
{*/
|
||||
// if that failed try again with the original code:
|
||||
// although it is likely not changed.
|
||||
/* input = this.getClass().getResourceAsStream(resourcePath);
|
||||
}
|
||||
}
|
||||
if (input == null) { throw new SAXException(Localizer.getMessage("jsp.error.internal.filenotfound", resourcePath)); }
|
||||
InputSource isrc = new InputSource(input);
|
||||
return isrc;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
|
@ -91,11 +91,11 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
|||
private transient boolean _enabled = true;
|
||||
private transient UnavailableException _unavailableEx;
|
||||
|
||||
public static final String GLASSFISH_SENTINEL_CLASS = "org.glassfish.jsp.api.ResourceInjector";
|
||||
|
||||
public static final String APACHE_SENTINEL_CLASS = "org.apache.tomcat.InstanceManager";
|
||||
public static final String JSP_GENERATED_PACKAGE_NAME = "org.eclipse.jetty.servlet.jspPackagePrefix";
|
||||
public static final Map<String,String> NO_MAPPED_ROLES = Collections.emptyMap();
|
||||
public static enum JspContainer {GLASSFISH, APACHE, OTHER};
|
||||
public static enum JspContainer {APACHE, OTHER};
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/** Constructor .
|
||||
|
@ -653,9 +653,6 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
|||
/* Set the webapp's classpath for Jasper */
|
||||
ch.setAttribute("org.apache.catalina.jsp_classpath", ch.getClassPath());
|
||||
|
||||
/* Set the system classpath for Jasper */
|
||||
setInitParameter("com.sun.appserv.jsp.classpath", Loader.getClassPath(ch.getClassLoader().getParent()));
|
||||
|
||||
/* Set up other classpath attribute */
|
||||
if ("?".equals(getInitParameter("classpath")))
|
||||
{
|
||||
|
@ -859,13 +856,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
|||
/* ------------------------------------------------------------ */
|
||||
private void adaptForcedPathToJspContainer (ServletRequest request)
|
||||
{
|
||||
if (_forcedPath != null && _jspContainer != null && JspContainer.GLASSFISH.equals(_jspContainer))
|
||||
{
|
||||
//if container is glassfish, set the request attribute org.apache.catalina.jsp_file to
|
||||
//ensure the delegate jsp will be compiled
|
||||
|
||||
request.setAttribute("org.apache.catalina.jsp_file",_forcedPath);
|
||||
}
|
||||
//no-op for apache jsp
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -873,29 +864,17 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
|||
{
|
||||
if (_jspContainer == null)
|
||||
{
|
||||
//check for glassfish
|
||||
try
|
||||
{
|
||||
//if container is glassfish, set the request attribute org.apache.catalina.jsp_file to
|
||||
//ensure the delegate jsp will be compiled
|
||||
Loader.loadClass(Holder.class, GLASSFISH_SENTINEL_CLASS);
|
||||
if (LOG.isDebugEnabled())LOG.debug("Glassfish jasper detected");
|
||||
_jspContainer = JspContainer.GLASSFISH;
|
||||
//check for apache
|
||||
Loader.loadClass(Holder.class, APACHE_SENTINEL_CLASS);
|
||||
if (LOG.isDebugEnabled())LOG.debug("Apache jasper detected");
|
||||
_jspContainer = JspContainer.APACHE;
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
catch (ClassNotFoundException x)
|
||||
{
|
||||
try
|
||||
{
|
||||
//check for apache
|
||||
Loader.loadClass(Holder.class, APACHE_SENTINEL_CLASS);
|
||||
if (LOG.isDebugEnabled())LOG.debug("Apache jasper detected");
|
||||
_jspContainer = JspContainer.APACHE;
|
||||
}
|
||||
catch (ClassNotFoundException x)
|
||||
{
|
||||
if (LOG.isDebugEnabled())LOG.debug("Other jasper detected");
|
||||
_jspContainer = JspContainer.OTHER;
|
||||
}
|
||||
if (LOG.isDebugEnabled())LOG.debug("Other jasper detected");
|
||||
_jspContainer = JspContainer.OTHER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue