1 package org.apache.maven.repository.proxy.configuration;
4 * Copyright 2005-2006 The Apache Software Foundation.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 import org.apache.maven.artifact.repository.ArtifactRepository;
20 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
21 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
22 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
23 import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
24 import org.apache.maven.repository.proxy.repository.ProxyRepository;
26 import java.util.ArrayList;
27 import java.util.Collections;
28 import java.util.List;
31 * Class to represent the configuration file for the proxy
33 * @author Edwin Punzalan
34 * @plexus.component role="org.apache.maven.repository.proxy.configuration.ProxyConfiguration"
36 public class ProxyConfiguration
38 public static final String ROLE = ProxyConfiguration.class.getName();
43 private ArtifactRepositoryFactory artifactRepositoryFactory;
45 private boolean browsable;
47 private ArtifactRepository repoCache;
48 private List repositories = new ArrayList();
51 * Method to set/unset the web-view of the repository cache
53 * @param browsable set to true to enable the web-view of the proxy repository cache
55 public void setBrowsable( boolean browsable )
57 this.browsable = browsable;
61 * Used to determine if the repsented configuration allows web view of the repository cache
63 * @return true if the repository cache is configured for web view.
65 public boolean isBrowsable()
71 * Used to set the location where the proxy should cache the configured repositories
75 public void setRepositoryCachePath( String repoCacheURL )
77 ArtifactRepositoryPolicy standardPolicy;
78 standardPolicy = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
79 ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
81 ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();
83 repoCache = artifactRepositoryFactory.createArtifactRepository( "localCache", repoCacheURL, layout,
84 standardPolicy, standardPolicy );
88 * Used to retrieve an ArtifactRepository Object of the proxy cache
90 * @return the ArtifactRepository representation of the proxy cache
92 public ArtifactRepository getRepositoryCache()
98 * Used to retrieved the absolute path of the repository cache
100 * @return path to the proxy cache
102 public String getRepositoryCachePath()
104 return repoCache.getBasedir();
108 * Used to add proxied repositories.
110 * @param repository the repository to be proxied
112 public void addRepository( ProxyRepository repository )
114 repositories.add( repository );
118 * Used to retrieve an unmodifyable list of proxied repositories. They returned list determines the search sequence
119 * for retrieving artifacts.
121 * @return a list of ProxyRepository objects representing proxied repositories
123 public List getRepositories()
125 return Collections.unmodifiableList( repositories );
129 * Used to set the list of repositories to be proxied. This replaces any repositories already added to this
130 * configuraion instance. Useful for re-arranging an existing proxied list.
132 * @param repositories
134 public void setRepositories( List repositories )
136 this.repositories = repositories;