View Javadoc

1   /**
2    *
3    *  Licensed to the Apache Software Foundation (ASF) under one or more
4    *  contributor license agreements.  See the NOTICE file distributed with
5    *  this work for additional information regarding copyright ownership.
6    *  The ASF licenses this file to You under the Apache License, Version 2.0
7    *  (the "License"); you may not use this file except in compliance with
8    *  the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing, software
13   *  distributed under the License is distributed on an "AS IS" BASIS,
14   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *  See the License for the specific language governing permissions and
16   *  limitations under the License.
17   */
18  package org.apache.geronimo.kernel.repository;
19  
20  import java.util.Collection;
21  import java.util.LinkedHashSet;
22  
23  /**
24   * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $
25   */
26  public interface ArtifactResolver {
27  
28      /**
29       * Used to generate a fully-populated Artifact from a partially-populated Artifact
30       * when you're about to deploy/save a new artifact.  That is, this method comes up
31       * with reasonable default values that hopefully do not conflict with anything
32       * that's already deployed.
33       *
34       * @param source       The artifact to complete (normally partially-populated)
35       * @param defaultType  The type to use for the resulting artifact if the source
36       *                     artifact doesn't have a type set
37       *
38       * @return If the source artifact is fully populated (e.g. artifact.isResolved()
39       *         == true) then it will be returned.  Otherwise a new fully-populated
40       *         artifact is returned.
41       */
42      Artifact generateArtifact(Artifact source, String defaultType);
43  
44      /**
45       * Used to search for existing artifacts that match the supplied artifact (which
46       * may be partially-populated).  Preference is given to artifacts that are already
47       * loaded, to reduce duplication.  If nothing can be found that's an error,
48       * because something depends on this.
49       */
50      Artifact resolveInClassLoader(Artifact source) throws MissingDependencyException;
51  
52      /**
53       * Used to search for existing artifacts that match the supplied artifact (which
54       * may be partially-populated).  Preference is given to artifacts that are already
55       * loaded, or that exist in the parent configurations, to reduce duplication.  If
56       * nothing can be found that's an error, because something depends on this.
57       *
58       * @param parentConfigurations A Collection with entries of type Configuration
59       */
60      Artifact resolveInClassLoader(Artifact source, Collection parentConfigurations) throws MissingDependencyException;
61  
62      /**
63       * Used to search for existing artifacts that match the supplied artifact (which
64       * may be partially-populated).  Preference is given to artifacts that are already
65       * loaded, to reduce duplication.  If nothing can be found that's an error,
66       * because something depends on this.
67       *
68       * @return A sorted set ordered in the same way the input was ordered, with
69       *         entries of type Artifact
70       */
71      LinkedHashSet resolveInClassLoader(Collection artifacts) throws MissingDependencyException;
72  
73      /**
74       * Used to search for existing artifacts that match the supplied artifact (which
75       * may be partially-populated).  Preference is given to artifacts that are already
76       * loaded, or that exist in the parent configurations, to reduce duplication.  If
77       * nothing can be found that's an error, because something depends on this.
78       *
79       * @param parentConfigurations A Collection with entries of type Configuration
80       *
81       * @return A sorted set ordered in the same way the input was ordered, with
82       *         entries of type Artifact
83       */
84      LinkedHashSet resolveInClassLoader(Collection artifacts, Collection parentConfigurations) throws MissingDependencyException;
85  
86      /**
87       * Used to search for existing artifacts in the server that match the supplied
88       * artifact (which may be partially-populated).  This method expects either no
89       * results or one result (multiple matches is an error).
90       *
91       * @return A matching artifact, or null of there were no matches
92       */
93      Artifact queryArtifact(Artifact artifact) throws MultipleMatchesException;
94  
95      /**
96       * Used to search for existing artifacts in the server that match the supplied
97       * artifact (which may be partially-populated).
98       *
99       * 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 }