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: */package org.apache.geronimo.kernel.repository;
017:
018: import java.util.Collection;
019: import java.util.LinkedHashSet;
020:
021: import org.apache.geronimo.kernel.config.Configuration;
022:
023: /**
024: * @version $Rev: 566893 $ $Date: 2007-08-16 17:52:52 -0700 (Thu, 16 Aug 2007) $
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-resolved)
035: * @param defaultType The type to use for the resulting artifact if the source
036: * artifact doesn't have a type set
037: * @return If the source artifact is fully resolved (e.g. artifact.isResolved()
038: * == true) then it will be returned. Otherwise a new fully-resolved
039: * artifact is returned.
040: */
041: Artifact generateArtifact(Artifact source, String defaultType);
042:
043: /**
044: * Used to search for existing artifacts that match the supplied artifact (which
045: * may be partially-populated). Preference is given to artifacts that are already
046: * loaded, to reduce duplication. If nothing can be found that's an error,
047: * because something depends on this.
048: *
049: * @param source incompletely resolved Artifact
050: * @return completely resolved Artifact matching the source
051: * @throws MissingDependencyException if no matching Artifact can be found.
052: */
053: Artifact resolveInClassLoader(Artifact source)
054: 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,
068: Collection<Configuration> parentConfigurations)
069: throws MissingDependencyException;
070:
071: /**
072: * Used to search for existing artifacts that match the supplied artifact (which
073: * may be partially-populated). Preference is given to artifacts that are already
074: * loaded, to reduce duplication. If nothing can be found that's an error,
075: * because something depends on this.
076: *
077: * @param sources incompletely resolved Artifact
078: * @return A sorted set ordered in the same way the input was ordered, with
079: * entries of type Artifact
080: * @throws MissingDependencyException if no matching Artifact can be found.
081: */
082: LinkedHashSet<Artifact> resolveInClassLoader(
083: Collection<Artifact> sources)
084: throws MissingDependencyException;
085:
086: /**
087: * Used to search for existing artifacts that match the supplied artifact (which
088: * may be partially-populated). Preference is given to artifacts that are already
089: * loaded, or that exist in the parent configurations, to reduce duplication. If
090: * nothing can be found that's an error, because something depends on this.
091: *
092: * @param sources incompletely resolved Artifacts to match
093: * @param parentConfigurations Configurations to search in
094: * @return A sorted set ordered in the same way the input was ordered, with
095: * entries of type Artifact
096: * @throws MissingDependencyException if no matching Artifact can be found.
097: */
098: LinkedHashSet<Artifact> resolveInClassLoader(
099: Collection<Artifact> sources,
100: Collection<Configuration> parentConfigurations)
101: throws MissingDependencyException;
102:
103: /**
104: * Used to search for existing artifacts in the server that match the supplied
105: * artifact (which may be partially-populated). This method expects either no
106: * results or one result (multiple matches is an error).
107: *
108: * @param artifact incompletely resolved artifact to match
109: * @return A matching artifact, or null of there were no matches
110: * @throws MultipleMatchesException if there is more than one match
111: */
112: Artifact queryArtifact(Artifact artifact)
113: throws MultipleMatchesException;
114:
115: /**
116: * Used to search for existing artifacts in the server that match the supplied
117: * artifact (which may be partially-populated).
118: * <p/>
119: * TODO: The artifacts should be sorted ascending by type then group then artifact then version
120: *
121: * @param artifact the Artifact to match.
122: * @return The matching artifacts, which may be 0, 1, or many
123: */
124: Artifact[] queryArtifacts(Artifact artifact);
125: }
|