本文整理汇总了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;
}
示例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));
}
示例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();
}
示例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);
}
}
示例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();
}
}
示例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();
}
示例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);
}
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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;
}
示例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();
}