[ 
https://issues.apache.org/jira/browse/CXF-5576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13947858#comment-13947858
 ] 

Andriy Redko commented on CXF-5576:
-----------------------------------

Hi Sergey,

I think I have something to suggest with respect to giving the developers 
freedom to customize their applications / endpoints. 
Roughly. it is small additional work to portable extension but we are able to 
do something like that:
{noformat}
public class AppConfig {
    @Inject private SomeRestService service;
    
    @Produces 
    public Server server( final Bus bus, final Application application ) {
        final JAXRSServerFactoryBean factory = 
RuntimeDelegate.getInstance().createEndpoint( application, 
JAXRSServerFactoryBean.class );        

        factory.setServiceBeans( Arrays.< Object >asList( service ) );
        factory.setInInterceptors( Arrays.< Interceptor< ? extends Message > 
>asList( new JAXRSBeanValidationInInterceptor() ) );
        factory.setOutInterceptors( Arrays.< Interceptor< ? extends Message > 
>asList( new JAXRSBeanValidationOutInterceptor() ) );
        factory.setProviders( Arrays.asList( new ValidationExceptionMapper(), 
new JacksonJsonProvider() ) );
        factory.setBus(bus);
        
        return factory.create();         
    }
}
{noformat}
Under the hood, the extension will figure out that there are some beans in the 
context (f.e. Server or JAXRSServerFactoryBean) and will not create those but 
forces their instantiation instead. Consequently, we can give full control over 
configuration and customization. For simplest use cases, the auto-discovery 
will work as expected (I am working on making it compliant with 
getSingletons()/getClasses() discovery as well). 

I totally understand that approach is not perfect and is CXF-specific but I 
think it may sound as a reasonable trade-off.

What do you think?
Thanks.

Andriy

> Initital support for CDI integration
> ------------------------------------
>
>                 Key: CXF-5576
>                 URL: https://issues.apache.org/jira/browse/CXF-5576
>             Project: CXF
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 3.0.0
>            Reporter: Andriy Redko
>            Assignee: Andriy Redko
>              Labels: cdi
>         Attachments: weld-one-jar.zip, weld-one-war.zip
>
>
> A per section 10.2.3 Context and Dependency Injection (CDI) of JAX-RS 2.0 
> specification, in a product that supports CDI, the implementations MUST 
> support the use of CDI-style Beans as root resource classes, providers and 
> Application subclasses. Providers and Application subclasses MUST be 
> singletons or use application scope.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to