First of all decide on the number and type of arguments that will be passed to your scheduled job. Now create a class file for the scheduled job. The class should extends oracle.iam.scheduler.vo.TaskSupport.
We can get the arguments passed to the job and from the hashmap and then we can write our business logic in the execute method. For demo purpose we are just printing the arguments to the console.
There are 3 abstratct methods that needs to be overridden.
execute (HashMap map)
getAttributes ()
setAttributes ()
The execute is the method that gets executed when the scheduled job is triggered. It accepts an argument Hashmap which contains the arguments passed to the scheduled job from OIM UI.
We can get the arguments passed to the job and from the hashmap and then we can write our business logic in the execute method. For demo purpose we are just printing the arguments to the console.
We have just created a demo scheduled job which takes two arguments and just prints them to console.
- Create the class file as mentioned above. Compile it into jar file.
- Create a plugin.xml file as below.
- Create a scheduler metadata file as below. The name of the file as well as scheduler should be same (Sample_Scheduler.xml).
- Create a directory structure as below:
- Inside the lib directory place the jar file.
- Inside META-INF place the scheduler metadata xml file. Alternatively you can register the scheduler metadata file to the mds.
- Create a zip selecting the above two folders and plugin.xml. If you are in development stage you can place the zip inside <OIM_HOME>/plugins in all the nodes. Once you are done with the development its ideal to register the plugin to the database.
- Next step is to create the scheduled job. Go to system administration console>Scheduled jobs.
- Click on the new button. Search the job with the name.Select the job and confirm.
- Select the job and confirm, fill in the details as below and Save.
- You can search and run it now. As per the code both the arguments will get printed on the console (oim_server.out file).
The scheduler files are available here
- If you have any questions or need more details, please update the comments. I will try my best to answer them.
-gaurav
This comment has been removed by the author.
ReplyDeleteHow to show failure message in ui of scheduled task on failed of scheduled task
ReplyDeleteHow to show failure message in ui of scheduled task on failed of scheduled task
ReplyDelete