-
1. Re: Bean types in Weld: "client-visible"
chasetec Feb 7, 2010 5:38 PM (in response to karypid)The bean types are the valid Java class and interface types that you can use in your references.
So with @Inject BizInt ref; the BizInt must be a valid bean type.
The types that are valid for a bean are normally the bean class, all parent classes (including Object), and all interface types.
You can restrict the valid types by using the @Typed annotation in the managed bean. Given the following class and the implied interface:
@Typed(AccountDAO.class) public class AccountJPA_DAO implements AccountDAO {}
The client could:
@javax.inject.Inject AccountDAO dao;
The client could not: (exception at runtime)
@javax.inject.Inject AccountJPA_DAO dao;
The thing about the example you quote is that it is an EJB example and the EJB spec says that when a session bean has a biz interface(s) you must use that as the type. So the bean class not being a valid type with an EJB is just because the session bean has a biz interface. But you have no-interface view session beans and you can add @LocalBean to the session bean re-enable the no-interface view if you have biz interfaces. I'm sure that in the case of a no-interface view session bean that the bean class would be a valid type.
-
2. Re: Bean types in Weld: "client-visible"
gavin.king Feb 8, 2010 8:59 AM (in response to karypid)
So, regarding "client-visible": who is the client and when is a type visible by the client?The client is the code that calls the bean. The client-visible types of a bean depend upon what kind of thing the bean is. If it is an EJB, for example, the bean class itself might not be visible to the client (as defined by the EJB spec). If it is a resource, then the implementation class is not visible to the client, only the standard EntityManager, Datasource, etc, interface that it implements.