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


Java XnioWorker类代码示例

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


XnioWorker类属于org.xnio包,在下文中一共展示了XnioWorker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: connect

import org.xnio.XnioWorker; //导入依赖的package包/类
@Override
public void connect(final ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, final XnioSsl ssl, final Pool<ByteBuffer> bufferPool, final OptionMap options) {
    ChannelListener<StreamConnection> openListener = new ChannelListener<StreamConnection>() {
        @Override
        public void handleEvent(StreamConnection connection) {
            handleConnected(connection, listener, uri, ssl, bufferPool, options);
        }
    };
    IoFuture.Notifier<StreamConnection, Object> notifier = new IoFuture.Notifier<StreamConnection, Object>() {
        @Override
        public void notify(IoFuture<? extends StreamConnection> ioFuture, Object o) {
            if (ioFuture.getStatus() == IoFuture.Status.FAILED) {
                listener.failed(ioFuture.getException());
            }
        }
    };
    if(bindAddress == null) {
        worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, options).addNotifier(notifier, null);
    } else {
        worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 8009 : uri.getPort()), openListener, null, options).addNotifier(notifier, null);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:AjpClientProvider.java

示例2: connect

import org.xnio.XnioWorker; //导入依赖的package包/类
public IoFuture<ClientConnection> connect(InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, XnioSsl ssl, Pool<ByteBuffer> bufferPool, OptionMap options) {
    ClientProvider provider = getClientProvider(uri);
    final FutureResult<ClientConnection> result = new FutureResult<>();
    provider.connect(new ClientCallback<ClientConnection>() {
        @Override
        public void completed(ClientConnection r) {
            result.setResult(r);
        }

        @Override
        public void failed(IOException e) {
            result.setException(e);
        }
    }, bindAddress, uri, worker, ssl, bufferPool, options);
    return result.getIoFuture();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:UndertowClient.java

示例3: connect

import org.xnio.XnioWorker; //导入依赖的package包/类
@Override
public void connect(ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, URI uri, XnioWorker worker, XnioSsl ssl, Pool<ByteBuffer> bufferPool, OptionMap options) {
    if (uri.getScheme().equals("https")) {
        if (ssl == null) {
            listener.failed(UndertowMessages.MESSAGES.sslWasNull());
            return;
        }
        if (bindAddress == null) {
            ssl.openSslConnection(worker, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null);
        } else {
            ssl.openSslConnection(worker, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null);
        }
    } else {
        if (bindAddress == null) {
            worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options), options).addNotifier(createNotifier(listener), null);
        } else {
            worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort()), createOpenListener(listener, bufferPool, options), null, options).addNotifier(createNotifier(listener), null);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:HttpClientProvider.java

示例4: main

import org.xnio.XnioWorker; //导入依赖的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

示例5: main

import org.xnio.XnioWorker; //导入依赖的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

示例6: installRemotingManagementEndpoint

import org.xnio.XnioWorker; //导入依赖的package包/类
public static void installRemotingManagementEndpoint(final ServiceTarget serviceTarget, final ServiceName endpointName,
                                                     final String hostName, final EndpointService.EndpointType type, final OptionMap options) {
    EndpointService service = new EndpointService(hostName, type, options);
    serviceTarget.addService(endpointName, service)
            .setInitialMode(Mode.ACTIVE)
            .addDependency(ServiceName.JBOSS.append("serverManagement", "controller", "management", "worker"), XnioWorker.class, service.getWorker())
            .install();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:9,代码来源:RemotingServices.java

示例7: performRuntime

import org.xnio.XnioWorker; //导入依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {

    ModelNode endpointModel = context.readResource(PathAddress.pathAddress(RemotingEndpointResource.ENDPOINT_PATH)).getModel();
    String workerName = WORKER.resolveModelAttribute(context, endpointModel).asString();

    final OptionMap map = EndpointConfigFactory.populate(context, endpointModel);

    // create endpoint
    final String nodeName = WildFlySecurityManager.getPropertyPrivileged(RemotingExtension.NODE_NAME_PROPERTY, null);
    final EndpointService endpointService = new EndpointService(nodeName, EndpointService.EndpointType.SUBSYSTEM, map);

    // In case of a managed server the subsystem endpoint might already be installed {@see DomainServerCommunicationServices}
    if (context.getProcessType() == ProcessType.DOMAIN_SERVER) {
        final ServiceController<?> controller = context.getServiceRegistry(false).getService(RemotingServices.SUBSYSTEM_ENDPOINT);
        if (controller != null) {
            // if installed, just skip the rest
            return;
        }
    }

    context.getCapabilityServiceTarget().addCapability(RemotingSubsystemRootResource.REMOTING_ENDPOINT_CAPABILITY, endpointService)
            .addCapabilityRequirement(RemotingSubsystemRootResource.IO_WORKER_CAPABILITY, XnioWorker.class, endpointService.getWorker(), workerName)
            .install();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:26,代码来源:RemotingSubsystemAdd.java

示例8: execute

import org.xnio.XnioWorker; //导入依赖的package包/类
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    XnioWorker worker = getXnioWorker(context);
    if (worker == null || worker.getMXBean() == null) {
        context.getResult().set(IOExtension.NO_METRICS);
        return;
    }
    XnioWorkerMXBean metrics = worker.getMXBean();
    Optional<XnioServerMXBean> serverMetrics = Optional.empty();
    for (XnioServerMXBean xnioServerMXBean : metrics.getServerMXBeans()) {
        if (xnioServerMXBean.getBindAddress().equals(context.getCurrentAddressValue())) {
            serverMetrics = Optional.of(xnioServerMXBean);
            break;
        }
    }
    if (serverMetrics.isPresent()) {
        context.getResult().set(getMetricValue(serverMetrics.get()));
    } else {
        context.getResult().set(IOExtension.NO_METRICS);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:WorkerServerDefinition.java

示例9: testRuntime

import org.xnio.XnioWorker; //导入依赖的package包/类
@Test
public void testRuntime() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization())
            .setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(String.valueOf(mainServices.getBootError()));
    }
    ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default"));
    workerServiceController.setMode(ServiceController.Mode.ACTIVE);
    workerServiceController.awaitValue();
    XnioWorker worker = workerServiceController.getService().getValue();
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount());
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue());
    PathAddress addr = PathAddress.parseCLIStyleAddress("/subsystem=io/worker=default");
    ModelNode op = Util.createOperation("read-resource", addr);
    op.get("include-runtime").set(true);
    mainServices.executeOperation(op);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:IOSubsystemTestCase.java

示例10: testRuntime

import org.xnio.XnioWorker; //导入依赖的package包/类
@Test
public void testRuntime() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization())
            .setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(mainServices.getBootError().toString());
    }
    ServiceController<XnioWorker> workerServiceController = (ServiceController<XnioWorker>) mainServices.getContainer().getService(IOServices.WORKER.append("default"));
    workerServiceController.setMode(ServiceController.Mode.ACTIVE);
    workerServiceController.awaitValue();
    XnioWorker worker = workerServiceController.getService().getValue();
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 2, worker.getIoThreadCount());
    Assert.assertEquals(ProcessorInfo.availableProcessors() * 16, worker.getOption(Options.WORKER_TASK_MAX_THREADS).intValue());
    PathAddress addr = PathAddress.parseCLIStyleAddress("/subsystem=io/worker=default");
    ModelNode op = Util.createOperation("read-resource", addr);
    op.get("include-runtime").set(true);
    mainServices.executeOperation(op);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:IOSubsystem11TestCase.java

示例11: AnnotatedWebSocketServer

import org.xnio.XnioWorker; //导入依赖的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

示例12: ProgrammaticWebSocketServer

import org.xnio.XnioWorker; //导入依赖的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

示例13: connect

import org.xnio.XnioWorker; //导入依赖的package包/类
@Override
public void connect(final ClientCallback<ClientConnection> listener, InetSocketAddress bindAddress, final URI uri, final XnioWorker worker, final XnioSsl ssl, final Pool<ByteBuffer> bufferPool, final OptionMap options) {
    if(uri.getScheme().equals("spdy-plain")) {

        if(bindAddress == null) {
            worker.openStreamConnection(new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, options), options).addNotifier(createNotifier(listener), null);
        } else {
            worker.openStreamConnection(bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, options), null, options).addNotifier(createNotifier(listener), null);
        }
        return;
    }


    if(ALPN_PUT_METHOD == null) {
        listener.failed(UndertowMessages.MESSAGES.jettyNPNNotAvailable());
        return;
    }
    if (ssl == null) {
        listener.failed(UndertowMessages.MESSAGES.sslWasNull());
        return;
    }
    if(bindAddress == null) {
        ssl.openSslConnection(worker, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, options), options).addNotifier(createNotifier(listener), null);
    } else {
        ssl.openSslConnection(worker, bindAddress, new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 443 : uri.getPort()), createOpenListener(listener, uri, ssl, bufferPool, options), options).addNotifier(createNotifier(listener), null);
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:SpdyClientProvider.java

示例14: SessionImpl

import org.xnio.XnioWorker; //导入依赖的package包/类
private SessionImpl(InMemorySessionManager sessionManager, final String sessionId, final SessionConfig sessionCookieConfig, final XnioExecutor executor, final XnioWorker worker, final Object evictionToken) {
    this.sessionManager = sessionManager;
    this.sessionId = sessionId;
    this.sessionCookieConfig = sessionCookieConfig;
    this.executor = executor;
    this.worker = worker;
    this.evictionToken = evictionToken;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:InMemorySessionManager.java

示例15: rollbackAfterBan

import org.xnio.XnioWorker; //导入依赖的package包/类
public static void rollbackAfterBan(User who, int seconds) {
    if (seconds <= 0) {
        return;
    }

    XnioWorker worker = server.getServer().getWorker();
    worker.execute(() -> rollbackAfterBan_(who, seconds));
}
 
开发者ID:xSke,项目名称:Pxls,代码行数:9,代码来源:App.java


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