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 Maven configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(String propertyName)Returns true if the the property was set.<T> Tget(String propertyName)Returns the property by name.booleangetCertificateCheck()Returns true if the certificate should be checked on SSL connection, false otherwise.List<MavenRepositoryURL>getDefaultRepositories()Returns a list of default repositories to be searched before any other repositories.StringgetGlobalChecksumPolicy()Global repository update policy.StringgetGlobalUpdatePolicy()Global repository update policy.MavenRepositoryURLgetLocalMavenRepositoryURL()Returns theMavenRepositoryURLfor Maven local repository.FilegetLocalRepository()Returns local repository directory by using the following resolution: looks for a configuration property namedlocalRepositorylooks for a framework property/system setting localRepository looks insettings.xml(see settings.xml resolution) looks for system propertymaven.repo.local(PAXURL-231) falls back to${user.home}/.m2/repositoryReturns the directory for Maven local repository.StringgetPid()Returns PID for properties used by this configuration.<T> TgetProperty(String name, T defaultValue, Class<T> clazz)Returns generic property by name and type.org.ops4j.util.property.PropertyResolvergetPropertyResolver()Returns aPropertyResolverbacking up this configuration object.List<MavenRepositoryURL>getRepositories()Returns a list of remote repositories to be searched.FilegetSecuritySettingsFile()Returns the location ofsettings-security.xmlfile used.org.apache.maven.settings.SettingsgetSettings()Returns MavenSettingsobject with decrypted values.FilegetSettingsFile()Returns the location ofsettings.xmlfile used.IntegergetTimeout()Returns the generic connection/read timeout configured in case the maven artifact is retrieved from a remote location.booleanisOffline()WhetherDefaultRepositorySystemSession.setOffline(boolean)should be set totrue.booleanisValid()Should the configuration be used at all?<T> Tset(String propertyName, T propertyValue)Sets a property.voidsetSettings(org.apache.maven.settings.Settings settings)booleanuseFallbackRepositories()Returns true if Maven Central should be added as fallback repository in addition to other configured repositories.Default value is true.
-
-
-
Constructor Detail
-
MavenConfigurationImpl
public MavenConfigurationImpl(org.ops4j.util.property.PropertyResolver propertyResolver, String pid)Creates a new Maven configuration. PassedPropertyResolveris immediately used to determine location ofsettings.xmlfile and local repository (in such order, because settings may specify<localRepository>element).- Parameters:
propertyResolver- propertyResolver used to resolve properties; mandatorypid- configuration PID. Set to "" if null.
-
-
Method Detail
-
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. Defaults toServiceConstants.PID.- Specified by:
getPidin interfaceMavenConfiguration- Returns:
-
getPropertyResolver
public org.ops4j.util.property.PropertyResolver getPropertyResolver()
Description copied from interface:MavenConfigurationReturns aPropertyResolverbacking up this configuration object.- Specified by:
getPropertyResolverin interfaceMavenConfiguration- Returns:
-
isValid
public boolean isValid()
Should the configuration be used at all? IfServiceConstants.REQUIRE_CONFIG_ADMIN_CONFIGproperty is present, it is a hint that there should be new configuration (without this property) available soon from different source (in practice - when switchin from default,BundleContextbased configuration to Configuration Admin based configuration (thus the name of the property).- Returns:
-
isOffline
public boolean isOffline()
Description copied from interface:MavenConfigurationWhetherDefaultRepositorySystemSession.setOffline(boolean)should be set totrue.- Specified by:
isOfflinein interfaceMavenConfiguration- Returns:
-
getSettingsFile
public File getSettingsFile()
Description copied from interface:MavenConfigurationReturns the location ofsettings.xmlfile used. Whennull, no external settings are loaded.- Specified by:
getSettingsFilein interfaceMavenConfiguration- Returns:
-
getSecuritySettingsFile
public File getSecuritySettingsFile()
Description copied from interface:MavenConfigurationReturns the location ofsettings-security.xmlfile used. Whennull, no external security settings are loaded.- Specified by:
getSecuritySettingsFilein interfaceMavenConfiguration- Returns:
-
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 File getLocalRepository()
Returns local repository directory by using the following resolution:- looks for a configuration property named
localRepository - looks for a framework property/system setting localRepository
- looks in
settings.xml(see settings.xml resolution) - looks for system property
maven.repo.local(PAXURL-231) - falls back to
${user.home}/.m2/repository
settings.xml,maven.repo.localsystem property and falls back to~/.m2/repository. Local repository must be specified in order to resolve remote artifacts.- Specified by:
getLocalRepositoryin interfaceMavenConfiguration- Returns:
- looks for a configuration property named
-
getLocalMavenRepositoryURL
public MavenRepositoryURL getLocalMavenRepositoryURL()
Description copied from interface:MavenConfigurationReturns theMavenRepositoryURLfor Maven local repository. This is the way to get more information about the repository (for example if is it split).- Specified by:
getLocalMavenRepositoryURLin interfaceMavenConfiguration- Returns:
-
useFallbackRepositories
public boolean useFallbackRepositories()
Description copied from interface:MavenConfigurationReturns true if Maven Central should be added as fallback repository in addition to other configured repositories.Default value is true.- Specified by:
useFallbackRepositoriesin interfaceMavenConfiguration- Returns:
- true if the fallback repositories should be used
-
getTimeout
public Integer getTimeout()
Description copied from interface:MavenConfigurationReturns the generic connection/read timeout configured in case the maven artifact is retrieved from a remote location. We can configure the timeouts separately using externalsettings.xmlas well as dedicated properties likeServiceConstants.PROPERTY_SOCKET_CONNECTION_TIMEOUT.- Specified by:
getTimeoutin interfaceMavenConfiguration- Returns:
- the timeout in case artifacts are retrieved from a remote location
-
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
-
getDefaultRepositories
public List<MavenRepositoryURL> getDefaultRepositories() throws MalformedURLException
Description copied from interface:MavenConfigurationReturns a list of default repositories to be searched before any other repositories. These should be file: based repositories. For example Karaf'ssystem/directory should be configured as default repository.- 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
-
getRepositories
public List<MavenRepositoryURL> getRepositories() throws MalformedURLException
Description copied from interface:MavenConfigurationReturns a list of remote repositories to be searched. When resolving artifacts from remote repositories, locally cached version is always created in configured local repository. These repositories may be file: based, but usually external http(s): repositories are used.- Specified by:
getRepositoriesin interfaceMavenConfiguration- Returns:
- a list of remote repositories. List can be null or empty if there are no repositories to be searched.
- Throws:
MalformedURLException
-
getSettings
public org.apache.maven.settings.Settings getSettings()
Description copied from interface:MavenConfigurationReturns MavenSettingsobject with decrypted values.- Specified by:
getSettingsin interfaceMavenConfiguration- Returns:
-
setSettings
public void setSettings(org.apache.maven.settings.Settings settings)
-
getProperty
public <T> T getProperty(String name, T defaultValue, Class<T> clazz)
Description copied from interface:MavenConfigurationReturns generic property by name and type.- Specified by:
getPropertyin 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
-
-