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