/**
* looks up an optional module instance by its class.
*/
public ModuleInstance getInstance(Class clazz) {
ModuleInstance moduleInstance = null;
if ( instances != null ) {
moduleInstance = (ModuleInstance) instances.get( clazz.getName() );
}
if (moduleInstance==null) {
if (transientInstances==null) transientInstances = new HashMap();
// client requested an instance that is not in the map of instances.
// so we can safely assume that the client wants a transient instance
moduleInstance = (ModuleInstance) transientInstances.get( clazz.getName() );
if (moduleInstance==null) {
try {
moduleInstance = (ModuleInstance) clazz.newInstance();
moduleInstance.setProcessInstance(this);
} catch (Exception e) {
e.printStackTrace();
throw new JbpmException("couldn't instantiate transient module '"+clazz.getName()+"' with the default constructor");
}