unpack WEB-INF
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@609 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
be33ce84fd
commit
e6b43daf54
|
@ -154,38 +154,7 @@ public class WebAppClassLoader extends URLClassLoader
|
|||
// Add resource or expand jar/
|
||||
if (!resource.isDirectory() && file == null)
|
||||
{
|
||||
InputStream in= resource.getInputStream();
|
||||
File tmp_dir=_context.getTempDirectory();
|
||||
if (tmp_dir==null)
|
||||
{
|
||||
tmp_dir = File.createTempFile("jetty.cl.lib",null);
|
||||
tmp_dir.mkdir();
|
||||
tmp_dir.deleteOnExit();
|
||||
}
|
||||
File lib= new File(tmp_dir, "lib");
|
||||
if (!lib.exists())
|
||||
{
|
||||
lib.mkdir();
|
||||
lib.deleteOnExit();
|
||||
}
|
||||
File jar= File.createTempFile("Jetty-", ".jar", lib);
|
||||
|
||||
jar.deleteOnExit();
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("Extract " + resource + " to " + jar);
|
||||
FileOutputStream out = null;
|
||||
try
|
||||
{
|
||||
out= new FileOutputStream(jar);
|
||||
IO.copy(in, out);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IO.close(out);
|
||||
}
|
||||
|
||||
URL url= jar.toURL();
|
||||
addURL(url);
|
||||
throw new IllegalArgumentException("!file: "+resource);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -378,22 +378,16 @@ public class WebInfConfiguration implements Configuration
|
|||
// No - then lets see if it can be turned into a jar URL.
|
||||
Resource jarWebApp = context.newResource("jar:" + web_app + "!/");
|
||||
if (jarWebApp.exists() && jarWebApp.isDirectory())
|
||||
{
|
||||
web_app= jarWebApp;
|
||||
}
|
||||
}
|
||||
|
||||
// If we should extract or the URL is still not usable
|
||||
if (web_app.exists() &&
|
||||
(
|
||||
(context.isCopyWebDir() && web_app.getFile()!= null && web_app.getFile().isDirectory())
|
||||
||
|
||||
(context.isExtractWAR() && web_app.getFile()!= null && !web_app.getFile().isDirectory())
|
||||
||
|
||||
(context.isExtractWAR() && web_app.getFile() == null)
|
||||
||
|
||||
!web_app.isDirectory()
|
||||
))
|
||||
if (web_app.exists() && (
|
||||
(context.isCopyWebDir() && web_app.getFile() != null && web_app.getFile().isDirectory()) ||
|
||||
(context.isExtractWAR() && web_app.getFile() != null && !web_app.getFile().isDirectory()) ||
|
||||
(context.isExtractWAR() && web_app.getFile() == null) ||
|
||||
!web_app.isDirectory())
|
||||
)
|
||||
{
|
||||
// Then extract it if necessary to the temporary location
|
||||
File extractedWebAppDir= new File(context.getTempDirectory(), "webapp");
|
||||
|
@ -441,6 +435,21 @@ public class WebInfConfiguration implements Configuration
|
|||
if (Log.isDebugEnabled())
|
||||
Log.debug("webapp=" + web_app);
|
||||
}
|
||||
|
||||
// Do we need to extract WEB-INF/lib?
|
||||
Resource web_inf= web_app.addPath("WEB-INF/");
|
||||
if (web_inf.exists() && web_inf.isDirectory() && (web_inf.getFile()==null || !web_app.getFile().isDirectory()))
|
||||
{
|
||||
File extractedWebInfDir= new File(context.getTempDirectory(), "webinf");
|
||||
if (extractedWebInfDir.exists())
|
||||
extractedWebInfDir.delete();
|
||||
extractedWebInfDir.mkdir();
|
||||
Log.info("Extract " + web_inf + " to " + extractedWebInfDir);
|
||||
JarResource.extract(web_app, extractedWebInfDir, false);
|
||||
web_inf=Resource.newResource(extractedWebInfDir.toURL());
|
||||
ResourceCollection rc = new ResourceCollection(new Resource[]{web_inf,web_app});
|
||||
context.setBaseResource(rc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ detected.
|
|||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<!-- Optional context configuration -->
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
<Set name="extractWAR">false</Set>
|
||||
<Set name="extractWAR">true</Set>
|
||||
<Set name="copyWebDir">false</Set>
|
||||
<Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
|
||||
<Set name="overrideDescriptor"><SystemProperty name="jetty.home" default="."/>/contexts/test.d/override-web.xml</Set>
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<web-app
|
||||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
version="3.0">
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
|
||||
<display-name>Test WebApp</display-name>
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
|||
<filter>
|
||||
<filter-name>QoSFilter</filter-name>
|
||||
<filter-class>org.eclipse.jetty.servlets.QoSFilter</filter-class>
|
||||
<async-support>true</async-support>
|
||||
<init-param>
|
||||
<param-name>maxRequests</param-name>
|
||||
<param-value>20</param-value>
|
||||
|
@ -30,7 +29,6 @@
|
|||
<filter>
|
||||
<filter-name>MultiPart</filter-name>
|
||||
<filter-class>org.eclipse.jetty.servlets.MultiPartFilter</filter-class>
|
||||
<async-support>true</async-support>
|
||||
<init-param>
|
||||
<param-name>deleteFiles</param-name>
|
||||
<param-value>true</param-value>
|
||||
|
@ -44,7 +42,6 @@
|
|||
<filter>
|
||||
<filter-name>GzipFilter</filter-name>
|
||||
<filter-class>org.eclipse.jetty.servlets.IncludableGzipFilter</filter-class>
|
||||
<async-support>true</async-support>
|
||||
<init-param>
|
||||
<param-name>bufferSize</param-name>
|
||||
<param-value>8192</param-value>
|
||||
|
@ -105,7 +102,6 @@
|
|||
<servlet>
|
||||
<servlet-name>Dump</servlet-name>
|
||||
<servlet-class>com.acme.Dump</servlet-class>
|
||||
<async-support>true</async-support>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
<run-as><role-name>admin</role-name></run-as>
|
||||
</servlet>
|
||||
|
@ -141,7 +137,6 @@
|
|||
<servlet>
|
||||
<servlet-name>Dispatch</servlet-name>
|
||||
<servlet-class>com.acme.DispatchServlet</servlet-class>
|
||||
<async-support>true</async-support>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
|
@ -164,7 +159,6 @@
|
|||
<servlet>
|
||||
<servlet-name>Chat</servlet-name>
|
||||
<servlet-class>com.acme.ChatServlet</servlet-class>
|
||||
<async-support>true</async-support>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
|
@ -176,13 +170,13 @@
|
|||
<servlet>
|
||||
<servlet-name>TransparentProxy</servlet-name>
|
||||
<servlet-class>org.eclipse.jetty.servlets.ProxyServlet$Transparent</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
<init-param>
|
||||
<param-name>ProxyTo</param-name><param-value>http://jetty.mortbay.org/test</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>Prefix</param-name><param-value>/jetty</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>ProxyTo</param-name><param-value>http://jetty.mortbay.org/test</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
|
|
Loading…
Reference in New Issue