本文整理匯總了Java中org.mortbay.jetty.handler.ContextHandlerCollection類的典型用法代碼示例。如果您正苦於以下問題:Java ContextHandlerCollection類的具體用法?Java ContextHandlerCollection怎麽用?Java ContextHandlerCollection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ContextHandlerCollection類屬於org.mortbay.jetty.handler包,在下文中一共展示了ContextHandlerCollection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
public static void main( String[] args )
throws Exception
{
Server server = new Server( 8081 );
WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/reporting" );
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();
}
示例2: configureHandlers
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
/**
* Set up the handler structure to receive a webapp. Also put in a DefaultHandler so we get a nice page than a 404
* if we hit the root and the webapp's context isn't at root.
*/
public void configureHandlers() throws Exception {
this.defaultHandler = new DefaultHandler();
this.requestLogHandler = new RequestLogHandler();
if (this.requestLog != null) {
this.requestLogHandler.setRequestLog(this.requestLog);
}
this.contexts = (ContextHandlerCollection) server.getChildHandlerByClass(ContextHandlerCollection.class);
if (this.contexts == null) {
this.contexts = new ContextHandlerCollection();
this.handlers = (HandlerCollection) server.getChildHandlerByClass(HandlerCollection.class);
if (this.handlers == null) {
this.handlers = new HandlerCollection();
this.server.setHandler(handlers);
this.handlers.setHandlers(new Handler[]{this.contexts, this.defaultHandler, this.requestLogHandler});
} else {
this.handlers.addHandler(this.contexts);
}
}
}
示例3: main
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
public static void main( String[] args )
throws Exception
{
Server server = new Server( 8080 );
WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/xdocreport-webapp" );
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 );
// JSP Servlet + Context
Context jsp_ctx = new Context( servlet_contexts, "/jsp", Context.SESSIONS );
jsp_ctx.addServlet( new ServletHolder( new org.apache.jasper.servlet.JspServlet() ), "*.jsp" );
server.start();
server.join();
}
示例4: addDefaultApps
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
/**
* Add default apps.
* @param appDir The application directory
* @throws IOException
*/
protected void addDefaultApps(ContextHandlerCollection parent,
final String appDir) throws IOException {
// set up the context for "/logs/" if "hadoop.log.dir" property is defined.
String logDir = System.getProperty("hadoop.log.dir");
if (logDir != null) {
Context logContext = new Context(parent, "/logs");
logContext.setResourceBase(logDir);
logContext.addServlet(StaticServlet.class, "/");
defaultContexts.put(logContext, true);
}
// set up the context for "/static/*"
Context staticContext = new Context(parent, "/static");
staticContext.setResourceBase(appDir + "/static");
staticContext.addServlet(StaticServlet.class, "/*");
defaultContexts.put(staticContext, true);
}
示例5: addDefaultApps
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
/**
* Add default apps.
*
* @param appDir
* The application directory
* @throws IOException
*/
protected void addDefaultApps(ContextHandlerCollection parent,
final String appDir, Configuration conf) throws IOException {
// set up the context for "/logs/" if "hadoop.log.dir" property is defined.
String logDir = System.getProperty("tajo.log.dir");
if (logDir != null) {
Context logContext = new Context(parent, "/logs");
logContext.setResourceBase(logDir);
//logContext.addServlet(AdminAuthorizedServlet.class, "/*");
logContext.setDisplayName("logs");
defaultContexts.put(logContext, true);
}
// set up the context for "/static/*"
Context staticContext = new Context(parent, "/static");
staticContext.setResourceBase(appDir + "/static");
staticContext.addServlet(DefaultServlet.class, "/*");
staticContext.setDisplayName("static");
defaultContexts.put(staticContext, true);
}
示例6: startServer
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
/**
* Starts the jetty web server.
* @return true on successful start.
*/
public boolean startServer() {
if (server != null && server.isRunning()) {
return true;
} else {
server = new Server(port);
ContextHandlerCollection contexts = new ContextHandlerCollection();
server.setHandler(contexts);
Context mjpg = new Context(contexts, MPEG, Context.SESSIONS);
mjpg.addServlet(new ServletHolder(new AxisServlet()), "/*");
try {
server.start();
return true;
} catch (Exception e1) {
log.error("Could not start server", e1);
}
}
return false;
}
示例7: addDefaultApps
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
/**
* Add default apps.
* @param appDir The application directory
* @throws IOException
*/
protected void addDefaultApps(ContextHandlerCollection parent,
final String appDir) throws IOException {
// set up the context for "/logs/" if "hadoop.log.dir" property is defined.
String logDir = System.getProperty("hadoop.log.dir");
if (logDir != null) {
Context logContext = new Context(parent, "/logs");
logContext.setResourceBase(logDir);
logContext.addServlet(AdminAuthorizedServlet.class, "/");
logContext.setDisplayName("logs");
setContextAttributes(logContext);
defaultContexts.put(logContext, true);
}
// set up the context for "/static/*"
Context staticContext = new Context(parent, "/static");
staticContext.setResourceBase(appDir + "/static");
staticContext.addServlet(DefaultServlet.class, "/*");
staticContext.setDisplayName("static");
setContextAttributes(staticContext);
defaultContexts.put(staticContext, true);
}
示例8: testStopWebAppCtx
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
public void testStopWebAppCtx() throws Exception {
final boolean[] stopped = new boolean[1];
Server tempServer = new Server() {
public Handler getChildHandlerByClass(Class byclass) {
if (ContextHandlerCollection.class.equals(byclass))
return null;
assertEquals(HandlerCollection.class, byclass);
return new HandlerCollection();
}
};
BundleContext bundleCtx = new MockBundleContext();
String contextPath = "/path";
deployer.setServer(tempServer);
deployer.afterPropertiesSet();
WarDeployment deployment = deployer.createDeployment(bundleCtx.getBundle(), contextPath);
deployment.undeploy();
}
示例9: addDefaultApps
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
/**
* Add default apps.
* @param appDir The application directory
* @throws IOException
*/
protected void addDefaultApps(ContextHandlerCollection parent,
final String appDir) throws IOException {
// set up the context for "/logs/" if "hadoop.log.dir" property is defined.
String logDir = System.getProperty("hadoop.log.dir");
if (logDir != null) {
Context logContext = new Context(parent, "/logs");
logContext.setResourceBase(logDir);
logContext.addServlet(DefaultServlet.class, "/");
defaultContexts.put(logContext, true);
}
// set up the context for "/static/*"
Context staticContext = new Context(parent, "/static");
staticContext.setResourceBase(appDir + "/static");
staticContext.addServlet(DefaultServlet.class, "/*");
defaultContexts.put(staticContext, true);
}
示例10: createHttpServer
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
@Override
public HttpServer createHttpServer(InetSocketAddress addr, int backlog)
throws IOException
{
Server server = _server;
boolean noServerCleanUp = true;
if (server == null)
{
server = new Server();
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] {new ContextHandlerCollection(), new DefaultHandler()});
server.setHandler(handlerCollection);
noServerCleanUp = false;
}
JettyHttpServer jettyHttpServer = new JettyHttpServer(server, noServerCleanUp);
jettyHttpServer.bind(addr, backlog);
return jettyHttpServer;
}
示例11: addDefaultApps
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
/**
* Add default apps.
* @param appDir The application directory
* @throws IOException
*/
protected void addDefaultApps(ContextHandlerCollection parent,
final String appDir, Configuration conf) throws IOException {
// set up the context for "/logs/" if "hadoop.log.dir" property is defined.
String logDir = System.getProperty("hadoop.log.dir");
if (logDir != null) {
Context logContext = new Context(parent, "/logs");
logContext.setResourceBase(logDir);
logContext.addServlet(AdminAuthorizedServlet.class, "/*");
if (conf.getBoolean(
CommonConfigurationKeys.HADOOP_JETTY_LOGS_SERVE_ALIASES,
CommonConfigurationKeys.DEFAULT_HADOOP_JETTY_LOGS_SERVE_ALIASES)) {
logContext.getInitParams().put(
"org.mortbay.jetty.servlet.Default.aliases", "true");
}
logContext.setDisplayName("logs");
setContextAttributes(logContext, conf);
addNoCacheFilter(webAppContext);
defaultContexts.put(logContext, true);
}
// set up the context for "/static/*"
Context staticContext = new Context(parent, "/static");
staticContext.setResourceBase(appDir + "/static");
staticContext.addServlet(DefaultServlet.class, "/*");
staticContext.setDisplayName("static");
setContextAttributes(staticContext, conf);
defaultContexts.put(staticContext, true);
}
示例12: addDefaultApps
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
/**
* Add default apps.
* @param appDir The application directory
* @throws IOException
*/
protected void addDefaultApps(ContextHandlerCollection parent,
final String appDir, Configuration conf) throws IOException {
// set up the context for "/logs/" if "hadoop.log.dir" property is defined.
String logDir = System.getProperty("hadoop.log.dir");
if (logDir != null) {
Context logContext = new Context(parent, "/logs");
logContext.setResourceBase(logDir);
logContext.addServlet(AdminAuthorizedServlet.class, "/*");
if (conf.getBoolean(
CommonConfigurationKeys.HADOOP_JETTY_LOGS_SERVE_ALIASES,
CommonConfigurationKeys.DEFAULT_HADOOP_JETTY_LOGS_SERVE_ALIASES)) {
@SuppressWarnings("unchecked")
Map<String, String> params = logContext.getInitParams();
params.put(
"org.mortbay.jetty.servlet.Default.aliases", "true");
}
logContext.setDisplayName("logs");
setContextAttributes(logContext, conf);
addNoCacheFilter(webAppContext);
defaultContexts.put(logContext, true);
}
// set up the context for "/static/*"
Context staticContext = new Context(parent, "/static");
staticContext.setResourceBase(appDir + "/static");
staticContext.addServlet(DefaultServlet.class, "/*");
staticContext.setDisplayName("static");
setContextAttributes(staticContext, conf);
defaultContexts.put(staticContext, true);
}
示例13: addDefaultApps
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
/**
* Add default apps.
* @param appDir The application directory
* @throws IOException
*/
protected void addDefaultApps(ContextHandlerCollection parent,
final String appDir, Configuration conf) throws IOException {
// set up the context for "/logs/" if "hadoop.log.dir" property is defined.
String logDir = this.logDir;
if (logDir == null) {
logDir = System.getProperty("hadoop.log.dir");
}
if (logDir != null) {
Context logContext = new Context(parent, "/logs");
logContext.setResourceBase(logDir);
logContext.addServlet(AdminAuthorizedServlet.class, "/*");
if (conf.getBoolean(
ServerConfigurationKeys.HBASE_JETTY_LOGS_SERVE_ALIASES,
ServerConfigurationKeys.DEFAULT_HBASE_JETTY_LOGS_SERVE_ALIASES)) {
@SuppressWarnings("unchecked")
Map<String, String> params = logContext.getInitParams();
params.put(
"org.mortbay.jetty.servlet.Default.aliases", "true");
}
logContext.setDisplayName("logs");
setContextAttributes(logContext, conf);
addNoCacheFilter(webAppContext);
defaultContexts.put(logContext, true);
}
// set up the context for "/static/*"
Context staticContext = new Context(parent, "/static");
staticContext.setResourceBase(appDir + "/static");
staticContext.addServlet(DefaultServlet.class, "/*");
staticContext.setDisplayName("static");
setContextAttributes(staticContext, conf);
defaultContexts.put(staticContext, true);
}
示例14: createApplicationContext
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
/**
* @see com.sabre.ant.jetty.WebApplicationProxy#createApplicationContext(org.mortbay.jetty.handler.ContextHandlerCollection)
*/
public void createApplicationContext(ContextHandlerCollection contexts)
{
webAppContext = new WebAppContext(contexts, warFile.getAbsolutePath(), contextPath);
webAppContext.setDisplayName(name);
configurePaths();
configureHandlers(contexts);
applyConfiguration();
}
示例15: configureHandlers
import org.mortbay.jetty.handler.ContextHandlerCollection; //導入依賴的package包/類
private void configureHandlers(ContextHandlerCollection contexts)
{
// adding extra context handlers
Iterator handlersIterator = contextHandlers.iterator();
while (handlersIterator.hasNext())
{
ContextHandler contextHandler = (ContextHandler) handlersIterator.next();
contexts.addHandler(contextHandler);
}
}