Search in sources :

Example 11 with ResteasyDeploymentImpl

use of org.jboss.resteasy.core.ResteasyDeploymentImpl in project resteasy by resteasy.

the class WadlUndertowConnector method deployToServer.

public UndertowJaxrsServer deployToServer(UndertowJaxrsServer server, Class<? extends Application> application, String contextPath) {
    ResteasyDeployment deployment = new ResteasyDeploymentImpl();
    deployment.setApplicationClass(application.getName());
    DeploymentInfo di = server.undertowDeployment(deployment, "/");
    di.setClassLoader(application.getClassLoader());
    di.setContextPath(contextPath);
    di.setDeploymentName("Resteasy" + contextPath);
    return server.deploy(di);
}
Also used : ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) ResteasyDeploymentImpl(org.jboss.resteasy.core.ResteasyDeploymentImpl) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo)

Example 12 with ResteasyDeploymentImpl

use of org.jboss.resteasy.core.ResteasyDeploymentImpl in project narayana by jbosstm.

the class VolatileParticipantResourceTestCase method beforeClass.

@BeforeClass
public static void beforeClass() {
    List<String> resourceClasses = new ArrayList<>();
    resourceClasses.add("org.jboss.narayana.rest.integration.VolatileParticipantResource");
    ResteasyDeployment resteasyDeployment = new ResteasyDeploymentImpl();
    resteasyDeployment.setResourceClasses(resourceClasses);
    NETTY = new NettyJaxrsServer();
    NETTY.setDeployment(resteasyDeployment);
    NETTY.setPort(TestPortProvider.getPort());
    NETTY.start();
}
Also used : ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) NettyJaxrsServer(org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer) ResteasyDeploymentImpl(org.jboss.resteasy.core.ResteasyDeploymentImpl) ArrayList(java.util.ArrayList) BeforeClass(org.junit.BeforeClass)

Example 13 with ResteasyDeploymentImpl

use of org.jboss.resteasy.core.ResteasyDeploymentImpl in project management-api-for-apache-cassandra by k8ssandra.

the class Cli method startHTTPService.

private NettyJaxrsServer startHTTPService(String hostname, int port) throws SSLException {
    NettyJaxrsServer server;
    if (useTls) {
        SslContext sslContext = SslContextBuilder.forServer(new File(tls_cert_file), new File(tls_key_file)).trustManager(new File(tls_ca_cert_file)).clientAuth(ClientAuth.REQUIRE).protocols(PROTOCOL_TLS_V1_2).ciphers(null, IdentityCipherSuiteFilter.INSTANCE).build();
        server = new NettyJaxrsTLSServer(sslContext);
    } else {
        server = new NettyJaxrsServer();
        server.setIoWorkerCount(2);
    }
    ResteasyDeployment deployment = new ResteasyDeploymentImpl();
    deployment.setApplication(application);
    server.setDeployment(deployment);
    server.setRootResourcePath("");
    server.setIdleTimeout(60);
    server.setSecurityDomain(null);
    server.setChannelOptions(ImmutableMap.of(ChannelOption.SO_REUSEADDR, true));
    server.setHostname(hostname);
    server.setPort(port);
    server.setHttpChannelHandlers(accessLogHandlers(useTls ? "https" : "http"));
    return server;
}
Also used : ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) NettyJaxrsServer(org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer) ResteasyDeploymentImpl(org.jboss.resteasy.core.ResteasyDeploymentImpl) File(java.io.File) SslContext(io.netty.handler.ssl.SslContext)

Example 14 with ResteasyDeploymentImpl

use of org.jboss.resteasy.core.ResteasyDeploymentImpl in project management-api-for-apache-cassandra by k8ssandra.

the class NettyTlsClientAuthTest method testHTTP.

@Test
public void testHTTP() throws Throwable {
    NettyJaxrsServer netty = new NettyJaxrsServer();
    ResteasyDeployment deployment = new ResteasyDeploymentImpl();
    netty.setDeployment(deployment);
    netty.setPort(TestPortProvider.getPort());
    netty.setRootResourcePath("");
    netty.setSecurityDomain(null);
    netty.start();
    deployment.getRegistry().addSingletonResource(new NettyHttpOverIPCTest.Resource());
    clientCall(null);
    netty.stop();
}
Also used : ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) NettyJaxrsServer(org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer) ResteasyDeploymentImpl(org.jboss.resteasy.core.ResteasyDeploymentImpl) Test(org.junit.Test)

Example 15 with ResteasyDeploymentImpl

use of org.jboss.resteasy.core.ResteasyDeploymentImpl in project management-api-for-apache-cassandra by k8ssandra.

the class NettyHttpOverIPCTest method testHttpIPC.

@Test
public void testHttpIPC() throws IOException, InterruptedException {
    if (!shouldRun())
        return;
    File socketFile = Files.createTempFile("http-over-ipc-test-", ".sock").toFile();
    socketFile.delete();
    EventLoopGroup loopGroup = eventLoop();
    ResteasyDeployment deployment = new ResteasyDeploymentImpl();
    NettyJaxrsIPCServer server = new NettyJaxrsIPCServer(loopGroup, socketFile);
    server.setDeployment(deployment);
    server.setRootResourcePath("");
    server.setIdleTimeout(IDLE_TIMEOUT);
    server.setSecurityDomain(null);
    server.start();
    deployment.getRegistry().addSingletonResource(new Resource());
    IPCController client = null;
    CountDownLatch latch = new CountDownLatch(1);
    try {
        client = IPCController.newClient().withEventLoop(eventLoop()).withSocketFile(socketFile).withChannelHandler(new ChannelInitializer<Channel>() {

            @Override
            protected void initChannel(Channel ch) throws Exception {
                ch.pipeline().addLast(new HttpClientCodec());
                ch.pipeline().addLast(new HttpObjectAggregator(4096));
                ch.pipeline().addLast(new SimpleChannelInboundHandler<FullHttpResponse>() {

                    @Override
                    protected void channelRead0(ChannelHandlerContext ctx, FullHttpResponse msg) {
                        System.out.println("HTTP response from resteasy: " + msg.content().getCharSequence(0, msg.content().readableBytes(), Charset.defaultCharset()));
                        Assert.assertEquals(HttpResponseStatus.OK, msg.status());
                        latch.countDown();
                    }
                });
            }
        }).build();
        client.start();
        // first request;
        URL url = new URL("http://localhost/test");
        // Prepare the HTTP request.
        HttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, url.getFile());
        request.headers().set(HttpHeaderNames.HOST, url.getHost());
        Channel channel = client.channel().orElseThrow(() -> new RuntimeException("NoClient"));
        // Send the HTTP request.
        channel.writeAndFlush(request);
        latch.await(10, TimeUnit.SECONDS);
        channel.close().await();
    } finally {
        server.stop();
        if (client != null)
            client.stop();
    }
}
Also used : SimpleChannelInboundHandler(io.netty.channel.SimpleChannelInboundHandler) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) HttpRequest(io.netty.handler.codec.http.HttpRequest) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) Channel(io.netty.channel.Channel) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) CountDownLatch(java.util.concurrent.CountDownLatch) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) TestPortProvider.generateURL(org.jboss.resteasy.test.TestPortProvider.generateURL) URL(java.net.URL) ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) HttpObjectAggregator(io.netty.handler.codec.http.HttpObjectAggregator) EpollEventLoopGroup(io.netty.channel.epoll.EpollEventLoopGroup) KQueueEventLoopGroup(io.netty.channel.kqueue.KQueueEventLoopGroup) EventLoopGroup(io.netty.channel.EventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) IPCController(com.datastax.mgmtapi.ipc.IPCController) ResteasyDeploymentImpl(org.jboss.resteasy.core.ResteasyDeploymentImpl) FullHttpResponse(io.netty.handler.codec.http.FullHttpResponse) File(java.io.File) Test(org.junit.Test)

Aggregations

ResteasyDeploymentImpl (org.jboss.resteasy.core.ResteasyDeploymentImpl)29 ResteasyDeployment (org.jboss.resteasy.spi.ResteasyDeployment)29 Test (org.junit.Test)9 NettyJaxrsServer (org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer)8 ReactorNettyJaxrsServer (org.jboss.resteasy.plugins.server.reactor.netty.ReactorNettyJaxrsServer)4 BeforeClass (org.junit.BeforeClass)4 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)3 Client (jakarta.ws.rs.client.Client)3 Response (jakarta.ws.rs.core.Response)3 EventLoopGroup (io.netty.channel.EventLoopGroup)2 EpollEventLoopGroup (io.netty.channel.epoll.EpollEventLoopGroup)2 KQueueEventLoopGroup (io.netty.channel.kqueue.KQueueEventLoopGroup)2 SslContext (io.netty.handler.ssl.SslContext)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Random (java.util.Random)2 CdiInjectorFactory (org.jboss.resteasy.cdi.CdiInjectorFactory)2 ResteasyCdiExtension (org.jboss.resteasy.cdi.ResteasyCdiExtension)2 Before (org.junit.Before)2 IPCController (com.datastax.mgmtapi.ipc.IPCController)1