private String instance2fqn(Instance instance) { if (instance instanceof ContainerNode || instance instanceof Group || instance instanceof Channel) { return instance.getName() + ": " + instance.getTypeDefinition().getName() + "/" + instance.getTypeDefinition().getVersion(); } else { return ((NamedElement) instance.eContainer()).getName() + "." + instance.getName() + ": " + instance.getTypeDefinition().getName() + "/" + instance.getTypeDefinition().getVersion(); } } }
@Override public ClassLoader installTypeDefinition(Instance instance) throws KevoreeCoreException { TypeDefinition td = instance.getTypeDefinition(); DeployUnit du = validateFilters(instance, td.select("deployUnits[]/filters[name=platform,value=java]")); return installDeployUnit(du); }
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()); } }
private String searchMainClassName(final Instance instance) throws KevoreeCoreException { TypeDefinition td = instance.getTypeDefinition(); DeployUnit du = validateFilters(instance, td.select("deployUnits[]/filters[name=platform,value=java]")); 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()); } }
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 isInstallable(TypeDefinition tdef) { List<DeployUnit> dus = tdef.getDeployUnits(); for (DeployUnit du : dus) { Value platform = du.findFiltersByID("platform"); if (platform != null && platform.getValue().equals("java")) { return true; } } return false; }
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); } }
private static void apply(ContainerNode node, Group group) { group.removeSubNodes(node); node.removeGroups(group); FragmentDictionary fDic = group.findFragmentDictionaryByID(node.getName()); if (fDic != null) { group.removeFragmentDictionary(fDic); } } }
private static void apply(Instance leftH, ContainerNode targetNode) throws KevScriptException { if (leftH instanceof ComponentInstance) { targetNode.addComponents((ComponentInstance) leftH); } else { if (leftH instanceof ContainerNode) { targetNode.addHosts((ContainerNode) leftH); } else { throw new KevScriptException("\""+leftH.getName()+"\" is not a node instance nor a component. Move failed"); } } } }
private static void apply(Instance leftH, ContainerNode targetNode) { if (leftH instanceof ComponentInstance) { targetNode.addComponents((ComponentInstance) leftH); } else { if (leftH instanceof ContainerNode) { targetNode.addHosts((ContainerNode) leftH); } else { throw new KevScriptError("\""+leftH.getName()+"\" is not a node instance nor a component. Move failed"); } } } }
public String toString() { String s = "StartStopInstance " + c.getName(); if (start) { s += " start"; } else { s += " stop"; } return s; }
public static String fqnGroup(DeployUnit du) { StringBuilder buffer = new StringBuilder(); org.kevoree.Package pack = (org.kevoree.Package) du.eContainer(); while (pack != null) { buffer.insert(0, "."); buffer.insert(0, pack.getName()); if (pack.eContainer() != null && pack.eContainer() instanceof Package) { pack = (org.kevoree.Package) pack.eContainer(); } else { pack = null; } } return buffer.substring(0, buffer.length()-1); }
protected final Resolver next() throws KevScriptException { if (this.next != null) { return this.next; } else { throw new KevScriptException("No successor found"); } } }
@Override public void checkExit(int status) { throw new KevoreeSecurityManager.Exception("System exit attempted and blocked (only Kevoree can exit itself)"); }
private static void apply(ContainerNode node, Group group) { group.removeSubNodes(node); node.removeGroups(group); FragmentDictionary fDic = group.findFragmentDictionaryByID(node.getName()); if (fDic != null) { group.removeFragmentDictionary(fDic); } } }
public String toString() { return "AddInstance " + c.getName(); } }