本文整理汇总了Java中org.mortbay.jetty.servlet.Context.setResourceBase方法的典型用法代码示例。如果您正苦于以下问题:Java Context.setResourceBase方法的具体用法?Java Context.setResourceBase怎么用?Java Context.setResourceBase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.servlet.Context
的用法示例。
在下文中一共展示了Context.setResourceBase方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDefaultApps
import org.mortbay.jetty.servlet.Context; //导入方法依赖的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);
}
示例2: start
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
public void start() throws Exception {
this.jetty.addConnector(connector);
ServletHandler servletHandler = new ServletHandler();
String filterName = "MyriadGuiceFilter";
FilterHolder holder = new FilterHolder(filter);
holder.setName(filterName);
FilterMapping filterMapping = new FilterMapping();
filterMapping.setPathSpec("/*");
filterMapping.setDispatches(Handler.ALL);
filterMapping.setFilterName(filterName);
servletHandler.addFilter(holder, filterMapping);
Context context = new Context();
context.setServletHandler(servletHandler);
context.addServlet(DefaultServlet.class, "/");
String staticDir = this.getClass().getClassLoader().getResource("webapp/public").toExternalForm();
context.setResourceBase(staticDir);
this.jetty.addHandler(context);
this.jetty.start();
}
示例3: addDefaultApps
import org.mortbay.jetty.servlet.Context; //导入方法依赖的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);
}
示例4: addDefaultApps
import org.mortbay.jetty.servlet.Context; //导入方法依赖的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);
}
示例5: main
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
* Sets up and runs server.
* @param args
*/
public static void main(String[] args)
{
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8080);
server.addConnector(connector);
Context htmlContext = new Context(server, "/", Context.SESSIONS);
ResourceHandler htmlHandler = new ResourceHandler();
htmlHandler.setResourceBase("web");
htmlContext.setHandler(htmlHandler);
Context servletContext = new Context(server, "/", Context.SESSIONS);
ServletHolder holder = new ServletHolder(new DwrServlet());
holder.setInitParameter("activeReverseAjaxEnabled", "true");
holder.setInitParameter("debug", "true");
servletContext.addServlet(holder, "/dwr/*");
servletContext.setResourceBase("web");
try
{
JettyShutdown.addShutdownHook(server);
server.start();
server.join();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
示例6: addDefaultApps
import org.mortbay.jetty.servlet.Context; //导入方法依赖的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);
}
示例7: addDefaultApps
import org.mortbay.jetty.servlet.Context; //导入方法依赖的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);
}
示例8: addDefaultApps
import org.mortbay.jetty.servlet.Context; //导入方法依赖的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);
}
示例9: fixupLogsServletLocation
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
* Fixup where the logs app points, make it point at hbase logs rather than
* hadoop logs.
*/
private void fixupLogsServletLocation() {
// Must be same as up in hadoop.
final String logsContextPath = "/logs";
// Now, put my logs in place of hadoops... disable old one first.
Context oldLogsContext = null;
for (Map.Entry<Context, Boolean> e : defaultContexts.entrySet()) {
if (e.getKey().getContextPath().equals(logsContextPath)) {
oldLogsContext = e.getKey();
break;
}
}
if (oldLogsContext != null) {
this.defaultContexts.put(oldLogsContext, Boolean.FALSE);
}
// Now do my logs.
// Set up the context for "/logs/" if "hbase.log.dir" property is defined.
String logDir = System.getProperty("hbase.log.dir");
if (logDir != null) {
// This is a little presumptious but seems to work.
Context logContext =
new Context((ContextHandlerCollection)this.webServer.getHandler(),
logsContextPath);
logContext.setResourceBase(logDir);
logContext.addServlet(DefaultServlet.class, "/");
defaultContexts.put(logContext, true);
}
}
示例10: fixupLogsServletLocation
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
/**
* Fixup where the logs app points, make it point at hbase logs rather than
* hadoop logs.
*/
private void fixupLogsServletLocation() {
// Must be same as up in hadoop.
final String logsContextPath = "/logs";
// Now, put my logs in place of hadoops... disable old one first.
Context oldLogsContext = null;
for (Map.Entry<Context, Boolean> e : defaultContexts.entrySet()) {
if (e.getKey().getContextPath().equals(logsContextPath)) {
oldLogsContext = e.getKey();
break;
}
}
if (oldLogsContext != null) {
this.defaultContexts.put(oldLogsContext, Boolean.FALSE);
}
// Now do my logs.
// Set up the context for "/logs/" if "hbase.log.dir" property is defined.
String logDir = System.getProperty("hbase.log.dir");
if (logDir != null) {
// This is a little presumptious but seems to work.
Context logContext =
new Context((ContextHandlerCollection)this.webServer.getHandler(),
logsContextPath);
logContext.setResourceBase(logDir);
logContext.addServlet(DefaultServlet.class, "/");
HttpServerUtil.constrainHttpMethods(logContext);
defaultContexts.put(logContext, true);
}
}
示例11: WebServer
import org.mortbay.jetty.servlet.Context; //导入方法依赖的package包/类
public WebServer(int httpport, DataStore data, MetadataStore metadata) throws IOException, URISyntaxException {
super(httpport);
extractWebUI();
this.data = data;
this.metadata = metadata;
// Initialize Velocity template engine
try {
Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.Log4JLogChute");
Velocity.setProperty("runtime.log.logsystem.log4j.logger", "edu.berkeley.xtrace.server.XTraceServer");
Velocity.setProperty("file.resource.loader.path", webui + "/templates");
Velocity.setProperty("file.resource.loader.cache", "true");
Velocity.init();
} catch (Exception e) {
LOG.warn("Failed to initialize Velocity", e);
}
// Create Jetty server
Context context = new Context(this, "/");
// Create a CGI servlet for scripts in webui/cgi-bin
ServletHolder cgiHolder = new ServletHolder(new CGI());
cgiHolder.setInitParameter("cgibinResourceBase", webui + "/cgi-bin");
// Pass any special PATH setting on to the execution environment
if (System.getenv("PATH") != null)
cgiHolder.setInitParameter("Path", System.getenv("PATH"));
context.addServlet(cgiHolder, "*.cgi");
context.addServlet(cgiHolder, "*.pl");
context.addServlet(cgiHolder, "*.py");
context.addServlet(cgiHolder, "*.rb");
context.addServlet(cgiHolder, "*.tcl");
context.addServlet(new ServletHolder(new GetReportsServlet()), "/reports/*");
context.addServlet(new ServletHolder(new TagServlet()), "/tag/*");
context.addServlet(new ServletHolder(new TitleServlet()), "/title/*");
context.addServlet(new ServletHolder(new TitleLikeServlet()), "/titleLike/*");
// JSON APIs for interactive visualization
context.addServlet(new ServletHolder(new GetJSONReportsServlet()), "/interactive/reports/*");
context.addServlet(new ServletHolder(new GetOverlappingTasksServlet()), "/interactive/overlapping/*");
context.addServlet(new ServletHolder(new GetTagsForTaskServlet()), "/interactive/tags/*");
context.addServlet(new ServletHolder(new GetTasksForTags()), "/interactive/taggedwith/*");
context.setResourceBase(webui + "/html");
context.addServlet(new ServletHolder(new IndexServlet()), "/");
}