Class MavenConfigurationImpl
- java.lang.Object
-
- org.ops4j.pax.url.mvn.internal.config.MavenConfigurationImpl
-
- All Implemented Interfaces:
MavenConfiguration
public class MavenConfigurationImpl extends Object implements MavenConfiguration
Service Configuration implementation.- Since:
- August 11, 2007
- Author:
- Alin Dreghiciu, Guillaume Nodet
- See Also:
MavenConfiguration
-
-
Constructor Summary
Constructors Constructor Description MavenConfigurationImpl(org.ops4j.util.property.PropertyResolver propertyResolver, String pid)Creates a new service configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancontains(String propertyName)Returns true if the the property was set.voidenableProxy(URL url)Deprecated.This method has side-effects and is only used in the "old" resolver.<T> Tget(String propertyName)Returns the property by name.BooleangetCertificateCheck()Returns true if the certificate should be checked on SSL connection, false otherwise.MavenRepositoryURLgetDefaultLocalRepository()List<MavenRepositoryURL>getDefaultRepositories()Repository is a comma separated list of repositories to be used.StringgetGlobalChecksumPolicy()Global repository update policy.StringgetGlobalUpdatePolicy()Global repository update policy.MavenRepositoryURLgetLocalRepository()Resolves local repository directory by using the following resolution:
1.Map<String,Map<String,String>>getMirrors()Returns the mirror settings from settings.xml.StringgetPid()Returns PID for properties used by this configuration.<T> TgetProperty(String name, T defaultValue, Class<T> clazz)Returns generic property by name.org.ops4j.util.property.PropertyResolvergetPropertyResolver()Map<String,Map<String,String>>getProxySettings(String... protocols)Returns the active proxy settings from settings.xml The fields are user, pass, host, port, nonProxyHosts, protocol.List<MavenRepositoryURL>getRepositories()Repository is a comma separated list of repositories to be used.StringgetSecuritySettings()org.apache.maven.settings.SettingsgetSettings()URLgetSettingsFileUrl()Returns the URL of settings file.IntegergetTimeout()Returns the read timeout configured in case the maven artifact is retrieved from a remote location.booleanisOffline()booleanisValid()<T> Tset(String propertyName, T propertyValue)Sets a property.voidsetSettings(org.apache.maven.settings.Settings settings)BooleanuseFallbackRepositories()Returns true if the fallback repositories should be used instead of default ones.
-
-
-
Constructor Detail
-
MavenConfigurationImpl
public MavenConfigurationImpl(org.ops4j.util.property.PropertyResolver propertyResolver, String pid)Creates a new service configuration.- Parameters:
propertyResolver- propertyResolver used to resolve properties; mandatorypid- configuration PID; mandatory
-
-
Method Detail
-
getPropertyResolver
public org.ops4j.util.property.PropertyResolver getPropertyResolver()
- Specified by:
getPropertyResolverin interfaceMavenConfiguration
-
isValid
public boolean isValid()
-
isOffline
public boolean isOffline()
- Specified by:
isOfflinein interfaceMavenConfiguration- See Also:
MavenConfiguration.isOffline()
-
getCertificateCheck
public Boolean getCertificateCheck()
Description copied from interface:MavenConfigurationReturns true if the certificate should be checked on SSL connection, false otherwise.- Specified by:
getCertificateCheckin interfaceMavenConfiguration- Returns:
- true if the certificate should be checked
- See Also:
MavenConfiguration.getCertificateCheck()
-
getSettingsFileUrl
public URL getSettingsFileUrl()
Returns the URL of settings file. Will try first to use the url as is. If a malformed url encountered then will try to use the url as a file path. If still not valid will throw the original Malformed URL exception.- Specified by:
getSettingsFileUrlin interfaceMavenConfiguration- Returns:
- the url to settings file
- See Also:
MavenConfiguration.getSettingsFileUrl()
-
getDefaultRepositories
public List<MavenRepositoryURL> getDefaultRepositories() throws MalformedURLException
Repository is a comma separated list of repositories to be used. If repository acces requests authentication the user name and password must be specified in the repository url as for example http://user:password@repository.ops4j.org/maven2.
If the repository from 1/2 bellow starts with a plus (+) the option 3 is also used and the repositories from settings.xml will be cummulated.
Repository resolution:
1. looks for a configuration property named repository;
2. looks for a framework property/system setting repository;
3. looks in settings.xml (see settings.xml resolution). in this case all configured repositories will be used including configured user/password. In this case the central repository is also added. Note that the local repository is added as the first repository if exists.- Specified by:
getDefaultRepositoriesin interfaceMavenConfiguration- Returns:
- a list of default repositories. List can be null or empty if there are not default repositories to be searched.
- Throws:
MalformedURLException- See Also:
MavenConfiguration.getRepositories(),MavenConfiguration.getLocalRepository()
-
getRepositories
public List<MavenRepositoryURL> getRepositories() throws MalformedURLException
Repository is a comma separated list of repositories to be used. If repository access requests authentication the user name and password must be specified in the repository url as for example http://user:password@repository.ops4j.org/maven2.
If the repository from 1/2 bellow starts with a plus (+) the option 3 is also used and the repositories from settings.xml will be cummulated.
Repository resolution:
1. looks for a configuration property named repository;
2. looks for a framework property/system setting repository;
3. looks in settings.xml (see settings.xml resolution). in this case all configured repositories will be used including configured user/password. In this case the central repository is also added. Note that the local repository is added as the first repository if exists.- Specified by:
getRepositoriesin interfaceMavenConfiguration- Returns:
- a list of repositories. List can be null or empty if there are no repositories to be searched.
- Throws:
MalformedURLException- See Also:
MavenConfiguration.getRepositories(),MavenConfiguration.getLocalRepository()
-
getGlobalUpdatePolicy
public String getGlobalUpdatePolicy()
Description copied from interface:MavenConfigurationGlobal repository update policy. SeeServiceConstants.PROPERTY_GLOBAL_UPDATE_POLICY- Specified by:
getGlobalUpdatePolicyin interfaceMavenConfiguration- Returns:
- repository update policy or null if not set
-
getGlobalChecksumPolicy
public String getGlobalChecksumPolicy()
Description copied from interface:MavenConfigurationGlobal repository update policy. SeeServiceConstants.PROPERTY_GLOBAL_CHECKSUM_POLICY- Specified by:
getGlobalChecksumPolicyin interfaceMavenConfiguration- Returns:
- repository update policy or null if not set
-
getLocalRepository
public MavenRepositoryURL getLocalRepository()
Resolves local repository directory by using the following resolution:
1. looks for a configuration property namedlocalRepository;
2. looks for a framework property/system setting localRepository;
3. looks in settings.xml (see settings.xml resolution);
4. looks for system propertymaven.repo.local(PAXURL-231);
5. falls back to ${user.home}/.m2/repository.- Specified by:
getLocalRepositoryin interfaceMavenConfiguration- Returns:
- url of local repository. Can be null if there is no local repository.
- See Also:
MavenConfiguration.getLocalRepository()
-
getDefaultLocalRepository
public MavenRepositoryURL getDefaultLocalRepository()
-
getTimeout
public Integer getTimeout()
Description copied from interface:MavenConfigurationReturns the read timeout configured in case the maven artifact is retrieved from a remote location.- Specified by:
getTimeoutin interfaceMavenConfiguration- Returns:
- the timeout in case artifacts are retrieved from a remote location
-
useFallbackRepositories
public Boolean useFallbackRepositories()
Returns true if the fallback repositories should be used instead of default ones. Default value is true.- Specified by:
useFallbackRepositoriesin interfaceMavenConfiguration- Returns:
- true if the fallback repositories should be used
-
enableProxy
@Deprecated public void enableProxy(URL url)
Deprecated.This method has side-effects and is only used in the "old" resolver.Enables the proxy server for a given URL.- Specified by:
enableProxyin interfaceMavenConfiguration- Parameters:
url- Enables the proxy server for a given URL.
-
getProxySettings
public Map<String,Map<String,String>> getProxySettings(String... protocols)
Description copied from interface:MavenConfigurationReturns the active proxy settings from settings.xml The fields are user, pass, host, port, nonProxyHosts, protocol.- Specified by:
getProxySettingsin interfaceMavenConfiguration- Parameters:
protocols- protocols to be recognized.- Returns:
- the active proxy settings
-
getMirrors
public Map<String,Map<String,String>> getMirrors()
Description copied from interface:MavenConfigurationReturns the mirror settings from settings.xml. The fields are id, url, mirrorOf, layout, mirrorOfLayouts.- Specified by:
getMirrorsin interfaceMavenConfiguration- Returns:
- the mirror settings
-
getSettings
public org.apache.maven.settings.Settings getSettings()
- Specified by:
getSettingsin interfaceMavenConfiguration
-
setSettings
public void setSettings(org.apache.maven.settings.Settings settings)
-
getSecuritySettings
public String getSecuritySettings()
- Specified by:
getSecuritySettingsin interfaceMavenConfiguration
-
getProperty
public <T> T getProperty(String name, T defaultValue, Class<T> clazz)
Description copied from interface:MavenConfigurationReturns generic property by name.- Specified by:
getPropertyin interfaceMavenConfiguration- Returns:
-
getPid
public String getPid()
Description copied from interface:MavenConfigurationReturns PID for properties used by this configuration. It's used as prefix for properties in associatedPropertyResolver- Specified by:
getPidin interfaceMavenConfiguration- Returns:
-
contains
public boolean contains(String propertyName)
Returns true if the the property was set.- Parameters:
propertyName- name of the property- Returns:
- true if property is set
-
set
public <T> T set(String propertyName, T propertyValue)
Sets a property.- Parameters:
propertyName- name of the property to setpropertyValue- value of the property to set- Returns:
- the value of property set (fluent api)
-
get
public <T> T get(String propertyName)
Returns the property by name.- Parameters:
propertyName- name of the property- Returns:
- property value
-
-