This note helps one getting started with the development of a custom OIM scheduler task using Eclipse as a development platform for Java. This note will guide you trough the following stages:
1. Creating the working folder structure
2. Adding the JAR files needed from OIM server
3. Creating a java project in Eclipse
4. Writing a sample java class that will implement SchedulerBaseTask
5. Compiling the code with Eclipse
6. Creating the JAR file containing the sheduled task
7. Configuring the Scheduled Task in OIM
This Content will only be Applicable for Identity Manager - Version: 9.1 or later
Software Requirements/Prerequisites
+ Java JDK + Eclipse platform -> for Java development
Configuring the Sample Code
1. Creating the working folder structure
The following structure must be created in the home directory of your project (Separate project home for each project):
The folders will store:
src - source code of your project
bin - compiled code of your project
lib - OIM API libraries
jar - the final JAR file containing the scheduled task
2. Adding the JAR files needed Copy the file file:
OIM_HOME\xellerate\lib\xlVO.jar to PROJECT_HOME\lib OIM_HOME\xellerate\lib\xlAPI.jar to PROJECT_HOME\lib OIM_HOME\xellerate\lib\xlScheduler.jar to PROJECT_HOME\lib OIM_HOME\xellerate\lib\xlLogger.jar to PROJECT_HOME\lib OIM_HOME\xellerate\lib\xlUtils.jar to PROJECT_HOME\lib
Depending on the custom code implemented, other JAR files might be needed.
Creating a java project in Eclipse Once the above steps are completed we are ready to create a Java project. (this step requires Eclipse to be installed on your development machine.
Eclipse can be downloaded from http://www.eclipse.org/)
+ Start Eclipse platform
+ Select File->New->Project from the menu on top
+ Select Java Project and click Next
+ Type in a project name (For example OIM_SCHEDULED_TASK)
+ In the Contents panel select "Create project from existing source", click Browse and select your
+ Click Finish to exit the wizard At this point the project is created and you should be able to browse trough it in Package Explorer. Setting src in the build path:
+ In Package Explorer right click on project name and select Properties
+ Select Java Build Path in the left and Source tab in the right
+ Click Add Folder and select your src folder
+ Click OK
Running the Sample Code
4. Writing a sample java class that will implement SchedulerBaseTask
+ In Package Explorer, right click on src and select New->Package
+ Type the name of the package as com.oracle.oim.sample.scheduledtasks
+ Click Finish
+ In Package Explorer, right click on com.oracle.oim.sample and select New->Class.
+ Type the name of the class as SampleScheduledTask
+ Click Finish Put the sample code in the class
5. Compiling the code with Eclipse
Make sure there are no compilation errors reported by Eclipse and then select from the menu: Project -> Build All
6. Creating the JAR file containing the event handler To generate the jar file,
execute:
The following output should be seen: added manifest
adding: com/(in = 0) (out= 0)(stored 0%)
adding: com/oracle/(in = 0) (out= 0)(stored 0%)
adding: com/oracle/oim/(in = 0) (out= 0)(stored 0%)
adding: com/oracle/oim/sample/(in = 0) (out= 0)(stored 0%)
adding: com/oracle/oim/sample/scheduledtasks/(in = 0) (out= 0)(stored 0%)
adding: com/oracle/oim/sample/scheduledtasks/SampleScheduledTask.class(in = 1803) (out= 878)(deflated 51%)
Copy the resulted jar file from:
7. Configuring the Scheduled Task in OIM + open OIM Design Console + Administration ->Task SchedulerScheduled Task :
MyCustomScheduledTask Class Name:
com.oracle.oim.sample.scheduledtasks.SampleScheduledTask
Click Save
If there are any custom attributes for the scheduled task,
click the Add button to define them.
In this example, custom attributes are attributeName1 and attributeName2.
Sample Code
package com.oracle.oim.sample.scheduledtasks;
import com.thortech.xl.scheduler.tasks.SchedulerBaseTask;
import com.thortech.util.logging.Logger;
public class SampleScheduledTask extends SchedulerBaseTask
{ //define here the task attributes private String attributeValue1;
private String attributeValue2; //define here the logger
private Logger logger = Logger.getLogger("XELLERATE.CUSTOM_TASK");
public SampleScheduledTask()
{
super();
}
public void init()
{ logger.info("Starting init() for SampleScheduledTask");
try
{ //the task attributes can be retrived here
attributeValue1 = getAttribute("attributeName1");
attributeValue2 = getAttribute("attributeName2"); //perform other init actions here }catch
(Exception e){ e.printStackTrace();
} logger.info("Finishing init() for SampleScheduledTask");
}
public void execute()
{
logger.info("Starting execute() for SampleScheduledTask"); //if an API utility is needed
Thor.API.Operations.tcLookupOperationsIntf lookupUtility = null;
try{ //execute the custom processing here
logger.info("Executing SampleScheduledTask"); //if an API utility is needed
lookupUtility = (Thor.API.Operations.tcLookupOperationsIntf) getUtility(
"Thor.API.Operations.tcLookupOperationsIntf"); //any other utility can be initialized in the same way
}
catch(Exception e)
{ //make sure no exception is thrown in the Quartz scheduler //all exceptions should be handled here
e.printStackTrace();
}
logger.info("Finishing execute() for SampleScheduledTask");
}
public boolean stop()
{ //Stop the execution of this task
return true;//or false if cannot be stopped
}
}