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


Java HandlerCollection类代码示例

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


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

示例1: main

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的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: configureHandlers

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的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

示例3: main

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的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

示例4: startWebAppContext

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的package包/类
/**
 * Starts the Jetty web context class.
 * 
 * @param wac,
 * @throws Exception
 */
private void startWebAppContext(WebAppContext wac) throws Exception {
	HandlerCollection contexts = getJettyContexts();

	// set the TCCL since it's used internally by Jetty
	Thread current = Thread.currentThread();
	ClassLoader old = current.getContextClassLoader();
	try {
		current.setContextClassLoader(wac.getClassLoader());
		if (contexts != null) {
			contexts.addHandler(wac);
		}
		wac.start();
		if (contexts != null) {
			contexts.start();
		}
	}
	finally {
		current.setContextClassLoader(old);
	}
}
 
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:27,代码来源:JettyWarDeployer.java

示例5: testStopWebAppCtx

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的package包/类
public void testStopWebAppCtx() throws Exception {
	final boolean[] stopped = new boolean[1];

	Server tempServer = new Server() {

		public Handler getChildHandlerByClass(Class byclass) {
			if (ContextHandlerCollection.class.equals(byclass))
				return null;
			assertEquals(HandlerCollection.class, byclass);
			return new HandlerCollection();
		}
	};

	BundleContext bundleCtx = new MockBundleContext();
	String contextPath = "/path";
	deployer.setServer(tempServer);
	deployer.afterPropertiesSet();
	WarDeployment deployment = deployer.createDeployment(bundleCtx.getBundle(), contextPath);
	deployment.undeploy();
}
 
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:21,代码来源:JettyWarDeployerTest.java

示例6: createHttpServer

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的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

示例7: setUpHandlers

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的package包/类
protected void setUpHandlers() {
    HandlerCollection handlerCollection = new HandlerCollection();

    Handler handler = newCounterHandler();
    handlerCollection.addHandler(handler);

    handler = newExitHandler();
    handlerCollection.addHandler(handler);
    
    server.setHandler(handlerCollection);
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:12,代码来源:WADITestServer.java

示例8: main

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的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

示例9: main

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的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

示例10: jettyServer

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的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

示例11: run

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的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

示例12: doInitialize

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的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

示例13: initializeWebServer

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的package包/类
private void initializeWebServer(String name, String hostName,
    Configuration conf, String[] pathSpecs)
    throws IOException {

  Preconditions.checkNotNull(webAppContext);

  int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
  // If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
  // default value (currently 250).
  QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
      : new QueuedThreadPool(maxThreads);
  threadPool.setDaemon(true);
  webServer.setThreadPool(threadPool);

  SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
  if (sm instanceof AbstractSessionManager) {
    AbstractSessionManager asm = (AbstractSessionManager)sm;
    asm.setHttpOnly(true);
    asm.setSecureCookies(true);
  }

  ContextHandlerCollection contexts = new ContextHandlerCollection();
  RequestLog requestLog = HttpRequestLog.getRequestLog(name);

  if (requestLog != null) {
    RequestLogHandler requestLogHandler = new RequestLogHandler();
    requestLogHandler.setRequestLog(requestLog);
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] {contexts, requestLogHandler});
    webServer.setHandler(handlers);
  } else {
    webServer.setHandler(contexts);
  }

  final String appDir = getWebAppsPath(name);

  webServer.addHandler(webAppContext);

  addDefaultApps(contexts, appDir, conf);

  addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
  final FilterInitializer[] initializers = getFilterInitializers(conf);
  if (initializers != null) {
    conf = new Configuration(conf);
    conf.set(BIND_ADDRESS, hostName);
    for (FilterInitializer c : initializers) {
      c.initFilter(this, conf);
    }
  }

  addDefaultServlets();

  if (pathSpecs != null) {
    for (String path : pathSpecs) {
      LOG.info("adding path spec: " + path);
      addFilterPathMapping(path, webAppContext);
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:60,代码来源:HttpServer2.java

示例14: initializeWebServer

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的package包/类
private void initializeWebServer(String name, String hostName,
    Configuration conf, String[] pathSpecs)
    throws FileNotFoundException, IOException {

  Preconditions.checkNotNull(webAppContext);

  int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
  // If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
  // default value (currently 250).
  QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
      : new QueuedThreadPool(maxThreads);
  threadPool.setDaemon(true);
  webServer.setThreadPool(threadPool);

  SessionManager sm = webAppContext.getSessionHandler().getSessionManager();
  if (sm instanceof AbstractSessionManager) {
    AbstractSessionManager asm = (AbstractSessionManager)sm;
    asm.setHttpOnly(true);
    asm.setSecureCookies(true);
  }

  ContextHandlerCollection contexts = new ContextHandlerCollection();
  RequestLog requestLog = HttpRequestLog.getRequestLog(name);

  if (requestLog != null) {
    RequestLogHandler requestLogHandler = new RequestLogHandler();
    requestLogHandler.setRequestLog(requestLog);
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] {contexts, requestLogHandler});
    webServer.setHandler(handlers);
  } else {
    webServer.setHandler(contexts);
  }

  final String appDir = getWebAppsPath(name);

  webServer.addHandler(webAppContext);

  addDefaultApps(contexts, appDir, conf);

  addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
  final FilterInitializer[] initializers = getFilterInitializers(conf);
  if (initializers != null) {
    conf = new Configuration(conf);
    conf.set(BIND_ADDRESS, hostName);
    for (FilterInitializer c : initializers) {
      c.initFilter(this, conf);
    }
  }

  addDefaultServlets();

  if (pathSpecs != null) {
    for (String path : pathSpecs) {
      LOG.info("adding path spec: " + path);
      addFilterPathMapping(path, webAppContext);
    }
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:60,代码来源:HttpServer2.java

示例15: initializeWebServer

import org.mortbay.jetty.handler.HandlerCollection; //导入依赖的package包/类
private void initializeWebServer(String name, String hostName,
    Configuration conf, String[] pathSpecs)
    throws FileNotFoundException, IOException {

  Preconditions.checkNotNull(webAppContext);

  int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
  // If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
  // default value (currently 250).
  QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool()
      : new QueuedThreadPool(maxThreads);
  threadPool.setDaemon(true);
  webServer.setThreadPool(threadPool);

  ContextHandlerCollection contexts = new ContextHandlerCollection();
  RequestLog requestLog = HttpRequestLog.getRequestLog(name);

  if (requestLog != null) {
    RequestLogHandler requestLogHandler = new RequestLogHandler();
    requestLogHandler.setRequestLog(requestLog);
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] { requestLogHandler, contexts });
    webServer.setHandler(handlers);
  } else {
    webServer.setHandler(contexts);
  }

  final String appDir = getWebAppsPath(name);

  webServer.addHandler(webAppContext);

  addDefaultApps(contexts, appDir, conf);

  addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
  final FilterInitializer[] initializers = getFilterInitializers(conf);
  if (initializers != null) {
    conf = new Configuration(conf);
    conf.set(BIND_ADDRESS, hostName);
    for (FilterInitializer c : initializers) {
      c.initFilter(this, conf);
    }
  }

  addDefaultServlets();

  if (pathSpecs != null) {
    for (String path : pathSpecs) {
      LOG.info("adding path spec: " + path);
      addFilterPathMapping(path, webAppContext);
    }
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:53,代码来源:HttpServer.java


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