本文整理了Java中org.eclipse.jetty.webapp.WebAppContext.setResourceBase()
方法的一些代码示例,展示了WebAppContext.setResourceBase()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebAppContext.setResourceBase()
方法的具体详情如下:
包路径:org.eclipse.jetty.webapp.WebAppContext
类名称:WebAppContext
方法名:setResourceBase
暂无
代码示例来源:origin: stackoverflow.com
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class JettyServer {
public static void main(String[] args) {
Server server = new Server(8080);
WebAppContext context = new WebAppContext();
context.setResourceBase("../webapp-project/WebContent");
context.setDescriptor("../webapp-project/WebContent/WEB-INF/web.xml");
context.setContextPath("/");
context.setParentLoaderPriority(true);
server.setHandler(context);
try {
server.start();
server.join();
} catch (Exception e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: ocpsoft/prettytime
public static void main(String[] args) throws Exception {
String weppAppHome = args[0];
Integer port = 8080;
Server server = new Server(port);
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
webapp.setCompactPath(true);
webapp.setDescriptor(weppAppHome + "/WEB-INF/web.xml");
webapp.setResourceBase(weppAppHome);
webapp.setParentLoaderPriority(true);
server.setHandler(webapp);
server.start();
server.join();
}
代码示例来源:origin: kaaproject/kaa
@Override
public void start() {
LOG.info("Starting Kaa Admin Web Server...");
server = new Server(adminPort);
webAppContext = new WebAppContext();
webAppContext.setEventListeners(new EventListener[]{adminContextLoaderListener});
webAppContext.setContextPath("/");
String webXmlLocation = AdminInitializationService.class.getResource("/admin-web/WEB-INF/"
+ webXmlFile).toString();
webAppContext.setDescriptor(webXmlLocation);
String resLocation = AdminInitializationService.class.getResource("/admin-web").toString();
webAppContext.setResourceBase(resLocation);
webAppContext.setParentLoaderPriority(true);
server.setHandler(webAppContext);
try {
server.start();
LOG.info("Kaa Admin Web Server started.");
} catch (Exception ex) {
LOG.error("Error starting Kaa Admin Web Server!", ex);
}
}
代码示例来源:origin: json-path/JsonPath
public static void main(String[] args) throws Exception {
String configPort = "8080";
if(args.length > 0){
configPort = args[0];
}
String port = System.getProperty("server.http.port", configPort);
System.out.println("Server started on port: " + port);
Server server = new Server();
server.setConnectors(new Connector[]{createConnector(server, Integer.parseInt(port))});
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
context.setContextPath("/api");
ServletHolder servletHolder = new ServletHolder(createJerseyServlet());
servletHolder.setInitOrder(1);
context.addServlet(servletHolder, "/*");
WebAppContext webAppContext = new WebAppContext();
webAppContext.setServer(server);
webAppContext.setContextPath("/");
String resourceBase = System.getProperty("resourceBase");
if(resourceBase != null){
webAppContext.setResourceBase(resourceBase);
} else {
webAppContext.setResourceBase(Main.class.getResource("/webapp").toExternalForm());
}
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{context, webAppContext});
server.setHandler(handlers);
server.start();
server.join();
}
代码示例来源:origin: Dreampie/Resty
webAppContext.setDescriptor(webXmlPath);
webAppContext.setContextPath(contextPath);
webAppContext.setResourceBase(webappUrl);
代码示例来源:origin: DeemOpen/zkui
servletContextHandler.setResourceBase("src/main/resources/" + webFolder);
ClassList clist = ClassList.setServerDefault(server);
clist.addBefore(JettyWebXmlConfiguration.class.getName(), AnnotationConfiguration.class.getName());
代码示例来源:origin: opensourceBIM/BIMserver
@Override
public void setResourceBase(String resourceBase) {
getContext().setResourceBase(resourceBase);
}
}
代码示例来源:origin: jamesagnew/hapi-fhir
public static void main(String[] theArgs) {
Server server = new Server(22);
String path = "../hapi-fhir-cli-jpaserver";
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-example");
webAppContext.setParentLoaderPriority(true);
server.setHandler(webAppContext);
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
}
ourLog.info("Started");
}
代码示例来源:origin: apache/phoenix
@Override
public int run(String[] arg0) throws Exception {
// logProcessInfo(getConf());
final int port = getConf().getInt(TRACE_SERVER_HTTP_PORT_KEY,
DEFAULT_HTTP_PORT);
BasicConfigurator.configure();
final String home = getConf().get(TRACE_SERVER_HTTP_JETTY_HOME_KEY,
DEFAULT_HTTP_HOME);
//setting up the embedded server
Server server = new Server(port);
WebAppContext root = new WebAppContext();
URL webAppDir = Thread.currentThread().getContextClassLoader().getResource(DEFAULT_WEBAPP_DIR_LOCATION);
if (webAppDir == null) {
throw new RuntimeException(String.format("No %s directory was found into the JAR file", DEFAULT_WEBAPP_DIR_LOCATION));
}
root.setContextPath(home);
root.setDescriptor(DEFAULT_WEBAPP_DIR_LOCATION + "/WEB-INF/web.xml");
root.setResourceBase(webAppDir.toURI().toString());
root.setParentLoaderPriority(true);
server.setHandler(root);
server.start();
server.join();
return 0;
}
}
代码示例来源:origin: pulsarIO/realtime-analytics
public void startStandAlone() {
try {
WebAppContext context = new WebAppContext();
String baseUrl = getBaseUrl();
LOGGER.info("Metric server baseUrl: " + baseUrl);
context.setDescriptor(baseUrl + "/WEB-INF/web.xml");
context.setResourceBase(baseUrl);
context.setContextPath("/");
context.setParentLoaderPriority(true);
context.setAttribute("JetStreamRoot", applicationContext);
Server s_server = new Server(s_port);
s_server.setHandler(context);
LOGGER.info( "Metric server started, listening on port " + s_port);
s_server.start();
running.set(true);
} catch (Throwable t) {
throw CommonUtils.runtimeException(t);
}
}
代码示例来源:origin: opensourceBIM/BIMserver
if (context.getResourceBase() == null) {
if (resourceBase == null) {
context.setResourceBase(Paths.get("www").toAbsolutePath().toString());
} else {
context.setResourceBase(resourceBase);
代码示例来源:origin: stackoverflow.com
WebAppContext webapp = new WebAppContext();
ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
URLClassLoader subClassLoader = new URLClassLoader(new URL[]{}, currentClassLoader);//this is the point.
webapp.setClassLoader(subClassLoader); //this is the point.
webapp.setContextPath("/");
webapp.setResourceBase("src/main/webapp");
server.setHandler(webapp);
server.start();
server.join();
代码示例来源:origin: stackoverflow.com
public class Jetty {
public static Server createServer(int port) {
Server server = new Server(port);
WebAppContext context = new WebAppContext();
context.setResourceBase("src/main/webapp");
context.setClassLoader(Thread.currentThread().getContextClassLoader());
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{context});
server.setHandler(handlers);
return server;
}
}
代码示例来源:origin: stackoverflow.com
private static void run(int port, String resourceBase, String descriptor) {
Server server = new Server(port);
WebAppContext context = new WebAppContext();
context.setResourceBase(resourceBase);
context.setDescriptor(descriptor);
context.setContextPath("/");
context.setParentLoaderPriority(true);
server.setHandler(context);
server.start();
server.join();
}
代码示例来源:origin: stackoverflow.com
private WebAppContext webAppContext;
public WebAppContext buildWebAppContext() {
webAppContext = new WebAppContext();
webAppContext.setDescriptor(webAppContext + "/WEB-INF/web.xml");
webAppContext.setResourceBase("src/main/webapp");
webAppContext.setContextPath("/Holmes");
return webAppContext;
}
}
代码示例来源:origin: stackoverflow.com
public class AppContextBuilder {
private WebAppContext webAppContext;
public WebAppContext buildWebAppContext() {
webAppContext = new WebAppContext();
webAppContext.setDescriptor(webAppContext + "/WEB-INF/web.xml");
webAppContext.setResourceBase(webAppContext);
webAppContext.setContextPath("/Holmes");
return webAppContext;
}
}
代码示例来源:origin: stackoverflow.com
Resource jettyConfig = Resource.newSystemResource("jetty.xml");
XmlConfiguration configuration = new XmlConfiguration(jettyConfig.getInputStream());
Server server = (Server)configuration.configure();
WebAppContext wac = new WebAppContext();
wac.setResourceBase(".");
wac.setDescriptor("WEB-INF/web.xml");
wac.setContextPath("/");
wac.setParentLoaderPriority(true);
server.setHandler(wac);
server.start();
代码示例来源:origin: org.eclipse.jetty/test-jetty-servlet
private static void initJetty() throws SAXException, IOException, MalformedURLException, Exception {
Server jetty = new Server(8080);
// configure your web application
WebAppContext appContext = new WebAppContext();
appContext.setContextPath("/flub");
appContext.addServlet(Jetty400Repro.class, "/servlet/");
appContext.setResourceBase(".");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { appContext, new DefaultHandler() });
jetty.setHandler(handlers);
jetty.start();
}
代码示例来源:origin: stackoverflow.com
WebAppContext context = new WebAppContext();
context.setContextPath("/myWebApp");
context.setExtractWAR(false);
context.setDescriptor("/file/system/path/to/your/wab/app/WEB-INF/web.xml");
context.setResourceBase("/file/system/path/to/your/wab/app");
context.setConfigurationDiscovered(false);
HandlerList handlerList=new HandlerList();
handlerList.addHandler(webAppContext);
Server server = new Server(threadPool);
server.setHandler(handlerList);
server.start();
代码示例来源:origin: epam/Wilma
private WebAppContext configureWebAppContext() {
final WebAppContext context = new WebAppContext();
String baseUrl = getBaseUrl();
context.setDescriptor(baseUrl + WEB_XML_LOCATION);
context.setResourceBase(baseUrl + "");
context.setContextPath("/");
context.setParentLoaderPriority(true);
WebAppStopper webAppStopper = new WebAppStopper(this, Executors.newSingleThreadExecutor());
Servlet shutdownServlet = new ShutdownServlet(webAppStopper);
context.addServlet(new ServletHolder(shutdownServlet), SHUTDOWN_URL);
return context;
}
内容来源于网络,如有侵权,请联系作者删除!