KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > artifact > repository > DefaultArtifactRepository


1 package org.apache.maven.artifact.repository;
2
3 /*
4  * Copyright 2001-2005 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * 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
19 import org.apache.maven.artifact.Artifact;
20 import org.apache.maven.artifact.metadata.ArtifactMetadata;
21 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
22 import org.apache.maven.wagon.repository.Repository;
23
24 /**
25  * This class is an abstraction of the location from/to resources can be
26  * transfered.
27  *
28  * @author <a HREF="michal.maczka@dimatics.com">Michal Maczka </a>
29  * @version $Id: DefaultArtifactRepository.java 306560 2005-10-06 09:40:13Z brett $
30  */

31 public class DefaultArtifactRepository
32     extends Repository
33     implements ArtifactRepository
34 {
35     private final ArtifactRepositoryLayout layout;
36
37     private ArtifactRepositoryPolicy snapshots;
38
39     private ArtifactRepositoryPolicy releases;
40
41     private boolean uniqueVersion;
42
43     private boolean blacklisted;
44
45     /**
46      * Create a local repository or a test repository.
47      *
48      * @param id the unique identifier of the repository
49      * @param url the URL of the repository
50      * @param layout the layout of the repository
51      */

52     public DefaultArtifactRepository( String JavaDoc id, String JavaDoc url, ArtifactRepositoryLayout layout )
53     {
54         this( id, url, layout, null, null );
55     }
56
57     /**
58      * Create a remote deployment repository.
59      *
60      * @param id the unique identifier of the repository
61      * @param url the URL of the repository
62      * @param layout the layout of the repository
63      * @param uniqueVersion whether to assign each snapshot a unique version
64      */

65     public DefaultArtifactRepository( String JavaDoc id, String JavaDoc url, ArtifactRepositoryLayout layout, boolean uniqueVersion )
66     {
67         super( id, url );
68         this.layout = layout;
69         this.uniqueVersion = uniqueVersion;
70     }
71
72     /**
73      * Create a remote download repository.
74      *
75      * @param id the unique identifier of the repository
76      * @param url the URL of the repository
77      * @param layout the layout of the repository
78      * @param snapshots the policies to use for snapshots
79      * @param releases the policies to use for releases
80      */

81     public DefaultArtifactRepository( String JavaDoc id, String JavaDoc url, ArtifactRepositoryLayout layout,
82                                       ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases )
83     {
84         super( id, url );
85
86         this.layout = layout;
87
88         if ( snapshots == null )
89         {
90             snapshots = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
91                                                       ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
92         }
93
94         this.snapshots = snapshots;
95
96         if ( releases == null )
97         {
98             releases = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
99                                                      ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
100         }
101
102         this.releases = releases;
103     }
104
105     public String JavaDoc pathOf( Artifact artifact )
106     {
107         return layout.pathOf( artifact );
108     }
109
110     public String JavaDoc pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata )
111     {
112         return layout.pathOfRemoteRepositoryMetadata( artifactMetadata );
113     }
114
115     public String JavaDoc pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
116     {
117         return layout.pathOfLocalRepositoryMetadata( metadata, repository );
118     }
119
120     public ArtifactRepositoryLayout getLayout()
121     {
122         return layout;
123     }
124
125     public ArtifactRepositoryPolicy getSnapshots()
126     {
127         return snapshots;
128     }
129
130     public ArtifactRepositoryPolicy getReleases()
131     {
132         return releases;
133     }
134
135     public String JavaDoc getKey()
136     {
137         return getId();
138     }
139
140     public boolean isUniqueVersion()
141     {
142         return uniqueVersion;
143     }
144
145     public boolean isBlacklisted()
146     {
147         return blacklisted;
148     }
149
150     public void setBlacklisted( boolean blacklisted )
151     {
152         this.blacklisted = blacklisted;
153     }
154 }
155
Popular Tags