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


Java Server.start方法代碼示例

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


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

示例1: init

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public @NotNull CollectorServer init(@NotNull InetSocketAddress address, @NotNull ExpositionFormat format) {
  try {
    Log.setLog(new Slf4jLog());

    final Server serverInstance = new Server(address);
    format.handler(serverInstance);
    serverInstance.start();

    server = serverInstance;

    Logger.instance.info("Prometheus server with JMX metrics started at " + address);
  } catch (Exception e) {
    Logger.instance.error("Failed to start server at " + address, e);
  }
  return this;
}
 
開發者ID:nolequen,項目名稱:jmx-prometheus-exporter,代碼行數:17,代碼來源:CollectorServer.java

示例2: beforeClass

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
@BeforeClass
public static void beforeClass() throws Exception {
    jettyServer = new Server(0);

    WebAppContext webApp = new WebAppContext();
    webApp.setServer(jettyServer);
    webApp.setContextPath(CONTEXT_PATH);
    webApp.setWar("src/test/webapp");

    jettyServer.setHandler(webApp);
    jettyServer.start();
    serverPort = ((ServerConnector)jettyServer.getConnectors()[0]).getLocalPort();

    testRestTemplate = new TestRestTemplate(new RestTemplateBuilder()
            .rootUri("http://localhost:" + serverPort + CONTEXT_PATH));
}
 
開發者ID:opentracing-contrib,項目名稱:java-spring-web,代碼行數:17,代碼來源:MVCJettyITest.java

示例3: main

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    NettyServerBuilder.forAddress(LocalAddress.ANY).forPort(19876)
        .maxConcurrentCallsPerConnection(12).maxMessageSize(16777216)
        .addService(new MockApplicationRegisterService())
        .addService(new MockInstanceDiscoveryService())
        .addService(new MockJVMMetricsService())
        .addService(new MockServiceNameDiscoveryService())
        .addService(new MockTraceSegmentService()).build().start();

    Server jettyServer = new Server(new InetSocketAddress("0.0.0.0",
        Integer.valueOf(12800)));
    String contextPath = "/";
    ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
    servletContextHandler.setContextPath(contextPath);
    servletContextHandler.addServlet(GrpcAddressHttpService.class, GrpcAddressHttpService.SERVLET_PATH);
    servletContextHandler.addServlet(ReceiveDataService.class, ReceiveDataService.SERVLET_PATH);
    servletContextHandler.addServlet(ClearReceiveDataService.class, ClearReceiveDataService.SERVLET_PATH);
    jettyServer.setHandler(servletContextHandler);
    jettyServer.start();
}
 
開發者ID:SkywalkingTest,項目名稱:skywalking-mock-collector,代碼行數:21,代碼來源:Main.java

示例4: main

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String[] args) {
    int port = 8297;
    HandlerList lst = new HandlerList();

    String password = null;//"pass";
    Server server = new Server(port);
    JDServerPOSTHandler hnd;
    LinkController ctr = new SampleLinkController();
    if(password != null) {
        lst.addHandler(new AuthorizationHandler(password));
    }
    lst.addHandler(new AjaxHandler(true));
    lst.addHandler(new JDServerGETHandler(ctr));
    lst.addHandler(new JDServerPOSTHandler(ctr));
    server.setHandler(lst);
    try {
        server.start();
        server.join();
    }
    catch(Exception e) {
        System.out.println(e);
    }
}
 
開發者ID:nemec,項目名稱:JDHttpAPI,代碼行數:24,代碼來源:Program.java

示例5: main

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String[] args) {  
try {  
    MergedLogSource src = new MergedLogSource(args);
    System.out.println(src);

    Server server = new Server(8182);
    server.setHandler(new LogServer(src));
    
    server.start();
    server.join();

} catch (Exception e) {  
    // Something is wrong.  
    e.printStackTrace();  
}  
   }
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:17,代碼來源:LogServer.java

示例6: main

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(@NotNull @NonNls String[] args) throws Exception {
	PropertyConfigurator.configure(System.getProperty("user.dir") + "/log4j.properties");
	logger.warn("StrictFP | Back-end");
	logger.info("StrictFP Back-end is now running...");
	Server server = new Server(Constant.SERVER.SERVER_PORT);
	ServletContextHandler context =
			new ServletContextHandler(ServletContextHandler.SESSIONS);
	context.setContextPath("/api/v0");
	server.setHandler(context);
	server.setStopAtShutdown(true);
	// 像下麵這行一樣
	context.addServlet(new ServletHolder(new GetQuiz()), "/misc/getquiz");
	context.addServlet(new ServletHolder(new TimeLine()), "/timeline");
	context.addServlet(new ServletHolder(new Counter()), "/misc/counter");
	context.addServlet(new ServletHolder(new User()), "/user");
	context.addServlet(new ServletHolder(new Heartbeat()), "/misc/heartbeat");
	context.addServlet(new ServletHolder(new SafeCheck()), "/misc/safecheck");
	context.addServlet(new ServletHolder(new CheckCert()), "/auth/check_cert");
	//
	server.start();
	server.join();
}
 
開發者ID:ProgramLeague,項目名稱:strictfp-back-end,代碼行數:23,代碼來源:MainServer.java

示例7: run

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public void run(final int port) {
    try {
        final Server server = createServer();

        final ServletContextHandler context = new ServletContextHandler();
        context.setContextPath("/");
        server.setHandler(context);

        for (final MinijaxApplication application : applications) {
            addApplication(context, application);
        }

        final ServerConnector connector = createConnector(server);
        connector.setPort(port);
        server.setConnectors(new Connector[] { connector });
        server.start();
        server.join();

    } catch (final Exception ex) {
        throw new MinijaxException(ex);
    }
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:23,代碼來源:Minijax.java

示例8: startJettyServer

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
/**
 * 啟動jetty服務,加載server.war
 */
public static void startJettyServer(String path) throws  Exception{
    String configPath=path+ File.separator+"conf"+File.separator+"conf.properties";
    InputStream is = new FileInputStream(configPath);;
    Properties properties =new Properties();
    properties.load(is);
    is.close();
    int serverPort = Integer.parseInt(properties.getProperty("server.port"));
    Server server = new Server(serverPort);
    WebAppContext context = new WebAppContext();
    context.setContextPath("/");
    context.setWar(path+"/bin/service.war");
    server.setHandler(context);
    server.start();
    server.join();
}
 
開發者ID:elves-project,項目名稱:openapi,代碼行數:19,代碼來源:ProgramEntrance.java

示例9: createAndStartServer

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static Server createAndStartServer(int port, Map<Class<? extends Servlet>, String> handlers) throws Exception {
    Server server = new Server(port);
    server.setStopAtShutdown(true);
    ServletHandler sh = new ServletHandler();
    handlers.entrySet().forEach(e -> sh.addServletWithMapping(e.getKey(), e.getValue()));
    server.setHandler(sh);
    server.start();
    return server;
}
 
開發者ID:CSCfi,項目名稱:exam,代碼行數:10,代碼來源:RemoteServerHelper.java

示例10: main

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    ApplicationContext context = new AnnotationConfigApplicationContext(Application.class);  // (1)
    Server server = context.getBean(Server.class);
    server.start();
    server.join();

    System.out.println("Press ENTER to exit.");
    System.in.read();
}
 
開發者ID:hantsy,項目名稱:spring-reactive-sample,代碼行數:10,代碼來源:Application.java

示例11: main

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String[] args) {  
    try {  
    	Server jettyServer = createDevServer();
        jettyServer.start();  
        jettyServer.join();  
  
    } catch (Exception e) {  
        e.printStackTrace();  
    }  
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:11,代碼來源:PlatformServerStarter.java

示例12: testRegisterUrl

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testRegisterUrl() throws Exception {
    String bedUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/genes_sorted.bed";
    String indexUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/genes_sorted.bed.tbi";

    Server server = UrlTestingUtils.getFileServer(context);
    try {
        server.start();

        IndexedFileRegistrationRequest request = new IndexedFileRegistrationRequest();
        request.setPath(bedUrl);
        request.setType(BiologicalDataItemResourceType.URL);
        request.setIndexType(BiologicalDataItemResourceType.URL);
        request.setIndexPath(indexUrl);
        request.setReferenceId(referenceId);

        BedFile bedFile = bedManager.registerBed(request);
        Assert.assertNotNull(bedFile);

        bedFile = bedFileManager.loadBedFile(bedFile.getId());
        Assert.assertNotNull(bedFile.getId());
        Assert.assertNotNull(bedFile.getBioDataItemId());
        Assert.assertNotNull(bedFile.getIndex());
        Assert.assertFalse(bedFile.getPath().isEmpty());
        Assert.assertFalse(bedFile.getIndex().getPath().isEmpty());

        testLoadBedRecords(bedFile);
    } finally {
        server.stop();
    }
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:33,代碼來源:BedManagerTest.java

示例13: startServer

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
protected static void startServer(int port, String rootPath, String dbCfgPath)
		throws Exception, InterruptedException {
	Server server = new Server(port);
	WebAppContext webAppContext = new WebAppContext();
	webAppContext.setContextPath(rootPath);
	if (dbCfgPath != null) {
		Configurator cfg = null;
		try {
			cfg = ConfiguratorFactory.getInstance(APPINFO.getDbCfgFile());
		} catch (Exception e) {
			cfg = ConfiguratorFactory.getDefaultInstance();
		}
		if(cfg!=null) {ProcessLogger.debug(cfg.toString());}
		else {
			ProcessLogger.warn("Could not find db config file.");
		}
	}
	/* Important: Use getResource */
	String webxmlLocation = AppStarter.class.getResource("/webapp/WEB-INF/web.xml").toString();
	webAppContext.setDescriptor(webxmlLocation);

	/* Important: Use getResource */
	String resLocation = AppStarter.class.getResource("/webapp").toString();
	webAppContext.setResourceBase(resLocation);

	webAppContext.setParentLoaderPriority(true);

	server.setHandler(webAppContext);
	server.start();
	server.join();
}
 
開發者ID:daileyet,項目名稱:helpdesk,代碼行數:32,代碼來源:AppStarter.java

示例14: createGitServer

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
private Server createGitServer(int port) throws Exception {
    final Server server = new Server(port);

    final ServletHandler handler = new ServletHandler();
    server.setHandler(handler);
    handler.addServletWithMapping(new ServletHolder(createGitServlet()), "/*");

    server.start();
    server.setStopAtShutdown(true);

    LOGGER.info("Started serving local git repositories [" + this.repositories.values().stream().map(
        LazilyLoadedRepository::getName).collect(Collectors.toList()) + "] under http://localhost:" + port);
    return server;
}
 
開發者ID:arquillian,項目名稱:smart-testing,代碼行數:15,代碼來源:EmbeddedHttpGitServer.java

示例15: start

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public void start(boolean devMode, int port) throws Exception {

        Server server = new Server(new QueuedThreadPool(500));

        WebAppContext appContext = new WebAppContext();

        String resourceBasePath = "";
        //開發者模式
        if (devMode) {
            String artifact = MavenUtils.get(Thread.currentThread().getContextClassLoader()).getArtifactId();
            resourceBasePath = artifact + "/src/main/webapp";
        }
        appContext.setDescriptor(resourceBasePath + "WEB-INF/web.xml");
        appContext.setResourceBase(resourceBasePath);
        appContext.setExtractWAR(true);

        //init param
        appContext.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
        if (CommonUtils.isWindowOs()) {
            appContext.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
        }

        //for jsp support
        appContext.addBean(new JettyJspParser(appContext));
        appContext.addServlet(JettyJspServlet.class, "*.jsp");

        appContext.setContextPath("/");
        appContext.getServletContext().setExtendedListenerTypes(true);
        appContext.setParentLoaderPriority(true);
        appContext.setThrowUnavailableOnStartupException(true);
        appContext.setConfigurationDiscovered(true);
        appContext.setClassLoader(Thread.currentThread().getContextClassLoader());

        ServerConnector connector = new ServerConnector(server);
        connector.setHost("0.0.0.0");
        connector.setPort(port);
        server.setConnectors(new Connector[]{connector});
        server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", 1024 * 1024 * 1024);
        server.setDumpAfterStart(false);
        server.setDumpBeforeStop(false);
        server.setStopAtShutdown(true);
        server.setHandler(appContext);
        logger.info("[opencron] JettyLauncher starting...");
        server.start();
    }
 
開發者ID:wolfboys,項目名稱:opencron,代碼行數:46,代碼來源:JettyLauncher.java


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