001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.geronimo.kernel.repository; 018 019 import java.util.Collection; 020 import java.util.LinkedHashSet; 021 022 import org.apache.geronimo.kernel.config.Configuration; 023 024 /** 025 * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $ 026 */ 027 public interface ArtifactResolver { 028 029 /** 030 * Used to generate a fully-populated Artifact from a partially-populated Artifact 031 * when you're about to deploy/save a new artifact. That is, this method comes up 032 * with reasonable default values that hopefully do not conflict with anything 033 * that's already deployed. 034 * 035 * @param source The artifact to complete (normally partially-resolved) 036 * @param defaultType The type to use for the resulting artifact if the source 037 * artifact doesn't have a type set 038 * @return If the source artifact is fully resolved (e.g. artifact.isResolved() 039 * == true) then it will be returned. Otherwise a new fully-resolved 040 * artifact is returned. 041 */ 042 Artifact generateArtifact(Artifact source, String defaultType); 043 044 /** 045 * Used to search for existing artifacts that match the supplied artifact (which 046 * may be partially-populated). Preference is given to artifacts that are already 047 * loaded, to reduce duplication. If nothing can be found that's an error, 048 * because something depends on this. 049 * 050 * @param source incompletely resolved Artifact 051 * @return completely resolved Artifact matching the source 052 * @throws MissingDependencyException if no matching Artifact can be found. 053 */ 054 Artifact resolveInClassLoader(Artifact source) throws MissingDependencyException; 055 056 /** 057 * Used to search for existing artifacts that match the supplied artifact (which 058 * may be partially-populated). Preference is given to artifacts that are already 059 * loaded, or that exist in the parent configurations, to reduce duplication. If 060 * nothing can be found that's an error, because something depends on this. 061 * 062 * @param source incompletely resolved Artifact 063 * @param parentConfigurations A Collection with entries of type Configuration 064 * @return completely resolved Artifact matching the source 065 * @throws MissingDependencyException if no matching Artifact can be found. 066 */ 067 Artifact resolveInClassLoader(Artifact source, Collection<Configuration> parentConfigurations) throws MissingDependencyException; 068 069 /** 070 * Used to search for existing artifacts that match the supplied artifact (which 071 * may be partially-populated). Preference is given to artifacts that are already 072 * loaded, to reduce duplication. If nothing can be found that's an error, 073 * because something depends on this. 074 * 075 * @param sources incompletely resolved Artifact 076 * @return A sorted set ordered in the same way the input was ordered, with 077 * entries of type Artifact 078 * @throws MissingDependencyException if no matching Artifact can be found. 079 */ 080 LinkedHashSet<Artifact> resolveInClassLoader(Collection<Artifact> sources) throws MissingDependencyException; 081 082 /** 083 * Used to search for existing artifacts that match the supplied artifact (which 084 * may be partially-populated). Preference is given to artifacts that are already 085 * loaded, or that exist in the parent configurations, to reduce duplication. If 086 * nothing can be found that's an error, because something depends on this. 087 * 088 * @param sources incompletely resolved Artifacts to match 089 * @param parentConfigurations Configurations to search in 090 * @return A sorted set ordered in the same way the input was ordered, with 091 * entries of type Artifact 092 * @throws MissingDependencyException if no matching Artifact can be found. 093 */ 094 LinkedHashSet<Artifact> resolveInClassLoader(Collection<Artifact> sources, Collection<Configuration> parentConfigurations) throws MissingDependencyException; 095 096 /** 097 * Used to search for existing artifacts in the server that match the supplied 098 * artifact (which may be partially-populated). This method expects either no 099 * results or one result (multiple matches is an error). 100 * 101 * @param artifact incompletely resolved artifact to match 102 * @return A matching artifact, or null of there were no matches 103 * @throws MultipleMatchesException if there is more than one match 104 */ 105 Artifact queryArtifact(Artifact artifact) throws MultipleMatchesException; 106 107 /** 108 * Used to search for existing artifacts in the server that match the supplied 109 * artifact (which may be partially-populated). 110 * <p/> 111 * TODO: The artifacts should be sorted ascending by type then group then artifact then version 112 * 113 * @param artifact the Artifact to match. 114 * @return The matching artifacts, which may be 0, 1, or many 115 */ 116 Artifact[] queryArtifacts(Artifact artifact); 117 }