本文整理汇总了Java中org.eclipse.jetty.annotations.AnnotationConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java AnnotationConfiguration类的具体用法?Java AnnotationConfiguration怎么用?Java AnnotationConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AnnotationConfiguration类属于org.eclipse.jetty.annotations包,在下文中一共展示了AnnotationConfiguration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: start
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
public void start() {
// TODO: remove redundant fields from config and move this check to XRE Redirector
if (! config.getEnableCommunicationEndpoint()) {
log.warn("skipping Jetty endpoint due to configuration");
return;
}
if (started) {
log.warn("Jetty is already started");
}
started = true;
Integer port = config.getCommunicationEndpointPort();
log.info("Starting embedded jetty server (XRERedirector Gateway) on port: {}", port);
WebAppContext webAppContext = new WebAppContext();
webAppContext.setConfigurations(new Configuration[]{new AnnotationConfiguration() {
@Override
public void preConfigure(WebAppContext context) {
ClassInheritanceMap map = new ClassInheritanceMap();
map.put(WebApplicationInitializer.class.getName(), new ConcurrentHashSet<String>() {{
add(WebAppInitializer.class.getName());
}});
context.setAttribute(CLASS_INHERITANCE_MAP, map);
_classInheritanceHandler = new ClassInheritanceHandler(map);
}
}});
server = new Server(port);
server.setHandler(webAppContext);
try {
server.start();
} catch (Exception e) {
log.error("Failed to start embedded jetty server (XRERedirector communication endpoint) on port: " + port, e);
}
log.info("Started embedded jetty server (Redirector Gateway) on port: {}", port);
}
开发者ID:Comcast,项目名称:redirector,代码行数:41,代码来源:EmbeddedJetty.java
示例2: JettyServer
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
public JettyServer(final NiFiRegistryProperties properties, final CryptoKeyProvider cryptoKeyProvider) {
final QueuedThreadPool threadPool = new QueuedThreadPool(properties.getWebThreads());
threadPool.setName("NiFi Registry Web Server");
this.properties = properties;
this.masterKeyProvider = cryptoKeyProvider;
this.server = new Server(threadPool);
// enable the annotation based configuration to ensure the jsp container is initialized properly
final Configuration.ClassList classlist = Configuration.ClassList.setServerDefault(server);
classlist.addBefore(JettyWebXmlConfiguration.class.getName(), AnnotationConfiguration.class.getName());
try {
configureConnectors();
loadWars();
} catch (final Throwable t) {
startUpFailure(t);
}
}
开发者ID:apache,项目名称:nifi-registry,代码行数:20,代码来源:JettyServer.java
示例3: init
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
private void init() {
System.out.println("host:" + hostList + " war:" + war);
this.setContextPath("/");
this.setWar(war);
if (hostList != null && !hostList.isEmpty()) {
if (!"localhost".equals(hostList.get(0))) {
String[] hosts = new String[hostList.size()];
hostList.toArray(hosts);
super.setVirtualHosts(hosts);
}
}
this.setConfigurations(new Configuration[] { //
new io.leopard.myjetty.webapp.EmbedWebInfConfiguration(hostList, war), //
new MetaInfConfiguration(), //
new AnnotationConfiguration(), //
new WebXmlConfiguration(), //
new FragmentConfiguration() //
// new TagLibConfiguration() //
});
}
开发者ID:tanhaichao,项目名称:leopard,代码行数:22,代码来源:MyJettyWebAppContext.java
示例4: main
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
int port = 8080;
Server server = new Server(port);
WebAppContext context = new WebAppContext();
context.setWar("./src/main/webapp");
context.setConfigurations(new Configuration[] {
new AnnotationConfiguration(), new WebXmlConfiguration(),
new WebInfConfiguration(), new TagLibConfiguration(),
new PlusConfiguration(), new MetaInfConfiguration(),
new FragmentConfiguration(), new EnvConfiguration() });
context.setContextPath("/");
context.setParentLoaderPriority(true);
server.setHandler(context);
server.start();
server.dump(System.err);
server.join();
}
开发者ID:extrema,项目名称:jetty-embedded,代码行数:21,代码来源:EmbedMe.java
示例5: main
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
// add web applications
HandlerCollection handlers = new HandlerCollection();
Preconditions.checkArgument(args != null && args.length > 0, "Missing args: web project. Please pass a list of web projects, e.g.: JettyServer helloworld");
for (String arg : args) {
Iterator<String> it = Splitter.on(":").split(arg).iterator();
String domain = it.next();
String projectName = it.hasNext() ? it.next() : domain;
WebAppContext webappContext = createContext(domain, projectName);
handlers.addHandler(webappContext);
}
server.setHandler(handlers);
// enable web 3.0 annotations
Configuration.ClassList classList = Configuration.ClassList.setServerDefault(server);
classList.addBefore(JettyWebXmlConfiguration.class.getName(), AnnotationConfiguration.class.getName());
server.start();
server.join();
}
开发者ID:extrema,项目名称:jetty-embedded,代码行数:24,代码来源:JettyServer.java
示例6: start
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
public void start() throws Exception {
server = new Server(8080);
WebAppContext webAppContext = new WebAppContext();
webAppContext.setResourceBase("src/main/webapp");
webAppContext.setContextPath("/");
File[] mavenLibs = Maven.resolver().loadPomFromFile("pom.xml")
.importCompileAndRuntimeDependencies()
.resolve().withTransitivity().asFile();
for (File file: mavenLibs) {
webAppContext.getMetaData().addWebInfJar(new FileResource(file.toURI()));
}
webAppContext.getMetaData().addContainerResource(new FileResource(new File("./target/classes").toURI()));
webAppContext.setConfigurations(new Configuration[] {
new AnnotationConfiguration(),
new WebXmlConfiguration(),
new WebInfConfiguration()
});
server.setHandler(webAppContext);
logger.info(">>> STARTING EMBEDDED JETTY SERVER");
server.start();
}
开发者ID:pjagielski,项目名称:jersey2-starter,代码行数:26,代码来源:EmbeddedJetty.java
示例7: createConfigurations
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
private Configuration[] createConfigurations() {
Configuration[] configurations = {
new AnnotationConfiguration(),
new WebInfConfiguration(),
new WebXmlConfiguration(),
new MetaInfConfiguration(),
new FragmentConfiguration(),
new EnvConfiguration(),
new PlusConfiguration(),
new JettyWebXmlConfiguration()
};
return configurations;
}
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:15,代码来源:Application.java
示例8: JettyConsoleWebappContext
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
public JettyConsoleWebappContext(HandlerContainer parent, String webApp, String contextPath) {
super(parent, webApp, contextPath);
setConfigurations(new Configuration[]{
new WebInfConfiguration(),
new WebXmlConfiguration(),
new MetaInfConfiguration(),
new FragmentConfiguration(),
new EnvConfiguration(),
new org.eclipse.jetty.plus.webapp.PlusConfiguration(),
new AnnotationConfiguration(),
new JettyWebXmlConfiguration()
});
}
开发者ID:eirbjo,项目名称:jetty-console,代码行数:14,代码来源:JettyConsoleWebappContext.java
示例9: createClassList
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
private Configuration.ClassList createClassList() {
Configuration.ClassList classList = new Configuration.ClassList(new String[0]);
classList.add(AnnotationConfiguration.class.getName());
classList.add(WebInfConfiguration.class.getName());
classList.add(WebXmlConfiguration.class.getName());
classList.add(MetaInfConfiguration.class.getName());
classList.add(FragmentConfiguration.class.getName());
classList.add(JettyWebXmlConfiguration.class.getName());
classList.add(EnvConfiguration.class.getName());
classList.add(PlusConfiguration.class.getName());
return classList;
}
开发者ID:kumuluz,项目名称:kumuluzee,代码行数:16,代码来源:JettyFactory.java
示例10: JettyLaucher
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
JettyLaucher(final Properties props) {
String host = props.getProperty("host", "127.0.0.1");
int port = Integer.parseInt(props.getProperty("port", "8080"));
int timeout = Integer.parseInt(props.getProperty("timeoutSec", "900"));
String baseDir = props.getProperty("baseDir", "webapp");
logger.info("Try to start server [{}:{}], baseDir={}, connection-timeout={}sec.", host, port, baseDir, timeout);
System.setProperty(Constants.SYSPROP_DIR_WEBAPP, baseDir);
// Handler for multiple web apps
HandlerCollection handlers = new HandlerCollection();
webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/classes/*");
webAppContext.setResourceBase(baseDir);
webAppContext.setConfigurations(new Configuration[] {
new AnnotationConfiguration(), new WebInfConfiguration(),
new PlusConfiguration(), new MetaInfConfiguration(),
new FragmentConfiguration(), new EnvConfiguration()
});
handlers.addHandler(webAppContext);
ServerConnector connector = new ServerConnector(server);
connector.setHost(host);
connector.setPort(port);
connector.setIdleTimeout(timeout * 1000);
server.addConnector(connector);
server.setHandler(handlers);
}
开发者ID:th-schwarz,项目名称:bacoma,代码行数:32,代码来源:JettyLaucher.java
示例11: start
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
private void start() {
ProtectionDomain domain = WebAppRunner.class.getProtectionDomain();
URL location = domain.getCodeSource().getLocation();
WebAppContext context = new WebAppContext();
context.setContextPath( "/" );
context.setWar( location.toExternalForm() );
context.setParentLoaderPriority( true );
context.setConfigurations( new Configuration[] {
new WebInfConfiguration(),
new WebXmlConfiguration(),
new MetaInfConfiguration(),
new PlusConfiguration(),
new JettyWebXmlConfiguration(),
new AnnotationConfiguration()
} );
Server server = new Server( 8080 );
server.dumpStdErr();
server.setHandler( context );
try {
server.start();
server.join();
}
catch ( Exception e ) {
LOG.warn( e );
}
}
开发者ID:ragnarruutel,项目名称:java8-jetty9-spring4-noxml,代码行数:30,代码来源:WebAppRunner.java
示例12: main
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
System.out.println(IOUtils.toString(new FileInputStream("../metl-server/src/main/resources/Metl.asciiart")));
new File(System.getProperty("java.io.tmpdir")).mkdirs();
new File("working").mkdirs();
System.setProperty("org.jumpmind.metl.ui.init.config.dir","working");
Server server = new Server(42000);
ClassList classlist = Configuration.ClassList.setServerDefault(server);
classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");
WebAppContext webapp = new WebAppContext();
webapp.setParentLoaderPriority(true);
webapp.setConfigurationDiscovered(true);
webapp.setContextPath("/metl");
webapp.setWar("../metl-war/src/main/webapp");
webapp.setResourceBase("../metl-war/src/main/webapp");
ConcurrentHashMap<String, ConcurrentHashSet<String>> map = new ClassInheritanceMap();
ConcurrentHashSet<String> set = new ConcurrentHashSet<>();
set.add("org.jumpmind.metl.ui.init.AppInitializer");
map.put("org.springframework.web.WebApplicationInitializer", set);
webapp.setAttribute(AnnotationConfiguration.CLASS_INHERITANCE_MAP, map);
server.setHandler(webapp);
ServerContainer webSocketServer = WebSocketServerContainerInitializer.configureContext(webapp);
webSocketServer.setDefaultMaxSessionIdleTimeout(10000000);
server.start();
server.join();
}
开发者ID:JumpMind,项目名称:metl,代码行数:35,代码来源:Develop.java
示例13: createWebAppContext
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
private WebAppContext createWebAppContext(String path, File war) throws MalformedURLException {
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath(path);
webAppContext.setParentLoaderPriority(false);
if (war == null) {
webAppContext.setWar(Main.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm());
} else {
webAppContext.setWar(war.toURI().toURL().toExternalForm());
}
webAppContext.setConfigurations(new Configuration[] { new AnnotationConfiguration(), new WebInfConfiguration(),
new WebXmlConfiguration(), new MetaInfConfiguration(), new FragmentConfiguration(),
new EnvConfiguration(), new PlusConfiguration(), new JettyWebXmlConfiguration() });
return webAppContext;
}
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:15,代码来源:Main.java
示例14: loadWar
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
private void loadWar()
{
File war = new File("./webapp/jqm-ws.war");
if (!war.exists() || !war.isFile())
{
return;
}
jqmlogger.info("Jetty will now load the web service application war");
// Load web application.
webAppContext = new WebAppContext(war.getPath(), "/");
webAppContext.setDisplayName("JqmWebServices");
// Hide server classes from the web app
final int nbEx = 5;
String[] defExcl = webAppContext.getDefaultServerClasses();
String[] exclusions = new String[defExcl.length + nbEx];
for (int i = nbEx; i <= defExcl.length; i++)
{
exclusions[i] = defExcl[i - nbEx];
}
exclusions[0] = "com.enioka.jqm.tools.";
exclusions[1] = "com.enioka.jqm.api.";
// exclusions[2] = "org.slf4j.";
// exclusions[3] = "org.apache.log4j.";
exclusions[4] = "org.glassfish."; // Jersey
webAppContext.setServerClasses(exclusions);
// JQM configuration should be on the class path
webAppContext.setExtraClasspath("conf/jqm.properties");
webAppContext.setInitParameter("jqmnode", node.getName());
webAppContext.setInitParameter("jqmnodeid", node.getId().toString());
// Set configurations (order is important: need to unpack war before reading web.xml)
webAppContext.setConfigurations(new Configuration[] { new WebInfConfiguration(), new WebXmlConfiguration(),
new MetaInfConfiguration(), new FragmentConfiguration(), new AnnotationConfiguration() });
h.addHandler(webAppContext);
}
开发者ID:enioka,项目名称:jqm,代码行数:40,代码来源:JettyServer.java
示例15: startJetty
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
@Before
public void startJetty() throws Exception {
server = new Server(new InetSocketAddress("127.0.0.1", 0));
final WebAppContext sillyWebApp = new WebAppContext("sillyWebApp", "/");
final AnnotationConfiguration annotationConfiguration = new AnnotationConfiguration();
annotationConfiguration.createServletContainerInitializerAnnotationHandlers(sillyWebApp,
Collections.<ServletContainerInitializer>singletonList(new TestConfig()));
sillyWebApp.setConfigurations(new Configuration[]{annotationConfiguration});
server.setHandler(sillyWebApp);
server.start();
serverUrl = "http://" + server.getConnectors()[0].getName() + "/";
}
开发者ID:tracee,项目名称:tracee,代码行数:14,代码来源:TraceeFilterIT.java
示例16: main
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
public static void main(final String[] args) {
InetSocketAddress _inetSocketAddress = new InetSocketAddress("localhost", 8080);
final Server server = new Server(_inetSocketAddress);
WebAppContext _webAppContext = new WebAppContext();
final Procedure1<WebAppContext> _function = (WebAppContext it) -> {
it.setResourceBase("WebRoot");
it.setWelcomeFiles(new String[] { "index.html" });
it.setContextPath("/");
AnnotationConfiguration _annotationConfiguration = new AnnotationConfiguration();
WebXmlConfiguration _webXmlConfiguration = new WebXmlConfiguration();
WebInfConfiguration _webInfConfiguration = new WebInfConfiguration();
MetaInfConfiguration _metaInfConfiguration = new MetaInfConfiguration();
it.setConfigurations(new Configuration[] { _annotationConfiguration, _webXmlConfiguration, _webInfConfiguration, _metaInfConfiguration });
it.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, ".*/com\\.hribol\\.bromium\\.dsl\\.web/.*,.*\\.jar");
it.setInitParameter("org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false");
};
WebAppContext _doubleArrow = ObjectExtensions.<WebAppContext>operator_doubleArrow(_webAppContext, _function);
server.setHandler(_doubleArrow);
String _name = ServerLauncher.class.getName();
final Slf4jLog log = new Slf4jLog(_name);
try {
server.start();
URI _uRI = server.getURI();
String _plus = ("Server started " + _uRI);
String _plus_1 = (_plus + "...");
log.info(_plus_1);
final Runnable _function_1 = () -> {
try {
log.info("Press enter to stop the server...");
final int key = System.in.read();
if ((key != (-1))) {
server.stop();
} else {
log.warn("Console input is not available. In order to stop the server, you need to cancel process manually.");
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
new Thread(_function_1).start();
server.join();
} catch (final Throwable _t) {
if (_t instanceof Exception) {
final Exception exception = (Exception)_t;
log.warn(exception.getMessage());
System.exit(1);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
开发者ID:hristo-vrigazov,项目名称:bromium,代码行数:52,代码来源:ServerLauncher.java
示例17: main
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
public static void main(final String[] args) {
InetSocketAddress _inetSocketAddress = new InetSocketAddress("localhost", 8080);
final Server server = new Server(_inetSocketAddress);
WebAppContext _webAppContext = new WebAppContext();
final Procedure1<WebAppContext> _function = (WebAppContext it) -> {
it.setResourceBase("WebRoot");
it.setWelcomeFiles(new String[] { "index.html" });
it.setContextPath("/");
AnnotationConfiguration _annotationConfiguration = new AnnotationConfiguration();
WebXmlConfiguration _webXmlConfiguration = new WebXmlConfiguration();
WebInfConfiguration _webInfConfiguration = new WebInfConfiguration();
MetaInfConfiguration _metaInfConfiguration = new MetaInfConfiguration();
it.setConfigurations(new Configuration[] { _annotationConfiguration, _webXmlConfiguration, _webInfConfiguration, _metaInfConfiguration });
it.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, ".*/org\\.xtext\\.dsl\\.restaurante\\.web/.*,.*\\.jar");
it.setInitParameter("org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false");
};
WebAppContext _doubleArrow = ObjectExtensions.<WebAppContext>operator_doubleArrow(_webAppContext, _function);
server.setHandler(_doubleArrow);
String _name = ServerLauncher.class.getName();
final Slf4jLog log = new Slf4jLog(_name);
try {
server.start();
URI _uRI = server.getURI();
String _plus = ("Server started " + _uRI);
String _plus_1 = (_plus + "...");
log.info(_plus_1);
final Runnable _function_1 = () -> {
try {
log.info("Press enter to stop the server...");
final int key = System.in.read();
if ((key != (-1))) {
server.stop();
} else {
log.warn("Console input is not available. In order to stop the server, you need to cancel process manually.");
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
new Thread(_function_1).start();
server.join();
} catch (final Throwable _t) {
if (_t instanceof Exception) {
final Exception exception = (Exception)_t;
log.warn(exception.getMessage());
System.exit(1);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
开发者ID:vicegd,项目名称:org.xtext.dsl.restaurante,代码行数:52,代码来源:ServerLauncher.java
示例18: build
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
/**
* 创建用于正常运行调试的Jetty Server, 以src/main/webapp为Web应用目录.
*/
@Override
public Server build(int port, String webApp, String contextPath) throws BindException {
port = this.getAutoPort(port);
serverInitializer.run();
Server server = new Server(port);
WebAppContext webContext = new WebAppContext(webApp, contextPath);
if (false) {
ServletHolder holder = new ServletHolder(new ProxyServlet());
holder.setInitParameter("proxyTo", "http://localhost:3000/");
holder.setInitParameter("prefix", "/");
webContext.addServlet(holder, "/app/");
webContext.addServlet(new ServletHolder(new IndexServlet()), "/proxy/");
}
// webContext.setDefaultsDescriptor("leopard-jetty/webdefault.xml");
// 问题点:http://stackoverflow.com/questions/13222071/spring-3-1-webapplicationinitializer-embedded-jetty-8-annotationconfiguration
webContext.setConfigurations(new Configuration[] { //
new EmbedWebInfConfiguration(), //
new MetaInfConfiguration(), //
new AnnotationConfiguration(), //
new WebXmlConfiguration(), //
new FragmentConfiguration() //
// new TagLibConfiguration() //
});
// webContext.setConfigurations(new Configuration[] { //
// new EmbedWebInfConfiguration()//
// , new EmbedWebXmlConfiguration()//
// , new EmbedMetaInfConfiguration()//
// , new EmbedFragmentConfiguration()//
// , new EmbedAnnotionConfiguration() //
// // , new PlusConfiguration(),//
// // new EnvConfiguration()//
// });
WebAppClassLoader classLoader = null;
try {
// addTldLib(webContext);
classLoader = new LeopardWebAppClassLoader(webContext);
}
catch (IOException e) {
e.printStackTrace();
}
// ClassLoader tldClassLoader = addTldLib(classLoader);
webContext.setClassLoader(classLoader);
webContext.setParentLoaderPriority(true);
// logger.debug(webContext.dump());
Handler rewriteHandler = ResourcesManager.getHandler();
if (rewriteHandler == null) {
server.setHandler(webContext);
}
else {
HandlerCollection handlers = new HandlerCollection();
handlers.addHandler(rewriteHandler);
handlers.addHandler(webContext);
server.setHandler(handlers);
}
server.setStopAtShutdown(true);
return server;
}
开发者ID:tanhaichao,项目名称:leopard,代码行数:73,代码来源:WebServerJettyImpl.java
示例19: startServer
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
public static void startServer(JettyConfig jettyConfig) throws Exception {
if(!jettyConfig.isQuietMode())
{
System.out.println();
System.out.println("Starting embedded jetty...");
}
//create the server
Server server = new Server();
ServerConnector c = new ServerConnector(server);
//set the context path
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setWelcomeFiles(new String[] {"/static/test.html"});
//tell the webApp about our Spring MVC web initializer. The hoops I jump through here are because
//Jetty 9 AnnotationConfiguration doesn't scan non-jar classpath locations for a class that implements WebApplicationInitializer.
//The code below explicitly tells Jetty about our implementation of WebApplicationInitializer.
//this Jetty bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=404176 and the discussion around it defines the issue best. I decided
//I would not rely on the potentially buggy solution put into Jetty 9 (discussed in the bug thread) and just go for a fix I know would work.
webAppContext.setConfigurations(new Configuration[] {
new AnnotationConfiguration() {
@Override
public void preConfigure(WebAppContext context) throws Exception {
ClassInheritanceMap map = new ClassInheritanceMap();
ConcurrentHashSet<String> hashSet = new ConcurrentHashSet<String>();
hashSet.add(SpringMvcInitializer.class.getName());
map.put(WebApplicationInitializer.class.getName(), hashSet);
context.setAttribute(CLASS_INHERITANCE_MAP, map);
_classInheritanceHandler = new ClassInheritanceHandler(map);
}
}
});
server.setHandler(webAppContext);
//core server configuration
c.setIdleTimeout(jettyConfig.getIdleTimeout());
c.setAcceptQueueSize(jettyConfig.getAcceptQueueSize());
c.setPort(jettyConfig.getPort());
c.setHost(jettyConfig.getHost());
server.addConnector(c);
//start the server and make it available when initialization is complete
server.start();
server.join();
}
开发者ID:orb15,项目名称:embeddedjetty9-spring4,代码行数:50,代码来源:EmbeddedJetty.java
示例20: main
import org.eclipse.jetty.annotations.AnnotationConfiguration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
OptionParser parser = new OptionParser();
ArgumentAcceptingOptionSpec<Integer> portOption = parser.accepts("port", "Create an HTTP listener on port n (default 8080)").withRequiredArg().ofType(Integer.class);
ArgumentAcceptingOptionSpec<String> bindAddressOption = parser.accepts("bindAddress", "Accept connections only on address addr (default: accept on any address)").withRequiredArg().ofType(String.class);
ArgumentAcceptingOptionSpec<String> tmpDirOption = parser.accepts("tmpDir", "Temporary directory").withRequiredArg().ofType(String.class);
ArgumentAcceptingOptionSpec<String> contextPathOption = parser.accepts("contextPath", "Set context path (default: /)").withRequiredArg().ofType(String.class);
ArgumentAcceptingOptionSpec<String> cookiePrefixOption = parser.accepts("cookiePrefix", "Prefix the cookies").withRequiredArg().ofType(String.class);
OptionSpecBuilder helpOption = parser.accepts("help", "Print this help message");
parser.accepts("headless", "legacy parameter, ignored");
parser.accepts("forwarded", "legacy parameter, ignored");
parser.accepts("sslProxied", "legacy parameter, ignored");
OptionSet options = parser.parse(args);
if (options.has(helpOption)) {
parser.printHelpOn(System.out);
return;
}
int port = options.has(portOption) ? options.valueOf(portOption) : 8080;
String bindAddress = options.has(bindAddressOption) ? options.valueOf(bindAddressOption) : "0.0.0.0";
String contextPath = options.has(contextPathOption) ? options.valueOf(contextPathOption) : "/";
if (options.has(cookiePrefixOption)) {
String cookiePrefixValue = options.valueOf(cookiePrefixOption);
System.out.println("Using cookie prefix " + cookiePrefixValue);
System.setProperty(CookieNames.PROPERTY_NAME, cookiePrefixValue);
}
InetSocketAddress address = new InetSocketAddress(bindAddress, port);
Server server = new Server(address);
WebAppContext webapp = new WebAppContext();
if (options.has(tmpDirOption)) {
webapp.setTempDirectory(new File(options.valueOf(tmpDirOption)));
}
webapp.setContextPath(contextPath);
webapp.setServer(server);
webapp.setWar(war());
webapp.setConfigurations(new Configuration[] {
new WebInfConfiguration(),
new WebXmlConfiguration(),
new MetaInfConfiguration(),
new AnnotationConfiguration(),
new JettyWebXmlConfiguration()
});
server.setHandler(webapp);
System.out.println("Starting jetty server " + Server.getVersion());
System.out.println("Server is listening at " + address.toString());
server.start();
server.join();
}
开发者ID:digitalfondue,项目名称:lavagna,代码行数:57,代码来源:Launcher.java
注:本文中的org.eclipse.jetty.annotations.AnnotationConfiguration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论