Skip to content

Instantly share code, notes, and snippets.

@bmvakili
Forked from rotty3000/MyAction.java
Created July 24, 2019 08:43
Show Gist options
  • Save bmvakili/1a4a71960c76676fe1ea151d3fcd5a74 to your computer and use it in GitHub Desktop.
Save bmvakili/1a4a71960c76676fe1ea151d3fcd5a74 to your computer and use it in GitHub Desktop.
MyAction
package com.liferay.events;
import aQute.bnd.annotation.component.Activate;
import aQute.bnd.annotation.component.Component;
import aQute.bnd.annotation.component.Deactivate;
import com.liferay.portal.kernel.events.ActionException;
import com.liferay.portal.kernel.events.SimpleAction;
/**
* @author Raymond Augé
*/
@Component(
immediate=true,
properties={
"lifecycle.event=global.startup.events|application.startup.events|global.shutdown.events",
"service.ranking:Integer=100000"
},
provide={MyAction.class, SimpleAction.class}
)
public class MyAction extends SimpleAction {
@Activate
public void activate() {
System.out.println(getClass().getName() + " activated!");
}
@Deactivate
public void deactivate() {
System.out.println(getClass().getName() + " deactivated!");
}
@Override
public void run(String[] ids) throws ActionException {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
StackTraceElement stackTraceElement = stackTrace[5];
System.out.println(
stackTraceElement.getClassName() + "." +
stackTraceElement.getMethodName() + "()[" +
stackTraceElement.getLineNumber() + "] called my action!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment