-
1. Re: identity.getUserName() deprecated
shane.bryzak Dec 30, 2009 8:43 PM (in response to asookazian)Use Credentials.getUsername().
http://docs.jboss.org/seam/2.2.0.GA/reference/en-US/html/security.html#d0e8733
-
2. Re: identity.getUserName() deprecated
asookazian Feb 24, 2010 12:59 AM (in response to asookazian)There is no instance() method in the API for Credentials. Must we use @In?
For example, how would I refactor the following w/o using @In?
String username = Identity.instance() != null ? Identity.instance().getUsername() : null;
-
3. Re: identity.getUserName() deprecated
shane.bryzak Feb 24, 2010 2:09 AM (in response to asookazian)Using @In is the recommended way, however if you don't want to inject it I guess you can get a reference with Component.getInstance(). FYI, there will be no <component>.instance() convenience methods in Seam 3.
-
4. Re: identity.getUserName() deprecated
shane.bryzak Feb 24, 2010 2:11 AM (in response to asookazian)Actually, you can use Identity.instance().getCredentials() also.
-
5. Re: identity.getUserName() deprecated
asookazian Feb 24, 2010 5:00 PM (in response to asookazian)
Shane Bryzak wrote on Feb 24, 2010 02:09:
Using @In is the recommended way, however if you don't want to inject it I guess you can get a reference with Component.getInstance(). FYI, there will be no <component>.instance() convenience methods in Seam 3.Thanks for your replies. I will use the last posted code snippet. This is a plain SFSB, not a Seam component. We are trying to keep some of our components as generic as possible (using @EJB as well to inject other EJBs) in case we need to migrate to Spring stack or other frmwks in the future. So that means I can't use @In right now unless I add the @Name("foo") to the SFSB or configure in the components.xml, the latter being a better solution in this scenario.
Also, trying to keep dynamic injection (and outjection, disinjection) to a minimum for performance reasons. @EJB is injected just once, the same as it is with @Inject.