-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Question
How to make a custom Event Handler that will be registered and has an additional custom field in the event's request payload?
Expected Behaviour
We want a custom Page Publish event which has custom fields in the event's request payload.
-
Create com.adobe.aio.aem.event.osgimapping.internal.OsgiEventMappingSupplierImpl-custom.cfg.json file in config.author directory containing the following:
{
"aio.event.code": "custom_published",
"aio.event.label": "Custom Page Published",
"aio.event.description": "Custom Page Published Event",
"aio.xdm.event.type": "com.adobe.xdm.event.AemPagePublishedEvent",
"osgi.event.handler.type": "com.proj.core.eventhandler.CustomHandler",
"osgi.topic": "com/day/cq/replication",
"osgi.filter": "(&(type=ACTIVATE)(!(event.application=*)))",
"osgi.jcr.path.filter": "/content/"
} -
CustomHandler inherits from one of the abstract classes like ReplicationEventHandler (and puts CustomPage inheriting from Page) or something else which will give access to add custom fields to the event's request payload.
-
Handler is registered and the event's request payload has defined by CustomHandler additional fields.
Actual Behaviour
-
When tried to inherit from ReplicationEventHandler<CustomPage> (where CustomPage inherits from com.adobe.xdm.content.Page) and AdobeIoEventHandler<CustomPage>, there was a problem, because List<Triple<Asset, String, Date>> getXdmObjectActorDateTriples(Event event, ResourceResolverWrapper resourceResolverWrapper) is package-private and there cannot be a class created outside this package and implements this method.
-
When inheriting eg. from PageReplicationEventHandler custom handler does not work and logs say:
com.adobe.aio.aem.event.osgimapping.internal.OsgiEventMappingRegistrationServiceImpl Adobe I/O Events' OSGI Handler Registration failed: `Unreferenced/unimplemented OSGI event Handler value: com.proj.core.eventhandler.CustomHandler com.adobe.aio.exception.AIOException: Unreferenced/unimplemented OSGI event Handler value: com.proj.core.eventhandler.CustomHandler