本文整理匯總了Java中org.eclipse.jetty.server.Server.join方法的典型用法代碼示例。如果您正苦於以下問題:Java Server.join方法的具體用法?Java Server.join怎麽用?Java Server.join使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.server.Server
的用法示例。
在下文中一共展示了Server.join方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(PUBLIC_HTML);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
//page reloaded by the timer
context.addServlet(TimerServlet.class, "/timer");
//part of a page reloaded by the timer
context.addServlet(AjaxTimerServlet.class, "/server-time");
//long-polling waits till a message
context.addServlet(new ServletHolder(new MessengerServlet()), "/messenger");
//web chat
context.addServlet(WebSocketChatServlet.class, "/chat");
Server server = new Server(PORT);
server.setHandler(new HandlerList(resourceHandler, context));
server.start();
server.join();
}
示例2: main
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
initWeixin();
Server server = new Server(8080);
ServletHandler servletHandler = new ServletHandler();
server.setHandler(servletHandler);
ServletHolder endpointServletHolder = new ServletHolder(new WxCpEndpointServlet(wxCpConfigStorage, wxCpService, wxCpMessageRouter));
servletHandler.addServletWithMapping(endpointServletHolder, "/*");
ServletHolder oauthServletHolder = new ServletHolder(new WxCpOAuth2Servlet(wxCpService));
servletHandler.addServletWithMapping(oauthServletHolder, "/oauth2/*");
server.start();
server.join();
}
示例3: startWebSocket
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
/**
* start server
*
* @param port
* @param path
* @param handlerClass
*/
public static void startWebSocket(int port, String path, String handlerClass) {
try {
Server server = new Server(port);
HandlerList handlerList = new HandlerList();
ServletContextHandler context = new ServletContextHandler(
ServletContextHandler.SESSIONS);
context.setContextPath("/");
context.addServlet(new ServletHolder(new Jwservlet(handlerClass)),
path);
handlerList.addHandler(context);
handlerList.addHandler(new DefaultHandler());
server.setHandler(handlerList);
server.start();
server.join();
} catch (Exception e) {
e.printStackTrace();
LogUtil.LOG("start websocket server error:" + e.getMessage(),
LogLev.ERROR, WebSocketServer.class);
System.exit(1);
}
}
示例4: main
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(PUBLIC_HTML);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(new LoginServlet("anonymous")), "/login");
context.addServlet(AdminServlet.class, "/admin");
context.addServlet(TimerServlet.class, "/timer");
Server server = new Server(PORT);
server.setHandler(new HandlerList(resourceHandler, context));
server.start();
server.join();
}
示例5: start
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
private void start() throws Exception {
resourcesExample();
ResourceHandler resourceHandler = new ResourceHandler();
Resource resource = Resource.newClassPathResource(PUBLIC_HTML);
resourceHandler.setBaseResource(resource);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(new TimerServlet()), "/timer");
Server server = new Server(PORT);
server.setHandler(new HandlerList(resourceHandler, context));
server.start();
server.join();
}
示例6: 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();
}
}
示例7: 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();
}
示例8: startJetty
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
private void startJetty() throws Exception {
QueuedThreadPool jettyThreadPool = new QueuedThreadPool(jettyServerThreads);
Server server = new Server(jettyThreadPool);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory());
http.setPort(jettyListenPort);
server.addConnector(http);
ContextHandler contextHandler = new ContextHandler();
contextHandler.setHandler(botSocketHandler);
server.setHandler(contextHandler);
server.start();
server.join();
}
示例9: 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);
}
}
示例10: main
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(PUBLIC_HTML);
Server server = new Server(PORT);
server.setHandler(resourceHandler);
server.start();
server.join();
}
示例11: main
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
/**
* Start expose storr rest API via jetty server
*
* The following parameters are allowed:
* - port (default port is 9998)
* - store path
*
* Example:
* port=9998 path=~/storr/
*
* @param args
* @throws Exception if the server or storr could not be launched successfully
*/
public static void main(String[] args) throws Exception {
HashMap<String, String> map = makeMap(args);
if (map.containsKey("port")) {
serverPort = Integer.parseInt(map.get("port"));
}
Path store_path;
if (map.containsKey("path")) {
store_path = Paths.get(map.get("path").replaceFirst("^~",System.getProperty("user.home")));
File path = new File(store_path.toString());
path.mkdirs();
} else {
store_path = Files.createTempDirectory(null);
}
System.out.println("Store will be created in path " + store_path);
System.out.println("REST API documentation available at localhost:" + serverPort +
"/swagger.json OR localhost:" + serverPort + "/swagger.yaml");
IStore store = new Store(store_path);
final Server server = StartServer(store);
try {
server.start();
server.join();
} finally {
server.destroy();
}
}
示例12: startJetty
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void startJetty() throws Exception {
// Jetty 起動
HandlerList handlers = new HandlerList();
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
ServletHolder servletHolder = context.addServlet(ServletContainer.class, "/*");
servletHolder.setInitOrder(0);
servletHolder.setInitParameter(
"com.sun.jersey.spi.container.ContainerResponseFilters",
"com.sun.jersey.api.container.filter.GZIPContentEncodingFilter");
// Pasaran API
RestAPIs.installRestApi(servletHolder,
CORSResponseFilter.class,
KeseranApi.class);
// 靜的コンテンツ
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase("web");
handlers.addHandler(resourceHandler);
handlers.addHandler(context);
String port = System.getProperty("jetty-port", "2510");
Server jetty = new Server(Integer.parseInt(port));
jetty.setHandler(handlers);
try {
// RolloverFileOutputStream os = new RolloverFileOutputStream("logs/yyyy_mm_dd_jetty.log", true);
// PrintStream logStream = new PrintStream(os);
// System.setOut(logStream);
// System.setErr(logStream);
// Log.getRootLogger().info("JCG Embedded Jetty logging started.", new Object[]{});
jetty.start();
jetty.join();
} finally {
jetty.destroy();
}
}
示例13: main
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
Server server = new Server(HTTP_PORT);
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setWelcomeFiles(new String[] {"index.html"});
resourceHandler.setDirectoriesListed(false);
// resource base is relative to the WORKSPACE file
resourceHandler.setResourceBase("./examples/resources");
HandlerList handlerList = new HandlerList();
handlerList.setHandlers(new Handler[] {resourceHandler, new GraphQlServer()});
server.setHandler(handlerList);
server.start();
server.join();
}
示例14: start
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public void start() {
Server server = new Server(new InetSocketAddress(config.getHostname(), config.getPort()));
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.packages(RESOURCE_PACKAGES_TO_SCAN);
registerMetrics(resourceConfig);
ServletContainer servletContainer = new ServletContainer(resourceConfig);
ServletHolder servletHolder = new ServletHolder(servletContainer);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
context.addServlet(servletHolder, API_PREFIX);
registerMetricsServlets(context);
server.setHandler(context);
ServerContainer wscontainer;
try {
wscontainer = WebSocketServerContainerInitializer.configureContext(context);
wscontainer.addEndpoint(EventSocket.class);
} catch (ServletException | DeploymentException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
server.start();
server.join();
} catch (Exception e) {
// TODO
e.printStackTrace();
}
}
示例15: main
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
String hostname = Optional.ofNullable(System.getenv("HOST")).orElse("localhost");
String port = Optional.ofNullable(System.getenv("PORT")).orElse("8080");
URI baseUri = UriBuilder.fromUri("http://" + hostname + "/").port(Integer.parseInt(port)).build();
ResourceConfig config = new ResourceConfig(StockPriceResource.class);
ServletHolder servlet = new ServletHolder(new ServletContainer(config));
Server server = new Server(Integer.valueOf(port));
ServletContextHandler context = new ServletContextHandler(server, "/*");
context.addServlet(servlet, "/*");
ServerContainer wscontainer = WebSocketServerContainerInitializer.configureContext(context);
wscontainer.addEndpoint(RealTimeStockTicker.class);
Broadcaster broadcaster = new Broadcaster();
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
System.out.println("Exiting");
try {
server.destroy();
System.out.println("Jetty stopped");
broadcaster.stop();
System.out.println("Broadcast stopped");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}));
server.start();
System.out.println("Application accessible at " + baseUri.toString());
broadcaster.start();
System.out.println("broadcast started..");
server.join();
}