Class PropertiesComponent
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.component.properties.PropertiesComponent
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.CamelContextAware,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.HasCamelContext,org.apache.camel.spi.PropertiesComponent,org.apache.camel.StatefulService,org.apache.camel.StaticService,org.apache.camel.SuspendableService
@ManagedResource(description="Managed PropertiesComponent")
@JdkService("properties-component-factory")
@Configurer(bootstrap=true)
public class PropertiesComponent
extends org.apache.camel.support.service.ServiceSupport
implements org.apache.camel.spi.PropertiesComponent, org.apache.camel.StaticService, org.apache.camel.CamelContextAware
The properties component allows you to use property placeholders in Camel.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCheck OS environment variables if not resolvable in the specified properties.static final intNever check OS environment variables.static final intCheck OS environment variables first, before trying the specified properties.static final StringKey for stores special override properties that containers such as OSGi can store in the OSGi service registrystatic final intCheck system properties if not resolvable in the specified properties.static final intNever check system properties.static final intCheck system properties variables) first, before trying the specified properties.Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDINGFields inherited from interface org.apache.camel.spi.PropertiesComponent
FACTORY, OPTIONAL_TOKEN, PREFIX_OPTIONAL_TOKEN, PREFIX_TOKEN, SUFFIX_TOKEN -
Constructor Summary
ConstructorsConstructorDescriptionPropertiesComponent(String location) A list of locations to load properties.PropertiesComponent(String... locations) A list of locations to load properties. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInitialProperty(String key, String value) voidaddLocation(String location) voidaddLocation(PropertiesLocation location) voidaddOverrideProperty(String key, String value) voidaddPropertiesFunction(org.apache.camel.spi.PropertiesFunction function) voidaddPropertiesLookupListener(org.apache.camel.PropertiesLookupListener propertiesLookupListener) voidaddPropertiesSource(org.apache.camel.spi.PropertiesSource propertiesSource) protected voiddoBuild()protected voiddoInit()protected voidprotected voiddoStart()protected voiddoStop()org.apache.camel.CamelContextintGets a list of properties that are local for the current thread only (ie thread local), or null if not currently in use.org.apache.camel.spi.PropertiesFunctiongetPropertiesFunction(String name) List<org.apache.camel.PropertiesLookupListener> Gets thePropertiesLookupListenerorg.apache.camel.spi.PropertiesSourcegetPropertiesSource(String name) org.apache.camel.spi.PropertiesSourceFactoryList<org.apache.camel.spi.PropertiesSource> intbooleanhasPropertiesFunction(String name) booleanbooleanbooleanbooleanbooleanvoidkeepOnlyChangeProperties(Properties properties) loadProperties(Predicate<String> filter) protected StringparseUri(String uri, PropertiesLookup properties, boolean keepUnresolvedOptional) booleanreloadProperties(String pattern) voidremovePropertiesLookupListener(org.apache.camel.PropertiesLookupListener propertiesLookupListener) RemovePropertiesLookupListenerresolveProperty(String key) voidsetAutoDiscoverPropertiesSources(boolean autoDiscoverPropertiesSources) Whether to automatically discovery instances ofPropertiesSourcefrom registry and service factory.voidsetCamelContext(org.apache.camel.CamelContext camelContext) voidsetDefaultFallbackEnabled(boolean defaultFallbackEnabled) If false, the component does not attempt to find a default for the key by looking after the colon separator.voidsetEncoding(String encoding) Encoding to use when loading properties file from the file system or classpath.voidsetEnvironmentVariableMode(int environmentVariableMode) Sets the OS environment variables mode (0 = never, 1 = fallback, 2 = override).voidsetIgnoreMissingLocation(boolean ignoreMissingLocation) voidsetIgnoreMissingProperty(boolean ignoreMissingProperty) voidsetInitialProperties(Properties initialProperties) voidsetLocalProperties(Properties localProperties) voidsetLocation(String location) A list of locations to load properties.voidsetLocations(String[] locationStrings) A list of locations to load properties.voidsetLocations(List<PropertiesLocation> locations) A list of locations to load properties.voidsetNestedPlaceholder(boolean nestedPlaceholder) voidsetOverrideProperties(Properties overrideProperties) voidsetPropertiesFunctionResolver(PropertiesFunctionResolver propertiesFunctionResolver) To use a custom PropertiesFunctionResolvervoidsetPropertiesParser(PropertiesParser propertiesParser) To use a custom PropertiesParservoidsetSystemPropertiesMode(int systemPropertiesMode) Sets the JVM system property mode (0 = never, 1 = fallback, 2 = override).Methods inherited from class org.apache.camel.support.service.BaseService
build, doFail, doLifecycleChange, doResume, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.spi.PropertiesComponent
getLocalPropertiesAsMap, loadPropertiesAsMap, loadPropertiesAsMapMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Field Details
-
SYSTEM_PROPERTIES_MODE_NEVER
public static final int SYSTEM_PROPERTIES_MODE_NEVERNever check system properties.- See Also:
-
SYSTEM_PROPERTIES_MODE_FALLBACK
public static final int SYSTEM_PROPERTIES_MODE_FALLBACKCheck system properties if not resolvable in the specified properties.- See Also:
-
SYSTEM_PROPERTIES_MODE_OVERRIDE
public static final int SYSTEM_PROPERTIES_MODE_OVERRIDECheck system properties variables) first, before trying the specified properties. This allows system properties to override any other property source (environment variable and then system properties takes precedence). This is the default.- See Also:
-
ENVIRONMENT_VARIABLES_MODE_NEVER
public static final int ENVIRONMENT_VARIABLES_MODE_NEVERNever check OS environment variables.- See Also:
-
ENVIRONMENT_VARIABLES_MODE_FALLBACK
public static final int ENVIRONMENT_VARIABLES_MODE_FALLBACKCheck OS environment variables if not resolvable in the specified properties. This is the default.- See Also:
-
ENVIRONMENT_VARIABLES_MODE_OVERRIDE
public static final int ENVIRONMENT_VARIABLES_MODE_OVERRIDECheck OS environment variables first, before trying the specified properties. This allows environment variables to override any other property source (environment variable and then system properties takes precedence).- See Also:
-
OVERRIDE_PROPERTIES
Key for stores special override properties that containers such as OSGi can store in the OSGi service registry
-
-
Constructor Details
-
PropertiesComponent
public PropertiesComponent() -
PropertiesComponent
A list of locations to load properties. You can use comma to separate multiple locations. -
PropertiesComponent
A list of locations to load properties.
-
-
Method Details
-
getCamelContext
public org.apache.camel.CamelContext getCamelContext()- Specified by:
getCamelContextin interfaceorg.apache.camel.spi.HasCamelContext
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContextin interfaceorg.apache.camel.CamelContextAware
-
parseUri
- Specified by:
parseUriin interfaceorg.apache.camel.spi.PropertiesComponent
-
parseUri
- Specified by:
parseUriin interfaceorg.apache.camel.spi.PropertiesComponent
-
resolveProperty
- Specified by:
resolvePropertyin interfaceorg.apache.camel.spi.PropertiesComponent
-
loadProperties
- Specified by:
loadPropertiesin interfaceorg.apache.camel.spi.PropertiesComponent
-
loadProperties
- Specified by:
loadPropertiesin interfaceorg.apache.camel.spi.PropertiesComponent
-
loadProperties
- Specified by:
loadPropertiesin interfaceorg.apache.camel.spi.PropertiesComponent
-
parseUri
-
getLocations
- Specified by:
getLocationsin interfaceorg.apache.camel.spi.PropertiesComponent
-
setLocations
A list of locations to load properties. This option will override any default locations and only use the locations from this option. -
setLocations
A list of locations to load properties. This option will override any default locations and only use the locations from this option. -
getPropertiesSourceFactory
public org.apache.camel.spi.PropertiesSourceFactory getPropertiesSourceFactory()- Specified by:
getPropertiesSourceFactoryin interfaceorg.apache.camel.spi.PropertiesComponent
-
addLocation
-
addLocation
- Specified by:
addLocationin interfaceorg.apache.camel.spi.PropertiesComponent
-
setLocation
A list of locations to load properties. You can use comma to separate multiple locations. This option will override any default locations and only use the locations from this option.- Specified by:
setLocationin interfaceorg.apache.camel.spi.PropertiesComponent
-
getLocation
-
getEncoding
@ManagedAttribute(description="Encoding to use when loading properties file from the file system or classpath") public String getEncoding() -
setEncoding
Encoding to use when loading properties file from the file system or classpath. If no encoding has been set, then the properties files is loaded using ISO-8859-1 encoding (latin-1) as documented byProperties.load(java.io.InputStream)- Specified by:
setEncodingin interfaceorg.apache.camel.spi.PropertiesComponent
-
getPropertiesParser
-
setPropertiesParser
To use a custom PropertiesParser -
getPropertiesFunctionResolver
-
setPropertiesFunctionResolver
To use a custom PropertiesFunctionResolver -
isDefaultFallbackEnabled
@ManagedAttribute(description="Whether to support using fallback values if a property cannot be found") public boolean isDefaultFallbackEnabled() -
setDefaultFallbackEnabled
public void setDefaultFallbackEnabled(boolean defaultFallbackEnabled) If false, the component does not attempt to find a default for the key by looking after the colon separator. -
isIgnoreMissingLocation
@ManagedAttribute(description="Ignore missing location") public boolean isIgnoreMissingLocation() -
setIgnoreMissingLocation
public void setIgnoreMissingLocation(boolean ignoreMissingLocation) - Specified by:
setIgnoreMissingLocationin interfaceorg.apache.camel.spi.PropertiesComponent
-
isIgnoreMissingProperty
@ManagedAttribute(description="Ignore missing location") public boolean isIgnoreMissingProperty() -
setIgnoreMissingProperty
public void setIgnoreMissingProperty(boolean ignoreMissingProperty) - Specified by:
setIgnoreMissingPropertyin interfaceorg.apache.camel.spi.PropertiesComponent
-
isNestedPlaceholder
@ManagedAttribute(description="Nested placeholder") public boolean isNestedPlaceholder() -
setNestedPlaceholder
public void setNestedPlaceholder(boolean nestedPlaceholder) - Specified by:
setNestedPlaceholderin interfaceorg.apache.camel.spi.PropertiesComponent
-
getInitialProperties
- Returns:
- a list of properties which will be used before any locations are resolved (can't be null).
-
setInitialProperties
- Specified by:
setInitialPropertiesin interfaceorg.apache.camel.spi.PropertiesComponent
-
addInitialProperty
- Specified by:
addInitialPropertyin interfaceorg.apache.camel.spi.PropertiesComponent
-
getOverrideProperties
- Returns:
- a list of properties that take precedence and will use first, if a property exists (can't be null).
-
setOverrideProperties
- Specified by:
setOverridePropertiesin interfaceorg.apache.camel.spi.PropertiesComponent
-
addOverrideProperty
- Specified by:
addOverridePropertyin interfaceorg.apache.camel.spi.PropertiesComponent
-
setLocalProperties
- Specified by:
setLocalPropertiesin interfaceorg.apache.camel.spi.PropertiesComponent
-
getLocalProperties
Gets a list of properties that are local for the current thread only (ie thread local), or null if not currently in use.- Specified by:
getLocalPropertiesin interfaceorg.apache.camel.spi.PropertiesComponent
-
getPropertiesFunction
- Specified by:
getPropertiesFunctionin interfaceorg.apache.camel.spi.PropertiesComponent
-
addPropertiesFunction
public void addPropertiesFunction(org.apache.camel.spi.PropertiesFunction function) - Specified by:
addPropertiesFunctionin interfaceorg.apache.camel.spi.PropertiesComponent
-
hasPropertiesFunction
- Specified by:
hasPropertiesFunctionin interfaceorg.apache.camel.spi.PropertiesComponent
-
getSystemPropertiesMode
@ManagedAttribute(description="System properties mode") public int getSystemPropertiesMode() -
setSystemPropertiesMode
public void setSystemPropertiesMode(int systemPropertiesMode) Sets the JVM system property mode (0 = never, 1 = fallback, 2 = override). The default mode (override) is to use system properties if present, and override any existing properties. OS environment variable mode is checked before JVM system property mode.- See Also:
-
getEnvironmentVariableMode
@ManagedAttribute(description="Environment variable mode") public int getEnvironmentVariableMode() -
setEnvironmentVariableMode
public void setEnvironmentVariableMode(int environmentVariableMode) Sets the OS environment variables mode (0 = never, 1 = fallback, 2 = override). The default mode (override) is to use OS environment variables if present, and override any existing properties. OS environment variable mode is checked before JVM system property mode.- See Also:
-
isAutoDiscoverPropertiesSources
public boolean isAutoDiscoverPropertiesSources() -
setAutoDiscoverPropertiesSources
public void setAutoDiscoverPropertiesSources(boolean autoDiscoverPropertiesSources) Whether to automatically discovery instances ofPropertiesSourcefrom registry and service factory. -
addPropertiesSource
public void addPropertiesSource(org.apache.camel.spi.PropertiesSource propertiesSource) - Specified by:
addPropertiesSourcein interfaceorg.apache.camel.spi.PropertiesComponent
-
getPropertiesSource
- Specified by:
getPropertiesSourcein interfaceorg.apache.camel.spi.PropertiesComponent
-
getPropertiesSources
- Specified by:
getPropertiesSourcesin interfaceorg.apache.camel.spi.PropertiesComponent
-
addPropertiesLookupListener
public void addPropertiesLookupListener(org.apache.camel.PropertiesLookupListener propertiesLookupListener) - Specified by:
addPropertiesLookupListenerin interfaceorg.apache.camel.spi.PropertiesComponent
-
removePropertiesLookupListener
public void removePropertiesLookupListener(org.apache.camel.PropertiesLookupListener propertiesLookupListener) RemovePropertiesLookupListener -
getPropertiesLookupListeners
Gets thePropertiesLookupListener -
reloadProperties
@ManagedOperation(description="Reload properties from the given location patterns") public boolean reloadProperties(String pattern) - Specified by:
reloadPropertiesin interfaceorg.apache.camel.spi.PropertiesComponent
-
keepOnlyChangeProperties
- Specified by:
keepOnlyChangePropertiesin interfaceorg.apache.camel.spi.PropertiesComponent
-
doInit
- Overrides:
doInitin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doBuild
- Overrides:
doBuildin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStart
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doShutdown
- Overrides:
doShutdownin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-