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