// Resource registration
Registry registry = getDispatcher().getRegistry();
for (final Class resourceClass : applicationConfig.getResourceClasses())
{
final Component seamComponent = applicationConfig.getResourceClassComponent(resourceClass);
if (seamComponent != null)
{
// Seam component lookup when call is dispatched to resource
registry.addResourceFactory(
new ResourceFactory()
{
private PropertyInjector propertyInjector;
public Class<?> getScannableClass()
{
return resourceClass;
}
public void registered(InjectorFactory factory)
{
this.propertyInjector = factory.createPropertyInjector(getScannableClass());
}
public Object createResource(HttpRequest request, HttpResponse response, InjectorFactory factory)
{
Object target = Component.getInstance(seamComponent.getName());
propertyInjector.inject(request, response, target);
return target;
}
public void requestFinished(HttpRequest request, HttpResponse response, Object resource)
{
}
public void unregistered()
{
}
}
);
}
else
{
// JAX-RS default lifecycle
registry.addResourceFactory(new POJOResourceFactory(resourceClass));
}
}
// Provider registration
if (applicationConfig.isUseBuiltinProviders())
{
log.info("registering built-in RESTEasy providers");
RegisterBuiltin.register(providerFactory);
}
for (Class providerClass : applicationConfig.getProviderClasses())
{
Component seamComponent = applicationConfig.getProviderClassComponent(providerClass);
if (seamComponent != null)
{
if (ScopeType.STATELESS.equals(seamComponent.getScope()))
{
throw new RuntimeException(
"Registration of STATELESS Seam components as RESTEasy providers not implemented!"
);
}
else if (ScopeType.APPLICATION.equals(seamComponent.getScope()))
{
Object providerInstance = Component.getInstance(seamComponent.getName());
providerFactory.registerProviderInstance(providerInstance);
}
}
else
{