本文整理汇总了Java中org.eclipse.jetty.server.handler.HandlerCollection.setHandlers方法的典型用法代码示例。如果您正苦于以下问题:Java HandlerCollection.setHandlers方法的具体用法?Java HandlerCollection.setHandlers怎么用?Java HandlerCollection.setHandlers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.server.handler.HandlerCollection
的用法示例。
在下文中一共展示了HandlerCollection.setHandlers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initServer
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
private static void initServer(Properties properties) throws Exception {
Integer port = Integer.valueOf(properties.getProperty("server.port"));
String host = properties.getProperty("server.host");
Integer clientId = Integer.valueOf(properties.getProperty("client.id"));
String clientSecret = properties.getProperty("client.secret");
HandlerCollection handlers = new HandlerCollection();
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[]{"index.html"});
resourceHandler.setResourceBase(Application.class.getResource("/static").getPath());
VkApiClient vk = new VkApiClient(new HttpTransportClient());
handlers.setHandlers(new Handler[]{resourceHandler, new RequestHandler(vk, clientId, clientSecret, host)});
Server server = new Server(port);
server.setHandler(handlers);
server.start();
server.join();
}
示例2: startServer
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
public static void startServer(String[] args) throws Exception {
Server server = new Server(8080);
WebAppContext ctx = new WebAppContext();
ctx.setContextPath("/");
ctx.setWar("src/main/webapp/");
HandlerCollection hc = new HandlerCollection();
hc.setHandlers(new Handler[] {ctx});
server.setHandler(hc);
server.setStopAtShutdown(true);
server.start();
server.join();
// server.removeBean(o);
// server.addBean(o);
}
示例3: start
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
public void start() throws Exception {
RequestLogHandler requestLogHandler = new RequestLogHandler();
Slf4jRequestLog requestLog = new Slf4jRequestLog();
requestLog.setExtended(true);
requestLog.setLogTimeZone(TimeZone.getDefault().getID());
requestLog.setLogLatency(true);
requestLogHandler.setRequestLog(requestLog);
handlers.add(0, new ContextHandlerCollection());
handlers.add(requestLogHandler);
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
server.setHandler(handlerCollection);
server.start();
log.info("Server started at end point {}", getServiceUri());
}
示例4: start
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
public void start() throws PulsarServerException {
log.info("Starting web socket proxy at port {}", conf.getWebServicePort());
try {
RequestLogHandler requestLogHandler = new RequestLogHandler();
Slf4jRequestLog requestLog = new Slf4jRequestLog();
requestLog.setExtended(true);
requestLog.setLogTimeZone(TimeZone.getDefault().getID());
requestLog.setLogLatency(true);
requestLogHandler.setRequestLog(requestLog);
handlers.add(0, new ContextHandlerCollection());
handlers.add(requestLogHandler);
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
server.setHandler(handlerCollection);
server.start();
} catch (Exception e) {
throw new PulsarServerException(e);
}
}
示例5: start
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
public void start() throws PulsarServerException {
try {
RequestLogHandler requestLogHandler = new RequestLogHandler();
Slf4jRequestLog requestLog = new Slf4jRequestLog();
requestLog.setExtended(true);
requestLog.setLogTimeZone(TimeZone.getDefault().getID());
requestLog.setLogLatency(true);
requestLogHandler.setRequestLog(requestLog);
handlers.add(0, new ContextHandlerCollection());
handlers.add(requestLogHandler);
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
server.setHandler(handlerCollection);
server.start();
log.info("Web Service started at {}", pulsar.getWebServiceAddress());
} catch (Exception e) {
throw new PulsarServerException(e);
}
}
示例6: main
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
public static void main( String[] args )
throws Exception
{
Server server = new Server( 8080 );
WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/jaxrs" );
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 );
server.start();
server.join();
}
示例7: Olingo2SampleServer
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
/**
*
* @param port
* @param resourcePath
*/
public Olingo2SampleServer(int port, String resourcePath) {
this.port = port;
server = new org.eclipse.jetty.server.Server(port);
WebAppContext webappcontext = new WebAppContext();
String contextPath = null;
try {
contextPath = Olingo2SampleServer.class.getResource(resourcePath).toURI().getPath();
} catch (URISyntaxException e) {
LOG.error("Unable to read the resource at {}", resourcePath, e);
}
webappcontext.setContextPath("/");
webappcontext.setWar(contextPath);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});
server.setHandler(handlers);
}
示例8: customizeServer
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
@Override
public void customizeServer(Server server) {
if(logFile != null) {
HandlerCollection rootHandler = (HandlerCollection) server.getHandler();
List<Handler> handlers = new ArrayList<Handler>();
handlers.addAll(Arrays.asList(rootHandler.getHandlers()));
RequestLogHandler requestLogHandler = new RequestLogHandler();
NCSARequestLog requestLog = new NCSARequestLog(logFile.getAbsolutePath());
requestLog.setRetainDays(0);
requestLog.setAppend(true);
requestLog.setExtended(extended);
requestLog.setLogTimeZone("GMT");
requestLogHandler.setRequestLog(requestLog);
handlers.add(requestLogHandler);
rootHandler.setHandlers(handlers.toArray(new Handler[handlers.size()]));
}
}
示例9: main
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
URI baseUri = UriBuilder.fromUri("http://localhost").port(SERVER_PORT)
.build();
ResourceConfig config = new ResourceConfig(Calculator.class);
Server server = JettyHttpContainerFactory.createServer(baseUri, config,
false);
ContextHandler contextHandler = new ContextHandler("/rest");
contextHandler.setHandler(server.getHandler());
ProtectionDomain protectionDomain = EmbeddedServer.class
.getProtectionDomain();
URL location = protectionDomain.getCodeSource().getLocation();
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setWelcomeFiles(new String[] { "index.html" });
resourceHandler.setResourceBase(location.toExternalForm());
System.out.println(location.toExternalForm());
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { resourceHandler,
contextHandler, new DefaultHandler() });
server.setHandler(handlerCollection);
server.start();
server.join();
}
示例10: createHandlers
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
private static HandlerCollection createHandlers(
final GatewayConfig config,
final GatewayServices services,
final ContextHandlerCollection contexts) {
HandlerCollection handlers = new HandlerCollection();
RequestLogHandler logHandler = new RequestLogHandler();
logHandler.setRequestLog(new AccessHandler());
TraceHandler traceHandler = new TraceHandler();
traceHandler.setHandler(contexts);
traceHandler.setTracedBodyFilter(System.getProperty("org.apache.knox.gateway.trace.body.status.filter"));
CorrelationHandler correlationHandler = new CorrelationHandler();
correlationHandler.setHandler(traceHandler);
DefaultTopologyHandler defaultTopoHandler = new DefaultTopologyHandler(config, services, contexts);
handlers.setHandlers(new Handler[]{correlationHandler, defaultTopoHandler, logHandler});
return handlers;
}
示例11: registerHandlers
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
/**
* Hook up Jetty handlers. Do this before start() is called.
*/
public void registerHandlers(HandlerWrapper s) {
GateHandler gh = new GateHandler();
AddCommonResponseHeadersHandler rhh = new AddCommonResponseHeadersHandler();
ExtensionHandler1 eh1 = new ExtensionHandler1();
ServletContextHandler context = new ServletContextHandler(
ServletContextHandler.SECURITY | ServletContextHandler.SESSIONS
);
context.setContextPath("/");
context.addServlet(H2oNpsBinServlet.class, "/3/NodePersistentStorage.bin/*");
context.addServlet(H2oPostFileServlet.class, "/3/PostFile.bin");
context.addServlet(H2oPostFileServlet.class, "/3/PostFile");
context.addServlet(H2oDatasetServlet.class, "/3/DownloadDataset");
context.addServlet(H2oDatasetServlet.class, "/3/DownloadDataset.bin");
context.addServlet(H2oDefaultServlet.class, "/");
Handler[] handlers = {gh, rhh, eh1, context};
HandlerCollection hc = new HandlerCollection();
hc.setHandlers(handlers);
s.setHandler(hc);
}
示例12: configureRedirectionRules
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
private Handler configureRedirectionRules(Handler appHandler) {
RewriteHandler handler = new RewriteHandler();
handler.setRewriteRequestURI(false);
handler.setRewritePathInfo(false);
handler.setOriginalPathAttribute("requestedPath");
RewriteRegexRule uiRewriteRule = new RewriteRegexRule();
uiRewriteRule.setRegex("^/collector/.*");
uiRewriteRule.setReplacement("/");
handler.addRule(uiRewriteRule);
handler.setHandler(appHandler);
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] {handler, appHandler});
return handlerCollection;
}
示例13: registerHandlers
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
@Override
protected void registerHandlers(HandlerWrapper handlerWrapper, ServletContextHandler context) {
// setup authenticating proxy servlet (each request is forwarded with BASIC AUTH)
ServletHolder proxyServlet = new ServletHolder(Transparent.class);
proxyServlet.setInitParameter("ProxyTo", _proxyTo);
proxyServlet.setInitParameter("Prefix", "/");
proxyServlet.setInitParameter("BasicAuth", _credentials.toBasicAuth());
context.addServlet(proxyServlet, "/*");
// authHandlers assume the user is already authenticated
HandlerCollection authHandlers = new HandlerCollection();
authHandlers.setHandlers(new Handler[]{
new AuthenticationHandler(),
context,
});
// handles requests of login form and delegates the rest to the authHandlers
LoginHandler loginHandler = new LoginHandler("/login", "/loginError");
loginHandler.setHandler(authHandlers);
// login handler is the root handler
handlerWrapper.setHandler(loginHandler);
}
示例14: startServer
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
public void startServer() throws Exception {
server = new Server();
WebAppContext pentahoContext = new WebAppContext();
pentahoContext.setClassLoader(getClass().getClassLoader());
pentahoContext.setContextPath("/pentaho"); //$NON-NLS-1$
pentahoContext.setWar(webappsFolder + "/pentaho"); //$NON-NLS-1$
pentahoContext.setParentLoaderPriority(true);
HandlerCollection handlers= new HandlerCollection();
handlers.setHandlers(new Handler[]{pentahoContext, new DefaultHandler()});
server.setHandler(handlers);
// Start execution
createListeners();
server.start();
}
示例15: startServer
import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
public void startServer() throws Exception {
Server server = new Server(this.port);
final HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {
new SideloadHandler(
this.imageStore,
this.store,
this.fingerprintSizeLarge,
this.fingerprintSizeSmall),
new ImageHandler(
this.imageStore,
this.cacheDir
)
});
server.setHandler(handlers);
server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", -1);
server.start();
server.join();
}