Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
31. Jul 2008, 14:20 CET | Link

Hello guys,

I have to use this proxy class in order to avoid concurrent calls exception (http://java.sun.com/blueprints/guidelines/designing_enterprise_applications/ejb_tier/qanda/#prevent):


public class CommentDAOImpl {

    private LocalCommentDAO commentDAO;

    public CommentDAOImpl() {
        this.commentDAO = (LocalCommentDAO) Contexts.getConversationContext().get(CommentDAO.class);
        System.out.println("context= " + Contexts.getConversationContext());
        System.out.println("setted commentDAO= " + commentDAO);
    }
...
}

CommentDAO looks like this:


@Stateful
@Name("commentDAO")
@AutoCreate
public class CommentDAO implements LocalCommentDAO {
...
}

But when I call the constructor of CommentDAOImpl, the commentDAO component is reported as null, even if the class is marked with @AutoCreate:


14:55:18,015 INFO  [STDOUT] context= ConversationContext(3)
14:55:18,015 INFO  [STDOUT] setted commentDAO= null

If I use the @In annotation to inject the commentDAO component in some other stateful components, it works ok and the commentDAO component is created.

So, what is the difference between the @In private LocalCommentDAO; annotation and the Contexts.getConversationContext().get(CommentDAO.class) calls? How can I create a component when it is injected through Contexts.getConversationContext().get(CommentDAO.class)?

Thank you in advance,

Bogdan.

2 Replies:
31. Jul 2008, 15:51 CET | Link
Bogdan Minciu wrote on Jul 31, 2008 14:20:
So, what is the difference between the @In private LocalCommentDAO; annotation and the Contexts.getConversationContext().get(CommentDAO.class) calls? How can I create a component when it is injected through Contexts.getConversationContext().get(CommentDAO.class)?

Component.getInstance(CommentDAO.class, true)

-P

Rating:  * * * *