本文整理汇总了Java中org.xnio.Xnio.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java Xnio.getInstance方法的具体用法?Java Xnio.getInstance怎么用?Java Xnio.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xnio.Xnio
的用法示例。
在下文中一共展示了Xnio.getInstance方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.xnio.Xnio; //导入方法依赖的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: main
import org.xnio.Xnio; //导入方法依赖的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();
}
示例3: AnnotatedWebSocketServer
import org.xnio.Xnio; //导入方法依赖的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();
}
示例4: ProgrammaticWebSocketServer
import org.xnio.Xnio; //导入方法依赖的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();
}
示例5: ConnectionProviderContextImpl
import org.xnio.Xnio; //导入方法依赖的package包/类
public ConnectionProviderContextImpl ( OptionMap opts, String endpointName ) throws IllegalArgumentException, IOException {
this.instance = Xnio.getInstance();
this.worker = this.instance.createWorker(opts);
this.endpoint = Remoting.createEndpoint(endpointName, this.worker, opts);
this.executor = Executors.newCachedThreadPool(new ThreadFactory() {
public Thread newThread ( Runnable r ) {
Thread t = new Thread(r, "Worker");
t.setDaemon(true);
return t;
}
});
}
示例6: ConnectionFactory
import org.xnio.Xnio; //导入方法依赖的package包/类
private ConnectionFactory(URI kubernetesMasterUri) {
this.kubernetesMasterUri = kubernetesMasterUri;
undertowClient = UndertowClient.getInstance();
Xnio xnio = Xnio.getInstance(Undertow.class.getClassLoader());
try {
ssl = new UndertowXnioSsl(xnio, OptionMap.EMPTY);
} catch (Exception e) {
throw new RuntimeException(e);
}
byteBufferPool = createByteBufferPool();
}
示例7: start
import org.xnio.Xnio; //导入方法依赖的package包/类
@Override
public void start(StartContext startContext) throws StartException {
final Xnio xnio = Xnio.getInstance();
try {
worker = xnio.createWorker(null, options, this::stopDone);
} catch (IOException e) {
throw new StartException(e);
}
}
示例8: before
import org.xnio.Xnio; //导入方法依赖的package包/类
@BeforeClass
public static void before() throws Exception {
Xnio xnio = Xnio.getInstance(WebSocketTest.class.getClassLoader());
worker = xnio.createWorker(OptionMap.builder()
.set(Options.WORKER_IO_THREADS, 2)
.set(Options.CONNECTION_HIGH_WATER, 1000000)
.set(Options.CONNECTION_LOW_WATER, 1000000)
.set(Options.WORKER_TASK_CORE_THREADS, 30)
.set(Options.WORKER_TASK_MAX_THREADS, 30)
.set(Options.TCP_NODELAY, true).set(Options.CORK, true)
.getMap());
}
示例9: main
import org.xnio.Xnio; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
final OptionMap options = OptionMap.builder()
.set(WORKER_IO_THREADS, 8)
.set(TCP_NODELAY, true)
.set(KEEP_ALIVE, true)
.set(WORKER_NAME, "Client")
.getMap();
final Xnio xnio = Xnio.getInstance();
final XnioWorker worker = xnio.createWorker(null, options);
final UndertowClient client = UndertowClient.getInstance();
final URI serverAddress = new URI(SERVER_URL);
final ClientConnection connection = client.connect(serverAddress, worker, new ByteBufferSlicePool(1024, 1024), EMPTY).get();
final CountDownLatch latch = new CountDownLatch(1);
try {
connection.getIoThread().execute(new Runnable() {
@Override
public void run() {
final ClientRequest request = new ClientRequest().setMethod(GET).setPath("/");
request.getRequestHeaders().add(UPGRADE, HORNETQ_REMOTING);
String secretKey = HandshakeUtil.createSecretKey();
request.getRequestHeaders().add(HttpString.tryFromString(HandshakeUtil.SEC_HORNETQ_REMOTING_KEY), secretKey);
connection.sendRequest(request, createClientCallback(latch, secretKey));
}
});
latch.await(10, TimeUnit.MINUTES);
if (connection.isUpgraded()) {
StreamConnection streamConnection = connection.performUpgrade();
switchToHornetQProtocol(streamConnection);
}
} finally {
IoUtils.safeClose(connection);
worker.shutdown();
}
}
示例10: run
import org.xnio.Xnio; //导入方法依赖的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();
}
示例11: createWorker
import org.xnio.Xnio; //导入方法依赖的package包/类
private XnioWorker createWorker() throws IOException {
Xnio xnio = Xnio.getInstance(Undertow.class.getClassLoader());
return xnio.createWorker(
OptionMap.builder().set(Options.THREAD_DAEMON, true).getMap());
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:6,代码来源:UndertowEmbeddedServletContainerFactory.java
示例12: createWorker
import org.xnio.Xnio; //导入方法依赖的package包/类
private XnioWorker createWorker() throws IOException {
Xnio xnio = Xnio.getInstance(Undertow.class.getClassLoader());
OptionMap.Builder builder = OptionMap.builder();
return xnio.createWorker(builder.getMap());
}
示例13: RedisClientFactory
import org.xnio.Xnio; //导入方法依赖的package包/类
public RedisClientFactory(Charset charset, int ioThreads) throws IOException {
Xnio xnio = Xnio.getInstance();
this.charset = charset;
worker = xnio.createWorker(OptionMap.create(Options.WORKER_IO_THREADS, ioThreads));
}
示例14: RedisClientFactory
import org.xnio.Xnio; //导入方法依赖的package包/类
public RedisClientFactory(Charset charset, int ioThreads) throws IOException {
Xnio xnio = Xnio.getInstance();
this.charset = charset;
worker = xnio.createWorker(OptionMap.create(Options.WORKER_IO_THREADS, ioThreads));
}