本文整理汇总了Java中org.mortbay.jetty.Handler类的典型用法代码示例。如果您正苦于以下问题:Java Handler类的具体用法?Java Handler怎么用?Java Handler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Handler类属于org.mortbay.jetty包,在下文中一共展示了Handler类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startServer
import org.mortbay.jetty.Handler; //导入依赖的package包/类
private static void startServer() throws Exception, InterruptedException {
Server server = new Server(port);
Context context = new Context(server, "/", Context.SESSIONS);
context.addServlet(DefaultServlet.class, "/*");
context.addEventListener(new ContextLoaderListener(getContext()));
context.addEventListener(new RequestContextListener());
WicketFilter filter = new WicketFilter();
filter.setFilterPath("/");
FilterHolder holder = new FilterHolder(filter);
holder.setInitParameter("applicationFactoryClassName", APP_FACTORY_NAME);
context.addFilter(holder, "/*", Handler.DEFAULT);
server.setHandler(context);
server.start();
server.join();
}
示例2: main
import org.mortbay.jetty.Handler; //导入依赖的package包/类
public static void main( String[] args )
throws Exception
{
Server server = new Server( 8081 );
WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/reporting" );
ContextHandlerCollection servlet_contexts = new ContextHandlerCollection();
webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() );
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } );
server.setHandler( handlers );
server.start();
server.join();
}
示例3: filters
import org.mortbay.jetty.Handler; //导入依赖的package包/类
/**
* Add an internal servlet in the server, specifying whether or not to
* protect with Kerberos authentication.
* Note: This method is to be used for adding servlets that facilitate
* internal communication and not for user facing functionality. For
+ * servlets added using this method, filters (except internal Kerberos
* filters) are not enabled.
*
* @param name The name of the servlet (can be passed as null)
* @param pathSpec The path spec for the servlet
* @param clazz The servlet class
* @param requireAuth Require Kerberos authenticate to access servlet
*/
public void addInternalServlet(String name, String pathSpec,
Class<? extends HttpServlet> clazz, boolean requireAuth) {
ServletHolder holder = new ServletHolder(clazz);
if (name != null) {
holder.setName(name);
}
webAppContext.addServlet(holder, pathSpec);
if(requireAuth && UserGroupInformation.isSecurityEnabled()) {
LOG.info("Adding Kerberos (SPNEGO) filter to " + name);
ServletHandler handler = webAppContext.getServletHandler();
FilterMapping fmap = new FilterMapping();
fmap.setPathSpec(pathSpec);
fmap.setFilterName(SPNEGO_FILTER);
fmap.setDispatches(Handler.ALL);
handler.addFilterMapping(fmap);
}
}
示例4: startup
import org.mortbay.jetty.Handler; //导入依赖的package包/类
public void startup() {
if (adminPort > 0) {
Connector httpConnector = new SelectChannelConnector();
httpConnector.setHost(adminHost);
httpConnector.setPort(adminPort);
adminServer.addConnector(httpConnector);
}
if (adminServer.getConnectors() == null
|| adminServer.getConnectors().length == 0) {
adminServer = null;
log.warn("Admin console not started due to configuration error.");
return;
}
adminServer
.setHandlers(new Handler[] { contexts, new DefaultHandler() });
try {
adminServer.start();
httpStarted = true;
log.debug("Admin console started.");
} catch (Exception e) {
log.error("Could not start admin conosle server", e);
}
}
示例5: configureHandlers
import org.mortbay.jetty.Handler; //导入依赖的package包/类
/**
* Set up the handler structure to receive a webapp. Also put in a DefaultHandler so we get a nice page than a 404
* if we hit the root and the webapp's context isn't at root.
*/
public void configureHandlers() throws Exception {
this.defaultHandler = new DefaultHandler();
this.requestLogHandler = new RequestLogHandler();
if (this.requestLog != null) {
this.requestLogHandler.setRequestLog(this.requestLog);
}
this.contexts = (ContextHandlerCollection) server.getChildHandlerByClass(ContextHandlerCollection.class);
if (this.contexts == null) {
this.contexts = new ContextHandlerCollection();
this.handlers = (HandlerCollection) server.getChildHandlerByClass(HandlerCollection.class);
if (this.handlers == null) {
this.handlers = new HandlerCollection();
this.server.setHandler(handlers);
this.handlers.setHandlers(new Handler[]{this.contexts, this.defaultHandler, this.requestLogHandler});
} else {
this.handlers.addHandler(this.contexts);
}
}
}
示例6: filters
import org.mortbay.jetty.Handler; //导入依赖的package包/类
/**
* Add an internal servlet in the server, specifying whether or not to
* protect with Kerberos authentication.
* Note: This method is to be used for adding servlets that facilitate
* internal communication and not for user facing functionality. For
+ * servlets added using this method, filters (except internal Kerberos
* filters) are not enabled.
*
* @param name The name of the servlet (can be passed as null)
* @param pathSpec The path spec for the servlet
* @param clazz The servlet class
* @param requireAuth Require Kerberos authenticate to access servlet
*/
public void addInternalServlet(String name, String pathSpec,
Class<? extends HttpServlet> clazz, boolean requireAuth) {
ServletHolder holder = new ServletHolder(clazz);
if (name != null) {
holder.setName(name);
}
webAppContext.addServlet(holder, pathSpec);
if(requireAuth && UserGroupInformation.isSecurityEnabled()) {
LOG.info("Adding Kerberos (SPNEGO) filter to " + name);
ServletHandler handler = webAppContext.getServletHandler();
FilterMapping fmap = new FilterMapping();
fmap.setPathSpec(pathSpec);
fmap.setFilterName(SPNEGO_FILTER);
fmap.setDispatches(Handler.ALL);
handler.addFilterMapping(fmap);
}
}
示例7: setupServerWithHandler
import org.mortbay.jetty.Handler; //导入依赖的package包/类
protected void setupServerWithHandler(
Handler handler) throws Exception
{
this.port = (int) (Math.random() * 10000.0 + 10000.0);
this.pspUrl = "http://localhost:" + this.port + "/PspServlet";
this.server = new Server(this.port);
Context context = new Context(server, "/", Context.SESSIONS);
if (handler != null)
{
context.addHandler(handler);
}
ServletHolder holder = context.addServlet(PspServlet.class, "/PspServlet");
holder.setInitParameter("serviceInterface.Echo", "com.gs.fw.common.mithra.test.tinyproxy.Echo");
holder.setInitParameter("serviceClass.Echo", "com.gs.fw.common.mithra.test.tinyproxy.EchoImpl");
holder.setInitOrder(10);
this.server.start();
this.servlet = (PspServlet) holder.getServlet();
}
示例8: invalidateAll
import org.mortbay.jetty.Handler; //导入依赖的package包/类
public void invalidateAll(String id)
{
//take the id out of the list of known sessionids for this node
removeSession(id);
synchronized (_sessionIds)
{
//tell all contexts that may have a session object with this id to
//get rid of them
Handler[] contexts = _server.getChildHandlersByClass(WebAppContext.class);
for (int i=0; contexts!=null && i<contexts.length; i++)
{
AbstractSessionManager manager = ((AbstractSessionManager)((WebAppContext)contexts[i]).getSessionHandler().getSessionManager());
if (manager instanceof GigaSessionManager)
{
((GigaSessionManager)manager).invalidateSession(id);
}
}
}
}
示例9: main
import org.mortbay.jetty.Handler; //导入依赖的package包/类
public static void main( String[] args )
throws Exception
{
Server server = new Server( 8080 );
WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/xdocreport-webapp" );
ContextHandlerCollection servlet_contexts = new ContextHandlerCollection();
webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() );
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } );
server.setHandler( handlers );
// JSP Servlet + Context
Context jsp_ctx = new Context( servlet_contexts, "/jsp", Context.SESSIONS );
jsp_ctx.addServlet( new ServletHolder( new org.apache.jasper.servlet.JspServlet() ), "*.jsp" );
server.start();
server.join();
}
示例10: addFilters
import org.mortbay.jetty.Handler; //导入依赖的package包/类
protected void addFilters(Context context) throws ClassNotFoundException, NoSuchMethodException,
InstantiationException, IllegalAccessException, InvocationTargetException {
context.addFilter(XdServletFilter.class, "/*", Handler.DEFAULT);
context.addFilter(MethodOverrideServletFilter.class, "/*", Handler.DEFAULT);
if (FlagConfig.enableAuth_FLAG.equalsIgnoreCase("true")) {
ServletHolder servletHolder2 = new ServletHolder(new GetAuthTokenServlet());
context.addServlet(servletHolder2, "/accounts/ClientLogin");
context.addFilter(SignedRequestFilter.class, "/*", org.mortbay.jetty.Handler.DEFAULT);
EventListener listener = new GuiceServletContextListener();
context.addEventListener(listener);
logger.info("FeedServer to accept signed requests");
} else if (!FlagConfig.enableOAuthSignedFetch_FLAG.equalsIgnoreCase("false")) {
// Register the OAuth filter
SimpleKeyMananger sKeyManager = new SimpleKeyMananger();
Filter oauthFilter =
createOAuthFilter(FlagConfig.enableOAuthSignedFetch_FLAG.equalsIgnoreCase("true") ?
FlagConfig.OAUTH_SIGNED_FETCH_FILTER_CLASS_NAME :
FlagConfig.enableOAuthSignedFetch_FLAG, sKeyManager);
context.addFilter(new FilterHolder(oauthFilter), "/*", org.mortbay.jetty.Handler.DEFAULT);
logger.info("FeedServer to accept OAuth signed requests");
}
}
示例11: start
import org.mortbay.jetty.Handler; //导入依赖的package包/类
public void start() throws Exception {
this.jetty.addConnector(connector);
ServletHandler servletHandler = new ServletHandler();
String filterName = "MyriadGuiceFilter";
FilterHolder holder = new FilterHolder(filter);
holder.setName(filterName);
FilterMapping filterMapping = new FilterMapping();
filterMapping.setPathSpec("/*");
filterMapping.setDispatches(Handler.ALL);
filterMapping.setFilterName(filterName);
servletHandler.addFilter(holder, filterMapping);
Context context = new Context();
context.setServletHandler(servletHandler);
context.addServlet(DefaultServlet.class, "/");
String staticDir = this.getClass().getClassLoader().getResource("webapp/public").toExternalForm();
context.setResourceBase(staticDir);
this.jetty.addHandler(context);
this.jetty.start();
}
示例12: addInternalServlet
import org.mortbay.jetty.Handler; //导入依赖的package包/类
/**
* Add an internal servlet in the server, specifying whether or not to
* protect with Kerberos authentication.
* Note: This method is to be used for adding servlets that facilitate
* internal communication and not for user facing functionality. For
* servlets added using this method, filters (except internal Kerberized
* filters) are not enabled.
*
* @param name The name of the servlet (can be passed as null)
* @param pathSpec The path spec for the servlet
* @param clazz The servlet class
*/
public void addInternalServlet(String name, String pathSpec,
Class<? extends HttpServlet> clazz, boolean requireAuth) {
ServletHolder holder = new ServletHolder(clazz);
if (name != null) {
holder.setName(name);
}
webAppContext.addServlet(holder, pathSpec);
if(requireAuth && UserGroupInformation.isSecurityEnabled()) {
LOG.info("Adding Kerberos filter to " + name);
ServletHandler handler = webAppContext.getServletHandler();
FilterMapping fmap = new FilterMapping();
fmap.setPathSpec(pathSpec);
fmap.setFilterName("krb5Filter");
fmap.setDispatches(Handler.ALL);
handler.addFilterMapping(fmap);
}
}
示例13: addInternalServlet
import org.mortbay.jetty.Handler; //导入依赖的package包/类
/**
* Add an internal servlet in the server, specifying whether or not to
* protect with Kerberos authentication.
* Note: This method is to be used for adding servlets that facilitate
* internal communication and not for user facing functionality. For
* servlets added using this method, filters (except internal Kerberos
* filters) are not enabled.
*
* @param name The name of the servlet (can be passed as null)
* @param pathSpec The path spec for the servlet
* @param clazz The servlet class
* @param requireAuth Require Kerberos authenticate to access servlet
*/
public void addInternalServlet(String name, String pathSpec,
Class<? extends HttpServlet> clazz, boolean requireAuth) {
ServletHolder holder = new ServletHolder(clazz);
if (name != null) {
holder.setName(name);
}
webAppContext.addServlet(holder, pathSpec);
if(requireAuth && UserGroupInformation.isSecurityEnabled()) {
LOG.info("Adding Kerberos (SPNEGO) filter to " + name);
ServletHandler handler = webAppContext.getServletHandler();
FilterMapping fmap = new FilterMapping();
fmap.setPathSpec(pathSpec);
fmap.setFilterName(SPNEGO_FILTER);
fmap.setDispatches(Handler.ALL);
handler.addFilterMapping(fmap);
}
}
示例14: handleRequest
import org.mortbay.jetty.Handler; //导入依赖的package包/类
protected void handleRequest() throws IOException
{
try
{
String info = URIUtil.canonicalPath(super._uri.getDecodedPath());
if (info==null) throw new HttpException(400);
info = info.substring(this.virtualContextPath.length());
super._request.setPathInfo(info);
HttpServletRequest request = super._request;
if( this.virtualContextPath != null )
{
request = new VirtualHttpServletRequestWrapper(super._request, this.virtualContextPath);
}
this.context.handle(info, request, _response, Handler.FORWARD);
}
catch (Exception e)
{
throw new IOException("Error handling request (" + e + ")!", e);
}
}