[seam-issues] [JBoss JIRA] (JBSEAM-2764) Factory method does not create objects properly

Marek Novotny (JIRA) jira-events at lists.jboss.org
Tue Jul 31 07:30:07 EDT 2012


     [ https://issues.jboss.org/browse/JBSEAM-2764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marek Novotny closed JBSEAM-2764.
---------------------------------

    Resolution: Out of Date

    
> Factory method does not create objects properly
> -----------------------------------------------
>
>                 Key: JBSEAM-2764
>                 URL: https://issues.jboss.org/browse/JBSEAM-2764
>             Project: Seam 2
>          Issue Type: Bug
>          Components: EJB3
>    Affects Versions: 2.0.1.GA
>            Reporter: Bogdan Minciu
>
> Hello,
> It seems that my @Factory method is recognizing the created objects only in its command block. I have this class:
> @Stateful
> @Name("xtw")
> @Scope(ScopeType.SESSION)
> @AutoCreate
> public class XTextSessionWrapper implements LocalXTextSessionWrapper {
> ...
>     @In(required=false, create=true)
>     @Out
>     private XLanguage activeLanguage;
>     public String getText(String identifier) {
>         log.info("getText(1): identifier= #0, activeLanguage= #1", identifier, getActiveLanguage());
>         XTextEntry xte = xTextEntryDAO.findXTextEntry(identifier, getActiveLanguage());
>         log.info("getText(2): identifier= #0, activeLanguage= #1", identifier, getActiveLanguage());
>         xte.getXtext();
>     }
>     @Factory(value="activeLanguage", autoCreate=true)
>     public void initActiveLanguage() {
>         XLanguage xl = xLanguageDAO.findXLanguageByIdentifier("ro");
>         log.info("initActiveLanguage(1): activeLanguage initialized to #0", xl.getIdentifier());
>         setActiveLanguage(xl);
>         log.info("initActiveLanguage(1): activeLanguage initialized to #0", getActiveLanguage().getIdentifier());
>     }
>     public XLanguage getActiveLanguage() {
>         return activeLanguage;
>     }
>     public void setActiveLanguage(XLanguage activeLanguage) {
>         this.activeLanguage = activeLanguage;
>     }
> ...
> }
> And i am calling the getText() method. The method calling is as expected:
>    1. the injected activeLanguage is detecting that it has a null value,
>    2. the initActiveLanguage() factory method is called
>    3. then the getText() method is continuing its execution.
> But, the problem is that when the application exists the @Factory method block, the created objects: activeLanguage is lost and reported again as null.
> Here is the output:
> 12:43:48,203 INFO  [XTextSessionWrapper] initActiveLanguage(1): activeLanguage initialized to ro
> 12:43:48,203 INFO  [XTextSessionWrapper] initActiveLanguage(1): activeLanguage initialized to ro
> 12:43:48,703 INFO  [XTextSessionWrapper] initActiveLanguage(1): activeLanguage initialized to ro
> 12:43:48,703 INFO  [XTextSessionWrapper] initActiveLanguage(1): activeLanguage initialized to ro
> 12:43:48,703 INFO  [XTextSessionWrapper] getText(1): identifier= com.brit.xcms.cms.Category.12.name, activeLanguage= null
> 12:43:49,234 INFO  [XTextSessionWrapper] getText(2): identifier= com.brit.xcms.cms.Category.12.name, activeLanguage= null
> Where did I went wrong? Why is the activeLanguage factoried value lost when i leave the initActiveLanguage() method?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the seam-issues mailing list