Closed maxleiko closed 10 years ago
import org.kevoree.impl.DefaultKevoreeFactory import org.kevoree.*; import org.kevoree.modeling.api.ModelSerializer; import org.kevoree.serializer.JSONModelSerializer; import org.kevoree.modeling.api.events.ModelElementListener; import org.kevoree.modeling.api.events.ModelEvent; import java.io.PrintWriter fun main(args: Array<String>) { var factory : KevoreeFactory = DefaultKevoreeFactory(); var model : ContainerRoot = factory.createContainerRoot(); var node : ContainerNode = factory.createContainerNode(); node.name = "node0"; model.addNodes(node); var grp : Group = factory.createGroup(); grp.name = "grp"; model.addGroups(grp); grp.addSubNodes(node); var comp : ComponentInstance = factory.createComponentInstance(); comp.name = "comp"; node.addComponents(comp); var chan : Channel = factory.createChannel(); chan.name = "chan"; model.addHubs(chan); var port : Port = factory.createPort(); port.name = "output"; comp.addRequired(port); var binding : MBinding = factory.createMBinding(); binding.hub = chan; binding.port = port; model.addMBindings(binding); node.addModelElementListener(object: ModelElementListener { override fun elementChanged(e: ModelEvent) { println(e.toString()); } }); node.delete(); // chan.delete(); var save : ModelSerializer = JSONModelSerializer(); var modelStr : String = save.serialize(model)!!; var writer : PrintWriter = PrintWriter("model.json", "UTF-8"); writer.write(modelStr); writer.close(); }
Saved model will still contain bindings to removed component Sample project
fixed in 1.10.0 and next Kevoree version , thx for the tricky but maxime :-)
Saved model will still contain bindings to removed component Sample project