This is from a recent DAllen post:
public
@Stateless
class AccountProducerBean implements AccountProducer
{
@PersistenceContext EntityManager em;
@Current Identity identity;
public
@Produces
@Registered
@SessionScoped
User getCurrentUser()
{
User user = em.find(User.class, identity.getUsername());
return user != null ? user : new User();
}
}Note that public access modifier keyword comes before the annotations. Is this required syntax by Web Beans RI or is it merely preference by DAllen?
I guess I should just experiment by modifying the example apps that ship with the RI distro...
Perference. Web Beans can't even enforce stuff like that, it's Java. A bit like preferring static final String
instead of final static String
.