-
-
Save bmvakili/1a4a71960c76676fe1ea151d3fcd5a74 to your computer and use it in GitHub Desktop.
MyAction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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