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


Java DefaultHandler类代码示例

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


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

示例1: main

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的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();
}
 
开发者ID:opensagres,项目名称:xdocreport.samples,代码行数:18,代码来源:EmbeddedServer.java

示例2: startup

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的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);
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:27,代码来源:AdminConsole.java

示例3: configureHandlers

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的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);
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:25,代码来源:Jetty6PluginServer.java

示例4: main

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的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();
}
 
开发者ID:DistX,项目名称:Learning,代码行数:22,代码来源:EmbeddedServer.java

示例5: createHttpServer

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的package包/类
@Override
 public HttpServer createHttpServer(InetSocketAddress addr, int backlog)
         throws IOException
 {
     Server server = _server;
 	boolean noServerCleanUp = true;
     if (server == null)
     {
     	server = new Server();
     	
     	HandlerCollection handlerCollection = new HandlerCollection();
     	handlerCollection.setHandlers(new Handler[] {new ContextHandlerCollection(), new DefaultHandler()});
server.setHandler(handlerCollection);
     	
     	noServerCleanUp = false;
     }

     JettyHttpServer jettyHttpServer = new JettyHttpServer(server, noServerCleanUp);
     jettyHttpServer.bind(addr, backlog);
     return jettyHttpServer;
 }
 
开发者ID:ZarGate,项目名称:OpenbravoPOS,代码行数:22,代码来源:JettyHttpServerProvider.java

示例6: main

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的package包/类
public static void main(String args[]) throws Exception
{
    String jetty_home=System.getProperty("jetty.home","../../..");

    String jetty_port=System.getProperty("jetty.port", "8080");

    String node_name=System.getProperty("node.name", "red");

    Server server = new Server();
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(Integer.parseInt(jetty_port));
    server.setConnectors(new Connector[]{connector});
    
    HandlerCollection handlers = new HandlerCollection();
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    
    //TODO: find a way to dynamically get the endpoint url
    WadiCluster wadiCluster = new WadiCluster("CLUSTER", node_name, "http://localhost:"+jetty_port+"/test");
    wadiCluster.doStart();
    
    WadiSessionManager wadiManager = new WadiSessionManager(wadiCluster, 2, 24, 360);
    
    WadiSessionHandler wSessionHandler = new WadiSessionHandler(wadiManager);
    WebAppContext wah = new WebAppContext(null, wSessionHandler, null, null);
    wah.setContextPath("/test");
    wah.setResourceBase(jetty_home+"/webapps/test");
    
    contexts.setHandlers(new Handler[]{wah});
    handlers.setHandlers(new Handler[]{contexts,new DefaultHandler()});
    server.setHandler(handlers);

    HashUserRealm hur = new HashUserRealm();
    hur.setName("Test Realm");
    hur.setConfig(jetty_home+"/etc/realm.properties");
    wah.getSecurityHandler().setUserRealm(hur);
    
    server.start();
    server.join();
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:40,代码来源:WadiSessionHandler.java

示例7: main

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的package包/类
/** temp main - just to help testing */
public static void main(String[] args)
throws Exception
{
    Server server = new Server();
    Connector connector=new GrizzlyConnector();
    connector.setPort(8080);
    server.setConnectors(new Connector[]{connector});
    
    HandlerCollection handlers = new HandlerCollection();
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    handlers.setHandlers(new Handler[]{contexts,new DefaultHandler()});
    server.setHandler(handlers);
    
    // TODO add javadoc context to contexts
    
    WebAppContext.addWebApplications(server, "../../webapps", "org/mortbay/jetty/webapp/webdefault.xml", true, false);
    
    HashUserRealm userRealm = new HashUserRealm();
    userRealm.setName("Test Realm");
    userRealm.setConfig("../../etc/realm.properties");
    server.setUserRealms(new UserRealm[]{userRealm});
    
    
    server.start();
    server.join();
    
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:29,代码来源:GrizzlyConnector.java

示例8: start

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的package包/类
public synchronized void start(int port, AbstractHandler... handlers) {
    if (isRunning()) {
        return;
    }
    // install shutdown hook to stop file server
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {

        @Override
        public void run() {
            stop();
        }

    }));
    if (log.isInfoEnabled()) {
        log.info("Starting file server");
    }
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(port);
    server.addConnector(connector);

    HandlerList _handlers = new HandlerList();
    List<AbstractHandler> list = new ArrayList<AbstractHandler>(Arrays.asList(handlers));
    list.add(new DefaultHandler());

    _handlers.setHandlers(list.toArray(new Handler[list.size()]));
    server.setHandler(_handlers);

    try {
        server.start();
    } catch (Exception e) {
        throw new PaxmlRuntimeException("Cannot start file server", e);
    }

    this.port = connector.getLocalPort();

    if (log.isInfoEnabled()) {
        log.info("File server started at port: " + this.port);
    }

}
 
开发者ID:niuxuetao,项目名称:paxml,代码行数:41,代码来源:FileServer.java

示例9: jettyServer

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的package包/类
@BeforeClass
public static void jettyServer() throws Exception {

	server = new Server();

	Connector connector = new SelectChannelConnector();
	connector.setPort(PORT);
	server.setConnectors(new Connector[] { connector });
	ConstraintMapping cm = new ConstraintMapping();
	Constraint constraint = new Constraint();
	constraint.setName(Constraint.__BASIC_AUTH);
	constraint.setRoles(new String[] { ROLE_NAME });
	constraint.setAuthenticate(true);
	cm.setConstraint(constraint);
	cm.setPathSpec("/*");

	sh = new SecurityHandler();
	userRealm = new HashUserRealm(REALM);
	userRealm.put(USERNAME, PASSWORD);
	userRealm.addUserToRole(USERNAME, ROLE_NAME);
	sh.setUserRealm(userRealm);
	sh.setConstraintMappings(new ConstraintMapping[] { cm });

	WebAppContext webappcontext = new WebAppContext();
	webappcontext.setContextPath("/");

	URL htmlRoot = HTTPAuthenticatorIT.class.getResource(HTML);
	assertNotNull("Could not find " + HTML, htmlRoot);
	webappcontext.setWar(htmlRoot.toExternalForm());
	
	webappcontext.addHandler(sh);

	HandlerCollection handlers = new HandlerCollection();
	handlers.setHandlers(new Handler[] { webappcontext,
			new DefaultHandler() });

	server.setHandler(handlers);
	server.start();
}
 
开发者ID:apache,项目名称:incubator-taverna-engine,代码行数:40,代码来源:HTTPAuthenticatorIT.java

示例10: run

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的package包/类
protected void run() {
    LOG.debug("Starting Server");

    server = new org.mortbay.jetty.Server();

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(9080);
    server.setConnectors(new Connector[] { connector });

    WebAppContext webappcontext = new WebAppContext();
    String contextPath = null;
    try {
        contextPath = getClass().getResource(".").toURI().getPath();
    } catch (URISyntaxException e1) {
        e1.printStackTrace();
    }
    System.out.println(contextPath);
    webappcontext.setContextPath("/api");

    webappcontext.setWar(contextPath);

    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });

    server.setHandler(handlers);
    try {
        server.start();

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:performancecopilot,项目名称:parfait,代码行数:33,代码来源:SpringCreatedTestServer.java

示例11: startup

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的package包/类
/**
 * Starts the Jetty server instance.
 */
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);
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:30,代码来源:AdminConsole.java

示例12: startup

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的package包/类
public void startup() {
    // Create connector for http traffic if it's enabled.
    if (adminPort > 0) {
        Connector httpConnector = new SelectChannelConnector();
        httpConnector.setHost(adminHost);
        httpConnector.setPort(adminPort);
        adminServer.addConnector(httpConnector);
    }

    // Make sure that at least one connector was registered.
    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);
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:29,代码来源:AdminConsole.java

示例13: doInitialize

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的package包/类
protected void doInitialize()
{
   super.doInitialize();
   
   try
   {
      if( this.server == null) this.server = new Server();
      
      HandlerCollection handlers = new HandlerCollection();
      ContextHandlerCollection contexts = new ContextHandlerCollection();
      handlers.setHandlers(new Handler[]{contexts,new DefaultHandler()});
      server.setHandler(handlers);
      
      this.adminCustomContext = new WebAppContext();
      this.adminCustomContext.setWar(this.customAdministrationWar.stringValue());
      this.adminCustomContext.setContextPath("/adminCustom");
      this.adminCustomContext.setParentLoaderPriority(true);
      contexts.addHandler(this.adminCustomContext);
      if (this.adminCustomContext.isStarted()) this.adminCustomContext.start();

      if( !this.server.isStarted() ) this.server.start();
   }
   catch (Exception e) 
   {
      super.logError("Error creating AdministrationWebAppHandler!", e);
      throw new StatusTransitionException("Error creating AdministrationWebAppHandler!", e);
   } 
}
 
开发者ID:tolo,项目名称:JServer,代码行数:29,代码来源:CustomAdministrationWebAppHandler.java

示例14: createJettyServer

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的package包/类
protected Server createJettyServer(Site site){
    Server server = new Server();
    //FIXME
    server.setStopAtShutdown(true);

    Connector defaultConnector = createConnector(null, port);
    server.setConnectors( new Connector[] { defaultConnector } );

    String root = site.getRoot();
    String resourceBase = site.getDestination().getPath();
    getLog().info("Server resource base: " + resourceBase);

    if("".equals(root)){
        ResourceHandler resourceHandler = new ResourceHandler();
        //resourceHandler.setDirectoriesListed(true);
        resourceHandler.setWelcomeFiles(new String[]{"index.html"});

        resourceHandler.setResourceBase(resourceBase/*site.getDestination().getPath()*/);

        HandlerList handlers = new HandlerList();
        handlers.setHandlers(new Handler[] { resourceHandler, new DefaultHandler()});
        server.setHandler(handlers);
        //server.setHandlers(new Handler[]{handlers, logHandler});
        //getLog().info( "Startisng preview server on http://localhost:" + port + "/" );
    } else {
        getLog().info("Using " + ContextHandler.class.getName());
        ContextHandler contextHandler = new ContextHandler();
        contextHandler.setContextPath(root);
        contextHandler.setHandler(new ResourceHandler());
        contextHandler.setResourceBase(resourceBase/*site.getDestination().getPath()*/);
        //server.setHandler(contextHandler);
        server.setHandlers(new Handler[]{contextHandler, new DefaultHandler()});
        //server.setHandlers(new Handler[]{contextHandler, logHandler});
        //log.info( "Starting preview server on http://localhost:" + port + root );
    }
    return server;
}
 
开发者ID:opoo,项目名称:opoopress,代码行数:38,代码来源:AbstractServerMojo.java

示例15: makeHandlers

import org.mortbay.jetty.handler.DefaultHandler; //导入依赖的package包/类
/**
 * Make the handlers for the HTTP server to test against
 * @return the handlers
 * @throws IOException if the handlers could not be created
 */
protected Handler[] makeHandlers() throws IOException {
    //serve resources from temporary folder
    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setBaseResource(Resource.newResource(
            folder.getRoot().getAbsolutePath()));
    return new Handler[] { resourceHandler, new DefaultHandler() };
}
 
开发者ID:michel-kraemer,项目名称:gradle-download-task,代码行数:13,代码来源:TestBase.java


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