[cdi-dev] [JBoss JIRA] (CDI-16) Improve EE 6 Managed Bean integration

hantsy bai (JIRA) jira-events at lists.jboss.org
Sun Sep 2 21:30:32 EDT 2012


    [ https://issues.jboss.org/browse/CDI-16?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12715312#comment-12715312 ] 

hantsy bai edited comment on CDI-16 at 9/2/12 9:30 PM:
-------------------------------------------------------

Currently I dislike CDI treat all classes(which has a constructor with no arguments) as CDI managed bean, I know Jboss Solder provides a @Veto to resolve this issue.

I think the matrix 2 is clear. I like the two classes solution.

1. the first level, the bean is injectable, has own scope. such EJB, basic Pojo(annotated with @ManagedBean), @Named etc. 

And other bean such as EJB can improve the lifecyle support transaction, security etc.

Compare to spring  framework, it provides @Component, and @Controller, @Service etc. but the later are refined from the @Component.
Why the @Named, @EJB can not be refined to use @ManagedBean(JEE)?

...
@ManagedBean
.....
interface @Named{
}

...
@ManagedBean
.....
interface @Stateful{
}

2. such as entity listener, faces converter, faces validator, bean validator, servlet & servlet listener, filter, etc, can inject other beans. 

For example, it should allow us inject EmtityManager in faces conventer.

But it can NOT be injected in other bean, and can NOT be defined in its own scope.

In fact, as a developer I only want to simplify programming, but do not want to change their lifecyle.

But besides the CDI interceptors, decorators, I think it should be optional, developer can select if use CDI to manage it. 

For the 2, is there a better solution to make it managed? Spring provides another @Configurable. In JEE 7, the jee7 expert group can consider a similar solution, for example, provides a @Managed annotation to improve the lifecyle.



@WebServlet
@Managed
class MyServlet extends HttpServlet{
    //you can use @Inject now, 

}


if it is not annotated with @Managed...it is no relation to CDI, only a generic servlet.

@WebServlet
class MyServlet extends HttpServlet{
    //@Inject is NOT supported, 

}

This maybe force the different spec providers leave some space for the CDI hooks in their lifecycle.



In summary, I hope all JEE specs looks smooth and seamless to developers.

Regards
Hantsy
















                
      was (Author: hantsy):
    
Currently I dislike CDI treat all classes(which has a constructor with no arguments) as CDI managed bean, I know Jboss Solder provides a @Veto to resolve this issue.

I think the matrix 2 is clear. I like the two classes solution.

1. the first level, the bean is injectable, has own scope. such EJB, basic Pojo(annotated with @ManagedBean), @Named etc. 

And other bean such as EJB can improve the lifecyle support transaction, security etc.

Compare to spring  framework, it provides @Component, and @Controller, @Service etc. but the later are refined from the @Component.
Why the @Named, @EJB can not be refined to use @ManagedBean(JEE)?

...
@ManagedBean
.....
interface @Named{
}

...
@ManagedBean
.....
interface @Stateful{
}

2. such as entity listener, faces converter, faces validator, bean validator, servlet & servlet listener, filter, etc, can inject other beans. 

For example, it should allow us inject EmtityManager in faces conventer.

But it can NOT be injected in other bean, and can NOT be defined in its own scope.

In fact, as a developer I only want to simplify programming, but do not want to change their lifecyle.

But besides the CDI interceptors, decorators, I think it should be optional, developer can select if use CDI to manage it. 

For the 2, is there a better solution to make it managed? Spring provides another @Configurable. In JEE 7, the jee7 expert group can consider a similar solution, for example, provides a @Managed annotation to improve the lifecyle.



@WebServlet
@Managed
class MyServlet extends HttpServlet{

    //you can use @Inject now, 

}


if it is not annotated with @Managed...it is no relation to CDI, only a generic servlet.

@WebServlet
class MyServlet extends HttpServlet{

    //@Inject is NOT supported, 

}

This maybe force the different spec providers leave some space for the CDI hooks in their lifecycle.



In summary, I hope all JEE specs looks smooth and seamless to developers.

Regards
Hantsy
















                  
> Improve EE 6 Managed Bean integration
> -------------------------------------
>
>                 Key: CDI-16
>                 URL: https://issues.jboss.org/browse/CDI-16
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Java EE integration
>    Affects Versions: 1.0
>            Reporter: Pete Muir
>             Fix For: TBD
>
>
> Try to work out if we can improve on this.
> At least, we should clarify what happens if a CDI managed bean is annotated with @ManagedBean

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the cdi-dev mailing list