private void monkeyPatchKMF(ContainerRoot proposedModel) { for (MBinding possibleBinding : proposedModel.getmBindings()) { String chanPath = (possibleBinding.getHub() != null ? possibleBinding.getHub().path() : "UNDEFINED"); String portPath = (possibleBinding.getPort() != null ? possibleBinding.getPort().path() : "UNDEFINED"); String hash = hash(chanPath + "_" + portPath); possibleBinding.reflexiveMutator(ActionType.SET, "generated_KMF_ID", hash, true, false); } }
public static void interpret(IAST<Type> stmt, ContainerRoot model, Map<String, String> ctxVars) throws KevScriptException { final List<Instance> channelsInstance2 = InstanceResolver.resolve(stmt.getChildren().get(1), model, ctxVars); final List<Port> ports = PortResolver.resolve(model, stmt.getChildren().get(0)); for (final Instance instance : channelsInstance2) { final Channel channel = (Channel) instance; MBinding toDrop = null; for (final MBinding mb : channel.getBindings()) { for (final Port p : ports) { if (mb.getPort().equals(p)) { toDrop = mb; } } } if (toDrop != null) { toDrop.delete(); } } } }
public static void interpret(IAST<Type> stmt, ContainerRoot model, Map<String, String> ctxVars) throws Exception { DefaultKevoreeFactory factory = new DefaultKevoreeFactory(); final List<Instance> channelsInstance = InstanceResolver.resolve(stmt.getChildren().get(1), model, ctxVars); for (final Instance instance : channelsInstance) { final Channel channel = (Channel) instance; final List<Port> ports = PortResolver.resolve(model, stmt.getChildren().get(0)); for (final Port p : ports) { final MBinding mb = factory.createMBinding(); mb.setPort(p); mb.setHub(channel); model.addMBindings(mb); } } } }
@Override public List<String> getRemotePortPaths() { ArrayList<String> result = new ArrayList<String>(); Channel channel = (Channel) modelService.getCurrentModel().getModel().findByPath(channelPath); if (channel != null) { for (MBinding binding : channel.getBindings()) { ContainerNode parentNode = (ContainerNode) binding.getPort().eContainer().eContainer(); if (parentNode != null) { if (!parentNode.getName().equals(localNodePath)) { org.kevoree.Port finalPort = binding.getPort(); if (finalPort != null) { result.add(finalPort.path()); } } } } } return result; } }
public static void interpret(IAST<Type> stmt, ContainerRoot model, Map<String, String> ctxVars) throws Exception { final List<Instance> toRemove = InstanceResolver.resolve(stmt.getChildren().get(0), model, ctxVars); for (final Instance toDrop : toRemove) { if (toDrop instanceof ComponentInstance) { final ComponentInstance ci = (ComponentInstance) toDrop; for (final Port p : ci.getProvided()) { for (final MBinding mb : p.getBindings()) { mb.delete(); } } for (final Port p : ci.getRequired()) { for (final MBinding mb : p.getBindings()) { mb.delete(); } } } toDrop.delete(); } } }
for (Port port : comp.getProvided()) { for (MBinding b : port.getBindings()) { if (b.getHub() != null && !channelsAlreadySeen.contains(b.getHub().path())) { Channel previousChannel = (Channel) currentModel.findByPath(b.getHub().path()); if (previousChannel != null) { traces.append(modelCompare.diff(previousChannel, b.getHub())); } else { traces.populate(deepToTrace(b.getHub(), nodeName)); channelsAlreadySeen.add(b.getHub().path()); if (b.getHub() != null && !channelsAlreadySeen.contains(b.getHub().path())) { Channel previousChannel = (Channel) currentModel.findByPath(b.getHub().path()); if (previousChannel != null) { traces.append(modelCompare.diff(previousChannel, b.getHub())); } else { traces.populate(deepToTrace(b.getHub(), nodeName)); channelsAlreadySeen.add(b.getHub().path());
public static void interpret(IAST<Type> stmt, ContainerRoot model, Map<String, String> ctxVars) throws Exception { final List<Instance> channelsInstance2 = InstanceResolver.resolve(stmt.getChildren().get(1), model, ctxVars); final List<Port> ports = PortResolver.resolve(model, stmt.getChildren().get(0)); for (final Instance instance : channelsInstance2) { final Channel channel = (Channel) instance; MBinding toDrop = null; for (final MBinding mb : channel.getBindings()) { for (final Port p : ports) { if (mb.getPort().equals(p)) { toDrop = mb; } } } if (toDrop != null) { toDrop.delete(); } } } }
public static void interpret(IAST<Type> stmt, ContainerRoot model, Map<String, String> ctxVars) throws KevScriptException { DefaultKevoreeFactory factory = new DefaultKevoreeFactory(); final List<Instance> channelsInstance = InstanceResolver.resolve(stmt.getChildren().get(1), model, ctxVars); for (final Instance instance : channelsInstance) { final Channel channel = (Channel) instance; final List<Port> ports = PortResolver.resolve(model, stmt.getChildren().get(0)); for (final Port p : ports) { final MBinding mb = factory.createMBinding(); mb.setPort(p); mb.setHub(channel); model.addMBindings(mb); } } } }
public static void interpret(IAST<Type> stmt, ContainerRoot model, Map<String, String> ctxVars) throws KevScriptException { final List<Instance> toRemove = InstanceResolver.resolve(stmt.getChildren().get(0), model, ctxVars); for (final Instance toDrop : toRemove) { if (toDrop instanceof ComponentInstance) { final ComponentInstance ci = (ComponentInstance) toDrop; for (final Port p : ci.getProvided()) { for (final MBinding mb : p.getBindings()) { mb.delete(); } } for (final Port p : ci.getRequired()) { for (final MBinding mb : p.getBindings()) { mb.delete(); } } } toDrop.delete(); } } }
if (trace instanceof ModelAddTrace) { MBinding binding = (MBinding) targetModel.findByPath(((ModelAddTrace) trace).getPreviousPath()); Channel channel = binding.getHub(); if (!isVirtual(channel.getTypeDefinition())) { adaptationModel.getAdaptations().add(adapt(AdaptationType.AddBinding, binding)); if (binding != null) { Channel chan = (Channel) targetModel.findByPath(binding.getHub().path()); boolean stillUsed = false; if (chan != null) { Channel oldChannel = binding.getHub(); if (!stillUsed && modelRegistry.lookup(oldChannel) != null) { TupleObjPrim removeTuple = new TupleObjPrim(oldChannel, AdaptationType.RemoveInstance);
private boolean isVirtual(KMFContainer element) { if (element instanceof Instance) { return isVirtual(((Instance) element).getTypeDefinition()); } else if (element instanceof TypeDefinition) { Value virtual = ((TypeDefinition) element).findMetaDataByID("virtual"); return virtual != null; } else if (element instanceof MBinding) { MBinding binding = (MBinding) element; if (binding.getHub() != null) { return isVirtual(binding.getHub().getTypeDefinition()); } if (binding.getPort() != null) { return isVirtual(binding.getPort().eContainer()); } } return false; }
private boolean isRelatedToPlatform(String nodeName, KMFContainer elem) { if (elem instanceof MBinding) { MBinding binding = (MBinding) elem; if (isRelatedToPlatform(nodeName, binding.getPort())) { return true; if (binding.getHub() != null) { return isRelatedToPlatform(nodeName, binding.getHub()); if (isRelatedToPlatform(nodeName, binding.getPort())) { return true;
@Override public boolean execute() { Object chan = registry.lookup(c.getHub()); Object comp = registry.lookup(c.getPort().eContainer()); if (chan != null && comp != null && comp instanceof ComponentWrapper && chan instanceof ChannelWrapper) { String portName = c.getPort().getPortTypeRef().getName(); RequiredPortImpl output = ((ComponentWrapper) comp).getRequiredPorts().get(portName); ProvidedPortImpl input = ((ComponentWrapper) comp).getProvidedPorts().get(portName); if (output == null && input == null) { Log.info("Port instance {} not found in component", portName); return false; } if (output != null) { output.addChannelWrapper(c, (ChannelWrapper) chan); Log.info("Bind {} {}", c.getPort().path(), c.getHub().path()); return true; } // Seems useless ((ChannelWrapper) chan).getContext().getBoundPorts().put(input.getPath(), input); Log.info("Bind {} {}", c.getPort().path(), c.getHub().path()); return true; } else { Log.error("Error while apply binding , channelFound=" + chan + ", componentFound=" + comp); return false; } }
public boolean execute() { try { Object kevoreeChannelFound = registry.lookup(c.getHub()); Object kevoreeComponentFound = registry.lookup(c.getPort().eContainer()); if(kevoreeChannelFound != null && kevoreeComponentFound != null && kevoreeComponentFound instanceof ComponentWrapper && kevoreeChannelFound instanceof ChannelWrapper){ String portName = c.getPort().getPortTypeRef().getName(); RequiredPortImpl foundNeedPort = ((ComponentWrapper) kevoreeComponentFound).getRequiredPorts().get(portName); ProvidedPortImpl foundHostedPort = ((ComponentWrapper) kevoreeComponentFound).getProvidedPorts().get(portName); if(foundNeedPort == null && foundHostedPort == null){ Log.info("Port instance not found in component"); return false; } if (foundNeedPort != null) { foundNeedPort.removeChannelWrapper(c); return true; } ((ChannelWrapper) kevoreeChannelFound).getContext().getPortsBinded().remove(foundHostedPort.getPath()); return true; } else { return false; } } catch (Exception e) { System.err.println("REMOVE BINDING FAILED"); e.printStackTrace(); } return false; }