Merge branch 'master' into jetty-8
This commit is contained in:
commit
0731cbe64d
|
@ -18,6 +18,8 @@ import java.io.InputStream;
|
|||
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -41,6 +43,8 @@ public interface HttpContent
|
|||
/* ------------------------------------------------------------ */
|
||||
public class ResourceAsHttpContent implements HttpContent
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ResourceAsHttpContent.class);
|
||||
|
||||
final Resource _resource;
|
||||
final Buffer _mimeType;
|
||||
final int _maxBuffer;
|
||||
|
@ -80,18 +84,34 @@ public interface HttpContent
|
|||
/* ------------------------------------------------------------ */
|
||||
public Buffer getIndirectBuffer()
|
||||
{
|
||||
InputStream inputStream = null;
|
||||
try
|
||||
{
|
||||
if (_resource.length()<=0 || _maxBuffer<_resource.length())
|
||||
if (_resource.length() <= 0 || _maxBuffer < _resource.length())
|
||||
return null;
|
||||
ByteArrayBuffer buffer = new ByteArrayBuffer((int)_resource.length());
|
||||
buffer.readFrom(_resource.getInputStream(),(int)_resource.length());
|
||||
inputStream = _resource.getInputStream();
|
||||
buffer.readFrom(inputStream,(int)_resource.length());
|
||||
return buffer;
|
||||
}
|
||||
catch(IOException e)
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (inputStream != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
inputStream.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOG.warn("Couldn't close inputStream. Possible file handle leak",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -55,25 +55,24 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
|
|||
*
|
||||
* Here is a typical jetty.xml configuration would be: <pre>
|
||||
*
|
||||
* <Set name="handler">
|
||||
* <New id="Handlers" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
|
||||
* <New id="RewriteHandler" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
|
||||
* <Set name="rules">
|
||||
* <Array type="org.eclipse.jetty.rewrite.handler.Rule">
|
||||
*
|
||||
*
|
||||
* <Item>
|
||||
* <New id="rewrite" class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
|
||||
* <Set name="pattern">/*</Set>
|
||||
* <Set name="replacement">/test</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
*
|
||||
* <Item>
|
||||
* <New id="rewrite" class="org.eclipse.jetty.rewrite.handler.ProxyRule">
|
||||
* <Set name="pattern">/*</Set>
|
||||
* <Set name="proxyTo">http://webtide.com:8080</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
*
|
||||
* <Item>
|
||||
* <New id="response" class="org.eclipse.jetty.rewrite.handler.ResponsePatternRule">
|
||||
* <Set name="pattern">/session/</Set>
|
||||
|
@ -81,7 +80,7 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
|
|||
* <Set name="reason">Setting error code 400</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
*
|
||||
* <Item>
|
||||
* <New id="header" class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
|
||||
* <Set name="pattern">*.jsp</Set>
|
||||
|
@ -89,7 +88,7 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
|
|||
* <Set name="value">dexter webserver</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
*
|
||||
* <Item>
|
||||
* <New id="header" class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
|
||||
* <Set name="pattern">*.jsp</Set>
|
||||
|
@ -97,21 +96,21 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
|
|||
* <Set name="value">driven header purpose</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
*
|
||||
* <Item>
|
||||
* <New id="redirect" class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">
|
||||
* <Set name="pattern">/test/dispatch</Set>
|
||||
* <Set name="location">http://jetty.eclipse.org</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
*
|
||||
* <Item>
|
||||
* <New id="regexRewrite" class="org.eclipse.jetty.rewrite.handler.RewriteRegexRule">
|
||||
* <Set name="regex">/test-jaas/$</Set>
|
||||
* <Set name="replacement">/demo</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
*
|
||||
* <Item>
|
||||
* <New id="forwardedHttps" class="org.eclipse.jetty.rewrite.handler.ForwardedSchemeHeaderRule">
|
||||
* <Set name="header">X-Forwarded-Scheme</Set>
|
||||
|
@ -119,10 +118,10 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
|
|||
* <Set name="scheme">https</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
*
|
||||
* <Item>
|
||||
* <New id="virtualHost" class="org.eclipse.jetty.rewrite.handler.VirtualHostRuleContainer">
|
||||
*
|
||||
*
|
||||
* <Set name="virtualHosts">
|
||||
* <Array type="java.lang.String">
|
||||
* <Item>eclipse.com</Item>
|
||||
|
@ -131,7 +130,7 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
|
|||
* <Item>www.eclipse.org</Item>
|
||||
* </Array>
|
||||
* </Set>
|
||||
*
|
||||
*
|
||||
* <Call name="addRule">
|
||||
* <Arg>
|
||||
* <New class="org.eclipse.jetty.rewrite.handler.CookiePatternRule">
|
||||
|
@ -141,33 +140,34 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
|
|||
* </New>
|
||||
* </Arg>
|
||||
* </Call>
|
||||
*
|
||||
*
|
||||
* </New>
|
||||
* </ Item>
|
||||
*
|
||||
* </Item>
|
||||
*
|
||||
* </Array>
|
||||
* </Set>
|
||||
*
|
||||
* <Set name="handler">
|
||||
* <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
|
||||
* <Set name="handlers">
|
||||
* <Array type="org.eclipse.jetty.server.Handler">
|
||||
* <Item>
|
||||
* <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
* </Item>
|
||||
* <Item>
|
||||
* <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
* </Item>
|
||||
* <Item>
|
||||
* <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
|
||||
* </Item>
|
||||
* </Array>
|
||||
* </Set>
|
||||
* </New>
|
||||
* </Set>
|
||||
*
|
||||
* </New>
|
||||
* </Set>
|
||||
*
|
||||
* <Set name="handler">
|
||||
* <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
|
||||
* <Set name="handlers">
|
||||
* <Array type="org.eclipse.jetty.server.Handler">
|
||||
* <Item>
|
||||
* <Ref id="RewriteHandler"/>
|
||||
* </Item>
|
||||
* <Item>
|
||||
* <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
* </Item>
|
||||
* <Item>
|
||||
* <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
* </Item>
|
||||
* <Item>
|
||||
* <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
|
||||
* </Item>
|
||||
* </Array>
|
||||
* </Set>
|
||||
* </New>
|
||||
* </Set>
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -575,6 +575,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
* @return Returns the Override Descriptor.
|
||||
* @deprecated use {@link #getOverrideDescriptors()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getOverrideDescriptor()
|
||||
{
|
||||
if (_overrideDescriptors.size()!=1)
|
||||
|
@ -686,20 +687,26 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
private void loadServerClasses()
|
||||
{
|
||||
if (_serverClasses != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//look for a Server attribute with the list of Server classes
|
||||
//to apply to every web application. If not present, use our defaults.
|
||||
// look for a Server attribute with the list of Server classes
|
||||
// to apply to every web application. If not present, use our defaults.
|
||||
Server server = getServer();
|
||||
if (server != null)
|
||||
{
|
||||
Object serverClasses = server.getAttribute(SERVER_SRV_CLASSES);
|
||||
if (serverClasses != null || serverClasses instanceof String[])
|
||||
if (serverClasses != null && serverClasses instanceof String[])
|
||||
{
|
||||
_serverClasses = new ClasspathPattern((String[])serverClasses);
|
||||
}
|
||||
}
|
||||
|
||||
if (_serverClasses == null)
|
||||
{
|
||||
_serverClasses = new ClasspathPattern(__dftServerClasses);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -873,6 +880,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
* @param overrideDescriptor The overrideDescritpor to set.
|
||||
* @deprecated use {@link #setOverrideDescriptors(List)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setOverrideDescriptor(String overrideDescriptor)
|
||||
{
|
||||
_overrideDescriptors.clear();
|
||||
|
@ -960,7 +968,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
@Override
|
||||
public void addEventListener(EventListener listener)
|
||||
{
|
||||
setEventListeners((EventListener[])LazyList.addToArray(getEventListeners(), listener, EventListener.class));
|
||||
setEventListeners(LazyList.addToArray(getEventListeners(), listener, EventListener.class));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1217,6 +1225,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
public class Context extends ServletContextHandler.Context
|
||||
{
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public URL getResource(String path) throws MalformedURLException
|
||||
{
|
||||
Resource resource=WebAppContext.this.getResource(path);
|
||||
|
|
Loading…
Reference in New Issue