@Nullable @Override public FlexyClassLoader installTypeDefinition(Instance instance) { TypeDefinition td = instance.getTypeDefinition(); List<KMFContainer> filters = td.select("deployUnits[]/filters[name=platform,value=java]"); if (filters.size() > 1) { String filtersStr = ""; for (int i=0; i < filters.size(); i++) { filtersStr += filters.get(i).eContainer().path(); if (i < filters.size() - 1) { filtersStr += ", "; } } throw new RuntimeException("Instance " + instance.path() + " has " + filters.size() + " deployUnits ("+filtersStr+") that matches platform \"java\" (must only be one)"); } DeployUnit du = (DeployUnit) filters.get(0).eContainer(); return installDeployUnit(du); }
private List<ModelTrace> deepToTrace(KMFContainer elem, final String currentNodeName) { final List<ModelTrace> result = new ArrayList<ModelTrace>(); result.addAll(elem.toTraces(true, true)); elem.visit(new ModelVisitor() { public void visit(KMFContainer child, String refNameInParent, KMFContainer parent) { if (child instanceof ContainerNode && !((ContainerNode) child).getName().equals(currentNodeName)) { noChildrenVisit(); noReferencesVisit(); //protection but should not be std case } else { result.addAll(child.toTraces(true, true)); } } }, true, true, false); return result; }
while (r.eContainer() != null) { r = r.eContainer();
public Object lookup(KMFContainer elem) { return registry.get(elem.path()); }
public void visit(KMFContainer child, String refNameInParent, KMFContainer parent) { if (child instanceof ContainerNode && !((ContainerNode) child).getName().equals(currentNodeName)) { noChildrenVisit(); noReferencesVisit(); //protection but should not be std case } else { result.addAll(child.toTraces(true, true)); } } }, true, true, false);
public KInstanceWrapper wrap(KMFContainer modelElement, Object newBeanInstance, ThreadGroup tg, BootstrapService bs, ModelService modelService) throws Exception { KInstanceWrapper wrapper = null; if (modelElement instanceof ComponentInstance) { wrapper = new ComponentWrapper(); } if (modelElement instanceof Group) { wrapper = new GroupWrapper(); } if (modelElement instanceof Channel) { wrapper = new ChannelWrapper(); } if (modelElement instanceof ContainerNode) { wrapper = new NodeWrapper(); } if (wrapper != null) { wrapper.setModelService(modelService); wrapper.setBs(bs); wrapper.setIsStarted(false); wrapper.setTg(tg); wrapper.setNodeName(nodeName); wrapper.setTargetObj(newBeanInstance); wrapper.setModelElement((Instance) modelElement); return wrapper; } else { throw new Exception("Unknow instance type " + modelElement.metaClassName()); } }
@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 drop(KMFContainer elem) { registry.remove(elem.path()); }
private String searchMainClassName(final Instance instance) { TypeDefinition td = instance.getTypeDefinition(); List<KMFContainer> filters = td.select("deployUnits[]/filters[name=platform,value=java]"); if (filters.size() > 1) { String filtersStr = ""; for (int i=0; i < filters.size(); i++) { filtersStr += filters.get(i).eContainer().path(); if (i < filters.size() - 1) { filtersStr += ", "; } } throw new RuntimeException("Instance " + instance.path() + " has " + filters.size() + " deployUnits ("+filtersStr+") that matches platform \"java\" (must only be one)"); } DeployUnit du = (DeployUnit) filters.get(0).eContainer(); String tag = "class:" + td.getName() + ":" + td.getVersion(); Value tdefClassName = du.findFiltersByID(tag); if (tdefClassName != null) { return tdefClassName.getValue(); } else { throw new RuntimeException("Cannot find meta-data \"" + tag + "\" in DeployUnit " + du.getHashcode() + "/" + du.getName() + "/" + du.getVersion()); } }
valueToInject = ((Value) previousValue).getValue(); } else { Instance instance = (Instance) dicValue.eContainer().eContainer(); DictionaryAttribute dicAtt = instance.getTypeDefinition().getDictionaryType().findAttributesByID(dicValue.getName()); if (dicAtt.getDefaultValue() != null && !dicAtt.getDefaultValue().equals("")) {
public void register(KMFContainer elem, Object obj) { registry.put(elem.path(), obj); }
TupleObjPrim updateVal = new TupleObjPrim(val, AdaptationType.UpdateDictionaryInstance); if (!elementAlreadyProcessed.containsKey(updateVal.getKey())) { Object[] values = new Object[] { val.eContainer().eContainer(), val }; adaptationModel.getAdaptations().add(adapt(AdaptationType.UpdateDictionaryInstance, values)); elementAlreadyProcessed.put(updateVal.getKey(), updateVal); TupleObjPrim updateVal = new TupleObjPrim(val, AdaptationType.UpdateDictionaryInstance); if (!elementAlreadyProcessed.containsKey(updateVal.getKey())) { Object[] values = new Object[] { val.eContainer().eContainer(), val }; adaptationModel.getAdaptations().add(adapt(AdaptationType.UpdateDictionaryInstance, values)); elementAlreadyProcessed.put(updateVal.getKey(), updateVal); if (modelElement.eContainer() instanceof ContainerNode && !modelElement.eContainer().path().equals(targetNode.path())) { if (trace instanceof ModelAddTrace) { if (modelElement instanceof Instance) { Instance currentModelElement = (Instance) currentModel.findByPath(modelElement.path()); Instance targetModelElement = (Instance) targetModel.findByPath(modelElement.path()); if (currentModelElement != null && targetModelElement != null) { if (modelElement.path().equals(targetNode.path())) { if (modelElement instanceof org.kevoree.Value && modelElement.eContainer() instanceof Dictionary) { Instance instance = (Instance) modelElement.eContainer().eContainer(); if (instance != null && instance instanceof ContainerNode && instance.getName().equals(nodeName) && currentNode == null) { KMFContainer dictionary = modelElement.eContainer(); if (dictionary != null && dictionary instanceof FragmentDictionary && !((FragmentDictionary) dictionary).getName().equals(nodeName)) {
if (elem != null && elem.eContainer() != null) { if (isRelatedToPlatform(nodeName, elem.eContainer())) { return true;
public void visit(KMFContainer elem, String refNameInParent, KMFContainer parent) { if (elem instanceof DeployUnit) { foundDeployUnitsToRemove.add(elem.path()); } //optimization purpose if ((elem instanceof ContainerNode && elem != currentNode)) { noChildrenVisit(); noReferencesVisit(); } }
private void debug(Value value) { Instance instance = (Instance) value.eContainer().eContainer(); DictionaryAttribute attr = instance.getTypeDefinition().getDictionaryType().findAttributesByID(value.getName()); if (attr.getFragmentDependant()) { Log.debug("Update param for {}.{}/{} = '{}'", instance.getName(), value.getName(), ((NamedElement) value.eContainer()).getName(), value.getValue()); } else { Log.debug("Update param for {}.{} = '{}'", instance.getName(), value.getName(), value.getValue()); } }
public String getKey() { return getObj().path() + "/" + p.name(); }
KMFContainer previousValue = previousModel.findByPath(dicValue.path()); if (previousValue == null) { Instance instance = (Instance) dicValue.eContainer().eContainer(); if (instance != null) { KMFContainer previousInstance = previousModel.findByPath(c.path());
public void visit(KMFContainer elem, String refNameInParent, KMFContainer parent) { if (elem instanceof DeployUnit) { DeployUnit elemDU = (DeployUnit) elem; if (elemDU.findFiltersByID("platform") == null || elemDU.findFiltersByID("platform").getValue().equals("java")) { if (modelRegistry.lookup(elem) == null) { adaptationModel.getAdaptations().add(adapt(AdaptationType.AddDeployUnit, elem)); adaptationModel.getAdaptations().add(adapt(AdaptationType.LinkDeployUnit, elem)); } foundDeployUnitsToRemove.remove(elem.path()); } } //optimization purpose if ((elem instanceof ContainerNode && elem != currentNode)) { noChildrenVisit(); noReferencesVisit(); } } }, true, true, true);