本文整理匯總了Java中org.eclipse.jetty.server.handler.ResourceHandler.setResourceBase方法的典型用法代碼示例。如果您正苦於以下問題:Java ResourceHandler.setResourceBase方法的具體用法?Java ResourceHandler.setResourceBase怎麽用?Java ResourceHandler.setResourceBase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.server.handler.ResourceHandler
的用法示例。
在下文中一共展示了ResourceHandler.setResourceBase方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的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.handler.ResourceHandler; //導入方法依賴的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();
}
示例3: main
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
// Create a basic Jetty server object that will listen on port 8080
Server server = new Server(8080);
// Create the ResourceHandler. It is the object that will actually
// handle the request for a given file. It is a Jetty Handler object
// so it is suitable for chaining with other handlers as you will see
// in other examples
ResourceHandler resource_handler = new ResourceHandler();
// Configure the ResourceHandler. Setting the resource base indicates
// where the files should be served out of
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[]{ "index.html" });
resource_handler.setResourceBase("src/main/webapp/");
// Add the ResourceHandler to the server
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
server.setHandler(handlers);
// Start server
server.start();
server.join();
}
示例4: main
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
AccountService accountService = new AccountService();
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(new SingUpServlet(accountService)), "/signup");
context.addServlet(new ServletHolder(new SignInServlet(accountService)), "/signin");
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setResourceBase("public_html");
HandlerList handlers = new HandlerList();
final Handler[] handler = {resource_handler, context};
handlers.setHandlers(handler);
Server server = new Server(8080);
server.setHandler(handlers);
server.start();
System.out.println("Server started");
server.join();
}
示例5: start
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的package包/類
/**
* Start the file server (blocking).
*
* @throws Exception If server cannot start
*/
public final void start() throws Exception {
LOGGER.info("Starting web interface at http://localhost:8000");
Server server = new Server(8000);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[]{"index.html"});
resource_handler.setResourceBase("../website");
HandlerList handlers = new HandlerList();
handlers.setHandlers(
new Handler[]{
resource_handler,
new DefaultHandler()});
server.setHandler(handlers);
server.start();
}
示例6: ConfigServer
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的package包/類
@Inject
public ConfigServer(HBaseFrameworkConfig hbaseFrameworkConfig,
IPersistentStateStore persistenceStore) {
this.hbaseFrameworkConfig = hbaseFrameworkConfig;
this.persistenceStore = persistenceStore;
engine = new Engine();
server = new Server(hbaseFrameworkConfig.getConfigServerPort());
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(hbaseFrameworkConfig.getExecutorPath());
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{
resourceHandler, new ServeHbaseConfigHandler()});
server.setHandler(handlers);
try {
server.start();
} catch (Exception e) {
final String msg = "Unable to start jetty server";
log.error(msg, e);
throw new ConfigServerException(msg, e);
}
}
示例7: run
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的package包/類
public void run(int port) throws Exception {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
server.addConnector(connector);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[] { "index.html" });
resource_handler.setResourceBase("./performance/site/");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler,
new DefaultHandler() });
server.setHandler(handlers);
server.start();
System.out.println("Started performance file server at port: " + port);
server.join();
}
示例8: main
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(new WebSocketChatServlet()), "/chat");
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setResourceBase("public_html");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{resource_handler, context});
server.setHandler(handlers);
server.start();
System.out.println("Server started!");
server.join();
}
示例9: WebSocketServer
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的package包/類
public WebSocketServer(int port, String rootDirPath, final MainWindow m, final Statement smt, final java.sql.Connection sqlcon) {
idCounter = 0;
connector = new SelectChannelConnector();
connector.setPort(port);
addConnector(connector);
wsHandler = new WebSocketHandler() {
@Override
public WebSocket doWebSocketConnect(HttpServletRequest request,
String protocol) {
idCounter++;
System.out.printf("Protocol:%s\n", protocol);
return new MyWebSocket(idCounter, m, smt, sqlcon);
}
};
resHandler = new ResourceHandler();
resHandler.setDirectoriesListed(true);
resHandler.setResourceBase(rootDirPath);
wsHandler.setHandler(resHandler);
setHandler(wsHandler);
}
開發者ID:ryohashioka,項目名稱:Visual-Programming-Environment-for-Coordinating-Appliances-and-Services-in-a-Smart-House,代碼行數:25,代碼來源:WebSocketServer.java
示例10: configure
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的package包/類
@Override
protected void configure(ServerBuilder sb) throws Exception {
sb.port(0, SessionProtocol.HTTP);
sb.port(0, SessionProtocol.HTTPS);
sb.sslContext(SessionProtocol.HTTPS,
certificate.certificateFile(),
certificate.privateKeyFile());
sb.serviceUnder(
"/jsp/",
new JettyServiceBuilder()
.handler(newWebAppContext())
.configurator(s -> jettyBeans.addAll(s.getBeans()))
.build()
.decorate(LoggingService.newDecorator()));
sb.serviceUnder(
"/default/",
new JettyServiceBuilder().handler(new DefaultHandler()).build());
final ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(webAppRoot().getPath());
sb.serviceUnder(
"/resources/",
new JettyServiceBuilder().handler(resourceHandler).build());
}
示例11: main
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
AccountService accountService = new AccountService();
accountService.addNewUser(new UserProfile("admin"));
accountService.addNewUser(new UserProfile("test"));
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(new UsersServlet(accountService)), "/api/v1/users");
context.addServlet(new ServletHolder(new SessionsServlet(accountService)), "/api/v1/sessions");
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setResourceBase("public_html");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{resource_handler, context});
Server server = new Server(8080);
server.setHandler(handlers);
server.start();
server.join();
}
示例12: main
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.out.append("Use port as the first argument");
System.exit(1);
}
String portString = args[0];
int port = Integer.valueOf(portString);
System.out.append("Starting at port: ").append(portString).append('\n');
Server server = new Server(port);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(new AdminPageServlet()), AdminPageServlet.adminPageURL);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setResourceBase("static");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{resource_handler, context});
server.setHandler(handlers);
server.start();
server.join();
}
示例13: init
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的package包/類
public static boolean init(WebServerConfig webServerConfig)
{
server = new Server(webServerConfig.port);
try
{
context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
context.setResourceBase("");
resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(webServerConfig.resourcePath);
handlerList.addHandler(context);
handlerList.addHandler(resourceHandler);
server.setHandler(handlerList);
loadWebServlet(webServerConfig.packages);
server.start();
}
catch (Exception e)
{
Log.error("WebServerMgr init error", e);
return false;
}
return true;
}
示例14: run
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的package包/類
@Override
public void run() {
try {
Server server = new Server(8080);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[] { "index.html" });
resource_handler.setResourceBase("./www");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler,
new StateHandler(this.geo) });
server.setHandler(handlers);
server.start();
server.join();
} catch (Exception e) {
e.printStackTrace();
}
}
示例15: before_suite
import org.eclipse.jetty.server.handler.ResourceHandler; //導入方法依賴的package包/類
@BeforeSuite
public void before_suite() throws Exception {
// Launch Protractor's own test app on http://localhost:8080
((StdErrLog) Log.getRootLogger()).setLevel(StdErrLog.LEVEL_OFF);
webServer = new Server(new QueuedThreadPool(6));
ServerConnector connector = new ServerConnector(webServer, new HttpConnectionFactory());
connector.setPort(8080);
webServer.addConnector(connector);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[]{"index.html"});
resource_handler.setResourceBase("src/test/webapp");
HandlerList handlers = new HandlerList();
MovedContextHandler effective_symlink = new MovedContextHandler(webServer, "/lib/angular", "/lib/angular_v1.2.9");
handlers.setHandlers(new Handler[] { effective_symlink, resource_handler, new DefaultHandler() });
webServer.setHandler(handlers);
webServer.start();
driver = new ChromeDriver();
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);
ngWebDriver = new NgWebDriver(driver);
}