}
}
public Definitions read(URL contributionURL, final URI uri, final URL url, ProcessorContext context) throws ContributionReadException {
InputStream urlStream = null;
Monitor monitor = context.getMonitor();
monitor.pushContext("Definitions: " + url);
try {
// Allow privileged access to open URL stream. Add FilePermission to added to security
// policy file.
try {
urlStream = AccessController.doPrivileged(new PrivilegedExceptionAction<InputStream>() {
public InputStream run() throws IOException {
return IOHelper.openStream(url);
}
});
} catch (PrivilegedActionException e) {
error(monitor, "PrivilegedActionException", url, (IOException)e.getException());
throw (IOException)e.getException();
}
//urlStream = createInputStream(url);
XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor());
Definitions definitions = definitionsFactory.createDefinitions();
int event = reader.getEventType();
while (reader.hasNext()) {
event = reader.next();
// We only deal with the root element
if (event == XMLStreamConstants.START_ELEMENT) {
// QName name = reader.getName();
Object model = extensionProcessor.read(reader, context);
if (model instanceof Definitions) {
DefinitionsUtil.aggregate((Definitions)model, definitions, monitor);
return definitions;
} else {
error(monitor, "ContributionReadException", model, null);
}
}
}
return definitions;
} catch (XMLStreamException e) {
ContributionReadException ce = new ContributionReadException(e);
error(monitor, "ContributionReadException", inputFactory, ce);
throw ce;
} catch (IOException e) {
ContributionReadException ce = new ContributionReadException(e);
error(monitor, "ContributionReadException", inputFactory, ce);
throw ce;
} finally {
try {
if (urlStream != null) {
urlStream.close();
urlStream = null;
}
} catch (IOException ioe) {
//ignore
}
monitor.popContext();
}
}