Tuesday, August 3, 2010

OIM Howto: Add parameters to your scheduled tasks

In many cases you want to externalize configuration parameters from the actual code in order to avoid having to recompile and deploy every time you want to change something. In scheduled tasks the simplest way to do this is to simply define your parameters in the scheduled task and then call them from the code.

public void init() {
 try {
    String dbName = getAttribute ( DATABASE_NAME );     
 } catch(Exception e) {
    logger.error ( "Exception while initializing recon analyzer scheduled task " + e.getMessage() ) ;
 }
}

This will get you access to the scheduled task attribute called DATABASE_NAME.

A slightly more advanced variant of the same is to let the attribute be a reference to another OIM object. In many cases ITResources are useful places to store attributes

String dbName = getAttribute ( DATABASE_NAME );
Hashtable itResourceAttr = tcUtilXellerateOperations.getITAssetProperties (super.getDataBase(), dbName.trim());

Now you have the parameters of this ItResource in the hashtable.

You will have to import com.thortech.xl.util.adapters.tcUtilXellerateOperations which is a very useful class full of nifty static methods.

No comments:

Post a Comment