adobe / adobe/aio-lib-java

`aem` `aio-aem-events-osgi-mapping` : Cannot make custom Event Handler Type

未关闭
#123 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Java
星标
7
派生
22
PR 合并指标
30 天内没有已合并 PR

描述

### 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.

1. 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/"
}

2. 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.
3. Handler is registered and the event's request payload has defined by CustomHandler additional fields.

### Actual Behaviour
1) When tried to inherit from **ReplicationEventHandler\** (where CustomPage inherits from com.adobe.xdm.content.Page) and **AdobeIoEventHandler\**, there was a problem, because **List> getXdmObjectActorDateTriples(Event event, ResourceResolverWrapper resourceResolverWrapper)** is package-private and there cannot be a class created outside this package and implements this method.
2) 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

贡献指南

打开贡献指南

调研方向

先阅读 OsgiEventMappingSupplierImpl 和 OsgiEventMappingRegistrationServiceImpl,然后跟踪 PageReplicationEventHandler 和 ReplicationEventHandler 是如何被识别的。检查 package-private 的 getXdmObjectActorDateTriples 方法以及未引用 handler 的错误。完成的标准是:自定义 handler 可以从所示 mapping 中注册,并向事件请求 payload 添加字段。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
backend
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。