use of org.eclipse.jst.server.generic.internal.servertype.definition.util.ServerTypeResourceFactoryImpl in project webtools.servertools by eclipse.
the class XMLUtils method readFile.
private ServerRuntime readFile(java.net.URI file) {
// Create a resource set.
ResourceSet resourceSet = new ResourceSetImpl();
// Register the default resource factory -- only needed for
// stand-alone!
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new ServerTypeResourceFactoryImpl());
ServerTypePackage gstPack = ServerTypePackage.eINSTANCE;
// Get the URI of the model file.
URI fileURI = URI.createURI(file.toString());
// Demand load the resource for this file.
Resource resource = null;
try {
resource = resourceSet.getResource(fileURI, true);
} catch (WrappedException e) {
// sth wrong with this .server file.
CorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 1, "Error loading the server type definition", // $NON-NLS-1$
e));
}
if (resource != null) {
ServerRuntime def = (ServerRuntime) resource.getContents().get(0);
if (def != null) {
def.setFilename(file.toString());
return def;
}
}
return null;
}
Aggregations