Implement thread safe, annotation based osgi event handling
Implement a new thread safe, annotation based osgi event handling mechanism as an alternative to the existing AbstractEventHandler approach.
The new approach consists of:
Annotation class for each predefined IEventTopic (PO_BEFORE_NEW, DOC_BEFORE_PREPARE, etc)
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.
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.
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:
At plugin Activator start method, register the event delegate class.
Create an osgi component, at the bind method for the IEventManager service.
Event handlers and Event delegates:
PO and FactValidate - ModelEventHandler and ModelEventDeleagete
Import (I_BPartner, I_Product, etc) - ImportEventHandler and ImportEventDelegate
Process - ProcessEventHandler and ProcessEventDelegate
Others - SimpleEventHandler and EventDelegate (and the optional, convenient delegate class of RequestSendEmailEventDelegate and AfterLoginEventDelegate)
There’s annotattion created for all predefined event delegate (“@AfterLogin”, “@AfterProcess”, “@BeforeComplete”, “@AfterImport”, etc)
Model/PO event annotation at org.adempiere.base.event.annotations.po
Process event annotation at org.adempiere.base.event.annotations.process
Import event annotation at org.adempiere.base.event.annotations.imp
Document event annotation at org.adempiere.base.event.annotations.doc
Base classes and Other event annotation at org.adempiere.base.event.annotations
Hi , the seed db is configured with automatic period control.
That’s due to period Feb 2021 is not open at seed db and unit test that try to post any docs will fail.
Hi , in my eclipse the EventHandlerTest is running fine, but in jenkins it failed
Can you please check?