本文整理汇总了Java中io.undertow.websockets.jsr.WebSocketDeploymentInfo类的典型用法代码示例。如果您正苦于以下问题:Java WebSocketDeploymentInfo类的具体用法?Java WebSocketDeploymentInfo怎么用?Java WebSocketDeploymentInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebSocketDeploymentInfo类属于io.undertow.websockets.jsr包,在下文中一共展示了WebSocketDeploymentInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的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();
}
示例2: mountServerEndpoints
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的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;
}
示例3: main
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的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();
}
示例4: AnnotatedWebSocketServer
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的package包/类
public AnnotatedWebSocketServer() throws IOException {
final Xnio xnio = Xnio.getInstance("nio", Undertow.class.getClassLoader());
final XnioWorker xnioWorker = xnio.createWorker(OptionMap.builder().getMap());
WebSocketDeploymentInfo websocket = new WebSocketDeploymentInfo()
.addEndpoint(MyAnnotatedEndpoint.class)
.setWorker(xnioWorker);
DeploymentInfo deploymentInfo = deployment()
.setClassLoader(MyAnnotatedEndpoint.class.getClassLoader())
.setContextPath("/myapp")
.setDeploymentName("websockets")
.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, websocket);
manager = defaultContainer().addDeployment(deploymentInfo);
manager.deploy();
}
示例5: ProgrammaticWebSocketServer
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的package包/类
public ProgrammaticWebSocketServer() throws IOException {
final Xnio xnio = Xnio.getInstance("nio", Undertow.class.getClassLoader());
final XnioWorker xnioWorker = xnio.createWorker(OptionMap.builder().getMap());
WebSocketDeploymentInfo websocket = new WebSocketDeploymentInfo()
.addEndpoint(MyAnnotatedEndpoint.class)
.setWorker(xnioWorker);
DeploymentInfo deploymentInfo = deployment()
.setClassLoader(MyAnnotatedEndpoint.class.getClassLoader())
.setContextPath("/myapp")
.setDeploymentName("websockets")
.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, websocket);
manager = defaultContainer().addDeployment(deploymentInfo);
manager.deploy();
}
示例6: main
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的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();
}
示例7: webSocketDeploymentInfo
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的package包/类
private static WebSocketDeploymentInfo webSocketDeploymentInfo(Config cfg) {
Config wsOptions = cfg.getConfig(KEY_WS_WEB_SOCKET_OPTIONS);
return new WebSocketDeploymentInfo()
.setWorker(webSocketWorker(wsOptions))
.setBuffers(new DefaultByteBufferPool(wsOptions.getBoolean(KEY_WS_USE_DIRECT_BUFFER),
wsOptions.getInt(KEY_WS_BUFFER_SIZE)))
.addEndpoint(ServerLogsWebSocket.class);
}
示例8: startUndertow
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的package包/类
private static void startUndertow() throws ServletException {
ServletInfo servletInfo = new ServletInfo(VaadinServlet.class.getName(), VaadinServlet.class)
.setAsyncSupported(true)
.setLoadOnStartup(1)
.addInitParam("ui", "com.hybridbpm.ui.HybridbpmUI").addInitParam("widgetset", "com.hybridbpm.ui.HybridbpmWidgetSet")
.addMapping("/*").addMapping("/VAADIN");
DeploymentInfo deploymentInfo = deployment()
.setClassLoader(HybridbpmServer.class.getClassLoader())
.setContextPath(PATH)
.setDeploymentName("hybridbpm.war")
.setDisplayName("HYBRIDBPM")
.setResourceManager(new ClassPathResourceManager(HybridbpmServer.class.getClassLoader()))
.addServlets(servletInfo)
.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo());
DeploymentManager manager = defaultContainer().addDeployment(deploymentInfo);
manager.deploy();
PathHandler path = Handlers.path(Handlers.redirect(PATH)).addPrefixPath(PATH, manager.start());
Undertow.Builder builder = Undertow.builder().addHttpListener(8080, "0.0.0.0").setHandler(path);
undertow = builder.build();
undertow.start();
logger.info("HybridbpmServer UI started");
}
示例9: createRootHandler
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的package包/类
public HttpHandler createRootHandler(Configuration configuration , ScannerResult scannerResult) {
PathHandler pathHandler = Handlers.path();
String appContext = "/" + configuration.getAppContext();
pathHandler.addPrefixPath( appContext , createAppHandlers(scannerResult));
if(!scannerResult.getServerEndpoints().isEmpty()){
DeploymentInfo builder = new DeploymentInfo().setClassLoader(this.getClass().getClassLoader()).setContextPath("/");
WebSocketDeploymentInfo wsDeployInfo = new WebSocketDeploymentInfo();
wsDeployInfo.setBuffers(new ByteBufferSlicePool(100, 1000));
for(Class<?> serverEndpoint : scannerResult.getServerEndpoints() ){
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();
try {
OvertownSessionManager sessionManager = OvertownSessionManager.getInstance();
String wsContextPath = "ws";
if( !appContext.endsWith("/") ){
wsContextPath += appContext + "/" + wsContextPath;
}
pathHandler.addPrefixPath( wsContextPath ,
new SessionAttachmentHandler( manager.start() , sessionManager.getSessionManager(),
sessionManager.getSessionConfig()) );
} catch (ServletException e) {
e.printStackTrace();
}
}
String staticContextPath = configuration.getStaticRootPath();
if( !appContext.endsWith("/") ){
staticContextPath = appContext + "/" + staticContextPath;
}
pathHandler.addPrefixPath( staticContextPath , new ResourceHandlerMounter().mount());
return pathHandler;
}
示例10: main
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的package包/类
public static void main(final String... args) throws Exception {
final DeploymentManager deployment = Servlets.defaultContainer()
.addDeployment(
Servlets.deployment()
.setClassLoader(AsyncWsConnectionTest.class.getClassLoader())
.setContextPath("/")
.setDeploymentName(AsyncWsConnectionTest.class.getName())
.addServletContextAttribute(
WebSocketDeploymentInfo.ATTRIBUTE_NAME,
new WebSocketDeploymentInfo()
.addEndpoint(serverEndpointConfig())
.setWorker(Xnio.getInstance().createWorker(OptionMap.builder().getMap()))
.setBuffers(new XnioByteBufferPool(new ByteBufferSlicePool(1024, 10240)))
)
);
deployment.deploy();
Undertow.builder()
.addHttpListener(PORT, HOST)
.setHandler(deployment.start())
.build()
.start();
TimeUnit.SECONDS.sleep(1);
if (true) {
client(new ServerWebSocketContainer(
DefaultClassIntrospector.INSTANCE,
Xnio.getInstance().createWorker(OptionMap.create(Options.THREAD_DAEMON, true)),
new XnioByteBufferPool(new ByteBufferSlicePool(1024, 10240)),
List.of(new ContextClassLoaderSetupAction(ClassLoader.getSystemClassLoader())),
true,
true
));
} else {
final ClientContainer container = new ClientContainer(); // $note: setSendTimeout not yet implemented in Jetty
container.start();
client(container);
}
}
示例11: run
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的package包/类
protected static void run(final CountDownLatch latch) throws Exception {
final Xnio xnio = Xnio.getInstance();
final DeploymentManager deployment = Servlets.defaultContainer()
.addDeployment(
Servlets.deployment()
.setClassLoader(UndertowTest.class.getClassLoader())
.setContextPath("/")
.setDeploymentName(UndertowTest.class.getName())
.addServletContextAttribute(
WebSocketDeploymentInfo.ATTRIBUTE_NAME,
new WebSocketDeploymentInfo()
.addEndpoint(serverEndpointConfig())
.setWorker(xnio.createWorker(OptionMap.builder().getMap()))
.setBuffers(new XnioByteBufferPool(new ByteBufferSlicePool(1024, 10240)))
)
);
deployment.deploy();
final Undertow server = Undertow.builder()
.addHttpListener(PORT, "localhost")
.setHandler(deployment.start())
.build();
server.start();
connect(
new ServerWebSocketContainer(
DefaultClassIntrospector.INSTANCE,
xnio.createWorker(OptionMap.create(Options.THREAD_DAEMON, true)),
new XnioByteBufferPool(new ByteBufferSlicePool(1024, 10240)),
List.of(new ContextClassLoaderSetupAction(ClassLoader.getSystemClassLoader())),
true,
true
),
latch
);
server.stop();
}
示例12: main
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的package包/类
public static void main(final String... args) throws Exception {
final DeploymentManager deployment = Servlets.defaultContainer()
.addDeployment(
Servlets.deployment()
.setClassLoader(UndertowAcceptor.class.getClassLoader())
.setContextPath("/")
.setDeploymentName(UndertowAcceptor.class.getName())
.addServlet(
Servlets.servlet("Xhr", XhrServlet.class)
.addMapping(XHR_PATH)
)
.addServletContextAttribute(
WebSocketDeploymentInfo.ATTRIBUTE_NAME,
new WebSocketDeploymentInfo()
.addEndpoint(ENDPOINT_CONFIG)
.setWorker(Xnio.getInstance().createWorker(OptionMap.builder().getMap()))
.setBuffers(new XnioByteBufferPool(new ByteBufferSlicePool(1024, 10240)))
)
);
deployment.deploy();
final HttpHandler servletHandler = deployment.start();
final HttpHandler fileHandler = Handlers.resource(new FileResourceManager(new File(WEB_PATH), 100));
Undertow.builder()
.addHttpListener(PORT, HOST)
.addHttpsListener(PORT + 1, HOST, SslConfig.SERVER.context) // $note: we don't know how to force client authentication
.setHandler(exchange -> {
final String path = exchange.getRequestPath();
if (WS_PATH.equals(path) || XHR_PATH.equals(path)) {
servletHandler.handleRequest(exchange);
} else {
fileHandler.handleRequest(exchange);
}
})
.build()
.start();
System.out.println("started");
}
示例13: initUndertowServer
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的package包/类
public void initUndertowServer() {
JbootServerClassloader classloader = new JbootServerClassloader(UnderTowServer.class.getClassLoader());
classloader.setDefaultAssertionStatus(false);
deploymentInfo = buildDeploymentInfo(classloader);
if (webConfig.isWebsocketEnable()) {
Set<Class> endPointClasses = JbootWebsocketManager.me().getWebsocketEndPoints();
WebSocketDeploymentInfo webSocketDeploymentInfo = new WebSocketDeploymentInfo();
webSocketDeploymentInfo.setBuffers(new DefaultByteBufferPool(true, webConfig.getWebsocketBufferPoolSize()));
for (Class endPointClass : endPointClasses) {
webSocketDeploymentInfo.addEndpoint(endPointClass);
}
deploymentInfo.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, webSocketDeploymentInfo);
}
servletContainer = Servlets.newContainer();
deploymentManager = servletContainer.addDeployment(deploymentInfo);
deploymentManager.deploy();
HttpHandler httpHandler = null;
try {
/**
* 启动并初始化servlet和filter
*/
httpHandler = deploymentManager.start();
} catch (Throwable ex) {
ex.printStackTrace();
}
pathHandler = Handlers.path(
Handlers.resource(new ClassPathResourceManager(classloader, "webRoot")));
pathHandler.addPrefixPath(config.getContextPath(), httpHandler);
undertow = Undertow.builder()
.addHttpListener(config.getPort(), config.getHost())
.setHandler(pathHandler)
.build();
}
示例14: customize
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的package包/类
@Override
public void customize(DeploymentInfo deploymentInfo) {
WebSocketDeploymentInfo info = new WebSocketDeploymentInfo();
deploymentInfo.addServletContextAttribute(
WebSocketDeploymentInfo.ATTRIBUTE_NAME, info);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:UndertowWebSocketContainerCustomizer.java
示例15: start
import io.undertow.websockets.jsr.WebSocketDeploymentInfo; //导入依赖的package包/类
@Override
public void start() {
DeploymentInfo di = new DeploymentInfo()
.setContextPath("/")
.setDeploymentName("Undertow")
.setResourceManager(new ClassPathResourceManager(getClass().getClassLoader()))
.setClassLoader(ClassLoader.getSystemClassLoader());
super.getListeners().forEach(c ->di.addListener(listener(c)));
Collection<Class<?>> endpoints = extension.getEndpointClasses();
if(!endpoints.isEmpty()) {
WebSocketDeploymentInfo webSocketDeploymentInfo = new WebSocketDeploymentInfo();
endpoints.forEach(webSocketDeploymentInfo::addEndpoint);
di.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, webSocketDeploymentInfo);
}
getServletContextAttributes().forEach(di::addServletContextAttribute);
servlets.forEach(di::addServlet);
getFilterDescriptors().forEach(filterDescriptor -> {
FilterInfo filterInfo = filter(filterDescriptor.displayName(), filterDescriptor.getClazz()).setAsyncSupported(filterDescriptor.asyncSupported());
if(filterDescriptor.initParams() != null) {
for (WebInitParam param : filterDescriptor.initParams()) {
filterInfo.addInitParam(param.name(), param.value());
}
}
di.addFilter(filterInfo);
for(String url : filterDescriptor.urlPatterns()) {
for(DispatcherType dispatcherType : filterDescriptor.dispatcherTypes()) {
di.addFilterUrlMapping(filterDescriptor.displayName(), url, dispatcherType);
}
}
});
getInitParams().forEach(di::addInitParameter);
DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(di);
deploymentManager.deploy();
try {
HttpHandler servletHandler = deploymentManager.start();
PathHandler path = path(Handlers.redirect("/"))
.addPrefixPath("/", servletHandler);
Builder undertowBuilder = Undertow.builder()
.addHttpListener(webServerConfiguration.getPort(), webServerConfiguration.getAddress())
.setHandler(path);
if (hammockRuntime.isSecuredConfigured()){
KeyManager[] keyManagers = loadKeyManager();
TrustManager[] trustManagers = loadTrustManager();
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManagers, trustManagers, null);
undertowBuilder = undertowBuilder.addHttpsListener(webServerConfiguration.getSecuredPort(), webServerConfiguration.getAddress(), sslContext);
}
this.undertow = undertowBuilder.build();
this.undertow.start();
} catch (ServletException | GeneralSecurityException | IOException e) {
throw new RuntimeException("Unable to start server", e);
}
}