[jboss-user] [EJB 3.0] - @PreDestroy and injected JavaBeans
beligum
do-not-reply at jboss.com
Thu Nov 29 16:51:44 EST 2007
Hi all,
I'm trying to do the following:
| @Stateful
| @Scope(SESSION)
| @Name("outboxManager")
| public class OutboxManagerImpl extends AbstractManagerImpl implements OutboxManager, Serializable
| {
| private Map<Principal, List<EmailMessage>> queuedMessages;
|
| @In(create=true)
| private EmailMessenger emailMessenger;
|
| [constructors, getters, setters, ...]
|
| @PreDestroy
| public void cleanup()
| {
| try {
| sendAllQueuedMessages();
| } catch (EmailException e) {
| e.printStackTrace();
| }
| }
| @Remove
| @Destroy
| public void destroy()
| {
| }
| }
|
Everything works fine, but when the @PreDestroy method is called, the injected JavaBean (POJO with @Name("emailMessenger")) has become null. I tried to re-inject it manually, but some other initialization-things (eg. the email renderer) go wrong then.
Am I missing the point here that the injected values are already irrevocably destroyed when @PreDestroy is reached/called, or is this expected behavior? If so, how do I send my queued mails when the session goes out of scope?
thanks a lot,
b.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4109080#4109080
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4109080
More information about the jboss-user
mailing list