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);
}
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();
}
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;
}
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();
}
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();
}
}
Aggregations