当前位置: 首页>>代码示例>>Java>>正文


Java Xnio.createWorker方法代码示例

本文整理汇总了Java中org.xnio.Xnio.createWorker方法的典型用法代码示例。如果您正苦于以下问题:Java Xnio.createWorker方法的具体用法?Java Xnio.createWorker怎么用?Java Xnio.createWorker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xnio.Xnio的用法示例。


在下文中一共展示了Xnio.createWorker方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();

}
 
开发者ID:actframework,项目名称:act-demo-apps,代码行数:23,代码来源:WebSocketServer.java

示例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();
}
 
开发者ID:kawasima,项目名称:websocket-classloader,代码行数:22,代码来源:ClassProviderStarter.java

示例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();
}
 
开发者ID:arun-gupta,项目名称:wildfly-samples,代码行数:18,代码来源:AnnotatedWebSocketServer.java

示例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();
}
 
开发者ID:arun-gupta,项目名称:wildfly-samples,代码行数:18,代码来源:ProgrammaticWebSocketServer.java

示例5: 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);
    }

}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:11,代码来源:ManagementWorkerService.java

示例6: 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());
}
 
开发者ID:taichi,项目名称:siden,代码行数:13,代码来源:WebSocketTest.java

示例7: 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();
    }
}
 
开发者ID:jmesnil,项目名称:hornetq-undertow-client,代码行数:38,代码来源:Client.java

示例8: 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

示例9: 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());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:6,代码来源:UndertowEmbeddedServletContainerFactory.java

示例10: 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));
}
 
开发者ID:vkorenev,项目名称:xnio-redis-client,代码行数:6,代码来源:RedisClientFactory.java

示例11: 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));
}
 
开发者ID:vkorenev,项目名称:RedRadishes,代码行数:6,代码来源:RedisClientFactory.java


注:本文中的org.xnio.Xnio.createWorker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。