Today we will see how we can create application start up events in Liferay 7.3 . By using this we can create our configuration on start up of your module. So we don't need to create Custom Fields, Structure, templates etc using Control Panel. As soon as module is deployed code will run automatically.
So lets start this step by step :-
Step 1:- Create a simple Liferay Module
Create a simple Liferay module Project and select api from Project Template Name. Provide the package name and class name and click finish. Now delete the old package as it is appended by api and create new package and also provide the new package entries in bnd file. Now create a Class that implement BundleActivator
StartUp.java
Explanation
Here in Line number 9 we provide key=application.startup.event.
Also we implement two methods start which run when we deploy the module and stop which run when we un deploy or stop our module
Step 2:- Provide entry in bnd file
Provide entry of your class in bnd
Bundle-Activator: com.liferay.start.up.StartUp
So now my bnd file become
bnd.bnd
Step 3:- Check output
Now deploy your module as soon as you deploy the module you will see message on your tomcat console
No comments:
Post a Comment