3 Replies Latest reply on Feb 18, 2008 7:22 AM by pmuir

    Event not raised with annotations - Bug?

    ruettimac

      Hi,

      I have two methods raising an event - one raises the event, the other not. If I raise the event programmatically it works, but not while I am annotating the raise of the event.

      First the method which does not raise the event with annotations:

      @RaiseEvent(value=SeamConstants.EVENT_SPORTEQUIPMENT_CHANGED)
       public String deleteSportEquipment(final SportEquipment pSportEquipment) throws PersistencyException {
       Validate.notNull(pSportEquipment, "Argument pSportEquipment is mandatory");
      
       try {
       SportEquipment toDelete = mEntityManager.merge(pSportEquipment);
       pSportEquipment.getCustomer().getSportEquipments().remove(pSportEquipment);
       mEntityManager.remove(toDelete);
       } catch (final Exception pException) {
       mLog.error("Failed to delete sport equipment #0 of customer #1", pException, pSportEquipment.getName(), pSportEquipment.getCustomer().
       getLogin().
       getSynonym());
       throw new PersistencyBackendException("exception.persistencybackend", pException);
       } finally {
       //Events.instance().raiseEvent(SeamConstants.EVENT_SPORTEQUIPMENT_CHANGED);
       }
      
       return NavigationConstants.REDISPLAY;
       }
      


      The constant NavigationConstants.REDISPLAY simply returns null.

      The second method which raises the event with annotations:

      @RaiseEvent(value=SeamConstants.EVENT_SPORTEQUIPMENT_CHANGED)
       public String persistSportEquipment(final SportEquipment pSportEquipment) throws PersistencyException {
       Validate.notNull(pSportEquipment, "Argument pSportEquipment is mandatory");
      
       SportEquipment sportEquipment = null;
      
       // update first if id already set, if id is null we have a fresh sport equipment
       if (null != pSportEquipment.getId()) {
       sportEquipment = mEntityManager.merge(pSportEquipment);
       } else {
       sportEquipment = pSportEquipment;
       sportEquipment.getCustomer().getSportEquipments().add(sportEquipment);
       }
      
       try {
       mEntityManager.persist(sportEquipment);
       } catch (final Exception pException) {
       mLog.error("Failed to save changed for sport equipment #0 of customer #1", pException, pSportEquipment.getName(), pSportEquipment.getCustomer().
       getLogin().
       getSynonym());
       throw new PersistencyBackendException("exception.persistencybackend", pException);
       } finally {
       //Events.instance().raiseEvent(SeamConstants.EVENT_SPORTEQUIPMENT_CHANGED);
       }
      
       return NavigationConstants.SUCCESS;
       }


      While looking at the code; Do you see anything that is wrong? The only difference I see is the return value. I validated, that if null is returned, the event is not fired. But If I return a value, the event is fired.

      I suppose this is a bug?!


      Regards,

      Cyrill