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    /**
023     * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
024     */
025    public interface ArtifactResolver {
026    
027        /**
028         * Used to generate a fully-populated Artifact from a partially-populated Artifact
029         * when you're about to deploy/save a new artifact.  That is, this method comes up
030         * with reasonable default values that hopefully do not conflict with anything
031         * that's already deployed.
032         *
033         * @param source       The artifact to complete (normally partially-populated)
034         * @param defaultType  The type to use for the resulting artifact if the source
035         *                     artifact doesn't have a type set
036         *
037         * @return If the source artifact is fully populated (e.g. artifact.isResolved()
038         *         == true) then it will be returned.  Otherwise a new fully-populated
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        Artifact resolveInClassLoader(Artifact source) throws MissingDependencyException;
050    
051        /**
052         * Used to search for existing artifacts that match the supplied artifact (which
053         * may be partially-populated).  Preference is given to artifacts that are already
054         * loaded, or that exist in the parent configurations, to reduce duplication.  If
055         * nothing can be found that's an error, because something depends on this.
056         *
057         * @param parentConfigurations A Collection with entries of type Configuration
058         */
059        Artifact resolveInClassLoader(Artifact source, Collection parentConfigurations) throws MissingDependencyException;
060    
061        /**
062         * Used to search for existing artifacts that match the supplied artifact (which
063         * may be partially-populated).  Preference is given to artifacts that are already
064         * loaded, to reduce duplication.  If nothing can be found that's an error,
065         * because something depends on this.
066         *
067         * @return A sorted set ordered in the same way the input was ordered, with
068         *         entries of type Artifact
069         */
070        LinkedHashSet resolveInClassLoader(Collection artifacts) throws MissingDependencyException;
071    
072        /**
073         * Used to search for existing artifacts that match the supplied artifact (which
074         * may be partially-populated).  Preference is given to artifacts that are already
075         * loaded, or that exist in the parent configurations, to reduce duplication.  If
076         * nothing can be found that's an error, because something depends on this.
077         *
078         * @param parentConfigurations A Collection with entries of type Configuration
079         *
080         * @return A sorted set ordered in the same way the input was ordered, with
081         *         entries of type Artifact
082         */
083        LinkedHashSet resolveInClassLoader(Collection artifacts, Collection parentConfigurations) throws MissingDependencyException;
084    
085        /**
086         * Used to search for existing artifacts in the server that match the supplied
087         * artifact (which may be partially-populated).  This method expects either no
088         * results or one result (multiple matches is an error).
089         *
090         * @return A matching artifact, or null of there were no matches
091         */
092        Artifact queryArtifact(Artifact artifact) throws MultipleMatchesException;
093    
094        /**
095         * Used to search for existing artifacts in the server that match the supplied
096         * artifact (which may be partially-populated).
097         *
098         * TODO: The artifacts should be sorted ascending by type then group then artifact then version
099         *
100         * @return The matching artifacts, which may be 0, 1, or many
101         */
102        Artifact[] queryArtifacts(Artifact artifact);
103    }