Search in sources :

Example 1 with CdiInjectorFactory

use of org.jboss.resteasy.cdi.CdiInjectorFactory in project resteasy by resteasy.

the class SeCdiNettyTest method init.

@SuppressWarnings("unchecked")
@Before
public void init() {
    while (port < 8000) this.port = (int) ((new Random().nextDouble() * 8000) + 1000);
    SeContainerInitializer initializer = SeContainerInitializer.newInstance();
    SeContainer container = initializer.disableDiscovery().addBeanClasses(EchoResource.class).addBeanClasses(DefaultExceptionMapper.class).addExtensions(ResteasyCdiExtension.class).initialize();
    ResteasyCdiExtension cdiExtension = container.select(ResteasyCdiExtension.class).get();
    CdiNettyJaxrsServer netty = new CdiNettyJaxrsServer(container);
    ResteasyDeployment rd = new ResteasyDeploymentImpl();
    rd.setActualResourceClasses(cdiExtension.getResources());
    rd.setInjectorFactory(new CdiInjectorFactory(container.getBeanManager()));
    rd.getActualProviderClasses().addAll(cdiExtension.getProviders());
    netty.setDeployment(rd);
    netty.setPort(port);
    netty.setRootResourcePath("/api");
    netty.start();
    this.server = netty;
}
Also used : ResteasyDeployment(org.jboss.resteasy.spi.ResteasyDeployment) Random(java.util.Random) ResteasyDeploymentImpl(org.jboss.resteasy.core.ResteasyDeploymentImpl) SeContainer(jakarta.enterprise.inject.se.SeContainer) CdiInjectorFactory(org.jboss.resteasy.cdi.CdiInjectorFactory) SeContainerInitializer(jakarta.enterprise.inject.se.SeContainerInitializer) ResteasyCdiExtension(org.jboss.resteasy.cdi.ResteasyCdiExtension) Before(org.junit.Before)

Aggregations

SeContainer (jakarta.enterprise.inject.se.SeContainer)1 SeContainerInitializer (jakarta.enterprise.inject.se.SeContainerInitializer)1 Random (java.util.Random)1 CdiInjectorFactory (org.jboss.resteasy.cdi.CdiInjectorFactory)1 ResteasyCdiExtension (org.jboss.resteasy.cdi.ResteasyCdiExtension)1 ResteasyDeploymentImpl (org.jboss.resteasy.core.ResteasyDeploymentImpl)1 ResteasyDeployment (org.jboss.resteasy.spi.ResteasyDeployment)1 Before (org.junit.Before)1