Module com.aoapps.appcluster.core
Package com.aoapps.appcluster
Class AppClusterPropertiesConfiguration
- java.lang.Object
-
- com.aoapps.appcluster.AppClusterPropertiesConfiguration
-
- All Implemented Interfaces:
AppClusterConfiguration
public class AppClusterPropertiesConfiguration extends Object implements AppClusterConfiguration
The configuration is provided in a properties file.- Author:
- AO Industries, Inc.
-
-
Constructor Summary
Constructors Constructor Description AppClusterPropertiesConfiguration(File file)Loads the properties from the provided file.AppClusterPropertiesConfiguration(Properties properties)Uses the provided configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConfigurationListener(AppClusterConfigurationListener listener)Will be called when the configuration has changed in any way.booleangetBoolean(String propertyName)StringgetDisplay()intgetInt(String propertyName)NamegetName(String propertyName)Set<? extends NodePropertiesConfiguration>getNodeConfigurations()Gets the set of nodes for the cluster.Set<? extends ResourceConfiguration<?,?>>getResourceConfigurations()Gets the set of resources for the cluster.SchedulegetSchedule(String propertyName)StringgetString(String propertyName, boolean required)Gets a trimmed property value, if required, not allowing null or empty string.Set<? extends Name>getUniqueNames(String propertyName)Gets a unique set of trimmed names.Set<String>getUniqueStrings(String propertyName, boolean required)Gets a unique set of trimmed strings.booleanisEnabled()voidremoveConfigurationListener(AppClusterConfigurationListener listener)Removes listener of configuration changes.voidstart()Called as the AppCluster starts, before any configuration values are accessed or listeners are added.voidstop()Called as the AppCluster stops, after all configuration values have been accessed and all listeners have been removed.
-
-
-
Constructor Detail
-
AppClusterPropertiesConfiguration
public AppClusterPropertiesConfiguration(File file)
Loads the properties from the provided file. Will detect changes in the file based on modified time, checking once every FILE_CHECK_INTERVAL milliseconds.
-
AppClusterPropertiesConfiguration
public AppClusterPropertiesConfiguration(Properties properties)
Uses the provided configuration. No changes to the properties will be detected.
-
-
Method Detail
-
start
public void start() throws AppClusterConfigurationExceptionDescription copied from interface:AppClusterConfigurationCalled as the AppCluster starts, before any configuration values are accessed or listeners are added.- Specified by:
startin interfaceAppClusterConfiguration- Throws:
AppClusterConfigurationException
-
stop
public void stop()
Description copied from interface:AppClusterConfigurationCalled as the AppCluster stops, after all configuration values have been accessed and all listeners have been removed.- Specified by:
stopin interfaceAppClusterConfiguration
-
addConfigurationListener
public void addConfigurationListener(AppClusterConfigurationListener listener)
Description copied from interface:AppClusterConfigurationWill be called when the configuration has changed in any way.- Specified by:
addConfigurationListenerin interfaceAppClusterConfiguration
-
removeConfigurationListener
public void removeConfigurationListener(AppClusterConfigurationListener listener)
Description copied from interface:AppClusterConfigurationRemoves listener of configuration changes.- Specified by:
removeConfigurationListenerin interfaceAppClusterConfiguration
-
getString
public String getString(String propertyName, boolean required) throws AppClusterConfigurationException
Gets a trimmed property value, if required, not allowing null or empty string. If not required, will convert empty string to null.- Throws:
AppClusterConfigurationException
-
getBoolean
public boolean getBoolean(String propertyName) throws AppClusterConfigurationException
- Throws:
AppClusterConfigurationException
-
getInt
public int getInt(String propertyName) throws AppClusterConfigurationException
- Throws:
AppClusterConfigurationException
-
getName
public Name getName(String propertyName) throws AppClusterConfigurationException
- Throws:
AppClusterConfigurationException
-
getSchedule
public Schedule getSchedule(String propertyName) throws AppClusterConfigurationException
- Throws:
AppClusterConfigurationException
-
getUniqueStrings
public Set<String> getUniqueStrings(String propertyName, boolean required) throws AppClusterConfigurationException
Gets a unique set of trimmed strings. Must have at least one value when required.- Throws:
AppClusterConfigurationException
-
getUniqueNames
public Set<? extends Name> getUniqueNames(String propertyName) throws AppClusterConfigurationException
Gets a unique set of trimmed names. Must have at least one value.- Throws:
AppClusterConfigurationException
-
isEnabled
public boolean isEnabled() throws AppClusterConfigurationException- Specified by:
isEnabledin interfaceAppClusterConfiguration- Throws:
AppClusterConfigurationException- See Also:
AppCluster.isEnabled()
-
getDisplay
public String getDisplay() throws AppClusterConfigurationException
- Specified by:
getDisplayin interfaceAppClusterConfiguration- Throws:
AppClusterConfigurationException- See Also:
AppCluster.getDisplay()
-
getNodeConfigurations
public Set<? extends NodePropertiesConfiguration> getNodeConfigurations() throws AppClusterConfigurationException
Description copied from interface:AppClusterConfigurationGets the set of nodes for the cluster.- Specified by:
getNodeConfigurationsin interfaceAppClusterConfiguration- Throws:
AppClusterConfigurationException
-
getResourceConfigurations
public Set<? extends ResourceConfiguration<?,?>> getResourceConfigurations() throws AppClusterConfigurationException
Description copied from interface:AppClusterConfigurationGets the set of resources for the cluster.- Specified by:
getResourceConfigurationsin interfaceAppClusterConfiguration- Throws:
AppClusterConfigurationException
-
-