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


Java ServletHolder类代码示例

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


ServletHolder类属于org.mortbay.jetty.servlet包,在下文中一共展示了ServletHolder类的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: filters

import org.mortbay.jetty.servlet.ServletHolder; //导入依赖的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);
  }
}
 
开发者ID:chendave,项目名称:hadoop-TCP,代码行数:32,代码来源:HttpServer.java

示例3: createWebAppContext

import org.mortbay.jetty.servlet.ServletHolder; //导入依赖的package包/类
private static WebAppContext createWebAppContext(String name,
    Configuration conf, AccessControlList adminsAcl, final String appDir) {
  WebAppContext ctx = new WebAppContext();
  ctx.setDefaultsDescriptor(null);
  ServletHolder holder = new ServletHolder(new DefaultServlet());
  Map<String, String> params = ImmutableMap. <String, String> builder()
          .put("acceptRanges", "true")
          .put("dirAllowed", "false")
          .put("gzip", "true")
          .put("useFileMappedBuffer", "true")
          .build();
  holder.setInitParameters(params);
  ctx.setWelcomeFiles(new String[] {"index.html"});
  ctx.addServlet(holder, "/");
  ctx.setDisplayName(name);
  ctx.setContextPath("/");
  ctx.setWar(appDir + "/" + name);
  ctx.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf);
  ctx.getServletContext().setAttribute(ADMINS_ACL, adminsAcl);
  addNoCacheFilter(ctx);
  return ctx;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:23,代码来源:HttpServer2.java

示例4: filters

import org.mortbay.jetty.servlet.ServletHolder; //导入依赖的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);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:32,代码来源:HttpServer2.java

示例5: start

import org.mortbay.jetty.servlet.ServletHolder; //导入依赖的package包/类
/**
 * Simple http server. Server should send answer with status 200
 */
@BeforeClass
public static void start() throws Exception {
  server = new Server(0);
  Context context = new Context();
  context.setContextPath("/foo");
  server.setHandler(context);
  context.addServlet(new ServletHolder(TestServlet.class), "/bar");
  server.getConnectors()[0].setHost("localhost");
  server.start();
  originalPort = server.getConnectors()[0].getLocalPort();
  LOG.info("Running embedded servlet container at: http://localhost:"
      + originalPort);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestWebAppProxyServlet.java

示例6: start

import org.mortbay.jetty.servlet.ServletHolder; //导入依赖的package包/类
/**
 * Simple http server. Server should send answer with status 200
 */
@BeforeClass
public static void start() throws Exception {
  server = new Server(0);
  Context context = new Context();
  context.setContextPath("/foo");
  server.setHandler(context);
  context.addServlet(new ServletHolder(TestServlet.class), "/bar");
  server.getConnectors()[0].setHost("localhost");
  server.start();
  originalPort = server.getConnectors()[0].getLocalPort();
  LOG.info("Running embedded servlet container at: http://localhost:"
      + originalPort);
  // This property needs to be set otherwise CORS Headers will be dropped
  // by HttpUrlConnection
  System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:20,代码来源:TestWebAppProxyServlet.java

示例7: 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

示例8: 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

示例9: 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

示例10: setup

import org.mortbay.jetty.servlet.ServletHolder; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception {
  try {
    JobCallbackRequestMaker.initialize(new Props());
    jobCBMaker = JobCallbackRequestMaker.getInstance();

    contextInfo = new HashMap<String, String>();
    contextInfo.put(CONTEXT_SERVER_TOKEN, SERVER_NAME);
    contextInfo.put(CONTEXT_PROJECT_TOKEN, PROJECT_NANE);
    contextInfo.put(CONTEXT_FLOW_TOKEN, FLOW_NANE);
    contextInfo.put(CONTEXT_EXECUTION_ID_TOKEN, EXECUTION_ID);
    contextInfo.put(CONTEXT_JOB_TOKEN, JOB_NANE);
    contextInfo.put(CONTEXT_JOB_STATUS_TOKEN, JobCallbackStatusEnum.STARTED.name());

    embeddedJettyServer = new Server(PORT_NUMBER);

    Context context = new Context(embeddedJettyServer, "/", Context.SESSIONS);
    context.addServlet(new ServletHolder(new DelayServlet()), "/delay");

    System.out.println("Start server");
    embeddedJettyServer.start();
  } catch (Exception e) {
    e.printStackTrace();
    throw e;
  }
}
 
开发者ID:JasonBian,项目名称:azkaban,代码行数:27,代码来源:JobCallbackRequestMakerTest.java

示例11: createHandler

import org.mortbay.jetty.servlet.ServletHolder; //导入依赖的package包/类
private Context createHandler(
    Map<String, Path> runfiles,
    ImmutableList<Route> routes,
    ImmutableList<Class<? extends Filter>> filters) {
  Context context = new Context(server, CONTEXT_PATH, Context.SESSIONS);
  context.addServlet(new ServletHolder(HealthzServlet.class), "/healthz");
  for (Map.Entry<String, Path> runfile : runfiles.entrySet()) {
    context.addServlet(
        StaticResourceServlet.create(runfile.getKey(), runfile.getValue()),
        runfile.getKey());
  }
  for (Route route : routes) {
    context.addServlet(
        new ServletHolder(wrapServlet(route.servletClass(), filters)), route.path());
  }
  ServletHolder holder = new ServletHolder(DefaultServlet.class);
  holder.setInitParameter("aliases", "1");
  context.addServlet(holder, "/*");
  return context;
}
 
开发者ID:google,项目名称:nomulus,代码行数:21,代码来源:TestServer.java

示例12: create

import org.mortbay.jetty.servlet.ServletHolder; //导入依赖的package包/类
/**
 * Creates a servlet holder for this servlet so it can be used with Jetty.
 *
 * @param prefix servlet path starting with a slash and ending with {@code "/*"} if {@code root}
 *     is a directory
 * @param root file or root directory to serve
 */
public static ServletHolder create(String prefix, Path root) {
  root = root.toAbsolutePath();
  checkArgument(Files.exists(root), "Root must exist: %s", root);
  checkArgument(prefix.startsWith("/"), "Prefix must start with a slash: %s", prefix);
  ServletHolder holder = new ServletHolder(StaticResourceServlet.class);
  holder.setInitParameter("root", root.toString());
  if (Files.isDirectory(root)) {
    checkArgument(prefix.endsWith("/*"),
        "Prefix (%s) must end with /* since root (%s) is a directory", prefix, root);
    holder.setInitParameter("prefix", prefix.substring(0, prefix.length() - 1));
  } else {
    holder.setInitParameter("prefix", prefix);
  }
  return holder;
}
 
开发者ID:google,项目名称:nomulus,代码行数:23,代码来源:StaticResourceServlet.java

示例13: main

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

示例14: startHttpServer

import org.mortbay.jetty.servlet.ServletHolder; //导入依赖的package包/类
private void startHttpServer() throws Exception {

    // Create the webServer
    if (webServer != null) {
      webServer.stop();
      webServer = null;
    }
    webServer = new Server(0);

    Context context = new Context(webServer, contextPath);

    // create servlet handler
    context.addServlet(new ServletHolder(new NotificationServlet()),
                       servletPath);

    // Start webServer
    webServer.start();
    port = webServer.getConnectors()[0].getLocalPort();

  }
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:21,代码来源:NotificationTestCase.java

示例15: start

import org.mortbay.jetty.servlet.ServletHolder; //导入依赖的package包/类
protected void start() throws Exception {
  server = new Server(0);
  context = new Context();
  context.setContextPath("/foo");
  server.setHandler(context);
  context.addFilter(new FilterHolder(TestFilter.class), "/*", 0);
  context.addServlet(new ServletHolder(TestServlet.class), "/bar");
  host = "localhost";
  ServerSocket ss = new ServerSocket(0);
  port = ss.getLocalPort();
  ss.close();
  server.getConnectors()[0].setHost(host);
  server.getConnectors()[0].setPort(port);
  server.start();
  System.out.println("Running embedded servlet container at: http://" + host + ":" + port);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:17,代码来源:AuthenticatorTestCase.java


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