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 Map<String, String> getDUVersions(List<DeployUnit> dus) { Map<String, String> versions = new HashMap<>(); dus.forEach(du -> { String platform = du.findFiltersByID("platform").getValue(); versions.put(platform, du.getVersion()); }); return versions; } }
private String printDesc(TypeDefinition tdef) { Value descMeta = tdef.findMetaDataByID("description"); if (descMeta != null) { String desc = descMeta.getValue(); if (desc.isEmpty()) { return "<none>"; } else { if (desc.length() > 50) { return desc.substring(0, 50) + "..."; } else { return desc; } } } else { return "<none>"; } }
@NotNull @Override public void injectDictionaryValue(Value dictionaryValue, Object target) { internalInjectField(dictionaryValue.getName(), dictionaryValue.getValue(), target); }
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 Map<String, String> getRepositories(DeployUnit deployUnit) { Map<String, String> repositories = new HashMap<>(); // hacky way to treat Maven repositories as I don't want to change the Kevoree MM for (Value val : deployUnit.getFilters()) { if (val.getName().startsWith("repo_")) { repositories.put(val.getName().substring(5), val.getValue()); } } return repositories; }
private boolean checkDUS(TypeDefinition tdef, Map<String, Object> duVersions) { boolean satisfied = true; for (Map.Entry<String, Object> entry : duVersions.entrySet()) { boolean found = false; for (int i=0; i < tdef.getDeployUnits().size(); i++) { DeployUnit du = tdef.getDeployUnits().get(i); String p = du.findFiltersByID("platform").getValue(); if (p.equals(entry.getKey()) && du.getVersion().equals(entry.getValue().toString())) { found = true; break; } } if (!found) { satisfied = false; break; } } return satisfied; } }
private ConfigurableMavenResolverSystem getResolver(DeployUnit deployUnit) { String offlineProp = System.getProperty("offline", "false"); boolean offline = Boolean.valueOf(offlineProp); ConfigurableMavenResolverSystem resolver = Maven .configureResolver() .useLegacyLocalRepo(true) .workOffline(offline); try { LogManager.getLogManager().readConfiguration(new FileInputStream(propFile)); } catch (IOException e) { throw new RuntimeException("Unable to read " + propFile.getAbsolutePath()); } // hacky way to treat Maven repositories as I don't want to change the Kevoree MM for (Value val : deployUnit.getFilters()) { if (val.getName().startsWith("repo_")) { try { resolver.withRemoteRepo(val.getName().substring(5), new URL(val.getValue()), "default"); } catch (MalformedURLException e) { throw new RuntimeException("Invalid repository URL: " + val.getValue()); } } } return resolver; }
private void saveDeployUnit(TypeFQN fqn, DeployUnit du) { Path path = getDUPath(fqn, du.findFiltersByID("platform").getValue(), du.getVersion()); String modelStr = serializer.serialize(du); writeFile(path.toFile(), modelStr); }
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);
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()); } }
@Override public ClassLoader installDeployUnit(DeployUnit du) throws KevoreeCoreException { Value kevVersion = du.findFiltersByID("kevoree_version"); if (kevVersion == null || kevVersion.getValue() == null) { throw new KevoreeCoreException("DeployUnit " + du.getName() + ":" + du.getVersion() + " is incompatible with current runtime v" + core.getFactory().getVersion()); } else if (!kevVersion.getValue().equals(core.getFactory().getVersion())) { throw new KevoreeCoreException("DeployUnit " + du.getName() + ":" + du.getVersion() + " targets v" + kevVersion.getValue() + " which is incompatible with current runtime v" + core.getFactory().getVersion());
KMFContainer previousValue = modelService.getCurrentModel().getModel().findByPath(dicValue.path()); if (previousValue != null && previousValue instanceof Value) { valueToInject = ((Value) previousValue).getValue(); } else { Instance instance = (Instance) dicValue.eContainer().eContainer();
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 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()); } }
if (!desc.getValue().isEmpty()) { tdef.addMetaData(desc);
private void processDeployUnit(ContainerRoot model, List<KMFContainer> tdefs, DeployUnit du) throws MojoExecutionException { String platform = du.findFiltersByID("platform").getValue();
DictionaryAttribute dicAtt = dt.findAttributesByID(dicValue.getName()); if (dicAtt != null && dicAtt.getDefaultValue() != null && dicAtt.getDefaultValue().equals(dicValue.getValue())) { return true;
param.setValue(attr.getDefaultValue()); node.getDictionary().addValues(param); Log.debug("Set default node param: {} = '{}'", param.getName(), param.getValue());