當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。