當前位置: 首頁>>代碼示例>>Java>>正文


Java Context.addServlet方法代碼示例

本文整理匯總了Java中org.mortbay.jetty.servlet.Context.addServlet方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.addServlet方法的具體用法?Java Context.addServlet怎麽用?Java Context.addServlet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mortbay.jetty.servlet.Context的用法示例。


在下文中一共展示了Context.addServlet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startServer

import org.mortbay.jetty.servlet.Context; //導入方法依賴的package包/類
private static void startServer() throws Exception, InterruptedException {
  Server server = new Server(port);
  Context context = new Context(server, "/", Context.SESSIONS);
  context.addServlet(DefaultServlet.class, "/*");

  context.addEventListener(new ContextLoaderListener(getContext()));
  context.addEventListener(new RequestContextListener());

  WicketFilter filter = new WicketFilter();
  filter.setFilterPath("/");
  FilterHolder holder = new FilterHolder(filter);
  holder.setInitParameter("applicationFactoryClassName", APP_FACTORY_NAME);
  context.addFilter(holder, "/*", Handler.DEFAULT);

  server.setHandler(context);
  server.start();
  server.join();
}
 
開發者ID:jorcox,項目名稱:GeoCrawler,代碼行數:19,代碼來源:NutchUiServer.java

示例2: start

import org.mortbay.jetty.servlet.Context; //導入方法依賴的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

示例3: testJetty

import org.mortbay.jetty.servlet.Context; //導入方法依賴的package包/類
@Test
@TestJetty
public void testJetty() throws Exception {
  Context context = new Context();
  context.setContextPath("/");
  context.addServlet(MyServlet.class, "/bar");
  Server server = TestJettyHelper.getJettyServer();
  server.addHandler(context);
  server.start();
  URL url = new URL(TestJettyHelper.getJettyURL(), "/bar");
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
  BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  assertEquals(reader.readLine(), "foo");
  reader.close();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:TestHTestCase.java

示例4: createHandler

import org.mortbay.jetty.servlet.Context; //導入方法依賴的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

示例5: setupPspMithraService

import org.mortbay.jetty.servlet.Context; //導入方法依賴的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

示例6: setupPspMithraService

import org.mortbay.jetty.servlet.Context; //導入方法依賴的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

示例7: main

import org.mortbay.jetty.servlet.Context; //導入方法依賴的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

示例8: setup

import org.mortbay.jetty.servlet.Context; //導入方法依賴的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

示例9: start

import org.mortbay.jetty.servlet.Context; //導入方法依賴的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

示例10: initServletDefinitions

import org.mortbay.jetty.servlet.Context; //導入方法依賴的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

示例11: addFilters

import org.mortbay.jetty.servlet.Context; //導入方法依賴的package包/類
protected void addFilters(Context context) throws ClassNotFoundException, NoSuchMethodException,
    InstantiationException, IllegalAccessException, InvocationTargetException {

  context.addFilter(XdServletFilter.class, "/*", Handler.DEFAULT);
  context.addFilter(MethodOverrideServletFilter.class, "/*", Handler.DEFAULT);

  if (FlagConfig.enableAuth_FLAG.equalsIgnoreCase("true")) {
    ServletHolder servletHolder2 = new ServletHolder(new GetAuthTokenServlet());
    context.addServlet(servletHolder2, "/accounts/ClientLogin");
    context.addFilter(SignedRequestFilter.class, "/*", org.mortbay.jetty.Handler.DEFAULT);
    EventListener listener = new GuiceServletContextListener();
    context.addEventListener(listener);
    logger.info("FeedServer to accept signed requests");
  } else if (!FlagConfig.enableOAuthSignedFetch_FLAG.equalsIgnoreCase("false")) {
    // Register the OAuth filter
    SimpleKeyMananger sKeyManager = new SimpleKeyMananger();
    Filter oauthFilter = 
        createOAuthFilter(FlagConfig.enableOAuthSignedFetch_FLAG.equalsIgnoreCase("true") ?
        FlagConfig.OAUTH_SIGNED_FETCH_FILTER_CLASS_NAME :
 		    FlagConfig.enableOAuthSignedFetch_FLAG, sKeyManager);
    context.addFilter(new FilterHolder(oauthFilter), "/*", org.mortbay.jetty.Handler.DEFAULT);
    logger.info("FeedServer to accept OAuth signed requests");
  }
}
 
開發者ID:jyang,項目名稱:google-feedserver,代碼行數:25,代碼來源:Main.java

示例12: startHttpServer

import org.mortbay.jetty.servlet.Context; //導入方法依賴的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:hopshadoop,項目名稱:hops,代碼行數:21,代碼來源:NotificationTestCase.java

示例13: testJetty

import org.mortbay.jetty.servlet.Context; //導入方法依賴的package包/類
@Test
@TestJetty
public void testJetty() throws Exception {
  Context context = new Context();
  context.setContextPath("/");
  context.addServlet(MyServlet.class, "/bar");
  Server server = TestJettyHelper.getJettyServer();
  server.addHandler(context);
  server.start();
  URL url = new URL(TestJettyHelper.getJettyURL(), "/bar");
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
  BufferedReader reader =
      new BufferedReader(new InputStreamReader(conn.getInputStream()));
  assertEquals(reader.readLine(), "foo");
  reader.close();
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:18,代碼來源:TestHTestCase.java

示例14: addDefaultApps

import org.mortbay.jetty.servlet.Context; //導入方法依賴的package包/類
/**
 * Add default apps.
 * @param appDir The application directory
 * @throws IOException
 */
protected void addDefaultApps(ContextHandlerCollection parent,
    final String appDir) throws IOException {
  // set up the context for "/logs/" if "hadoop.log.dir" property is defined. 
  String logDir = System.getProperty("hadoop.log.dir");
  if (logDir != null) {
    Context logContext = new Context(parent, "/logs");
    logContext.setResourceBase(logDir);
    logContext.addServlet(DefaultServlet.class, "/");
    defaultContexts.put(logContext, true);
  }
  // set up the context for "/static/*"
  Context staticContext = new Context(parent, "/static");
  staticContext.setResourceBase(appDir + "/static");
  staticContext.addServlet(DefaultServlet.class, "/*");
  defaultContexts.put(staticContext, true);
}
 
開發者ID:iVCE,項目名稱:RDFS,代碼行數:22,代碼來源:HttpServer.java

示例15: setup

import org.mortbay.jetty.servlet.Context; //導入方法依賴的package包/類
@BeforeMethod
public void         setup() throws Exception
{
    RestEasyApplication.singletonsRef.set(new RestEasySingletons());

    ResteasyProviderFactory.setInstance(new ResteasyProviderFactory());

    HttpServletDispatcher   dispatcher = new HttpServletDispatcher();

    port = InstanceSpec.getRandomPort();
    server = new Server(port);
    Context root = new Context(server, "/", Context.SESSIONS);
    root.getInitParams().put("javax.ws.rs.Application", RestEasyApplication.class.getName());
    root.addServlet(new ServletHolder(dispatcher), "/*");
    root.addEventListener(new ResteasyBootstrap());
    server.start();
}
 
開發者ID:apache,項目名稱:curator,代碼行數:18,代碼來源:TestStringsWithRestEasy.java


注:本文中的org.mortbay.jetty.servlet.Context.addServlet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。