org.jboss.resteasy.spi.ResteasyDeployment Java Examples

The following examples show how to use org.jboss.resteasy.spi.ResteasyDeployment. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DubboHttpServer.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Override
protected void doStart(URL url) {
    // TODO jetty will by default enable keepAlive so the xml config has no effect now jetty将默认启用keepAlive,所以xml配置现在没有效果
    httpServer = httpBinder.bind(url, new RestHandler());

    ServletContext servletContext = ServletManager.getInstance().getServletContext(url.getPort());
    if (servletContext == null) {
        servletContext = ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT);
    }
    if (servletContext == null) {
        throw new RpcException("No servlet context found. If you are using server='servlet', " +
                "make sure that you've configured " + BootstrapListener.class.getName() + " in web.xml");
    }

    servletContext.setAttribute(ResteasyDeployment.class.getName(), deployment);

    try {
        dispatcher.init(new SimpleServletConfig(servletContext));
    } catch (ServletException e) {
        throw new RpcException(e);
    }
}
 
Example #2
Source File: DubboHttpServer.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
protected void doStart(URL url) {
    // TODO jetty will by default enable keepAlive so the xml config has no effect now
    httpServer = httpBinder.bind(url, new RestHandler());

    ServletContext servletContext = ServletManager.getInstance().getServletContext(url.getPort());
    if (servletContext == null) {
        servletContext = ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT);
    }
    if (servletContext == null) {
        throw new RpcException("No servlet context found. If you are using server='servlet', " +
                "make sure that you've configured " + BootstrapListener.class.getName() + " in web.xml");
    }

    servletContext.setAttribute(ResteasyDeployment.class.getName(), deployment);

    try {
        dispatcher.init(new SimpleServletConfig(servletContext));
    } catch (ServletException e) {
        throw new RpcException(e);
    }
}
 
Example #3
Source File: DubboHttpServer.java    From dubbox with Apache License 2.0 6 votes vote down vote up
protected void doStart(URL url) {
    // TODO jetty will by default enable keepAlive so the xml config has no effect now
    httpServer = httpBinder.bind(url, new RestHandler());

    ServletContext servletContext = ServletManager.getInstance().getServletContext(url.getPort());
    if (servletContext == null) {
        servletContext = ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT);
    }
    if (servletContext == null) {
        throw new RpcException("No servlet context found. If you are using server='servlet', " +
                "make sure that you've configured " + BootstrapListener.class.getName() + " in web.xml");
    }

    servletContext.setAttribute(ResteasyDeployment.class.getName(), deployment);

    try {
        dispatcher.init(new SimpleServletConfig(servletContext));
    } catch (ServletException e) {
        throw new RpcException(e);
    }
}
 
Example #4
Source File: DubboHttpServer.java    From dubbox with Apache License 2.0 6 votes vote down vote up
protected void doStart(URL url) {
    // TODO jetty will by default enable keepAlive so the xml config has no effect now
    httpServer = httpBinder.bind(url, new RestHandler());

    ServletContext servletContext = ServletManager.getInstance().getServletContext(url.getPort());
    if (servletContext == null) {
        servletContext = ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT);
    }
    if (servletContext == null) {
        throw new RpcException("No servlet context found. If you are using server='servlet', " +
                "make sure that you've configured " + BootstrapListener.class.getName() + " in web.xml");
    }

    servletContext.setAttribute(ResteasyDeployment.class.getName(), deployment);

    try {
        dispatcher.init(new SimpleServletConfig(servletContext));
    } catch (ServletException e) {
        throw new RpcException(e);
    }
}
 
Example #5
Source File: RestEasyUndertowServletRule.java    From jax-rs-pac4j with Apache License 2.0 6 votes vote down vote up
@Override
protected void before() throws Throwable {
    // Used by Jersey Client to store cookies
    CookieHandler.setDefault(new CookieManager());

    // we don't need a resteasy client, and the jersey one works better with redirect
    client = new JerseyClientBuilder().build();

    // TODO use an autogenerated port...
    System.setProperty("org.jboss.resteasy.port", "24257");
    server = new UndertowJaxrsServer().start();

    ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.setInjectorFactoryClass(CdiInjectorFactory.class.getName());
    deployment.setApplication(new MyApp());
    DeploymentInfo di = server.undertowDeployment(deployment)
            .setContextPath("/")
            .setDeploymentName("DI")
            .setClassLoader(getClass().getClassLoader())
            .addListeners(Servlets.listener(Listener.class));
    server.deploy(di);
}
 
Example #6
Source File: Demo.java    From resteasy-examples with Apache License 2.0 6 votes vote down vote up
public static UndertowJaxrsServer buildServer() {
    UndertowJaxrsServer server;
    System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
    try {
        LogManager.getLogManager().readConfiguration(Main.class.getClassLoader().getResourceAsStream("logging.jboss.properties"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    server = new UndertowJaxrsServer().start();

    ResteasyDeployment deployment = new ResteasyDeploymentImpl();

    deployment.setApplicationClass(TracingApp.class.getName());

    DeploymentInfo di = server.undertowDeployment(deployment);
    di.setClassLoader(TracingApp.class.getClassLoader());
    di.setContextPath("");
    di.setDeploymentName("Resteasy");
    di.getServlets().get("ResteasyServlet").addInitParam(ResteasyContextParameters.RESTEASY_TRACING_TYPE, ResteasyContextParameters.RESTEASY_TRACING_TYPE_ALL)
            .addInitParam(ResteasyContextParameters.RESTEASY_TRACING_THRESHOLD, ResteasyContextParameters.RESTEASY_TRACING_LEVEL_VERBOSE);
    server.deploy(di);
    return server;
}
 
Example #7
Source File: ComponentContainerImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
private void doInit(final ServletConfig servletConfig) throws ServletException {
  deployment.start();

  servletConfig.getServletContext().setAttribute(ResteasyDeployment.class.getName(), deployment);
  servletConfig.getServletContext().setAttribute(
      SiestaResourceMethodFinder.class.getName(), new SiestaResourceMethodFinder(this, deployment));

  super.init(servletConfig);

  if (log.isDebugEnabled()) {
    ResteasyProviderFactory providerFactory = getDispatcher().getProviderFactory();
    log.debug("Provider factory: {}", providerFactory);
    log.debug("Configuration: {}", providerFactory.getConfiguration());
    log.debug("Runtime type: {}", providerFactory.getRuntimeType());
    log.debug("Built-ins registered: {}", providerFactory.isBuiltinsRegistered());
    log.debug("Properties: {}", providerFactory.getProperties());
    log.debug("Dynamic features: {}", providerFactory.getServerDynamicFeatures());
    log.debug("Enabled features: {}", providerFactory.getEnabledFeatures());
    log.debug("Class contracts: {}", providerFactory.getClassContracts());
    log.debug("Reader interceptor registry: {}", providerFactory.getServerReaderInterceptorRegistry());
    log.debug("Writer interceptor registry: {}", providerFactory.getServerWriterInterceptorRegistry());
    log.debug("Injector factory: {}", providerFactory.getInjectorFactory());
    log.debug("Instances: {}", providerFactory.getInstances());
    log.debug("Exception mappers: {}", providerFactory.getExceptionMappers());
  }
}
 
Example #8
Source File: RestServer.java    From sofa-rpc with Apache License 2.0 6 votes vote down vote up
protected SofaNettyJaxrsServer buildServer() {
    // 生成Server对象
    SofaNettyJaxrsServer httpServer = new SofaNettyJaxrsServer(serverConfig);

    int bossThreads = serverConfig.getIoThreads();
    if (bossThreads > 0) {
        httpServer.setIoWorkerCount(bossThreads); // 其实是boss+worker线程 默认cpu*2
    }
    httpServer.setExecutorThreadCount(serverConfig.getMaxThreads()); // 业务线程
    httpServer.setMaxRequestSize(serverConfig.getPayload());
    httpServer.setHostname(serverConfig.getBoundHost());
    httpServer.setPort(serverConfig.getPort());

    ResteasyDeployment resteasyDeployment = httpServer.getDeployment();
    resteasyDeployment.start();

    ResteasyProviderFactory providerFactory = resteasyDeployment.getProviderFactory();
    registerProvider(providerFactory);

    return httpServer;
}
 
Example #9
Source File: Main.java    From Jax-RS-Performance-Comparison with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    String host = "0.0.0.0";
    int port = 8080;
    if (args.length > 0) {
        host = args[0];
    }
    if (args.length > 1) {
        port = Integer.parseInt(args[1]);
    }


    NettyJaxrsServer netty = new NettyJaxrsServer();
    ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.setApplication(new MyApplication());
    netty.setDeployment(deployment);
    netty.setHostname(host);
    netty.setPort(port);
    netty.setRootResourcePath("/");
    netty.setSecurityDomain(null);
    netty.start();
}
 
Example #10
Source File: Main.java    From Jax-RS-Performance-Comparison with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    String host = "0.0.0.0";
    int port = 8080;
    if (args.length > 0) {
        host = args[0];
    }
    if (args.length > 1) {
        port = Integer.parseInt(args[1]);
    }


    NettyJaxrsServer netty = new NettyJaxrsServer();
    ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.setApplication(new MyApplication());
    netty.setDeployment(deployment);
    netty.setHostname(host);
    netty.setPort(port);
    netty.setRootResourcePath("/");
    netty.setSecurityDomain(null);
    netty.start();
}
 
Example #11
Source File: DubboHttpServer.java    From dubbox with Apache License 2.0 6 votes vote down vote up
protected void doStart(URL url) {
    // TODO jetty will by default enable keepAlive so the xml config has no effect now
    httpServer = httpBinder.bind(url, new RestHandler());

    ServletContext servletContext = ServletManager.getInstance().getServletContext(url.getPort());
    if (servletContext == null) {
        servletContext = ServletManager.getInstance().getServletContext(ServletManager.EXTERNAL_SERVER_PORT);
    }
    if (servletContext == null) {
        throw new RpcException("No servlet context found. If you are using server='servlet', " +
                "make sure that you've configured " + BootstrapListener.class.getName() + " in web.xml");
    }

    servletContext.setAttribute(ResteasyDeployment.class.getName(), deployment);

    try {
        dispatcher.init(new SimpleServletConfig(servletContext));
    } catch (ServletException e) {
        throw new RpcException(e);
    }
}
 
Example #12
Source File: VertxRequestHandler.java    From quarkus with Apache License 2.0 6 votes vote down vote up
public VertxRequestHandler(Vertx vertx,
        BeanContainer beanContainer,
        ResteasyDeployment deployment,
        String rootPath,
        BufferAllocator allocator, Executor executor, long readTimeout) {
    this.vertx = vertx;
    this.beanContainer = beanContainer;
    this.dispatcher = new RequestDispatcher((SynchronousDispatcher) deployment.getDispatcher(),
            deployment.getProviderFactory(), null, Thread.currentThread().getContextClassLoader());
    this.rootPath = rootPath;
    this.allocator = allocator;
    this.executor = executor;
    this.readTimeout = readTimeout;
    Instance<CurrentIdentityAssociation> association = CDI.current().select(CurrentIdentityAssociation.class);
    this.association = association.isResolvable() ? association.get() : null;
    currentVertxRequest = CDI.current().select(CurrentVertxRequest.class).get();
}
 
Example #13
Source File: ResteasyServletContextAttributeProvider.java    From hammock with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, Object> getAttributes() {
    ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.getActualResourceClasses().addAll(resteasyCdiExtension.getResources());
    deployment.getActualProviderClasses().addAll(resteasyCdiExtension.getProviders());
    if( !(applicationInstance.isUnsatisfied() || applicationInstance.isAmbiguous())) {
        deployment.setApplication(applicationInstance.get());
    }
    deployment.setInjectorFactoryClass(Cdi11InjectorFactory.class.getName());
    return singletonMap(ResteasyDeployment.class.getName(), deployment);
}
 
Example #14
Source File: VertxPluginRequestHandler.java    From redpipe with Apache License 2.0 5 votes vote down vote up
public VertxPluginRequestHandler(Vertx vertx, ResteasyDeployment deployment, String servletMappingPrefix, SecurityDomain domain, List<Plugin> plugins)
{
   this.vertx = vertx;
   this.dispatcher = new PluginRequestDispatcher((SynchronousDispatcher) deployment.getDispatcher(), deployment.getProviderFactory(), domain, plugins);
   this.servletMappingPrefix = servletMappingPrefix;
   appGlobals = AppGlobals.get();
}
 
Example #15
Source File: ResteasyStandaloneRecorder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public void staticInit(ResteasyDeployment dep, String path, Set<String> known) {
    if (dep != null) {
        deployment = dep;
        deployment.start();
    }
    knownPaths = known;
    contextPath = path;
}
 
Example #16
Source File: SpringWebProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
public void process(BeanArchiveIndexBuildItem beanArchiveIndexBuildItem,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        BuildProducer<ServletInitParamBuildItem> initParamProducer,
        BuildProducer<ResteasyDeploymentCustomizerBuildItem> deploymentCustomizerProducer) {

    validateControllers(beanArchiveIndexBuildItem);

    final IndexView index = beanArchiveIndexBuildItem.getIndex();
    final Collection<AnnotationInstance> annotations = index.getAnnotations(REST_CONTROLLER_ANNOTATION);
    if (annotations.isEmpty()) {
        return;
    }

    final Set<String> classNames = new HashSet<>();
    for (AnnotationInstance annotation : annotations) {
        classNames.add(annotation.target().asClass().toString());
    }

    // initialize the init params that will be used in case of servlet
    initParamProducer.produce(
            new ServletInitParamBuildItem(
                    ResteasyContextParameters.RESTEASY_SCANNED_RESOURCE_CLASSES_WITH_BUILDER,
                    SpringResourceBuilder.class.getName() + ":" + String.join(",", classNames)));
    // customize the deployment that will be used in case of RESTEasy standalone
    deploymentCustomizerProducer.produce(new ResteasyDeploymentCustomizerBuildItem(new Consumer<ResteasyDeployment>() {
        @Override
        public void accept(ResteasyDeployment resteasyDeployment) {
            resteasyDeployment.getScannedResourceClassesWithBuilder().put(SpringResourceBuilder.class.getName(),
                    new ArrayList<>(classNames));
        }
    }));

    reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, false, SpringResourceBuilder.class.getName()));
}
 
Example #17
Source File: ResteasyServerCommonProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private static void registerProviders(ResteasyDeployment deployment,
        Map<String, String> resteasyInitParameters,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        BuildProducer<UnremovableBeanBuildItem> unremovableBeans,
        JaxrsProvidersToRegisterBuildItem jaxrsProvidersToRegisterBuildItem) {

    if (jaxrsProvidersToRegisterBuildItem.useBuiltIn()) {
        // if we find a wildcard media type, we just use the built-in providers
        resteasyInitParameters.put(ResteasyContextParameters.RESTEASY_USE_BUILTIN_PROVIDERS, "true");
        deployment.setRegisterBuiltin(true);

        if (!jaxrsProvidersToRegisterBuildItem.getContributedProviders().isEmpty()) {
            deployment.getProviderClasses().addAll(jaxrsProvidersToRegisterBuildItem.getContributedProviders());
            resteasyInitParameters.put(ResteasyContextParameters.RESTEASY_PROVIDERS,
                    String.join(",", jaxrsProvidersToRegisterBuildItem.getContributedProviders()));
        }
    } else {
        deployment.setRegisterBuiltin(false);
        deployment.getProviderClasses().addAll(jaxrsProvidersToRegisterBuildItem.getProviders());
        resteasyInitParameters.put(ResteasyContextParameters.RESTEASY_USE_BUILTIN_PROVIDERS, "false");
        resteasyInitParameters.put(ResteasyContextParameters.RESTEASY_PROVIDERS,
                String.join(",", jaxrsProvidersToRegisterBuildItem.getProviders()));
    }

    // register the providers for reflection
    for (String providerToRegister : jaxrsProvidersToRegisterBuildItem.getProviders()) {
        reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, providerToRegister));
    }

    // special case: our config providers
    reflectiveClass.produce(new ReflectiveClassBuildItem(false, false,
            ServletConfigSource.class,
            ServletContextConfigSource.class,
            FilterConfigSource.class));

    // Providers that are also beans are unremovable
    unremovableBeans.produce(new UnremovableBeanBuildItem(
            b -> jaxrsProvidersToRegisterBuildItem.getProviders().contains(b.getBeanClass().toString())));
}
 
Example #18
Source File: ITSpanCustomizingContainerFilter.java    From brave with Apache License 2.0 5 votes vote down vote up
@Override public void contextInitialized(ServletContextEvent event) {
  ServletContext servletContext = event.getServletContext();
  ListenerBootstrap config = new ListenerBootstrap(servletContext);
  servletContext.setAttribute(ResteasyDeployment.class.getName(), deployment);
  deployment.getDefaultContextObjects().put(ResteasyConfiguration.class, config);
  config.createDeployment();
  deployment.start();
}
 
Example #19
Source File: ITSpanCustomizingContainerFilter.java    From brave with Apache License 2.0 5 votes vote down vote up
TaggingBootstrap(Object resource) {
  deployment = new ResteasyDeployment();
  deployment.setApplication(new Application() {
    @Override public Set<Object> getSingletons() {
      return new LinkedHashSet<>(Arrays.asList(
        resource,
        SpanCustomizingContainerFilter.create()
      ));
    }
  });
}
 
Example #20
Source File: ArchistarS3.java    From archistar-core with GNU General Public License v2.0 5 votes vote down vote up
private static NettyJaxrsServer createServer(ResteasyDeployment deployment) throws Exception {
    NettyJaxrsServer netty = new NettyJaxrsServer();
    netty.setDeployment(deployment);
    netty.setPort(8080);
    netty.setRootResourcePath("");
    netty.setSecurityDomain(null);
    return netty;
}
 
Example #21
Source File: ArchistarS3.java    From archistar-core with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    NettyJaxrsServer netty;

    Logger logger = LoggerFactory.getLogger(ArchistarS3.class);

    logger.info("Starting archistar storage engine");
    Engine engine = createEngine();
    engine.connect();


    /* setup buckets/services? */
    ResteasyDeployment deployment = new ResteasyDeployment();

    HashMap<String, FakeBucket> buckets = new HashMap<>();
    buckets.put("fake_bucket", new FakeBucket(engine));

    List<Object> resources = new LinkedList<>();
    resources.add(new FakeRoot(buckets));
    deployment.setResources(resources);

    List<Object> providers = new LinkedList<>();
    providers.add(new RedirectorFilter());
    deployment.setProviders(providers);

    netty = createServer(deployment);
    netty.start();
}
 
Example #22
Source File: JettyAppServer.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private void addRestEasyServlet(WebArchive archive, WebAppContext webAppContext) {
    log.debug("Starting Resteasy deployment");
    boolean addServlet = true;
    ServletHolder resteasyServlet = new ServletHolder("javax.ws.rs.core.Application", new HttpServlet30Dispatcher());

    String jaxrsApplication = getJaxRsApplication(archive);
    Set<Class<?>> pathAnnotatedClasses = getPathAnnotatedClasses(archive);

    if (jaxrsApplication != null) {
        log.debug("App has an Application.class: " + jaxrsApplication);
        resteasyServlet.setInitParameter("javax.ws.rs.Application", jaxrsApplication);
    } else if (!pathAnnotatedClasses.isEmpty()) {
        log.debug("App has @Path annotated classes: " + pathAnnotatedClasses);
        ResteasyDeployment deployment = new ResteasyDeployment();
        deployment.setApplication(new RestSamlApplicationConfig(pathAnnotatedClasses));
        webAppContext.setAttribute(ResteasyDeployment.class.getName(), deployment);
    } else {
        log.debug("An application doesn't have Application.class, nor @Path annotated classes. Skipping Resteasy initialization.");
        addServlet = false;
    }

    if (addServlet) {
        // this should be /* in general. However Jetty 9.2 (this is bug specific to this version),
        // can not merge two instances of javax.ws.rs.Application together (one from web.xml
        // and the other one added here). In 9.1 and 9.4 this works fine.
        // Once we stop supporting 9.2, this should replaced with /* and this comment should be removed.
        webAppContext.addServlet(resteasyServlet, "/");
    }
    log.debug("Finished Resteasy deployment");
}
 
Example #23
Source File: MyContextLoaderListener.java    From resteasy-examples with Apache License 2.0 5 votes vote down vote up
@Override
protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext configurableWebApplicationContext) {
    super.customizeContext(servletContext, configurableWebApplicationContext);

    ResteasyDeployment deployment = (ResteasyDeployment) servletContext.getAttribute(ResteasyDeployment.class.getName());
    if (deployment == null) {
        throw new RuntimeException(Messages.MESSAGES.deploymentIsNull());
    }

    SpringBeanProcessor processor = new SpringBeanProcessor(deployment);
    configurableWebApplicationContext.addBeanFactoryPostProcessor(processor);
    configurableWebApplicationContext.addApplicationListener(processor);
}
 
Example #24
Source File: UndertowAppServer.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private ResteasyDeployment discoverPathAnnotatedClasses(WebArchive webArchive) {
    //take all classes from war and add those with @Path annotation to RestSamlApplicationConfig
    Set<Class<?>> classes = webArchive.getContent(archivePath ->
            archivePath.get().startsWith("/WEB-INF/classes/") &&
            archivePath.get().endsWith(".class")
    ).values().stream()
            .filter(node -> node.getAsset() instanceof ClassAsset)
            .map(node -> ((ClassAsset)node.getAsset()).getSource())
            .filter(clazz -> clazz.isAnnotationPresent(Path.class))
            .collect(Collectors.toSet());

    ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.setApplication(new RestSamlApplicationConfig(classes));
    return deployment;
}
 
Example #25
Source File: KeycloakOnUndertow.java    From keycloak with Apache License 2.0 5 votes vote down vote up
private DeploymentInfo createAuthServerDeploymentInfo() {
    ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.setApplicationClass(KeycloakApplication.class.getName());

    // RESTEASY-2034
    deployment.setProperty(ResteasyContextParameters.RESTEASY_DISABLE_HTML_SANITIZER, true);

    DeploymentInfo di = undertow.undertowDeployment(deployment);
    di.setClassLoader(getClass().getClassLoader());
    di.setContextPath("/auth");
    di.setDeploymentName("Keycloak");
    if (configuration.getKeycloakConfigPropertyOverridesMap() != null) {
        try {
            di.addInitParameter(JsonConfigProviderFactory.SERVER_CONTEXT_CONFIG_PROPERTY_OVERRIDES,
              JsonSerialization.writeValueAsString(configuration.getKeycloakConfigPropertyOverridesMap()));
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }

    di.setDefaultServletConfig(new DefaultServletConfig(true));
    di.addWelcomePage("theme/keycloak/welcome/resources/index.html");

    FilterInfo filter = Servlets.filter("SessionFilter", TestKeycloakSessionServletFilter.class);
    di.addFilter(filter);
    di.addFilterUrlMapping("SessionFilter", "/*", DispatcherType.REQUEST);
    filter.setAsyncSupported(true);

    return di;
}
 
Example #26
Source File: JfDemoESPlugin.java    From jframe with Apache License 2.0 5 votes vote down vote up
private void startHttpServer() throws PluginException {
    try {
        int port = Integer.parseInt(getConfig(HttpConstants.HTTP_PORT, "8018"));
        String host = getConfig(HttpConstants.HTTP_HOST, "0.0.0.0");
        int bossCount = Integer.parseInt(getConfig(HttpConstants.HTTP_BOSS_COUNT, "-1"));
        bossCount = bossCount < 0 ? Runtime.getRuntime().availableProcessors() * 2 : bossCount;
        int workCount = Integer.parseInt(getConfig(HttpConstants.HTTP_WORK_COUNT, "200"));

        LOG.info("Starting http server, listen on port->{}", port);
        netty = new NettyJaxrsServer();
        netty.setIoWorkerCount(bossCount);
        netty.setExecutorThreadCount(workCount);

        ResteasyDeployment deployment = new ResteasyDeployment();
        deployment.setProviderFactory(new ResteasyProviderFactory());
        // deployment.getProviderFactory().register(ResteasyJacksonProvider.class);
        deployment.setApplication(new ESApplication());
        netty.setDeployment(deployment);
        netty.setHostname(host);
        netty.setPort(port);
        netty.setRootResourcePath(HttpConstants.PATH_ROOT);

        netty.setSecurityDomain(null);
        if (isHttpsEnabled()) {
            // SelfSignedCertificate ssc = new SelfSignedCertificate();
            // netty.setSSLContext(SslContextBuilder.forServer(ssc.certificate(),
            // ssc.privateKey()).build());
        }

        netty.start();
        LOG.info("Start http server successfully!");
    } catch (Exception e) {
        throw new PluginException(e.getCause());
    }
}
 
Example #27
Source File: DubboHttpServer.java    From dubbox with Apache License 2.0 4 votes vote down vote up
protected ResteasyDeployment getDeployment() {
    return deployment;
}
 
Example #28
Source File: NettyServer.java    From dubbox with Apache License 2.0 4 votes vote down vote up
protected ResteasyDeployment getDeployment() {
    return server.getDeployment();
}
 
Example #29
Source File: ResteasyDeploymentBuildItem.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public ResteasyDeploymentBuildItem(String rootPath, ResteasyDeployment deployment) {
    this.deployment = deployment;
    this.rootPath = rootPath;
}
 
Example #30
Source File: SunHttpServer.java    From dubbox with Apache License 2.0 4 votes vote down vote up
protected ResteasyDeployment getDeployment() {
    return server.getDeployment();
}