@ManagedResource(description="Managed PropertiesComponent")
public class PropertiesComponent
extends org.apache.camel.support.service.ServiceSupport
implements org.apache.camel.spi.PropertiesComponent, org.apache.camel.StaticService, org.apache.camel.CamelContextAware
Modifier and Type | Field and Description |
---|---|
static int |
ENVIRONMENT_VARIABLES_MODE_FALLBACK
Check OS environment variables if not resolvable in the specified properties.
|
static int |
ENVIRONMENT_VARIABLES_MODE_NEVER
Never check OS environment variables.
|
static int |
ENVIRONMENT_VARIABLES_MODE_OVERRIDE
Check OS environment variables first, before trying the specified properties.
|
static String |
OVERRIDE_PROPERTIES
Key for stores special override properties that containers such as OSGi can store
in the OSGi service registry
|
static int |
SYSTEM_PROPERTIES_MODE_FALLBACK
Check system properties if not resolvable in the specified properties.
|
static int |
SYSTEM_PROPERTIES_MODE_NEVER
Never check system properties.
|
static int |
SYSTEM_PROPERTIES_MODE_OVERRIDE
Check system properties variables) first, before trying the specified properties.
|
Constructor and Description |
---|
PropertiesComponent() |
PropertiesComponent(String... locations)
A list of locations to load properties.
|
PropertiesComponent(String location)
A list of locations to load properties.
|
Modifier and Type | Method and Description |
---|---|
void |
addFunction(PropertiesFunction function)
Registers the
PropertiesFunction as a function to this component. |
void |
addLocation(PropertiesLocation location) |
void |
addLocation(String location) |
void |
addPropertiesSource(org.apache.camel.spi.PropertiesSource propertiesSource) |
protected void |
doInit() |
protected void |
doStart() |
protected void |
doStop() |
org.apache.camel.CamelContext |
getCamelContext() |
String |
getEncoding() |
int |
getEnvironmentVariableMode() |
Map<String,PropertiesFunction> |
getFunctions()
Gets the functions registered in this properties component.
|
Properties |
getInitialProperties() |
String |
getLocation() |
List<String> |
getLocations() |
Properties |
getOverrideProperties() |
PropertiesParser |
getPropertiesParser() |
List<org.apache.camel.spi.PropertiesSource> |
getSources() |
int |
getSystemPropertiesMode() |
boolean |
hasFunction(String name)
Is there a
PropertiesFunction with the given name? |
boolean |
isAutoDiscoverPropertiesSources() |
boolean |
isDefaultFallbackEnabled() |
boolean |
isIgnoreMissingLocation() |
Properties |
loadProperties() |
Properties |
loadProperties(Predicate<String> filter) |
String |
parseUri(String uri) |
protected String |
parseUri(String uri,
PropertiesLookup properties) |
Optional<String> |
resolveProperty(String key) |
void |
setAutoDiscoverPropertiesSources(boolean autoDiscoverPropertiesSources)
Whether to automatically discovery instances of
PropertiesSource 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)
Whether to silently ignore if a location cannot be located, such as a properties file not found.
|
void |
setInitialProperties(Properties initialProperties)
Sets initial properties which will be used before any locations are resolved.
|
void |
setLocation(String location)
A list of locations to load properties.
|
void |
setLocations(Collection<String> locationStrings)
A list of locations to load properties.
|
void |
setLocations(List<PropertiesLocation> locations)
A list of locations to load properties.
|
void |
setLocations(String[] locationStrings)
A list of locations to load properties.
|
void |
setOverrideProperties(Properties overrideProperties)
Sets a special list of override properties that take precedence
and will use first, if a property exist.
|
void |
setPropertiesParser(PropertiesParser propertiesParser)
To use a custom PropertiesParser
|
void |
setSystemPropertiesMode(int systemPropertiesMode)
Sets the JVM system property mode (0 = never, 1 = fallback, 2 = override).
|
build, doBuild, doResume, doShutdown, doSuspend, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public static final int SYSTEM_PROPERTIES_MODE_NEVER
public static final int SYSTEM_PROPERTIES_MODE_FALLBACK
public static final int SYSTEM_PROPERTIES_MODE_OVERRIDE
public static final int ENVIRONMENT_VARIABLES_MODE_NEVER
public static final int ENVIRONMENT_VARIABLES_MODE_FALLBACK
public static final int ENVIRONMENT_VARIABLES_MODE_OVERRIDE
public static final String OVERRIDE_PROPERTIES
public PropertiesComponent()
public PropertiesComponent(String location)
public PropertiesComponent(String... locations)
public org.apache.camel.CamelContext getCamelContext()
getCamelContext
in interface org.apache.camel.CamelContextAware
public void setCamelContext(org.apache.camel.CamelContext camelContext)
setCamelContext
in interface org.apache.camel.CamelContextAware
public String parseUri(String uri)
parseUri
in interface org.apache.camel.spi.PropertiesComponent
public Optional<String> resolveProperty(String key)
resolveProperty
in interface org.apache.camel.spi.PropertiesComponent
public Properties loadProperties()
loadProperties
in interface org.apache.camel.spi.PropertiesComponent
public Properties loadProperties(Predicate<String> filter)
loadProperties
in interface org.apache.camel.spi.PropertiesComponent
protected String parseUri(String uri, PropertiesLookup properties)
public List<String> getLocations()
getLocations
in interface org.apache.camel.spi.PropertiesComponent
public void setLocations(List<PropertiesLocation> locations)
public void setLocations(String[] locationStrings)
public void setLocations(Collection<String> locationStrings)
public void addLocation(PropertiesLocation location)
public void addLocation(String location)
addLocation
in interface org.apache.camel.spi.PropertiesComponent
public void setLocation(String location)
setLocation
in interface org.apache.camel.spi.PropertiesComponent
public String getLocation()
@ManagedAttribute(description="Encoding to use when loading properties file from the file system or classpath") public String getEncoding()
public void setEncoding(String encoding)
Properties.load(java.io.InputStream)
setEncoding
in interface org.apache.camel.spi.PropertiesComponent
public PropertiesParser getPropertiesParser()
public void setPropertiesParser(PropertiesParser propertiesParser)
@ManagedAttribute(description="Whether to support using fallback values if a property cannot be found") public boolean isDefaultFallbackEnabled()
public void setDefaultFallbackEnabled(boolean defaultFallbackEnabled)
@ManagedAttribute(description="Ignore missing location") public boolean isIgnoreMissingLocation()
public void setIgnoreMissingLocation(boolean ignoreMissingLocation)
setIgnoreMissingLocation
in interface org.apache.camel.spi.PropertiesComponent
public Properties getInitialProperties()
public void setInitialProperties(Properties initialProperties)
setInitialProperties
in interface org.apache.camel.spi.PropertiesComponent
public Properties getOverrideProperties()
public void setOverrideProperties(Properties overrideProperties)
setOverrideProperties
in interface org.apache.camel.spi.PropertiesComponent
public Map<String,PropertiesFunction> getFunctions()
public void addFunction(PropertiesFunction function)
PropertiesFunction
as a function to this component.public boolean hasFunction(String name)
PropertiesFunction
with the given name?@ManagedAttribute(description="System properties mode") public int getSystemPropertiesMode()
public void setSystemPropertiesMode(int systemPropertiesMode)
@ManagedAttribute(description="Environment variable mode") public int getEnvironmentVariableMode()
public void setEnvironmentVariableMode(int environmentVariableMode)
public boolean isAutoDiscoverPropertiesSources()
public void setAutoDiscoverPropertiesSources(boolean autoDiscoverPropertiesSources)
PropertiesSource
from registry and service factory.public void addPropertiesSource(org.apache.camel.spi.PropertiesSource propertiesSource)
addPropertiesSource
in interface org.apache.camel.spi.PropertiesComponent
public List<org.apache.camel.spi.PropertiesSource> getSources()
protected void doInit() throws Exception
doInit
in class org.apache.camel.support.service.ServiceSupport
Exception
protected void doStart() throws Exception
doStart
in class org.apache.camel.support.service.ServiceSupport
Exception
Apache Camel