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


Java ServletHolder.setInitOrder方法代码示例

本文整理汇总了Java中org.mortbay.jetty.servlet.ServletHolder.setInitOrder方法的典型用法代码示例。如果您正苦于以下问题:Java ServletHolder.setInitOrder方法的具体用法?Java ServletHolder.setInitOrder怎么用?Java ServletHolder.setInitOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mortbay.jetty.servlet.ServletHolder的用法示例。


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

示例1: setupServer

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
private void setupServer() throws Exception
{
    this.server = new HttpServer();
    SocketListener listener = new SocketListener();
    listener.setPort(PORT);
    this.server.addListener(listener);
    HttpContext context = new HttpContext();
    context.setContextPath("/");

    ServletHandler servletHandler = new ServletHandler();
    context.addHandler(servletHandler);

    // Map a servlet onto the container
    ServletHolder holder =
            servletHandler.addServlet("JrpipServlet", "/JrpipServlet", "com.gs.jrpip.server.JrpipServlet");
    holder.put("serviceInterface.Echo", "com.gs.jrpip.Echo");
    holder.put("vmBoundServiceClass.Echo", "com.gs.jrpip.EchoImpl");
    holder.setInitOrder(10);

    this.server.addContext(context);

    this.server.start();
    this.servlet = (JrpipServlet) holder.getServlet();
}
 
开发者ID:goldmansachs,项目名称:jrpip,代码行数:25,代码来源:VmBoundServiceTest.java

示例2: setupPspMithraService

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
protected void setupPspMithraService()
    {
        server = new Server(this.getApplicationPort1());
        Context context = new Context (server,"/",Context.SESSIONS);
        ServletHolder holder = context.addServlet(PspServlet.class, "/PspServlet");
        holder.setInitParameter("serviceInterface.MasterCacheService", "com.gs.fw.common.mithra.cache.offheap.MasterCacheService");
        holder.setInitParameter("serviceClass.MasterCacheService", "com.gs.fw.common.mithra.cache.offheap.MasterCacheServiceImpl");
        holder.setInitOrder(10);
//        System.out.println(holder.getServlet().getClass().getName());

        try
        {
            server.start();
        }
        catch (Exception e)
        {
            throw new RuntimeException("could not start server", e);
        }
        finally
        {
        }
    }
 
开发者ID:goldmansachs,项目名称:reladomo,代码行数:23,代码来源:CacheReplicationTestCase.java

示例3: setupServerWithHandler

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的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();
}
 
开发者ID:goldmansachs,项目名称:reladomo,代码行数:20,代码来源:PspTestCase.java

示例4: setupPspMithraService

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
protected void setupPspMithraService()
{
    server = new Server(this.getApplicationPort1());
    Context context = new Context (server,"/",Context.SESSIONS);
    ServletHolder holder = context.addServlet(PspServlet.class, "/PspServlet");
    holder.setInitParameter("serviceInterface.RemoteMithraService", "com.gs.fw.common.mithra.remote.RemoteMithraService");
    holder.setInitParameter("serviceClass.RemoteMithraService", "com.gs.fw.common.mithra.remote.RemoteMithraServiceImpl");
    holder.setInitOrder(10);

    try
    {
        server.start();
    }
    catch (Exception e)
    {
        throw new RuntimeException("could not start server", e);
    }
    finally
    {
    }
}
 
开发者ID:goldmansachs,项目名称:reladomo,代码行数:22,代码来源:RemoteMithraServerTestCase.java

示例5: initServletDefinitions

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
/**
 * @param servletDefinitions
 *          the servletDefinitions to set
 * @throws ClassNotFoundException
 */
private void initServletDefinitions() {
  try {
    Context context = getContext();
    int order = isLazy() ? -1 : 0;
    for (ServletDefinition sd : m_servletDefinitions) {
      ServletHolder holder = new ServletHolder(sd.getServletClass());
      if (order >= 0)
        order++;
      holder.setInitOrder(order);
      Map<String, String> initParams = sd.getInitParams();
      if (initParams != null)
        holder.setInitParameters(initParams);
      context.addServlet(holder, sd.getUrlPath());
      
    }
  }
  catch (Exception e) {
  	LOGGER.error( e.getMessage(), e);
  }

}
 
开发者ID:pulsarIO,项目名称:jetstream,代码行数:27,代码来源:JettyServer.java

示例6: JettyHttpServer

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public JettyHttpServer(URL url, final HttpHandler handler){
    super(url, handler);
    DispatcherServlet.addHttpHandler(url.getPort(), handler);
    
    int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setDaemon(true);
    threadPool.setMaxThreads(threads);
    threadPool.setMinThreads(threads);

    SelectChannelConnector connector = new SelectChannelConnector();
    if (! url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) {
        connector.setHost(url.getHost());
    }
    connector.setPort(url.getPort());

    server = new Server();
    server.setThreadPool(threadPool);
    server.addConnector(connector);
    
    ServletHandler servletHandler = new ServletHandler();
    ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
    servletHolder.setInitOrder(2);
    
    server.addHandler(servletHandler);
    
    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: "
                                        + e.getMessage(), e);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:34,代码来源:JettyHttpServer.java

示例7: start

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public void start() {
    String serverPort = ConfigUtils.getProperty(JETTY_PORT);
    int port;
    if (serverPort == null || serverPort.length() == 0) {
        port = DEFAULT_JETTY_PORT;
    } else {
        port = Integer.parseInt(serverPort);
    }
    connector = new SelectChannelConnector();
    connector.setPort(port);
    ServletHandler handler = new ServletHandler();
    
    String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
    if (resources != null && resources.length() > 0) {
        FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
        resourceHolder.setInitParameter("resources", resources);
    }
    
    ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
    pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
    pageHolder.setInitOrder(2);
    
    Server server = new Server();
    server.addConnector(connector);
    server.addHandler(handler);
    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:32,代码来源:JettyContainer.java

示例8: setupServerWithHandler

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
protected void setupServerWithHandler(
        HttpHandler handler,
        SecurityConstraint constraint,
        UserRealm realm) throws Exception
{
    this.port = (int) (Math.random() * 10000.0 + 10000.0);
    this.jrpipUrl = "http://localhost:" + this.port + "/JrpipServlet";
    this.server = new HttpServer();
    SocketListener listener = new SocketListener();
    listener.setPort(this.port);
    this.server.addListener(listener);
    HttpContext context = new HttpContext();
    context.setContextPath("/");

    if (realm != null)
    {
        context.setRealm(realm);
    }

    if (constraint != null)
    {
        context.addSecurityConstraint("/", constraint);
    }

    if (handler != null)
    {
        context.addHandler(handler);
    }

    ServletHandler servletHandler = new ServletHandler();
    context.addHandler(servletHandler);

    ServletHolder holder = servletHandler.addServlet("JrpipServlet", "/JrpipServlet", "com.gs.jrpip.server.JrpipServlet");
    holder.put("serviceInterface.Echo", "com.gs.jrpip.Echo");
    holder.put("serviceClass.Echo", "com.gs.jrpip.EchoImpl");

    this.addCustomConfiguration(holder);

    holder.setInitOrder(10);

    this.server.addContext(context);
    this.server.start();
    this.servlet = (JrpipServlet) holder.getServlet();
}
 
开发者ID:goldmansachs,项目名称:jrpip,代码行数:45,代码来源:JrpipTestCase.java

示例9: start

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public void start() {
    String serverPort = ConfigUtils.getProperty(JETTY_PORT);
    int port;
    if (serverPort == null || serverPort.length() == 0) {
        port = DEFAULT_JETTY_PORT;
    } else {
        port = Integer.parseInt(serverPort);
    }
    connector = new SelectChannelConnector();
    
    connector.setPort(port);
    ServletHandler handler = new ServletHandler();
    
    String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
    if (resources != null && resources.length() > 0) {
        FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
        resourceHolder.setInitParameter("resources", resources);
    }
    
    ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
    pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
    pageHolder.setInitOrder(2);
    
    Server server = new Server();
    server.addConnector(connector);
    server.addHandler(handler);
    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
    }
}
 
开发者ID:spccold,项目名称:dubbo-comments,代码行数:33,代码来源:JettyContainer.java

示例10: addContext

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public static void addContext(HttpServer server, String strContext, String host, String path, String strWebContext, String strServerContext) {

    	if (strWebContext == null) strWebContext = "./web";
    	if (strServerContext == null) strServerContext = "./server";
        
        HttpContext context = new HttpContext();
        context.setContextPath(strContext);
        context.addWelcomeFile("index.cfm");

	    if ( host != null && !host.isEmpty() )
	        context.addVirtualHost(host);

        server.addContext(context);

        // Create a servlet container
        ServletHandler servlets = new ServletHandler();
        context.addHandler(servlets);

        // Map a servlet onto the container
        ServletHolder cfml = servlets.addServlet("CFMLServlet", "*.cfc/*,*.cfm/*,*.cfml/*,*.cfc,*.cfm,*.cfml", "lucee.debug.loader.servlet.CFMLServlet");
        cfml.setInitOrder(0);

        cfml.setInitParameter("lucee-server-directory", strServerContext);
        
        // Lucee REST Servlet
        ServletHolder rest = servlets.addServlet("RESTServlet", "/rest/*", "lucee.debug.loader.servlet.RESTServlet");
        rest.setInitOrder(0);

        strWebContext += path;
        context.setResourceBase(strWebContext);
        context.addHandler(new ResourceHandler());
    }
 
开发者ID:lucee,项目名称:Lucee4,代码行数:33,代码来源:RunAsJavaApplication.java

示例11: JettyHttpServer

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public JettyHttpServer(URL url, final HttpHandler handler) {
    super(url, handler);
    DispatcherServlet.addHttpHandler(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()), handler);

    int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setDaemon(true);
    threadPool.setMaxThreads(threads);
    threadPool.setMinThreads(threads);

    SelectChannelConnector connector = new SelectChannelConnector();

    String bindIp = url.getParameter(Constants.BIND_IP_KEY, url.getHost());
    if (!url.isAnyHost() && NetUtils.isValidLocalHost(bindIp)) {
        connector.setHost(bindIp);
    }
    connector.setPort(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()));

    server = new Server();
    server.setThreadPool(threadPool);
    server.addConnector(connector);

    ServletHandler servletHandler = new ServletHandler();
    ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
    servletHolder.setInitOrder(2);

    server.addHandler(servletHandler);

    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + url.getParameter(Constants.BIND_IP_KEY) + ":" + url.getParameter(Constants.BIND_PORT_KEY) + ", cause: "
                + e.getMessage(), e);
    }
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:36,代码来源:JettyHttpServer.java

示例12: start

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public void start() {
    String serverPort = ConfigUtils.getProperty(JETTY_PORT);
    int port;
    if (serverPort == null || serverPort.length() == 0) {
        port = DEFAULT_JETTY_PORT;
    } else {
        port = Integer.parseInt(serverPort);
    }
    connector = new SelectChannelConnector();
    connector.setPort(port);
    ServletHandler handler = new ServletHandler();

    String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
    if (resources != null && resources.length() > 0) {
        FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
        resourceHolder.setInitParameter("resources", resources);
    }

    ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
    pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
    pageHolder.setInitOrder(2);

    Server server = new Server();
    server.addConnector(connector);
    server.addHandler(handler);
    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
    }
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:32,代码来源:JettyContainer.java

示例13: JettyHttpServer

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public JettyHttpServer(URL url, final HttpHandler handler){
        super(url, handler);

        // modified by lishen
        this.url = url;
        // TODO we should leave this setting to slf4j
        Log.setLog(new StdErrLog());
        Log.getLog().setDebugEnabled(false);

        DispatcherServlet.addHttpHandler(url.getPort(), handler);

        int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
        QueuedThreadPool threadPool = new QueuedThreadPool();
        threadPool.setDaemon(true);
        threadPool.setMaxThreads(threads);
        threadPool.setMinThreads(threads);

        SelectChannelConnector connector = new SelectChannelConnector();
        if (! url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) {
            connector.setHost(url.getHost());
        }
        connector.setPort(url.getPort());

        server = new Server();
        server.setThreadPool(threadPool);
        server.addConnector(connector);

        ServletHandler servletHandler = new ServletHandler();
        ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
        servletHolder.setInitOrder(2);

        // modified by lishen
        // dubbo's original impl can't support the use of ServletContext
//        server.addHandler(servletHandler);
        // TODO Context.SESSIONS is the best option here?
        Context context = new Context(server, "/", Context.SESSIONS);
        context.setServletHandler(servletHandler);
        ServletManager.getInstance().addServletContext(url.getPort(), context.getServletContext());

        try {
            server.start();
        } catch (Exception e) {
            throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: "
                                            + e.getMessage(), e);
        }
    }
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:47,代码来源:JettyHttpServer.java

示例14: JettyHttpServer

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public JettyHttpServer(URL url, final HttpHandler handler){
        super(url, handler);

        // modified by lishen
        this.url = url;
        // TODO we should leave this setting to slf4j
        Log.setLog(new StdErrLog());
        Log.getLog().setDebugEnabled(false);

        DispatcherServlet.addHttpHandler(url.getPort(), handler);

        int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
        QueuedThreadPool threadPool = new QueuedThreadPool();
        threadPool.setDaemon(true);
        threadPool.setMaxThreads(threads);
        threadPool.setMinThreads(threads);

        SelectChannelConnector connector = new SelectChannelConnector();
        if (! url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) {
            connector.setHost(url.getHost());
        }
        connector.setPort(url.getPort());

        server = new Server();
        server.setThreadPool(threadPool);
        server.addConnector(connector);

        ServletHandler servletHandler = new ServletHandler();
        ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
        servletHolder.setInitOrder(2);

        // modified by lishen
        // dubbo's original impl can't support the use of ServletContext
//        server.addHandler(servletHandler);
        // TODO Context.SESSIONS is the best option here?
        Context context = new Context(server, "/", Context.SESSIONS);
        context.setServletHandler(servletHandler);
        BaseContext.CTX.addServletContext(url.getPort(), context.getServletContext());

        try {
            server.start();
        } catch (Exception e) {
            throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: "
                                            + e.getMessage(), e);
        }
    }
 
开发者ID:nince-wyj,项目名称:jahhan,代码行数:47,代码来源:JettyHttpServer.java

示例15: main

import org.mortbay.jetty.servlet.ServletHolder; //导入方法依赖的package包/类
public static void main(String[] args) {
  /* parse properties */

  int port = 8989;
  for (String arg: args) {
    if (arg.startsWith("-Droot="))
      rootPath = arg.substring(7);
    else if (arg.startsWith("-DWOPort="))
      port = Integer.parseInt(arg.substring(9));
  }
  
  /* setup HTTP server */
  
  Server server = new Server(port);
  log.info("application started on HTTP port: " + port);
  
  /* create a context */

  org.mortbay.jetty.servlet.Context root = 
  	new org.mortbay.jetty.servlet.Context(server, "/",
  			org.mortbay.jetty.servlet.Context.NO_SESSIONS |
  			org.mortbay.jetty.servlet.Context.NO_SECURITY);
  
  /* a ServletHolder wraps a Servlet configuration in Jetty */
  String _appName = "org.opengroupware.pubexport.OGoPubExport";
  ServletHolder servletHolder = new ServletHolder(WOServletAdaptor.class);
  servletHolder.setName(_appName);
  servletHolder.setInitParameter("WOAppName", _appName);
  
  /* This makes the Servlet being initialize on startup (instead of first
   * request).
   */
  servletHolder.setInitOrder(10); /* positive values: init asap */
  
  /* add Servlet to the Jetty Context */
  
  root.addServlet(servletHolder, "/");
  
  /* start server */
  
  log.debug("starting Jetty ...");
  try {
    server.start();
    log.debug("Jetty is running ...");
  }
  catch (Exception e) {
    log.error("Jetty exception", e);
  }
}
 
开发者ID:AlwaysRightInstitute,项目名称:StaticCMS,代码行数:50,代码来源:pubd.java


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