367680 jsp-file with load-on-startup not precompiled
This commit is contained in:
parent
7d662360f1
commit
7db7620c36
|
@ -846,7 +846,7 @@ public class ServletHandler extends ScopedHandler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (servlet.getClassName() == null && servlet.getForcedPath() != null)
|
/* if (servlet.getClassName() == null && servlet.getForcedPath() != null)
|
||||||
{
|
{
|
||||||
ServletHolder forced_holder = _servletPathMap.match(servlet.getForcedPath());
|
ServletHolder forced_holder = _servletPathMap.match(servlet.getForcedPath());
|
||||||
if (forced_holder == null || forced_holder.getClassName() == null)
|
if (forced_holder == null || forced_holder.getClassName() == null)
|
||||||
|
@ -854,8 +854,9 @@ public class ServletHandler extends ScopedHandler
|
||||||
mx.add(new IllegalStateException("No forced path servlet for " + servlet.getForcedPath()));
|
mx.add(new IllegalStateException("No forced path servlet for " + servlet.getForcedPath()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
System.err.println("ServletHandler setting forced path classname to "+forced_holder.getClassName()+ " for "+servlet.getForcedPath());
|
||||||
servlet.setClassName(forced_holder.getClassName());
|
servlet.setClassName(forced_holder.getClassName());
|
||||||
}
|
}*/
|
||||||
|
|
||||||
servlet.start();
|
servlet.start();
|
||||||
servlet.initialize();
|
servlet.initialize();
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.eclipse.jetty.servlet;
|
package org.eclipse.jetty.servlet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -86,6 +87,8 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
||||||
private transient long _unavailable;
|
private transient long _unavailable;
|
||||||
private transient boolean _enabled = true;
|
private transient boolean _enabled = true;
|
||||||
private transient UnavailableException _unavailableEx;
|
private transient UnavailableException _unavailableEx;
|
||||||
|
|
||||||
|
public static final String JSP_GENERATED_PACKAGE_NAME = "org.eclipse.jetty.jspPackagePrefix";
|
||||||
public static final Map<String,String> NO_MAPPED_ROLES = Collections.emptyMap();
|
public static final Map<String,String> NO_MAPPED_ROLES = Collections.emptyMap();
|
||||||
|
|
||||||
/* ---------------------------------------------------------------- */
|
/* ---------------------------------------------------------------- */
|
||||||
|
@ -277,8 +280,6 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
||||||
public void doStart()
|
public void doStart()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
_unavailable=0;
|
_unavailable=0;
|
||||||
if (!_enabled)
|
if (!_enabled)
|
||||||
return;
|
return;
|
||||||
|
@ -287,8 +288,8 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
||||||
if (_forcedPath != null)
|
if (_forcedPath != null)
|
||||||
{
|
{
|
||||||
// Look for a precompiled JSP Servlet
|
// Look for a precompiled JSP Servlet
|
||||||
String precompiled="org.apache.jsp"+_forcedPath.replace('.','_').replace('/','.');
|
String precompiled=getClassNameForJsp(_forcedPath);
|
||||||
|
LOG.debug("Checking for precompiled servlet {} for jsp {}", precompiled, _forcedPath);
|
||||||
ServletHolder jsp=getServletHandler().getServlet(precompiled);
|
ServletHolder jsp=getServletHandler().getServlet(precompiled);
|
||||||
if (jsp!=null)
|
if (jsp!=null)
|
||||||
{
|
{
|
||||||
|
@ -298,12 +299,24 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Look for normal JSP servlet
|
if (getClassName() == null)
|
||||||
jsp=getServletHandler().getServlet("jsp");
|
|
||||||
if (jsp!=null)
|
|
||||||
{
|
{
|
||||||
LOG.debug("JSP file {} for {} mapped to Servlet {}",_forcedPath, getName(),jsp.getClassName());
|
// Look for normal JSP servlet
|
||||||
setClassName(jsp.getClassName());
|
jsp=getServletHandler().getServlet("jsp");
|
||||||
|
if (jsp!=null)
|
||||||
|
{
|
||||||
|
LOG.debug("JSP file {} for {} mapped to Servlet {}",_forcedPath, getName(),jsp.getClassName());
|
||||||
|
setClassName(jsp.getClassName());
|
||||||
|
//copy jsp init params that don't exist for this servlet
|
||||||
|
for (Map.Entry<String, String> entry:jsp.getInitParameters().entrySet())
|
||||||
|
{
|
||||||
|
if (!_initParams.containsKey(entry.getKey()))
|
||||||
|
setInitParameter(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
//jsp specific: set up the jsp-file on the JspServlet so it can precompile iff load-on-startup is >=0
|
||||||
|
if (_initOnStartup)
|
||||||
|
setInitParameter("jspFile", _forcedPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -786,6 +799,78 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
private String getNameOfJspClass (String jsp)
|
||||||
|
{
|
||||||
|
if (jsp == null)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
int i = jsp.lastIndexOf('/') + 1;
|
||||||
|
jsp = jsp.substring(i);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Class jspUtil = Loader.loadClass(Holder.class, "org.apache.jasper.compiler.JspUtil");
|
||||||
|
Method makeJavaIdentifier = jspUtil.getMethod("makeJavaIdentifier", String.class);
|
||||||
|
return (String)makeJavaIdentifier.invoke(null, jsp);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
String tmp = jsp.replace('.','_');
|
||||||
|
LOG.warn("Unable to make identifier for jsp "+jsp +" trying "+tmp+" instead");
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.warn(e);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
private String getPackageOfJspClass (String jsp)
|
||||||
|
{
|
||||||
|
if (jsp == null)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
int i = jsp.lastIndexOf('/');
|
||||||
|
if (i <= 0)
|
||||||
|
return "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Class jspUtil = Loader.loadClass(Holder.class, "org.apache.jasper.compiler.JspUtil");
|
||||||
|
Method makeJavaPackage = jspUtil.getMethod("makeJavaPackage", String.class);
|
||||||
|
return (String)makeJavaPackage.invoke(null, jsp.substring(0,i));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
String tmp = jsp.substring(1).replace('/','.');
|
||||||
|
LOG.warn("Unable to make package for jsp "+jsp +" trying "+tmp+" instead");
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.warn(e);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
private String getJspPackagePrefix ()
|
||||||
|
{
|
||||||
|
String jspPackageName = (String)getServletHandler().getServletContext().getAttribute(JSP_GENERATED_PACKAGE_NAME );
|
||||||
|
if (jspPackageName == null)
|
||||||
|
jspPackageName = "org.apache.jsp";
|
||||||
|
|
||||||
|
return jspPackageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
private String getClassNameForJsp (String jsp)
|
||||||
|
{
|
||||||
|
if (jsp == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return getJspPackagePrefix() + "." +getPackageOfJspClass(jsp) + "." + getNameOfJspClass(jsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
Loading…
Reference in New Issue