private DeployUnit getJavaDeployUnit(Instance instance) { TypeDefinition tdef = instance.getTypeDefinition(); if (tdef != null) { return tdef.getDeployUnits().stream().filter(du -> { Value filter = du.findFiltersByID("platform"); return filter != null && filter.getValue() != null && filter.getValue().equals("java"); }).findFirst().orElse(null); } return null; }
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(); } } }
@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); }
public boolean execute() { List<KMFContainer> metas = c.getTypeDefinition().select("deployUnits[]/filters[name=platform,value=java]"); if (metas.isEmpty()) { Log.error("No DeployUnit found for '" + c.getName() + ": " + c.getTypeDefinition().getName() + "/" + c.getTypeDefinition().getVersion() + "' that matches the 'java' platform"); return false; } Thread subThread = null; try { tg = new KevoreeThreadGroup("kev/" + c.path()); subThread = new Thread(tg, this); subThread.start(); subThread.join(); return resultSub; } catch (Throwable e) { if (subThread != null) { try { //subThread.stop(); //kill sub thread subThread.interrupt(); } catch (Throwable t) { //ignore killing thread } } Log.error("Could not add the instance {}:{}", c.getName(), c.getTypeDefinition().getName(), e); return false; } }
@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 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()); } }
public static FlexyClassLoader createInstanceClassLoader(Instance c, String nodeName, BootstrapService bs) { if (c instanceof ContainerNode && ((ContainerNode) c).getHost() != null && ((ContainerNode) c).getHost().getName().equals(nodeName)) { return createTypeClassLoader(((ContainerNode) c).getHost().getTypeDefinition(), nodeName, bs); } else { return createTypeClassLoader(c.getTypeDefinition(), nodeName, bs); } }
} else { Instance instance = (Instance) dicValue.eContainer().eContainer(); DictionaryAttribute dicAtt = instance.getTypeDefinition().getDictionaryType().findAttributesByID(dicValue.getName()); if (dicAtt.getDefaultValue() != null && !dicAtt.getDefaultValue().equals("")) { valueToInject = dicAtt.getDefaultValue();
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()); } }
@NotNull @Override public void injectDictionary(Instance instance, Object target, boolean defaultOnly) { if (instance.getTypeDefinition() == null || instance.getTypeDefinition().getDictionaryType() == null) { return; for (DictionaryAttribute att : instance.getTypeDefinition().getDictionaryType().getAttributes()) { String defValue = null; String value = null;
@Override public Object createInstance(final Instance instance, final FlexyClassLoader classLoader) { try { final String mainClassName = searchMainClassName(instance); final Class clazz = classLoader.loadClass(mainClassName); final Object newInstance = clazz.newInstance(); injector.register(Context.class, new InstanceContext(instance.path(), nodeName, instance.getName())); injector.register(ModelService.class, new ContextAwareAdapter(core, instance.path())); injector.register(PlatformService.class, core); injector.inject(newInstance); return newInstance; } catch (final Exception e) { Log.error("Error while creating instance \"{}\" of type {}", e, instance.getName(), instance.getTypeDefinition().getName()); } return null; }
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; }
if (dicValue == null) { dicValue = factory.createValue(); if (target.getTypeDefinition().getDictionaryType() != null) { final DictionaryAttribute dicAtt = target.getTypeDefinition().getDictionaryType() .findAttributesByID(propName); if (dicAtt == null) { if (dicValue == null) { dicValue = factory.createValue(); if (target.getTypeDefinition().getDictionaryType() != null) { final DictionaryAttribute dicAtt = target.getTypeDefinition().getDictionaryType() .findAttributesByID(propName); if (dicAtt == null) {
if (dicValue == null) { dicValue = factory.createValue(); if (target.getTypeDefinition().getDictionaryType() != null) { final DictionaryAttribute dicAtt = target.getTypeDefinition().getDictionaryType() .findAttributesByID(propName); if (dicAtt == null) { if (dicValue == null) { dicValue = factory.createValue(); if (target.getTypeDefinition().getDictionaryType() != null) { final DictionaryAttribute dicAtt = target.getTypeDefinition().getDictionaryType() .findAttributesByID(propName); if (dicAtt == null) {
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()); } }
i.setStarted(true); Dictionary dictionary = factory.createDictionary().withGenerated_KMF_ID("0.0"); DictionaryType dictionaryType = i.getTypeDefinition().getDictionaryType(); if (dictionaryType != null) { for (DictionaryAttribute attr : dictionaryType.getAttributes()) {
i.setStarted(true); Dictionary dictionary = factory.createDictionary().withGenerated_KMF_ID("0.0"); DictionaryType dictionaryType = i.getTypeDefinition().getDictionaryType(); if (dictionaryType != null) { for (DictionaryAttribute attr : dictionaryType.getAttributes()) {
KMFContainer previousInstance = previousModel.findByPath(c.path()); if (previousInstance != null) { DictionaryType dt = instance.getTypeDefinition().getDictionaryType(); DictionaryAttribute dicAtt = dt.findAttributesByID(dicValue.getName()); if (dicAtt != null && dicAtt.getDefaultValue() != null