public void removeChannelWrapper(MBinding binding) { delegate.remove(binding.getHub().path()+"_"+binding.getPort().path()); } }
public void addChannelWrapper(MBinding binding, ChannelWrapper chan) { delegate.put(binding.getHub().path()+"_"+binding.getPort().path(), chan); }
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); } }
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());
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; }
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; }
@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; } }
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);