[jboss-user] [JBoss Seam] - Re: Can not persist EJB3 Timer since Jboss 4.2.0cr2 + seam
gena777
do-not-reply at jboss.com
Mon Apr 23 06:29:42 EDT 2007
Hello, i'm using the seam-wrapper for EJB3 timers via @Asynchronous. In a simple case it works fine:
Timer iface:
@Local
| public interface TimerTester {
| @Asynchronous
| public abstract Timer say(String what, @Expiration
| Date expireTime, @IntervalDuration
| Long intervallDuration, @Duration Long duration);
| }
Timer Bean:
@Name("timerTester")
| @AutoCreate
| @Stateless
| public class TimerTesterImpl implements TimerTester{
| @In
| Timer timer;
| @Resource
| TimerService timerService;
| public Timer say(String what, Date expireTime, Long intervallDuration, Long duration) {
| System.out.println(what);
| return timer;
| }
| }
controller (stateless bean with local iface):
public void sayHello() {
| Timer timer =timerTester.say("hello", new Date(System.currentTimeMillis()+1000), 10000l,10l);
| log.info(timer, null);
| }
Page
| <h:commandLink value="Say Hello!" action="#{sampleController.sayHello}"/>
My case, which doesn't work anymore:
SFSB:
| ...
| @In(create = true)
| OfferLifecycle offerLifecycle;
| ...
| if (persistOffer()) {
| if (schedule) {
|
| timer = offerLifecycle.scheduleOfferStart(inOffer.getId(), inOffer.getStartTimestamp());
|
| debug("offer start pending with timer ");
|
| timer = offerLifecycle.scheduleOfferEnd(inOffer.getId(), inOffer.getEndTimestamp());
|
| debug("offer end pending with timer");
| }
Timer bean:
@Local
| public interface OfferLifecycle {
| @Asynchronous
| public abstract Timer scheduleOfferStart(Long offerId, @Expiration
| Date startTime);
| @Asynchronous
| public abstract Timer scheduleOfferEnd(Long offerId, @Expiration
| Date expireTime);
| }
@Stateless
| @Name("offerLifecycle")
| public class OfferLifecycleBean implements OfferLifecycle {
|
| @In(create = true)
| OfferDAO offerDAO;
| @In
| Timer timer;
| @Resource
| TimerService timerService;
|
| public Timer scheduleOfferStart(Long offerId, Date startTime) {
| offerStart(loadOffer(offerId));
| return timer;
| }
| public Timer scheduleOfferEnd(Long offerId, Date expireTime) {
|
| offerEnd(loadOffer(offerId));
| return timer;
| }
| private Offer loadOffer(Long offerId) {
| return offerDAO.findById( offerId,
| LockMode.UPGRADE);
| }
persistOffer() has flushed the session (because of flush mode manual)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4039778#4039778
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4039778
More information about the jboss-user
mailing list