/** * Registers an {@link XMIResourceFactoryImpl} for the given extension. * @param ext The extension as a String. */ public static void registerExtensionForXmiSerializer(String ext) { Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE; Map<String, Object> m = reg.getExtensionToFactoryMap(); m.computeIfAbsent(ext, e -> new XMIResourceFactoryImpl()); }
public void registerResourceFactories(ResourceSet resourceSet) { super.registerResourceFactories(resourceSet); // code added by me resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("systembehavior", new XMIResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("peerbehavior", new XMIResourceFactoryImpl()); }
protected static void setDefaultResourceFactory() { //This is not done outside of Eclipse if (Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().get(Resource.Factory.Registry.DEFAULT_EXTENSION) == null) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); }
private static SecurityModel read(final String modelString) throws IOException { final ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); final org.eclipse.emf.ecore.resource.Resource xmlResource = resourceSet.createResource(URI.createURI("dummy.deploy")); //$NON-NLS-1$ // Register the package -- only needed for stand-alone! resourceSet.getPackageRegistry().put(UamPackage.eNS_URI, UamPackage.eINSTANCE); resourceSet.getPackageRegistry().put(ExpressionPackage.eNS_URI, ExpressionPackage.eINSTANCE); resourceSet.getPackageRegistry().put(StdlibPackage.eNS_URI, StdlibPackage.eINSTANCE); final ByteArrayInputStream bais = new ByteArrayInputStream(modelString.getBytes()); xmlResource.load(bais, Collections.emptyMap()); return (SecurityModel) xmlResource.getContents().get(0); }
public static void initializeDefaults() { //EMF Standalone setup if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "ecore", new EcoreResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xmi", new XMIResourceFactoryImpl()); if (!EPackage.Registry.INSTANCE.containsKey(EcorePackage.eNS_URI)) EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI)) EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE); }
ResourceSet resourceSet = new ResourceSetImpl(); // register UML Map packageRegistry = resourceSet.getPackageRegistry(); packageRegistry.put(list.ListPackage.eNS_URI, list.ListPackage.eINSTANCE); // Register XML resource as UMLResource.Factory.Instance Map extensionFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); extensionFactoryMap.put("xmi", new XMIResourceFactoryImpl()); Resource resource = (Resource) resourceSet.createResource(uri); // try to load the file into resource resource.load(null);
public static void initializeDefaults() { //EMF Standalone setup if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "ecore", new EcoreResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xmi", new XMIResourceFactoryImpl()); if (!EPackage.Registry.INSTANCE.containsKey(EcorePackage.eNS_URI)) EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI)) EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE); }
public static void initializeDefaults() { //EMF Standalone setup if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "ecore", new EcoreResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xmi", new XMIResourceFactoryImpl()); if (!EPackage.Registry.INSTANCE.containsKey(EcorePackage.eNS_URI)) EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI)) EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE); }
protected void registerCrossx() { // Create a resource set to hold the resources. // EPackage.Registry.INSTANCE.put(CrossxPackage.eNS_URI, CrossxPackage.eINSTANCE); ResourceSet resourceSet = new ResourceSetImpl(); // Register the appropriate resource factory to handle all file extensions. // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put (Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); // Register the package to ensure it is available during loading. // resourceSet.getPackageRegistry().put (CrossxPackage.eNS_URI, CrossxPackage.eINSTANCE); }
protected void registerCrossx() { // Create a resource set to hold the resources. // EPackage.Registry.INSTANCE.put(CrossxPackage.eNS_URI, CrossxPackage.eINSTANCE); ResourceSet resourceSet = new ResourceSetImpl(); // Register the appropriate resource factory to handle all file extensions. // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put (Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); // Register the package to ensure it is available during loading. // resourceSet.getPackageRegistry().put (CrossxPackage.eNS_URI, CrossxPackage.eINSTANCE); }
private void registerDefaultFactories() { if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) { Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); } if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi")) { Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl()); } if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin")) { Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xtextbin", new BinaryGrammarResourceFactoryImpl()); } if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI)) { EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE); } }
public Injector createInjectorAndDoEMFRegistration() { // register default ePackages if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "ecore", new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xmi", new org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl()); if (!EPackage.Registry.INSTANCE.containsKey(org.eclipse.xtext.XtextPackage.eNS_URI)) EPackage.Registry.INSTANCE.put(org.eclipse.xtext.XtextPackage.eNS_URI, org.eclipse.xtext.XtextPackage.eINSTANCE); Injector injector = createInjector(); register(injector); return injector; }
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE; Map<String, Object> m = reg.getExtensionToFactoryMap(); m.put("key", new XMIResourceFactoryImpl()); ResourceSet resSet = new ResourceSetImpl(); Resource resource = resSet.createResource(URI.createFileURI(fileName)); resource.getContents().add(data); resource.save(Collections.EMPTY_MAP);
public Injector createInjectorAndDoEMFRegistration() { // register default ePackages if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "ecore", new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xmi", new org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xtextbin", new org.eclipse.xtext.resource.impl.BinaryGrammarResourceFactoryImpl()); if (!EPackage.Registry.INSTANCE.containsKey(org.eclipse.xtext.XtextPackage.eNS_URI)) EPackage.Registry.INSTANCE.put(org.eclipse.xtext.XtextPackage.eNS_URI, org.eclipse.xtext.XtextPackage.eINSTANCE); Injector injector = createInjector(); register(injector); return injector; }
@Override public Injector createInjectorAndDoEMFRegistration() { // register default ePackages if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "ecore", new EcoreResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xmi", new XMIResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xtextbin", new BinaryGrammarResourceFactoryImpl()); if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI)) EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE); Injector injector = createInjector(); register(injector); return injector; }
public Injector createInjectorAndDoEMFRegistration() { // register default ePackages if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "ecore", new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xmi", new org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xtextbin", new org.eclipse.xtext.resource.impl.BinaryGrammarResourceFactoryImpl()); if (!EPackage.Registry.INSTANCE.containsKey(org.eclipse.xtext.XtextPackage.eNS_URI)) EPackage.Registry.INSTANCE.put(org.eclipse.xtext.XtextPackage.eNS_URI, org.eclipse.xtext.XtextPackage.eINSTANCE); Injector injector = createInjector(); register(injector); return injector; }
public Injector createInjectorAndDoEMFRegistration() { // register default ePackages if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "ecore", new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xmi", new org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xtextbin", new org.eclipse.xtext.resource.impl.BinaryGrammarResourceFactoryImpl()); if (!EPackage.Registry.INSTANCE.containsKey(org.eclipse.xtext.XtextPackage.eNS_URI)) EPackage.Registry.INSTANCE.put(org.eclipse.xtext.XtextPackage.eNS_URI, org.eclipse.xtext.XtextPackage.eINSTANCE); Injector injector = createInjector(); register(injector); return injector; }
@Override public Injector createInjectorAndDoEMFRegistration() { // register default ePackages if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "ecore", new EcoreResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xmi", new XMIResourceFactoryImpl()); if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin")) Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( "xtextbin", new BinaryGrammarResourceFactoryImpl()); if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI)) EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE); Injector injector = createInjector(); register(injector); return injector; }
ExecEnv env = EmftvmFactory.eINSTANCE.createExecEnv(); ResourceSet rs = new ResourceSetImpl(); rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl()); rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("emftvm", new EMFTVMResourceFactoryImpl());
public static EObject loadEObjectFromString(String myModelXml, EPackage ePackage) throws IOException { // Create a ResourceSet ResourceSet resourceSet = new ResourceSetImpl(); // register XMIRegistryResourceFactoryIml resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put (Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); // register your epackage to the resource set so it has a reference to your ecore // you can get an instance to your epackage by calling YourEPackageClass.getInstace(); resourceSet.getPackageRegistry().put(ePackage.getNsURI(), ePackage); Resource resource = resourceSet.createResource(URI.createURI("*.modelextension")); resource.load(new URIConverter.ReadableInputStream(myModelXml), null); // return the root model object and there you have it, all you need is to // cast it to the right EObject based on your model return resource.getContents().get(0); }