Java Code Examples for org.jboss.resteasy.spi.ResteasyDeployment#setApplication()
The following examples show how to use
org.jboss.resteasy.spi.ResteasyDeployment#setApplication() .
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: RestEasyUndertowServletRule.java From jax-rs-pac4j with Apache License 2.0 | 6 votes |
@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 2
Source File: Main.java From Jax-RS-Performance-Comparison with Apache License 2.0 | 6 votes |
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 3
Source File: Main.java From Jax-RS-Performance-Comparison with Apache License 2.0 | 6 votes |
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 4
Source File: JfDemoESPlugin.java From jframe with Apache License 2.0 | 5 votes |
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 5
Source File: ResteasyServletContextAttributeProvider.java From hammock with Apache License 2.0 | 5 votes |
@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 6
Source File: UndertowAppServer.java From keycloak with Apache License 2.0 | 5 votes |
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 7
Source File: JettyAppServer.java From keycloak with Apache License 2.0 | 5 votes |
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 8
Source File: ITSpanCustomizingContainerFilter.java From brave with Apache License 2.0 | 5 votes |
TaggingBootstrap(Object resource) { deployment = new ResteasyDeployment(); deployment.setApplication(new Application() { @Override public Set<Object> getSingletons() { return new LinkedHashSet<>(Arrays.asList( resource, SpanCustomizingContainerFilter.create() )); } }); }