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.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
Modifier and TypeFieldDescriptionstatic final int
Check OS environment variables if not resolvable in the specified properties.static final int
Never check OS environment variables.static final int
Check OS environment variables first, before trying the specified properties.static final String
Key for stores special override properties that containers such as OSGi can store in the OSGi service registrystatic final int
Check system properties if not resolvable in the specified properties.static final int
Never check system properties.static final int
Check 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, SUSPENDING
Fields inherited from interface org.apache.camel.spi.PropertiesComponent
FACTORY, OPTIONAL_TOKEN, PREFIX_OPTIONAL_TOKEN, PREFIX_TOKEN, SUFFIX_TOKEN
-
Constructor Summary
ConstructorDescriptionPropertiesComponent
(String location) A list of locations to load properties.PropertiesComponent
(String... locations) A list of locations to load properties. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInitialProperty
(String key, String value) void
addLocation
(String location) void
addLocation
(PropertiesLocation location) void
addOverrideProperty
(String key, String value) void
addPropertiesFunction
(org.apache.camel.spi.PropertiesFunction function) void
addPropertiesLookupListener
(org.apache.camel.PropertiesLookupListener propertiesLookupListener) void
addPropertiesSource
(org.apache.camel.spi.PropertiesSource propertiesSource) protected void
doBuild()
protected void
doInit()
protected void
protected void
doStart()
protected void
doStop()
org.apache.camel.CamelContext
int
Deprecated.Gets 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.PropertiesFunction
getPropertiesFunction
(String name) List<org.apache.camel.PropertiesLookupListener>
Gets thePropertiesLookupListener
org.apache.camel.spi.PropertiesSource
getPropertiesSource
(String name) List<org.apache.camel.spi.PropertiesSource>
int
boolean
hasFunction
(String name) Deprecated.use hasPropertiesFunctionboolean
hasPropertiesFunction
(String name) boolean
boolean
boolean
boolean
loadProperties
(Predicate<String> filter) protected String
parseUri
(String uri, PropertiesLookup properties, boolean keepUnresolvedOptional) boolean
reloadProperties
(String pattern) void
removePropertiesLookupListener
(org.apache.camel.PropertiesLookupListener propertiesLookupListener) RemovePropertiesLookupListener
resolveProperty
(String key) void
setAutoDiscoverPropertiesSources
(boolean autoDiscoverPropertiesSources) Whether to automatically discovery instances ofPropertiesSource
from registry and service factory.void
setCamelContext
(org.apache.camel.CamelContext camelContext) void
setDefaultFallbackEnabled
(boolean defaultFallbackEnabled) If false, the component does not attempt to find a default for the key by looking after the colon separator.void
setEncoding
(String encoding) Encoding to use when loading properties file from the file system or classpath.void
setEnvironmentVariableMode
(int environmentVariableMode) Sets the OS environment variables mode (0 = never, 1 = fallback, 2 = override).void
setIgnoreMissingLocation
(boolean ignoreMissingLocation) void
setInitialProperties
(Properties initialProperties) void
setLocalProperties
(Properties localProperties) void
setLocation
(String location) A list of locations to load properties.void
setLocations
(String[] locationStrings) A list of locations to load properties.void
setLocations
(List<PropertiesLocation> locations) A list of locations to load properties.void
setNestedPlaceholder
(boolean nestedPlaceholder) void
setOverrideProperties
(Properties overrideProperties) void
setPropertiesFunctionResolver
(PropertiesFunctionResolver propertiesFunctionResolver) To use a custom PropertiesFunctionResolvervoid
setPropertiesParser
(PropertiesParser propertiesParser) To use a custom PropertiesParservoid
setSystemPropertiesMode
(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, suspend
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.camel.spi.PropertiesComponent
getLocalPropertiesAsMap, loadPropertiesAsMap, loadPropertiesAsMap
Methods inherited from interface org.apache.camel.Service
build, close, init, start, stop
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods 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:
getCamelContext
in interfaceorg.apache.camel.CamelContextAware
-
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
setCamelContext
in interfaceorg.apache.camel.CamelContextAware
-
parseUri
- Specified by:
parseUri
in interfaceorg.apache.camel.spi.PropertiesComponent
-
parseUri
- Specified by:
parseUri
in interfaceorg.apache.camel.spi.PropertiesComponent
-
resolveProperty
- Specified by:
resolveProperty
in interfaceorg.apache.camel.spi.PropertiesComponent
-
loadProperties
- Specified by:
loadProperties
in interfaceorg.apache.camel.spi.PropertiesComponent
-
loadProperties
- Specified by:
loadProperties
in interfaceorg.apache.camel.spi.PropertiesComponent
-
loadProperties
- Specified by:
loadProperties
in interfaceorg.apache.camel.spi.PropertiesComponent
-
parseUri
-
getLocations
- Specified by:
getLocations
in 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. -
addLocation
-
addLocation
- Specified by:
addLocation
in 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:
setLocation
in 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:
setEncoding
in 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:
setIgnoreMissingLocation
in interfaceorg.apache.camel.spi.PropertiesComponent
-
isNestedPlaceholder
@ManagedAttribute(description="Nested placeholder") public boolean isNestedPlaceholder() -
setNestedPlaceholder
public void setNestedPlaceholder(boolean nestedPlaceholder) - Specified by:
setNestedPlaceholder
in 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:
setInitialProperties
in interfaceorg.apache.camel.spi.PropertiesComponent
-
addInitialProperty
- Specified by:
addInitialProperty
in 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:
setOverrideProperties
in interfaceorg.apache.camel.spi.PropertiesComponent
-
addOverrideProperty
- Specified by:
addOverrideProperty
in interfaceorg.apache.camel.spi.PropertiesComponent
-
setLocalProperties
- Specified by:
setLocalProperties
in 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:
getLocalProperties
in interfaceorg.apache.camel.spi.PropertiesComponent
-
getFunctions
Deprecated.Gets the functions registered in this properties component. -
getPropertiesFunction
- Specified by:
getPropertiesFunction
in interfaceorg.apache.camel.spi.PropertiesComponent
-
addPropertiesFunction
public void addPropertiesFunction(org.apache.camel.spi.PropertiesFunction function) - Specified by:
addPropertiesFunction
in interfaceorg.apache.camel.spi.PropertiesComponent
-
hasPropertiesFunction
- Specified by:
hasPropertiesFunction
in interfaceorg.apache.camel.spi.PropertiesComponent
-
hasFunction
Deprecated.use hasPropertiesFunctionIs there aPropertiesFunction
with the given name? -
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. -
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. -
isAutoDiscoverPropertiesSources
public boolean isAutoDiscoverPropertiesSources() -
setAutoDiscoverPropertiesSources
public void setAutoDiscoverPropertiesSources(boolean autoDiscoverPropertiesSources) Whether to automatically discovery instances ofPropertiesSource
from registry and service factory. -
addPropertiesSource
public void addPropertiesSource(org.apache.camel.spi.PropertiesSource propertiesSource) - Specified by:
addPropertiesSource
in interfaceorg.apache.camel.spi.PropertiesComponent
-
getPropertiesSource
- Specified by:
getPropertiesSource
in interfaceorg.apache.camel.spi.PropertiesComponent
-
getPropertiesSources
- Specified by:
getPropertiesSources
in interfaceorg.apache.camel.spi.PropertiesComponent
-
addPropertiesLookupListener
public void addPropertiesLookupListener(org.apache.camel.PropertiesLookupListener propertiesLookupListener) - Specified by:
addPropertiesLookupListener
in 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:
reloadProperties
in interfaceorg.apache.camel.spi.PropertiesComponent
-
doInit
- Overrides:
doInit
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doBuild
- Overrides:
doBuild
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStart
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doShutdown
- Overrides:
doShutdown
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-