-
1. Re: Inject a POJO
mail.micke Aug 28, 2008 11:00 AM (in response to timerons)Hi
Is the pojo annotated with Seam annotations?
If it is there a seam.properties file in there so that it is scanned by Seam at startup?If the pojo is discovered as a Seam component you should be able to see this in the log when the server starts up.
If not you could define the pojo as a bean in components.xml or in Spring or perhaps via faces-config.xml.
- micke
-
2. Re: Inject a POJO
accless Aug 28, 2008 4:03 PM (in response to timerons)Seam can only inject/outject ejbs and pojos which are manageable and regocnized at startup of the web app.
There are two (or even more ways) to inform seam about these manageable objects:- annotations
- components.xml
u have to use components.xml, if u cannot or do not want to recompile (using name-annotations) the target-class itself
example
<component name="someName" class="FULL_QUALIFIED_NAME_OF_THE_CLASS_U_WANT_TO_MAKE_MANAGABLE" auto-create="true" scope="EVENT" > </component>
-
3. Re: Inject a POJO
timerons Aug 28, 2008 6:37 PM (in response to timerons)thanks a lot that was what i looking for. i will test it and give you feedback. :-)
-
4. Re: Inject a POJO
timerons Sep 3, 2008 8:31 AM (in response to timerons)hello
thanks this works well in a normal bean. thanks a lot for you help.
now i like to use this bean the authenticator
every thing work well except of the injection of the
ldapServiceAuthenticate
i did the following entry's in the components.xml:
<security:identity authenticate-method="#{authenticator.authenticate}"/> <component name="ldapServiceAuthenticate" class="com.xxx.ldap.LdapServiceAuthenticate" auto-create="true" scope="application">
in my beans i use the following:
@In(create=true) private LdapServiceAuthenticate ldapServiceAuthenticate;
- in a normal bean i get the
ldapServiceAuthenticate
injected :-)- in my
authenticator
i let inject theLDAPService
(work well), that get theldapServiceAuthenticate
injectet that is always null.other things work well when we like that to be injected:
@Stateless @Name("authenticator") public class Authenticator implements IAuthenticator { @In Identity identity; @Out(required = false, scope = SESSION) private User user; @EJB private IConfigurationDAO configDAO; @EJB private IUserDAO userDAO; @EJB private ILDAPService ldapService; @In private FacesMessages facesMessages;
@Stateless public class LDAPService implements ILDAPService { @In(create=true) private LdapServiceAuthenticate ldapServiceAuthenticate;
that works well:
@Stateful @Scope(ScopeType.CONVERSATION) @Name("productCreationCtrl") public class ProductCreationController implements IProductCreationController { @In private FacesMessages facesMessages; @In(create=true) private LdapServiceAuthenticate ldapServiceAuthenticate;
may someone has a clue why i can't inject something in the Authenticator or better in the LDAPService
best regards