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: */
018: package org.apache.ivy.plugins.resolver;
019:
020: import java.io.File;
021: import java.io.IOException;
022: import java.text.ParseException;
023: import java.util.Map;
024:
025: import org.apache.ivy.core.cache.RepositoryCacheManager;
026: import org.apache.ivy.core.module.descriptor.Artifact;
027: import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
028: import org.apache.ivy.core.module.id.ModuleRevisionId;
029: import org.apache.ivy.core.report.DownloadReport;
030: import org.apache.ivy.core.resolve.DownloadOptions;
031: import org.apache.ivy.core.resolve.ResolveData;
032: import org.apache.ivy.core.resolve.ResolvedModuleRevision;
033: import org.apache.ivy.core.search.ModuleEntry;
034: import org.apache.ivy.core.search.OrganisationEntry;
035: import org.apache.ivy.core.search.RevisionEntry;
036: import org.apache.ivy.plugins.resolver.util.ResolvedResource;
037:
038: /**
039: *
040: */
041: public interface DependencyResolver {
042: String getName();
043:
044: /**
045: * Should only be used by configurator
046: *
047: * @param name
048: * the new name of the resolver
049: */
050: void setName(String name);
051:
052: /**
053: * Resolve a module by id, getting its module descriptor and resolving the revision if it's a
054: * latest one (i.e. a revision uniquely identifying the revision of a module in the current
055: * environment - If this revision is not able to identify uniquelely the revision of the module
056: * outside of the current environment, then the resolved revision must begin by ##)
057: *
058: * @throws ParseException
059: */
060: ResolvedModuleRevision getDependency(DependencyDescriptor dd,
061: ResolveData data) throws ParseException;
062:
063: /**
064: * Finds the module descriptor for the specified <tt>DependencyDescriptor</tt>.
065: * If this resolver can't find the module descriptor, <tt>null</tt> is returned.
066: *
067: * @param dd the dependency descriptor
068: * @param data the resolve data
069: * @return the module descriptor, or <tt>null</tt>
070: */
071: ResolvedResource findIvyFileRef(DependencyDescriptor dd,
072: ResolveData data);
073:
074: DownloadReport download(Artifact[] artifacts,
075: DownloadOptions options);
076:
077: boolean exists(Artifact artifact);
078:
079: void publish(Artifact artifact, File src, boolean overwrite)
080: throws IOException;
081:
082: void beginPublishTransaction(ModuleRevisionId module,
083: boolean overwrite) throws IOException;
084:
085: void abortPublishTransaction() throws IOException;
086:
087: void commitPublishTransaction() throws IOException;
088:
089: /**
090: * Reports last resolve failure as Messages
091: */
092: void reportFailure();
093:
094: /**
095: * Reports last artifact download failure as Messages
096: *
097: * @param art
098: */
099: void reportFailure(Artifact art);
100:
101: // listing methods, enable to know what is available from this resolver
102: // the listing methods must only list entries directly
103: // available from them, no recursion is needed as long as sub resolvers
104: // are registered in ivy too.
105:
106: /**
107: * List all the values the given token can take if other tokens are set as described in the
108: * otherTokenValues map. For instance, if token = "revision" and the map contains
109: * "organisation"->"foo" "module"->"bar" The results will be the list of revisions of the module
110: * bar from the org foo.
111: */
112: String[] listTokenValues(String token, Map otherTokenValues);
113:
114: OrganisationEntry[] listOrganisations();
115:
116: ModuleEntry[] listModules(OrganisationEntry org);
117:
118: RevisionEntry[] listRevisions(ModuleEntry module);
119:
120: void dumpSettings();
121:
122: void setSettings(ResolverSettings settings);
123:
124: /**
125: * Returns the {@link RepositoryCacheManager} used to manage the repository cache associated
126: * with this dependency resolver.
127: *
128: * @return the {@link RepositoryCacheManager} used to manage the repository cache associated
129: * with this dependency resolver.
130: */
131: RepositoryCacheManager getRepositoryCacheManager();
132: }
|