Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding EventHandler for specific event.topic

Tags:

osgi

aem

I'm discovering AEM workflows and the flow of the Request for Approval model. I've noticed (confirmed on AEM docs) that "if the user does not have the required privileges for publishing a specific page a workflow will be triggered to notify the appropriate person of your request to publish".

Trying to find how it's triggered I've found out ReplicationProcess that handles the activation action and sends a com/day/cq/wcm/workflow/req/for/activation event. Here is where I get lost - none of the AEM OSGi console known to me covers this relationship.

How can I find the event handler that is used for handling a specific event topic?

like image 271
Mateusz Chromiński Avatar asked Aug 13 '15 09:08

Mateusz Chromiński


People also ask

What is an event handler give example?

In general, an event handler has the name of the event, preceded by "on." For example, the event handler for the Focus event is onFocus. Many objects also have methods that emulate events. For example, button has a click method that emulates the button being clicked.

What is the difference between event handler and event listener?

Note: Event handlers are sometimes called event listeners — they are pretty much interchangeable for our purposes, although strictly speaking, they work together. The listener listens out for the event happening, and the handler is the code that is run in response to it happening.

What is a event handler?

In programming, an event handler is a callback routine that operates asynchronously once an event takes place. It dictates the action that follows the event. The programmer writes a code for this action to take place. An event is an action that takes place when a user interacts with a program.


1 Answers

If you know the event topic you can use bundleContext to find reference to proper EventHandler OSGi service, e.g. using AEM Groovy Console :

ServiceReference[] sr = bundleContext.getServiceReferences(org.osgi.service.event.EventHandler.class, "(event.topics=com/day/cq/wcm/workflow/req/for/activation)")

for (i=0; i< sr.length; i++) {
    println bundleContext.getService(sr[i])
}

Output

com.day.cq.wcm.workflow.impl.WcmWorkflowServiceImpl@618c5804

You can also use OSGi Felix Web Console (services tab) to find it:

web console service tab

like image 64
pacoolsky Avatar answered Nov 15 '22 08:11

pacoolsky