当前位置: 首页>>代码示例>>Java>>正文


Java Handler类代码示例

本文整理汇总了Java中org.eclipse.jetty.server.Handler的典型用法代码示例。如果您正苦于以下问题:Java Handler类的具体用法?Java Handler怎么用?Java Handler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Handler类属于org.eclipse.jetty.server包,在下文中一共展示了Handler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initServer

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
private static void initServer(Properties properties) throws Exception {
    Integer port = Integer.valueOf(properties.getProperty("server.port"));
    String host = properties.getProperty("server.host");

    Integer clientId = Integer.valueOf(properties.getProperty("client.id"));
    String clientSecret = properties.getProperty("client.secret");

    HandlerCollection handlers = new HandlerCollection();

    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setDirectoriesListed(true);
    resourceHandler.setWelcomeFiles(new String[]{"index.html"});
    resourceHandler.setResourceBase(Application.class.getResource("/static").getPath());

    VkApiClient vk = new VkApiClient(new HttpTransportClient());
    handlers.setHandlers(new Handler[]{resourceHandler, new RequestHandler(vk, clientId, clientSecret, host)});

    Server server = new Server(port);
    server.setHandler(handlers);

    server.start();
    server.join();
}
 
开发者ID:VKCOM,项目名称:vk-java-sdk,代码行数:24,代码来源:Application.java

示例2: main

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        // Create a basic Jetty server object that will listen on port 8080
        Server server = new Server(8080);

        // Create the ResourceHandler. It is the object that will actually
        // handle the request for a given file. It is a Jetty Handler object
        // so it is suitable for chaining with other handlers as you will see
        // in other examples
        ResourceHandler resource_handler = new ResourceHandler();

        // Configure the ResourceHandler. Setting the resource base indicates
        // where the files should be served out of
        resource_handler.setDirectoriesListed(true);
        resource_handler.setWelcomeFiles(new String[]{ "index.html" });
        resource_handler.setResourceBase("src/main/webapp/");

        // Add the ResourceHandler to the server
        HandlerList handlers = new HandlerList();
        handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
        server.setHandler(handlers);

        // Start server
        server.start();
        server.join();
    }
 
开发者ID:biblelamp,项目名称:JavaEE,代码行数:27,代码来源:Main.java

示例3: startServer

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
public static void startServer(String[] args) throws Exception {
	Server server = new Server(8080);
	
	WebAppContext ctx = new WebAppContext();
	ctx.setContextPath("/");
	ctx.setWar("src/main/webapp/");
	HandlerCollection hc = new HandlerCollection();
	hc.setHandlers(new Handler[] {ctx});
	
	server.setHandler(hc);
	server.setStopAtShutdown(true);
	server.start();
	
	server.join();
	
	// server.removeBean(o);
	// server.addBean(o);
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:19,代码来源:ScratchPad.java

示例4: start

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
public void start() throws Exception {
    Resource configXml = Resource.newSystemResource(config);
    XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
    server = (Server) configuration.configure();

    //        Integer port = getPort();
    //        if (port != null && port > 0) {
    //            Connector[] connectors = server.getConnectors();
    //            for (Connector connector : connectors) {
    //                connector.setPort(port);
    //            }
    //        }
    Handler handler = server.getHandler();
    if (handler != null && handler instanceof WebAppContext) {
        WebAppContext webAppContext = (WebAppContext) handler;
        webAppContext.setResourceBase(JettyEmbedServer.class.getResource("/webapp").toString());
    }
    server.start();
    if (logger.isInfoEnabled()) {
        logger.info("##Jetty Embed Server is startup!");
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:23,代码来源:JettyEmbedServer.java

示例5: afterPropertiesSet

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
    Resource configXml = Resource.newSystemResource(config);
    XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
    server = (Server) configuration.configure();
    Integer port = getPort();
    if (port != null && port > 0) {
        Connector[] connectors = server.getConnectors();
        for (Connector connector : connectors) {
            connector.setPort(port);
        }
    }

    Handler handler = server.getHandler();
    if (handler != null && handler instanceof ServletContextHandler) {
        ServletContextHandler servletHandler = (ServletContextHandler) handler;
        servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", htdocsDir);
    }

    server.start();
    if (logger.isInfoEnabled()) {
        logger.info("##Jetty Embed Server is startup!");
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:24,代码来源:JettyEmbedServer.java

示例6: main

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    Resource jetty_xml = Resource.newSystemResource("jetty/jetty.xml");
    XmlConfiguration configuration = new XmlConfiguration(jetty_xml.getInputStream());
    Server server = (Server) configuration.configure();
    int port = 8081;
    Connector[] connectors = server.getConnectors();
    for (Connector connector : connectors) {
        connector.setPort(port);
    }

    Handler handler = server.getHandler();
    if (handler != null && handler instanceof ServletContextHandler) {
        ServletContextHandler servletHandler = (ServletContextHandler) handler;
        servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", "/tmp/");
    }

    server.start();
    server.join();
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:20,代码来源:JettyEmbedIntegration.java

示例7: prepare

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
public void prepare() {
    try {
        Tools.verifyLocalPort("DBServer ", port());
        server = new Server();
        DefaultHandler webHandler = new DefaultHandler();
        HandlerList handlers = new HandlerList();
        handlers.setHandlers(new Handler[]{getResourceHandler(),
            getUIWSHandler(), webHandler});

        ServerConnector connector = new ServerConnector(server);
        connector.setPort(port());
        server.setConnectors(new Connector[]{connector});
        server.setHandler(handlers);

        LOG.log(Level.INFO, "DB Server on : http://{0}:{1}",
                new Object[]{Tools.IP(), port() + ""});

    } catch (Exception ex) {
        LOG.log(Level.SEVERE, ex.getMessage(), ex);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:22,代码来源:DashBoardServer.java

示例8: getAllServices

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
private HandlerList getAllServices() throws Exception{
    // File server & Context Handler for root, also setting the index.html
    // to be the "welcome file", i.e, autolink on root addresses.
    ContextHandler rootContext = new ContextHandler();
    rootContext.setContextPath("/*");
    rootContext.setHandler(getResourceHandlers());

    // Possible servlet lists, for all servlets or custom services you want to access later.
    // Warning, it might become a little bit nested if you add to many classes.
    ServletHandler questionHandler = new ServletHandler();
    questionHandler.addServletWithMapping(QuestionHandler.class, "/question");

    // Add the ResourceHandler to the server.
    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] {
            rootContext ,
            questionHandler,
    });

    return handlers;
}
 
开发者ID:Rebstorm,项目名称:paul0-application-server,代码行数:22,代码来源:HomeServerConfig.java

示例9: setSessionHandler

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
/**
 * @param sessionHandler The sessionHandler to set.
 */
public void setSessionHandler(SessionHandler sessionHandler)
{
    if (isStarted())
        throw new IllegalStateException("STARTED");

    Handler next=null;
    if (_sessionHandler!=null)
    {
        next=_sessionHandler.getHandler();
        _sessionHandler.setHandler(null);
        replaceHandler(_sessionHandler,sessionHandler);
    }

    _sessionHandler = sessionHandler;
    if (next!=null && _sessionHandler.getHandler()==null)
        _sessionHandler.setHandler(next);
    relinkHandlers();
}
 
开发者ID:xiaomin0322,项目名称:marathon-auth-plugin,代码行数:22,代码来源:ServletContextHandler.java

示例10: setSecurityHandler

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
/**
 * @param securityHandler The {@link SecurityHandler} to set on this context.
 */
public void setSecurityHandler(SecurityHandler securityHandler)
{
    if (isStarted())
        throw new IllegalStateException("STARTED");

    Handler next=null;
    if (_securityHandler!=null)
    {
        next=_securityHandler.getHandler();
        _securityHandler.setHandler(null);
        replaceHandler(_securityHandler,securityHandler);
    }
    
    _securityHandler = securityHandler;
    if (next!=null && _securityHandler.getHandler()==null)
        _securityHandler.setHandler(next);
    relinkHandlers();
}
 
开发者ID:xiaomin0322,项目名称:marathon-auth-plugin,代码行数:22,代码来源:ServletContextHandler.java

示例11: setGzipHandler

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
/**
 * @param gzipHandler The {@link GzipHandler} to set on this context.
 */
public void setGzipHandler(GzipHandler gzipHandler)
{
    if (isStarted())
        throw new IllegalStateException("STARTED");

    Handler next=null;
    if (_gzipHandler!=null)
    {
        next=_gzipHandler.getHandler();
        _gzipHandler.setHandler(null);
        replaceHandler(_gzipHandler,gzipHandler);
    }
    
    _gzipHandler = gzipHandler;
    if (next!=null && _gzipHandler.getHandler()==null)
        _gzipHandler.setHandler(next);
    relinkHandlers();
}
 
开发者ID:xiaomin0322,项目名称:marathon-auth-plugin,代码行数:22,代码来源:ServletContextHandler.java

示例12: setServletHandler

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
/**
 * @param servletHandler The servletHandler to set.
 */
public void setServletHandler(ServletHandler servletHandler)
{
    if (isStarted())
        throw new IllegalStateException("STARTED");

    Handler next=null;
    if (_servletHandler!=null)
    {
        next=_servletHandler.getHandler();
        _servletHandler.setHandler(null);
        replaceHandler(_servletHandler,servletHandler);
    }
    _servletHandler = servletHandler;
    if (next!=null && _servletHandler.getHandler()==null)
        _servletHandler.setHandler(next);
    relinkHandlers();
}
 
开发者ID:xiaomin0322,项目名称:marathon-auth-plugin,代码行数:21,代码来源:ServletContextHandler.java

示例13: start

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
public void start() {
    try {
        // start the server
        server.start();

        // ensure everything started successfully
        for (Handler handler : server.getChildHandlers()) {
            // see if the handler is a web app
            if (handler instanceof WebAppContext) {
                WebAppContext context = (WebAppContext) handler;

                // see if this webapp had any exceptions that would
                // cause it to be unavailable
                if (context.getUnavailableException() != null) {
                    startUpFailure(context.getUnavailableException());
                }
            }
        }

        dumpUrls();
    } catch (final Throwable t) {
        startUpFailure(t);
    }
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:25,代码来源:JettyServer.java

示例14: main

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
public static void main( String[] args )
    throws Exception
{
    Server server = new Server( 8080 );

    WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/jaxrs" );

    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();
}
 
开发者ID:DistX,项目名称:Learning,代码行数:19,代码来源:EmbeddedServer.java

示例15: beforeClass

import org.eclipse.jetty.server.Handler; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
	ccowServer = new Server(serverPort);

	final CCOWContextListener c = new CCOWContextListener(commonContext, new InlinedContextAgentRepositoryModule());

	final MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
	ccowServer.addBean(mbContainer);

	final ServletContextHandler webSocketServletContextHandler = new ServletContextHandler(ccowServer, "/ws",
			ServletContextHandler.SESSIONS);
	webSocketServletContextHandler.addEventListener(c);
	WebSocketServerContainerInitializer.configureContext(webSocketServletContextHandler);

	final ServletContextHandler restServletContextHandler = new ServletContextHandler(ccowServer, "/");
	restServletContextHandler.addEventListener(c);
	restServletContextHandler.addFilter(AppGuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));

	 final ContextHandlerCollection contexts = new ContextHandlerCollection();
        contexts.setHandlers(new Handler[] { webSocketServletContextHandler, restServletContextHandler});
        
	ccowServer.setHandler(contexts);
	ccowServer.start();

}
 
开发者ID:jkiddo,项目名称:ccow,代码行数:26,代码来源:WebSocketsTestSuite.java


注:本文中的org.eclipse.jetty.server.Handler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。