* Read and parse an XML descriptor file
*/
public AbstractDescriptor read( File descriptorFile , Class handlerClass ) throws JMSException
{
if (!descriptorFile.canRead())
throw new FFMQException("Can't read descriptor file : "+descriptorFile.getAbsolutePath(),"FS_ERROR");
log.debug("Parsing descriptor : "+descriptorFile.getAbsolutePath());
AbstractXMLDescriptorHandler handler;
try
{
// Create an handler instance
handler = (AbstractXMLDescriptorHandler)handlerClass.newInstance();
// Parse the descriptor file
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
FileInputStream in = new FileInputStream(descriptorFile);
parser.parse(in,handler);
in.close();
}
catch (Exception e)
{
throw new FFMQException("Cannot parse descriptor file : "+descriptorFile.getAbsolutePath(),"PARSE_ERROR",e);
}
AbstractDescriptor descriptor = handler.getDescriptor();
descriptor.setDescriptorFile(descriptorFile);