@Test public void testEventTrace() { KevoreeFactory factory = new DefaultKevoreeFactory(); ContainerRoot model = factory.createContainerRoot(); ContainerNode node0 = factory.createContainerNode(); node0.setName("node0"); model.addNodes(node0); ContainerNode web = factory.createContainerNode(); web.setName("web"); model.addNodes(web); node0.addHosts(web); try { ContainerRoot clonedModel = (ContainerRoot) cloner.clone(model); EventListenerImpl listener = new EventListenerImpl(); model.addModelTreeListener(listener); ContainerNode newChildNode = factory.createContainerNode(); newChildNode.setName("toto"); model.addNodes(newChildNode); node0.addHosts(newChildNode); listener.traceSequence.applyOn(clonedModel); } catch (Exception e) { e.printStackTrace(); } }
@Override public void execute(Object p) { if (p instanceof ComponentPanel && !(p instanceof ComponentTypePanel)) { ComponentPanel panel = (ComponentPanel) p; ContainerNode node = (ContainerNode) kernel.getUifactory().getMapping().get(nodepanel); ComponentInstance type = (ComponentInstance) kernel.getUifactory().getMapping().get(p); if (!node.getComponents().contains(type)) { panel.getParent().remove(panel); nodepanel.add(panel); node.addComponents(type); } kernel.getModelHandler().notifyChanged(); } }
private String[] getWebServerName(ContainerRoot model) { for (ContainerNode node : model.getNodes()) { for (ComponentInstance component : node.getComponents()) { // for (TypeDefinition typeDefinition : // component.getTypeDefinition().getSuperTypesForJ()) { org.kevoree.log.Log.debug(component.getTypeDefinition().getName()); if ("SprayWebServer" .equals( component .getTypeDefinition() .getName())) { // must be change if the webserver implementation is changed return new String[] {component.getName(), node.getName()}; } // } } } return null; }
@Override public void triggerModelUpdate() { if (starting) { final Option<ContainerRoot> modelOption = NodeNetworkHelper.updateModelWithNetworkProperty(this); if (modelOption.isDefined()) { new Thread() { public void run() { getModelService().unregisterModelListener(getModelListener()); getModelService().atomicUpdateModel(modelOption.get()); getModelService().registerModelListener(getModelListener()); } }.start(); } starting = false; } else { Group group = getModelElement(); for (ContainerNode subNode : group.getSubNodesForJ()) { if (!subNode.getName().equals(this.getNodeName())) { internalPush(getModelService().getLastModel(), subNode.getName(), this.getNodeName()); } } } }