}
public static FlowController produceFlowController( String aFlowControllerDescriptor ) throws Exception
{
FlowControllerDescription specifier = (FlowControllerDescription)
UIMAFramework.getXMLParser().parseResourceSpecifier(new XMLInputSource(new File(aFlowControllerDescriptor)));
String flowControllerClassName;
flowControllerClassName = specifier.getImplementationName();
if (flowControllerClassName == null || flowControllerClassName.length() == 0)
{
throw new ResourceInitializationException(ResourceInitializationException.MISSING_IMPLEMENTATION_CLASS_NAME, new Object[] { specifier.getSourceUrlString() });
}
// load FlowController class
Class flowControllerClass = null;
try
{
// use application ClassLoader to load the class
flowControllerClass = Class.forName(flowControllerClassName);
}
catch ( ClassNotFoundException e)
{
throw new ResourceInitializationException(ResourceInitializationException.CLASS_NOT_FOUND, new Object[] { flowControllerClassName, specifier.getSourceUrlString() }, e);
}
Object userObject;
try
{
userObject = flowControllerClass.newInstance();
}
catch ( Exception e)
{
throw new ResourceInitializationException(ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] { flowControllerClassName, specifier.getSourceUrlString() }, e);
}
if (!(userObject instanceof FlowController))
{
throw new ResourceInitializationException(ResourceInitializationException.RESOURCE_DOES_NOT_IMPLEMENT_INTERFACE, new Object[] { flowControllerClassName, FlowController.class, specifier.getSourceUrlString() });
}
return (FlowController) userObject;
}