Search in sources :

Example 1 with UndertowJaxrsServer

use of org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer in project keycloak by keycloak.

the class UndertowAppServer method start.

@Override
public void start() throws LifecycleException {
    long start = System.currentTimeMillis();
    undertow = new UndertowJaxrsServer();
    undertow.start(Undertow.builder().addHttpListener(configuration.getBindHttpPort(), configuration.getBindAddress()));
    log.infof("App server started in %dms on http://%s:%d/", (System.currentTimeMillis() - start), configuration.getBindAddress(), configuration.getBindHttpPort());
}
Also used : UndertowJaxrsServer(org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer)

Example 2 with UndertowJaxrsServer

use of org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer in project narayana by jbosstm.

the class BaseTest method startUndertow.

protected static void startUndertow(Class<?>... classes) throws Exception {
    undertow = new UndertowJaxrsServer();
    undertow.start(Undertow.builder().addHttpListener(PORT, "localhost"));
    // , SURL + "tx/");
    undertow.deploy(new TMApplication(classes));
    System.out.printf("server is ready:");
}
Also used : TMApplication(org.jboss.jbossts.star.service.TMApplication) UndertowJaxrsServer(org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer)

Example 3 with UndertowJaxrsServer

use of org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer in project keycloak by keycloak.

the class KeycloakServer method start.

public void start() throws Throwable {
    long start = System.currentTimeMillis();
    ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.setApplicationClass(KeycloakApplication.class.getName());
    Builder builder = Undertow.builder().addHttpListener(config.getPort(), config.getHost()).setWorkerThreads(config.getWorkerThreads()).setIoThreads(config.getWorkerThreads() / 8);
    if (config.getPortHttps() != -1) {
        builder = builder.addHttpsListener(config.getPortHttps(), config.getHost(), createSSLContext()).setSocketOption(Options.SSL_CLIENT_AUTH_MODE, SslClientAuthMode.REQUESTED);
    }
    server = new UndertowJaxrsServer();
    try {
        server.start(builder);
        DeploymentInfo di = server.undertowDeployment(deployment, "");
        di.setClassLoader(getClass().getClassLoader());
        di.setContextPath("/auth");
        di.setDeploymentName("Keycloak");
        di.setDefaultEncoding("UTF-8");
        di.setDefaultServletConfig(new DefaultServletConfig(true));
        // Note that the ResteasyServlet is configured via server.undertowDeployment(...);
        // KEYCLOAK-14178
        deployment.setProperty(ResteasyContextParameters.RESTEASY_DISABLE_HTML_SANITIZER, true);
        InstanceHandle<Filter> filterInstance = new InstanceHandle<Filter>() {

            @Override
            public Filter getInstance() {
                return new UndertowRequestFilter(sessionFactory);
            }

            @Override
            public void release() {
            }
        };
        FilterInfo filter = Servlets.filter("SessionFilter", UndertowRequestFilter.class, () -> filterInstance);
        filter.setAsyncSupported(true);
        di.addFilter(filter);
        di.addFilterUrlMapping("SessionFilter", "/*", DispatcherType.REQUEST);
        server.deploy(di);
        sessionFactory = KeycloakApplication.getSessionFactory();
        setupDevConfig();
        if (config.getResourcesHome() != null) {
            info("Loading resources from " + config.getResourcesHome());
        }
        info("Started Keycloak (http://" + config.getHost() + ":" + config.getPort() + "/auth" + (config.getPortHttps() > 0 ? ", https://" + config.getHost() + ":" + config.getPortHttps() + "/auth" : "") + ") in " + (System.currentTimeMillis() - start) + " ms\n");
    } catch (RuntimeException e) {
        server.stop();
        throw e;
    }
}
Also used : KeycloakApplication(org.keycloak.services.resources.KeycloakApplication) Builder(io.undertow.Undertow.Builder) ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) Filter(javax.servlet.Filter) DefaultServletConfig(io.undertow.servlet.api.DefaultServletConfig) InstanceHandle(io.undertow.servlet.api.InstanceHandle) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) FilterInfo(io.undertow.servlet.api.FilterInfo) UndertowJaxrsServer(org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer)

Aggregations

UndertowJaxrsServer (org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer)3 Builder (io.undertow.Undertow.Builder)1 DefaultServletConfig (io.undertow.servlet.api.DefaultServletConfig)1 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)1 FilterInfo (io.undertow.servlet.api.FilterInfo)1 InstanceHandle (io.undertow.servlet.api.InstanceHandle)1 Filter (javax.servlet.Filter)1 TMApplication (org.jboss.jbossts.star.service.TMApplication)1 ResteasyDeployment (org.jboss.resteasy.spi.ResteasyDeployment)1 KeycloakApplication (org.keycloak.services.resources.KeycloakApplication)1