Intro

In Memory model are useful for holding a model in a java application without having to write to to a file as many examples show, this is very useful when deploying to cloud or AWS services.

UML Example

    ResourceSet resourceSet = new ResourceSetImpl();

    //creates required uml packages
    EPackage ePackage = EcorePackage.eINSTANCE;
    resourceSet.getPackageRegistry().put(ePackage.getNsURI(), ePackage);
    resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new UMLResourceFactoryImpl());
    Resource resource = resourceSet.createResource(URI.createURI(UMLPackage.eNS_URI));

    //adds the model string
    resource.load(new ByteArrayInputStream(modelContents), null);

    InMemoryEmfModel modelMem = new InMemoryEmfModel(resource);
    //the In memeory model that can then be based into and EVL, EOL , etc.
    modelMem.setName("UMLModel");

Plain XML example

    var model = new PlainXmlModel();
    model.setName("XMLModel");
    //this will be a string of the model (usually from a Frontend)
    model.setXml(modelContent);
    model.load();