本文整理汇总了Java中org.eclipse.jetty.server.handler.ContextHandlerCollection类的典型用法代码示例。如果您正苦于以下问题:Java ContextHandlerCollection类的具体用法?Java ContextHandlerCollection怎么用?Java ContextHandlerCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContextHandlerCollection类属于org.eclipse.jetty.server.handler包,在下文中一共展示了ContextHandlerCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeClass
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
ccowServer = new Server(serverPort);
final CCOWContextListener c = new CCOWContextListener(commonContext, new InlinedContextAgentRepositoryModule());
final MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
ccowServer.addBean(mbContainer);
final ServletContextHandler webSocketServletContextHandler = new ServletContextHandler(ccowServer, "/ws",
ServletContextHandler.SESSIONS);
webSocketServletContextHandler.addEventListener(c);
WebSocketServerContainerInitializer.configureContext(webSocketServletContextHandler);
final ServletContextHandler restServletContextHandler = new ServletContextHandler(ccowServer, "/");
restServletContextHandler.addEventListener(c);
restServletContextHandler.addFilter(AppGuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
final ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(new Handler[] { webSocketServletContextHandler, restServletContextHandler});
ccowServer.setHandler(contexts);
ccowServer.start();
}
示例2: start
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的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());
}
示例3: start
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的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);
}
}
示例4: start
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的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);
}
}
示例5: initializeServer
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的package包/类
private void initializeServer() {
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.packages(GridServices.class.getPackage().getName());
resourceConfig.register(JacksonJaxbJsonProvider.class);
final Grid grid = this;
resourceConfig.register(new AbstractBinder() {
@Override
protected void configure() {
bind(grid).to(Grid.class);
bind(fileManager).to(FileProvider.class);
}
});
ServletContainer servletContainer = new ServletContainer(resourceConfig);
ServletHolder sh = new ServletHolder(servletContainer);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
context.addServlet(sh, "/*");
server = new Server(port);
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(new Handler[] { context});
server.setHandler(contexts);
}
示例6: main
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的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: initJettyServer
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的package包/类
private Server initJettyServer(ComponentRepository repo) {
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(getPort());
connector.setConfidentialPort(getSecurePort());
connector.setRequestHeaderSize(16384);
Server jettyServer = new Server();
jettyServer.setConnectors(new Connector[] {connector});
ContextHandlerCollection contexts = new ContextHandlerCollection();
HandlerCollection handlers = new HandlerCollection();
handlers.addHandler(contexts);
addHandlers(repo, jettyServer, contexts);
jettyServer.setHandler(handlers);
jettyServer.setStopAtShutdown(true);
jettyServer.setGracefulShutdown(2000);
jettyServer.setSendDateHeader(true);
jettyServer.setSendServerVersion(true);
ComponentInfo info = new ComponentInfo(Server.class, "jetty");
repo.registerComponent(info, jettyServer);
repo.registerLifecycle(new ServerLifecycle(jettyServer));
return jettyServer;
}
示例8: startServer
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的package包/类
@BeforeClass
public void startServer() throws Exception {
int port = 49152 + RandomUtils.nextInt(65535 - 49152);
String serverUrl = "http://localhost:" + port + "/jax";
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
_jettyServer = new Server();
_jettyServer.setConnectors(new Connector[]{connector});
ContextHandlerCollection contexts = new ContextHandlerCollection();
HandlerCollection handlers = new HandlerCollection();
handlers.addHandler(contexts);
WebAppContext ogWebAppContext = new WebAppContext("RemoteViewRunnerTest", "/");
org.springframework.core.io.Resource resource = new ClassPathResource("web-engine");
ogWebAppContext.setBaseResource(Resource.newResource(resource.getFile()));
DataViewRunnerResource viewRunnerResource = new DataViewRunnerResource(new TestViewRunner());
ComponentRepository repo = new ComponentRepository(ComponentLogger.Console.VERBOSE);
repo.getRestComponents().publishResource(viewRunnerResource);
repo.getRestComponents().publishHelper(new FudgeObjectBinaryConsumer());
repo.getRestComponents().publishHelper(new FudgeObjectBinaryProducer());
ogWebAppContext.setEventListeners(new EventListener[]{new ComponentRepositoryServletContextListener(repo)});
handlers.addHandler(ogWebAppContext);
_jettyServer.setHandler(handlers);
_jettyServer.start();
_remoteViewRunner = new RemoteViewRunner(URI.create(serverUrl));
}
示例9: RestfulServer
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的package包/类
public RestfulServer(boolean loopback,
int port,
String applicationName,
boolean sslEnabled,
String keyStoreAlias,
String keyStorePassword,
String keyStorePath,
int maxNumberOfThreads,
int maxQueuedRequests) {
this.applicationName = applicationName;
int maxThreads = maxNumberOfThreads + ACCEPTORS + SELECTORS;
BlockingArrayQueue<Runnable> queue = new BlockingArrayQueue<>(MIN_THREADS, MIN_THREADS, maxQueuedRequests);
this.queuedThreadPool = new QueuedThreadPool(maxThreads, MIN_THREADS, IDLE_TIMEOUT, queue);
this.server = new Server(queuedThreadPool);
this.handlers = new ContextHandlerCollection();
server.addEventListener(new MBeanContainer(ManagementFactory.getPlatformMBeanServer()));
server.setHandler(handlers);
if (sslEnabled) {
server.addConnector(makeSslConnector(keyStoreAlias, keyStorePassword, keyStorePath, port));
} else {
server.addConnector(makeConnector(loopback, port));
}
}
示例10: createHandlers
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的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: applyHandle
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的package包/类
private void applyHandle(final String contextPath, final String warPath) {
final ContextHandlerCollection handler = new ContextHandlerCollection();
final WebAppContext webapp = new WebAppContext();
webapp.setContextPath(contextPath);
webapp.setDefaultsDescriptor(WEB_DEFAULT);
if (StringUtils.isEmpty(warPath)) {
webapp.setResourceBase(DEFAULT_RESOURCE_BASE);
webapp.setDescriptor(DEFAULT_WEB_XML_PATH);
} else {
webapp.setWar(warPath);
}
applySessionHandler(webapp);
handler.addHandler(webapp);
super.setHandler(handler);
}
示例12: attachHandlers
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的package包/类
private ContextHandlerCollection attachHandlers(final File staticsFolder, final Module... overrides) {
final MoodcatHandler moodcatHandler = new MoodcatHandler(this, staticsFolder, overrides);
final ResourceHandler resources = new ResourceHandler();
resources.setBaseResource(Resource.newResource(staticsFolder));
resources.setDirectoriesListed(false);
resources.setCacheControl("max-age=3600");
final HashSessionManager hashSessionManager = new HashSessionManager();
hashSessionManager.setMaxInactiveInterval(SESSION_KEEP_ALIVE);
final ContextHandlerCollection handlers = new ContextHandlerCollection();
// CHECKSTYLE:OFF
handlers.addContext("/", "/").setHandler(resources);
handlers.addContext("/", "/").setHandler(moodcatHandler);
// CHECKSTYLE:ON
return handlers;
}
示例13: ManagerHandler
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的package包/类
public ManagerHandler(
final String baseURL,
final Server server,
final ConnectorStatistics connectorStats,
final StatisticsHandler statHandler,
final ContextHandlerCollection handlers,
final String thumbnailsDirectoryName )
throws IOException, URISyntaxException
{
this.baseURL = baseURL;
this.server = server;
this.handlers = handlers;
this.statHandler = statHandler;
this.connectorStats = connectorStats;
this.thumbnailsDirectoryName = thumbnailsDirectoryName;
setContextPath( "/" + Constants.MANAGER_CONTEXT_NAME );
}
示例14: createHandlers
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的package包/类
private static ContextHandlerCollection createHandlers( final String baseURL, final Map< String, String > dataSet, final String thumbnailsDirectoryName ) throws SpimDataException, IOException
{
final ContextHandlerCollection handlers = new ContextHandlerCollection();
for ( final Entry< String, String > entry : dataSet.entrySet() )
{
final String name = entry.getKey();
final String xmlpath = entry.getValue();
final String context = "/" + name;
final CellHandler ctx = new CellHandler( baseURL + context + "/", xmlpath, name, thumbnailsDirectoryName );
ctx.setContextPath( context );
handlers.addHandler( ctx );
}
return handlers;
}
示例15: startWebApp
import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入依赖的package包/类
/**
* Big hack for the moment, not using properties for directory and port
* Go through all the Jetty servers, find the one serving port 7657,
* requested and add the .war to that one
*/
private void startWebApp(String app) {
ContextHandlerCollection s = WebAppStarter.getConsoleServer();
if (s != null) {
try {
File path = new File(_context.getBaseDir(), "webapps");
path = new File(path, app + ".war");
WebAppStarter.startWebApp(_context, s, app, path.getAbsolutePath());
addFormNoticeNoEscape(_("WebApp") + " <a href=\"/" + app + "/\">" + _(app) + "</a> " + _("started") + '.');
} catch (Throwable e) {
addFormError(_("Failed to start") + ' ' + _(app) + " " + e + '.');
_log.error("Failed to start webapp " + app, e);
}
return;
}
addFormError(_("Failed to find server."));
}