本文整理匯總了Java中io.undertow.servlet.api.DeploymentManager類的典型用法代碼示例。如果您正苦於以下問題:Java DeploymentManager類的具體用法?Java DeploymentManager怎麽用?Java DeploymentManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DeploymentManager類屬於io.undertow.servlet.api包,在下文中一共展示了DeploymentManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDeploymentByPath
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
@Override
public DeploymentManager getDeploymentByPath(final String path) {
DeploymentManager exact = deploymentsByPath.get(path.isEmpty() ? "/" : path);
if (exact != null) {
return exact;
}
int length = path.length();
int pos = length;
while (pos > 1) {
--pos;
if (path.charAt(pos) == '/') {
String part = path.substring(0, pos);
DeploymentManager deployment = deploymentsByPath.get(part);
if (deployment != null) {
return deployment;
}
}
}
return deploymentsByPath.get("/");
}
示例2: start
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
public static void start(String[] args) throws ServletException {
Map<String, String> commands = Arrays.stream(args)
.map(cmd -> cmd.split(REGEX_EQ))
.collect(toMap(cmdArray -> cmdArray[IDX_ZERO], cmdArray -> cmdArray[IDX_ONE]));
Config undertowConf = Configs.DEFAULT.undertow();
Config httpConf = undertowConf.getConfig(KEY_HTTP);
Logger logger = LoggerFactory.getLogger(Server.class);
logger.debug("Commands to AdeptJ Runtime: {}", commands);
int httpPort = handlePortAvailability(httpConf, logger);
logger.info("Starting AdeptJ Runtime @port: [{}]", httpPort);
printBanner(logger);
DeploymentManager manager = Servlets.defaultContainer().addDeployment(deploymentInfo(undertowConf));
manager.deploy();
Builder builder = Undertow.builder();
optimizeWorkerOptions(builder, undertowConf, logger);
ServerOptions.build(builder, undertowConf);
builder.addHttpListener(httpPort, httpConf.getString(KEY_HOST));
enableHttp2(undertowConf, builder, logger);
enableAJP(undertowConf, builder, logger);
GracefulShutdownHandler rootHandler = rootHandler(headersHandler(manager.start(), undertowConf), undertowConf);
Undertow server = builder.setHandler(rootHandler).build();
server.start();
Runtime.getRuntime().addShutdownHook(new ShutdownHook(server, manager, rootHandler));
launchBrowser(commands, httpPort, logger);
if (!Environment.isServerConfFileExists()) {
createServerConfFile(logger);
}
}
示例3: initServlet
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
private static void initServlet() throws ServletException, NoSuchMethodException {
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
DeploymentInfo deploymentInfo = new DeploymentInfo()
.addListener(Servlets.listener(WeldInitialListener.class))
.addListener(Servlets.listener(WeldTerminalListener.class))
.setContextPath("/")
.setDeploymentName("standalone-javax-mvc-app")
.addServlet(
createServletInfo("/resources/*", "JAX-RS Resources", org.glassfish.jersey.servlet.ServletContainer.class)
)
.setResourceManager(new ClassPathResourceManager(classLoader, "META-INF/webapp"))
.setClassIntrospecter(CdiClassIntrospecter.INSTANCE)
.setAllowNonStandardWrappers(true)
.setClassLoader(classLoader);
ServletContainer servletContainer = Servlets.defaultContainer();
DeploymentManager deploymentManager = servletContainer.addDeployment(deploymentInfo);
deploymentManager.deploy();
Undertow server = Undertow.builder()
.addHttpListener(8080, "0.0.0.0")
.setHandler(deploymentManager.start())
.build();
server.start();
}
示例4: createHtmlManager
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
private static HttpHandler createHtmlManager() throws ServletException {
final DeploymentInfo deploymentInfo = Servlets.deployment()
.setClassLoader(HttpServerUtil.class.getClassLoader())
.setContextPath(SERVLET_CONTEXT_PATH)
.setDeploymentName("uaiMockServer.war")
.addServlets(
servlet("UaiIndexServlet", UaiIndexServlet.class).addMapping("/index"),
servlet("UaiPageServlet", UaiPageServlet.class).addMapping("/page"),
servlet("JavascriptServlet", UaiJavascriptServlet.class).addMapping("/javascript"),
servlet("CssServlet", UaiCssServlet.class).addMapping("/css"),
servlet("CssMapServlet", UaiCssMapServlet.class).addMapping("/bootstrap.css.map"),
servlet("AngularMapServlet", UAiAngularMapServlet.class).addMapping("/angular.js.map"),
servlet("UaiRouteServlet", UaiRouteServlet.class).addMapping("/uaiRoute"),
servlet("UaiRouteCloneServlet", UaiRouteCloneServlet.class).addMapping("/uaiRoute/clone"),
servlet("UaiRootConfigurationsServlet", UaiRootConfigurationsServlet.class).addMapping("/rootConfigurations")
);
final DeploymentManager manager = Servlets.defaultContainer().addDeployment(deploymentInfo);
manager.deploy();
return manager.start();
}
示例5: main
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
public static void main(String[] args) throws ServletException, IOException {
final Xnio xnio = Xnio.getInstance("nio", Undertow.class.getClassLoader());
final XnioWorker xnioWorker = xnio.createWorker(OptionMap.builder().getMap());
final WebSocketDeploymentInfo webSockets = new WebSocketDeploymentInfo()
.addEndpoint(SocketProxy.class)
.setWorker(xnioWorker);
final DeploymentManager deployment = defaultContainer()
.addDeployment(deployment()
.setClassLoader(WebSocketServer.class.getClassLoader())
.setContextPath("/")
.setDeploymentName("embedded-websockets")
.addServletContextAttribute(ATTRIBUTE_NAME, webSockets));
deployment.deploy();
Undertow.builder().
addListener(8080, "localhost")
.setHandler(deployment.start())
.setHandler(Handlers.path().addPrefixPath("/test", Handlers.resource(new ClassPathResourceManager(WebSocketServer.class.getClassLoader(), WebSocketServer.class.getPackage())).addWelcomeFiles("index.html")))
.build()
.start();
}
示例6: deployLogs
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
protected void deployLogs(BootContext context, ServletContainer servletContainer) {
String adminLogs = context.properties().getProperty("vas.admin.logs", "false");
if(Boolean.valueOf(adminLogs)) {
DeploymentInfo deploymentInfo = Servlets
.deployment()
.setContextPath("/")
.setDeploymentName("logback.war")
.setClassLoader(getClass().getClassLoader())
.addServlet(
Servlets.servlet("logback", ViewStatusMessagesServlet.class).setEnabled(true).setAsyncSupported(true)
.setLoadOnStartup(1).addMappings("/"));
DeploymentManager deploymentManager = servletContainer.addDeployment(deploymentInfo);
deploymentManager.deploy();
try {
context.pathHandler().addPrefixPath("/admin/logs", deploymentManager.start());
} catch (ServletException e) {
throw new RuntimeException(e);
}
}
}
示例7: init
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
private void init(PathHandler pathHandler) throws ServletException {
// Deployment info
ServletContainer servletContainer = Servlets.defaultContainer();
DeploymentInfo deploymentInfo = VasHelper.deploymentInfo();
// Boot context & post processors
context = new BootContextImpl(properties, pathHandler, deploymentInfo, services);
VasHelper.lookupHandlerPostProcessors(context);
// Deployment
DeploymentManager deploymentManager = servletContainer.addDeployment(deploymentInfo);
deploymentManager.deploy();
pathHandler.addPrefixPath(Const.CONTEXT_NAME, deploymentManager.start());
boot();
}
示例8: setUpClass
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
/**
* Sets up the test environment, generates data to upload, starts an
* Undertow instance which will receive the client requests.
* @throws Exception If an error occurred with the servlets
*/
@BeforeClass
public static void setUpClass() throws Exception {
DeploymentInfo servletBuilder = Servlets.deployment()
.setClassLoader(UndertowIntegrationTest.class.getClassLoader())
.setContextPath("/")
.setDeploymentName("ROOT.war")
.addServlets(
Servlets.servlet("AsyncUploadServlet", AsyncUploadServlet.class)
.addMapping("/async")
.setAsyncSupported(true),
Servlets.servlet("BlockingUploadServlet", BlockingUploadServlet.class)
.addMapping("/blocking")
.setAsyncSupported(false)
);
DeploymentManager manager = Servlets.defaultContainer().addDeployment(servletBuilder);
manager.deploy();
PathHandler path = Handlers.path(Handlers.redirect("/")).addPrefixPath("/", manager.start());
server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(path)
.build();
server.start();
}
示例9: mountServerEndpoints
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
protected PathHandler mountServerEndpoints(final PathHandler pathHandler , List<Class<?>> serverEndpoints) throws ServletException{
if(!serverEndpoints.isEmpty()){
DeploymentInfo builder = new DeploymentInfo()
.setClassLoader(this.getClass().getClassLoader())
.setContextPath("/");
WebSocketDeploymentInfo wsDeployInfo = new WebSocketDeploymentInfo();
wsDeployInfo.setBuffers(new ByteBufferSlicePool(100, 1000));
for(Class<?> serverEndpoint : serverEndpoints ){
wsDeployInfo.addEndpoint( serverEndpoint );
}
builder.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, wsDeployInfo );
builder.setDeploymentName("websocketDeploy.war");
final ServletContainer container = ServletContainer.Factory.newInstance();
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
pathHandler.addPrefixPath("/", manager.start() );
}
return pathHandler;
}
示例10: main
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
public static void main(String[] args) throws IOException, ServletException {
final Xnio xnio = Xnio.getInstance("nio", Undertow.class.getClassLoader());
final XnioWorker xnioWorker = xnio.createWorker(OptionMap.builder().getMap());
final WebSocketDeploymentInfo webSockets = new WebSocketDeploymentInfo()
.addEndpoint(ClassProvider.class)
.setWorker(xnioWorker);
final DeploymentManager deploymentManager = Servlets.defaultContainer()
.addDeployment(Servlets.deployment()
.setClassLoader(ClassProviderStarter.class.getClassLoader())
.setContextPath("/")
.setDeploymentName("class-provider")
.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, webSockets));
deploymentManager.deploy();
//noinspection deprecation
Undertow.builder()
.addListener(5000, "localhost")
.setHandler(deploymentManager.start())
.build()
.start();
}
示例11: deployApplications
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
/**
* Setup the deployment managers for a given set of applications
*
* @param apps
* @return list of deployment managers
*/
public List<DeploymentManager> deployApplications(List<Application> apps) {
List<DeploymentManager> deployManagers = new ArrayList<DeploymentManager>();
for (Application app : apps) {
DeploymentInfo deployInfo = app.getDeploymentInfo();
// Add default listeners
ListenerInfo cdiListener = Servlets.listener(CdiServletRequestListener.class);
deployInfo.addListener(cdiListener);
DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(deployInfo);
try {
deploymentManager.deploy();
deployManagers.add(deploymentManager);
} catch (Exception e) {
logger.log(Level.SEVERE, "stokesdrift:server:start[status=app_deploy_fail,app_type=" + app.getClass().getSimpleName() + "]", e);
}
}
return deployManagers;
}
示例12: start
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
public void start() throws Exception {
logger.log(Level.INFO, "stokesdrift:server:start[status=in_progress]");
logger.log(Level.INFO, "stokesdrift:server:load_cdi_container[status=in_progress]");
weld = new Weld();
container = weld.initialize();
logger.log(Level.INFO, "stokesdrift:server:load_cdi_container[status=complete]");
applications = loadApplicationDefinitions(config);
Undertow.Builder builder = Undertow.builder().addHttpListener(config.getPort(), config.getHost());
List<DeploymentManager> managers = deployApplications(applications);
for (DeploymentManager deploymentManager : managers) {
builder.setHandler(deploymentManager.start());
}
server = builder.build();
server.start();
logger.log(Level.INFO, "stokesdrift:server:http[port="+config.getPort()+",host="+config.getHost()+"]");
logger.log(Level.INFO, "stokesdrift:server:start[status=complete]");
}
示例13: testUndertowLoading
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
@Test
public void testUndertowLoading() throws Exception {
int port = 8888;
FilterInfo filter = Servlets.filter("RackFilter", RackFilter.class);
ListenerInfo listenerInfo = Servlets.listener(RackServletContextListener.class);
DeploymentInfo di = new DeploymentInfo()
.addListener(listenerInfo)
.setContextPath("/")
// .addInitParameter(name, value)
.addFilter(filter)
.addFilterUrlMapping("RackFilter", "/*", DispatcherType.ASYNC)
// .addServlet(servletInfo)
.setDeploymentName("RackServlet")
.setClassLoader(ClassLoader.getSystemClassLoader());
DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(di);
deploymentManager.deploy();
Undertow server = Undertow.builder()
.addHttpListener(port, "localhost")
.setHandler(deploymentManager.start())
.build();
Assert.assertNotNull(server);
// server.start();
}
示例14: SimpleServletServer
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
public SimpleServletServer() {
DeploymentInfo deploymentInfo = deployment()
.setClassLoader(SimpleServletServer.class.getClassLoader())
.setContextPath("/helloworld")
.setDeploymentName("helloworld.war")
.addServlets(
Servlets.servlet("MyServlet", MyServlet.class)
.addInitParam("message", "Hello World")
.addMapping("/MyServlet"),
Servlets.servlet("MyAnotherServlet", MyAnotherServlet.class)
.addMapping("/MyAnotherServlet")
);
DeploymentManager manager = defaultContainer().addDeployment(deploymentInfo);
manager.deploy ();
try {
server = Undertow.builder()
.addListener(8080, "localhost")
.setHandler(manager.start())
.build();
} catch (ServletException ex) {
Logger.getLogger(SimpleServletServer.class.getName()).log(Level.SEVERE, null, ex);
}
}
示例15: main
import io.undertow.servlet.api.DeploymentManager; //導入依賴的package包/類
public static void main(final String... args) throws Exception {
final DeploymentManager deployment = Servlets.defaultContainer()
.addDeployment(
Servlets.deployment()
.setClassLoader(UndertowContainer.class.getClassLoader())
.setContextPath("/")
.setDeploymentName(UndertowContainer.class.getName())
.addServletContextAttribute(
WebSocketDeploymentInfo.ATTRIBUTE_NAME,
new WebSocketDeploymentInfo()
.addEndpoint(ApplicationConfig.ENDPOINT_CONFIG)
.setWorker(Xnio.getInstance().createWorker(OptionMap.builder().getMap()))
.setBuffers(new XnioByteBufferPool(new ByteBufferSlicePool(1024, 10240)))
)
);
deployment.deploy();
final HttpHandler servletHandler = deployment.start();
Undertow.builder()
.addHttpListener(Client.PORT, Client.HOST)
.setHandler(servletHandler)
.build()
.start();
}