[javaee-spec users] Managed bean alignment...

From: <>
Date: Wed, 12 Sep 2012 08:16:28 +0000 (GMT)

I noticed there is a topic in the expert mail list,

As an end developer, I only want to express my idea here.

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)?

interface @Named{

interface @Stateful{

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

For example, it should allow us inject EmtityManager in faces

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

In fact, as an end 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.

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

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

class MyServlet extends HttpServlet{ //_at_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

Additionally, the @Entity, I can use @PostLoad, etc. I think it is can
also be managed when JPA process the jpa lifecyle, sush as persist,
merge etc.

class MyEntity{

@Inject Entitymanager em;

@Inject @Loggedin User currentUser;

public void prepersist(){
setCreatedOn(new Date());