Tuesday, January 11, 2011

Creating a generic BPEL process to purge instances

The final piece of the puzzle...

I create a composite -






I created the following process variables



and added the following connection properties to composite.xml



I added the following embedded Java to the BPEL process.



----------------------------------------------------------

Hashtable jndiProps = new Hashtable();

String PROVIDER_URL = (String)getVariableData("v_PROVIDER_URL");
String INITIAL_CONTEXT_FACTORY = (String)getVariableData("v_INITIAL_CONTEXT_FACTORY");
String SECURITY_PRINCIPAL = (String)getVariableData("v_SECURITY_PRINCIPAL");
String SECURITY_CREDENTIALS = (String)getVariableData("v_SECURITY_CREDENTIALS");

jndiProps.put(javax.naming.Context.PROVIDER_URL,PROVIDER_URL);
jndiProps.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,INITIAL_CONTEXT_FACTORY);
jndiProps.put(javax.naming.Context.SECURITY_PRINCIPAL, SECURITY_PRINCIPAL);
jndiProps.put(javax.naming.Context.SECURITY_CREDENTIALS, SECURITY_CREDENTIALS);

jndiProps.put("dedicated.connection", "true");
System.out.println("*** Purge composite instance... ");
Locator locator = null;
System.out.println("*** Purge composite instance - about to get id ");

String compositeID = (String)getVariableData("v_compositeID");
System.out.println("*** Purge composite instance - got id " + compositeID);
try {
LocatorFactory.createLocator(jndiProps);
locator = LocatorFactory.createLocator(jndiProps);
CompositeInstanceFilter coif = new CompositeInstanceFilter();
coif.setId(compositeID);
List list = locator.getCompositeInstances(coif);
System.out.println("*** Composite Instance " + compositeID + " about to be deleted...");

for(int i = 0 ; i < list.size() ; i ++){
CompositeInstance coi = (CompositeInstance)list.get(i);
System.out.println("*** Composite Instance State = " +coi.getState());
System.out.println("*** Composite Instance " + compositeID + " about to be deleted...");
// locator.purgeInstance(coif);
}
}
catch (Exception e) {

e.printStackTrace();
}
locator.close();

----------------------------------------------------------



Now kick off the cancel process –


No comments:

Post a Comment