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); }
@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 void setModelElement(Instance modelElement) { super.setModelElement(modelElement); ComponentInstance instance = (ComponentInstance) getModelElement(); for (Port requiredPort : instance.getRequired()) { Field field = recursivelyLookForDeclaredRequiredPort(requiredPort.getPortTypeRef().getName(), getTargetObj().getClass()); if (field != null) { if (!field.isAccessible()) { field.setAccessible(true); } RequiredPortImpl portWrapper = new RequiredPortImpl(requiredPort.path()); try { field.set(getTargetObj(), portWrapper); } catch (IllegalAccessException e) { e.printStackTrace(); } requiredPorts.put(requiredPort.getPortTypeRef().getName(), portWrapper); } else { Log.warn("A required Port is defined at the model level but is not available at the implementation level"); } } for (Port providedPort : instance.getProvided()) { ProvidedPortImpl portWrapper = new ProvidedPortImpl(getTargetObj(), providedPort.getPortTypeRef().getName(), providedPort.path(), this); providedPorts.put(providedPort.getPortTypeRef().getName(), portWrapper); } }
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); } }
@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; } }