Implement thread safe, annotation based osgi event handling

Description

Implement a new thread safe, annotation based osgi event handling mechanism as an alternative to the existing AbstractEventHandler approach.

The new approach consists of:

  1. Annotation class for each predefined IEventTopic (PO_BEFORE_NEW, DOC_BEFORE_PREPARE, etc)

  2. BaseEventHandler and its subclass of SimpleEventHandler and ModelEventHandler. This is the class that developer will use to register with EventManager/EventAdmin. However, actual work is delegate to the EventDelegate class below.

  3. EventDelegate. Developer will extends this to perform action for each event call. Developer will use annotation to denote which event an EventDelegate subclass will listen to. Note that the subclass of EventDelegate doesn't have to be thread safe as BaseEventHandler will create and throw away instance of EventDelegate for each event call.

Example Usage:

To listen to before change of C_BPartner (MBPartner), create new ModelEventDelegate subclass and use "@BeforeChange" annotation for before change event (method name is insignificant here).

Developer can use one of the following approach to register the event delegate:

  1. At plugin Activator start method, register the event delegate class.

  2. Create an osgi component, at the bind method for the IEventManager service.

 

Event handlers and Event delegates:

  1. PO and FactValidate - ModelEventHandler and ModelEventDeleagete

  2. Import (I_BPartner, I_Product, etc) - ImportEventHandler and ImportEventDelegate

  3. Process - ProcessEventHandler and ProcessEventDelegate

  4. Others - SimpleEventHandler and EventDelegate (and the optional, convenient delegate class of RequestSendEmailEventDelegate and AfterLoginEventDelegate)

Annotation:

  1. There’s annotattion created for all predefined event delegate (“@AfterLogin”, “@AfterProcess”, “@BeforeComplete”, “@AfterImport”, etc)

  2. Model/PO event annotation at org.adempiere.base.event.annotations.po

  3. Process event annotation at org.adempiere.base.event.annotations.process

  4. Import event annotation at org.adempiere.base.event.annotations.imp

  5. Document event annotation at org.adempiere.base.event.annotations.doc

  6. Base classes and Other event annotation at org.adempiere.base.event.annotations

Environment

None

Activity

Show:
Carlos Ruiz
February 11, 2021, 8:33 AM

Hi , the seed db is configured with automatic period control.

Heng Sin Low
February 11, 2021, 8:12 AM

Hi ,

That’s due to period Feb 2021 is not open at seed db and unit test that try to post any docs will fail.

Regards,

Low

Carlos Ruiz
February 11, 2021, 7:50 AM

Hi , in my eclipse the EventHandlerTest is running fine, but in jenkins it failed

https://jenkins.idempiere.org/job/iDempiereDaily/401/org.idempiere$org.idempiere.test/testReport/junit/org.idempiere.test.event/EventHandlerTest/testFactValidate/

Can you please check?

Regards,

Carlos Ruiz

Fixed

Assignee

Heng Sin Low

Reporter

Heng Sin Low

Labels

None

Tested By

None

Components

Fix versions

Priority

Major