本文整理汇总了Java中org.eclipse.jetty.server.handler.ContextHandler.Context方法的典型用法代码示例。如果您正苦于以下问题:Java ContextHandler.Context方法的具体用法?Java ContextHandler.Context怎么用?Java ContextHandler.Context使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.server.handler.ContextHandler
的用法示例。
在下文中一共展示了ContextHandler.Context方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onWrapServletContext
import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
/**
* onWrapServletContext Jetty的场景下需要采用一些Wrapper来替代Proxy,因为不全是接口
*
* @param args
*/
public ContextHandler.Context onWrapServletContext(Object... args) {
ServletContextHandler.Context oContext = (ServletContextHandler.Context) args[0];
ServletContextHandlerWrapper.JettyContextWrapper ctx = new ServletContextHandlerWrapper().new JettyContextWrapper(
oContext);
return ctx;
}
示例2: ServletContextHandler
import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
public ServletContextHandler(HandlerContainer parent, String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler,int options)
{
super((ContextHandler.Context)null);
_options=options;
_scontext = new Context();
_sessionHandler = sessionHandler;
_securityHandler = securityHandler;
_servletHandler = servletHandler;
if (contextPath!=null)
setContextPath(contextPath);
if (parent instanceof HandlerWrapper)
((HandlerWrapper)parent).setHandler(this);
else if (parent instanceof HandlerCollection)
((HandlerCollection)parent).addHandler(this);
// Link the handlers
relinkHandlers();
if (errorHandler!=null)
setErrorHandler(errorHandler);
this.addFilter(new FilterHolder(new HTTPAuthFilter()), "/v2/*", EnumSet.allOf(DispatcherType.class));
}
示例3: run
import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
public void run(HtmlResponse source, HttpServletResponse response) throws IOException{
ContextHandler.Context context = WebAppContext.getCurrentContext();
HttpServletRequest request = requestPool.getByType(HttpServletRequest.class);
WebContext webContext = new WebContext(request, response, context.getContext("/"));
webContext.setVariables(source.getData());
templateEngine.process(source.getHtmlPath(), webContext, response.getWriter());
}
示例4: initContextHandler
import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
/**
* Compute the field _contextHandler.<br>
* In the case where the DefaultServlet is deployed on the HttpService it is likely that
* this method needs to be overwritten to unwrap the ServletContext facade until we reach
* the original jetty's ContextHandler.
* @param servletContext The servletContext of this servlet.
* @return the jetty's ContextHandler for this servletContext.
*/
protected ContextHandler initContextHandler(ServletContext servletContext)
{
ContextHandler.Context scontext = ContextHandler.getCurrentContext();
if (scontext == null)
{
if (servletContext instanceof ContextHandler.Context)
return ((ContextHandler.Context)servletContext).getContextHandler();
else
throw new IllegalArgumentException(
"The servletContext " + servletContext + " " + servletContext.getClass().getName() + " is not " + ContextHandler.Context.class.getName());
}
else
return ContextHandler.getCurrentContext().getContextHandler();
}
示例5: getResource
import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
/** get Resource to serve.
* Map a path to a resource. The default implementation calls
* HttpContext.getResource but derived servlets may provide
* their own mapping.
* @param pathInContext The path to find a resource for.
* @return The resource to serve.
*/
@Override
public Resource getResource(String pathInContext)
{
Resource r = null;
if (_relativeResourceBase != null)
pathInContext = URIUtil.addPaths(_relativeResourceBase, pathInContext);
try
{
if (_resourceBase != null)
{
r = _resourceBase.addPath(pathInContext);
if (!_contextHandler.checkAlias(pathInContext, r))
r = null;
}
else if (_servletContext instanceof ContextHandler.Context)
{
r = _contextHandler.getResource(pathInContext);
}
else
{
URL u = _servletContext.getResource(pathInContext);
r = _contextHandler.newResource(u);
}
if (LOG.isDebugEnabled())
LOG.debug("Resource " + pathInContext + "=" + r);
}
catch (IOException e)
{
LOG.ignore(e);
}
if ((r == null || !r.exists()) && pathInContext.endsWith("/jetty-dir.css"))
r = _stylesheet;
return r;
}