private boolean matches(Dependency defaultDependency, Dependency actualDependency) { if (defaultDependency.getArtifact().matches(actualDependency.getArtifact()) || actualDependency.getArtifact().matches(defaultDependency.getArtifact())) { return defaultDependency.getImportType() == actualDependency.getImportType() || actualDependency.getImportType() == ImportType.ALL; } return false; }
private LinkedHashSet<Artifact> resolveParentIds(ConfigurationData configurationData) throws MissingDependencyException, InvalidConfigException { Environment environment = configurationData.getEnvironment(); LinkedHashSet<Artifact> parentIds = new LinkedHashSet<Artifact>(); List<Dependency> dependencies = new ArrayList<Dependency>(environment.getDependencies()); for (ListIterator<Dependency> iterator = dependencies.listIterator(); iterator.hasNext();) { Dependency dependency = iterator.next(); Artifact resolvedArtifact = artifactResolver.resolveInClassLoader(dependency.getArtifact()); if (isConfiguration(resolvedArtifact)) { parentIds.add(resolvedArtifact); // update the dependency list to contain the resolved artifact dependency = new Dependency(resolvedArtifact, dependency.getImportType()); iterator.set(dependency); } else if (dependency.getImportType() == ImportType.SERVICES) { // Service depdendencies require that the depdencency be a configuration throw new InvalidConfigException("Dependency does not have services: " + resolvedArtifact); } } for (Iterator iterator = configurationData.getChildConfigurations().values().iterator(); iterator.hasNext();) { ConfigurationData childConfigurationData = (ConfigurationData) iterator.next(); LinkedHashSet<Artifact> childParentIds = resolveParentIds(childConfigurationData); // remove this configuration's id from the parent Ids since it will cause an infinite loop childParentIds.remove(configurationData.getId()); parentIds.addAll(childParentIds); } return parentIds; }
private Dependency resolveDependency(Collection parents, Dependency dependency, Stack<Dependency> parentStack) throws MissingDependencyException { Artifact artifact = dependency.getArtifact(); // if it is already resolved we are done if (artifact.isResolved()) { return dependency; } // we need an artifact resolver at this point if (artifactResolver == null) { throw new MissingDependencyException("Artifact is not resolved and there no artifact resolver available: " + artifact); } // resolve the artifact try { artifact = artifactResolver.resolveInClassLoader(artifact, parents); } catch (MissingDependencyException e) { // I'm throwing away the original error as the new message is lost on the stack as // most folks will drill down to the message on the bottom of the stack. StringBuffer sb = new StringBuffer(); sb.append(e.getMessage().trim()+"\n"+" Parent stack:\n"); boolean first = true; for (Dependency d : parentStack) { sb.append(" "+d.getArtifact().toString().trim()+(first?" (top)":"")+"\n"); first = false; } throw new MissingDependencyException(sb.toString()); } // build a new dependency object to contain the resolved artifact Dependency resolvedDependency = new Dependency(artifact, dependency.getImportType()); return resolvedDependency; }
private static DependencyType toDependencyType(Dependency dependency) { DependencyType dependencyType = DependencyType.Factory.newInstance(); fillArtifactType(dependency.getArtifact(), dependencyType); org.apache.geronimo.kernel.repository.ImportType importType = dependency.getImportType(); if (importType == org.apache.geronimo.kernel.repository.ImportType.CLASSES) { dependencyType.setImport(ImportType.CLASSES); } else if (importType == org.apache.geronimo.kernel.repository.ImportType.SERVICES) { dependencyType.setImport(ImportType.SERVICES); } return dependencyType; }
if (parentsById.containsKey(artifact)) { Configuration parent = parentsById.get(artifact); if (dependency.getImportType() == ImportType.CLASSES || dependency.getImportType() == ImportType.ALL) { classParents.add(parent); if (dependency.getImportType() == ImportType.SERVICES || dependency.getImportType() == ImportType.ALL) { serviceParents.add(parent); } else if (dependency.getImportType() == ImportType.SERVICES) { throw new IllegalStateException("Could not find parent " + artifact + " in the parents collection"); } else {