Package org.opennms.netmgt.config
Class VacuumdConfigFactory
- java.lang.Object
-
- org.opennms.netmgt.config.VacuumdConfigFactory
-
public final class VacuumdConfigFactory extends Object
This is the singleton class used to load the configuration for the OpenNMS Vacuumd process from the vacuumd-configuration xml file. Note: Users of this class should make sure the setReader() method is called before calling any other method to ensure the config is loaded before accessing other convenience methods.- Author:
- David Hustace , Mathew Brozowski , OpenNMS
-
-
Constructor Summary
Constructors Constructor Description VacuumdConfigFactory(InputStream stream)Constructor for VacuumdConfigFactory.VacuumdConfigFactory(VacuumdConfiguration config)Constructor for VacuumdConfigFactory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Optional<Action>getAction(String actionName)Returns an Action with a name matching the string parmaterActionEventgetActionEvent(String name)getActionEventCollection<ActionEvent>getActionEvents()getActionEventsCollection<Action>getActions()Returns a Collection of actions defined in the configAutoEventgetAutoEvent(String name)Deprecated.UseActionEventobjects instead.Collection<AutoEvent>getAutoEvents()Returns a Collection of named events to that may have been configured to be sent after an automation has run.AutomationgetAutomation(String autoName)Returns an Automation with a name matching the string parameterCollection<Automation>getAutomations()Returns a Collection of automations defined in the configstatic VacuumdConfigFactorygetInstance()Return the singleton instance of this factory.intgetPeriod()getPeriodString[]getSqlStatements()getSqlStatementsList<Statement>getStatements()getStatementsTriggergetTrigger(String triggerName)Returns a Trigger with a name matching the string parameterCollection<Trigger>getTriggers()Returns a Collection of triggers defined in the configstatic voidinit()Load the config from the default config file and create the singleton instance of this factory.static voidreload()Reload the config from the default config filestatic voidsetInstance(VacuumdConfigFactory instance)Set the singleton instance of this factory.
-
-
-
Constructor Detail
-
VacuumdConfigFactory
public VacuumdConfigFactory(InputStream stream)
Constructor for VacuumdConfigFactory.
- Parameters:
stream- aInputStreamobject.
-
VacuumdConfigFactory
public VacuumdConfigFactory(VacuumdConfiguration config)
Constructor for VacuumdConfigFactory.
Calling reload() on a instance created with method will have no effect.- Parameters:
config- The configuration the use.
-
-
Method Detail
-
init
public static void init() throws IOExceptionLoad the config from the default config file and create the singleton instance of this factory.- Throws:
IOException- Thrown if the specified config file cannot be readIOException- if any.
-
reload
public static void reload() throws IOExceptionReload the config from the default config file- Throws:
IOException- Thrown if the specified config file cannot be read/loadedIOException- if any.
-
getInstance
public static VacuumdConfigFactory getInstance()
Return the singleton instance of this factory.- Returns:
- The current factory instance.
- Throws:
IllegalStateException- Thrown if the factory has not yet been initialized.
-
setInstance
public static void setInstance(VacuumdConfigFactory instance)
Set the singleton instance of this factory.- Parameters:
instance- The factory instance to set.
-
getAutomations
public Collection<Automation> getAutomations()
Returns a Collection of automations defined in the config- Returns:
- a
Collectionobject.
-
getTriggers
public Collection<Trigger> getTriggers()
Returns a Collection of triggers defined in the config- Returns:
- a
Collectionobject.
-
getActions
public Collection<Action> getActions()
Returns a Collection of actions defined in the config- Returns:
- a
Collectionobject.
-
getAutoEvents
public Collection<AutoEvent> getAutoEvents()
Returns a Collection of named events to that may have been configured to be sent after an automation has run.- Returns:
- a
Collectionobject.
-
getActionEvents
public Collection<ActionEvent> getActionEvents()
getActionEvents
- Returns:
- a
Collectionobject.
-
getPeriod
public int getPeriod()
getPeriod
- Returns:
- a int.
-
getTrigger
public Trigger getTrigger(String triggerName)
Returns a Trigger with a name matching the string parameter
-
getAction
public Optional<Action> getAction(String actionName)
Returns an Action with a name matching the string parmater
-
getAutomation
public Automation getAutomation(String autoName)
Returns an Automation with a name matching the string parameter- Parameters:
autoName- aStringobject.- Returns:
- a
Automationobject.
-
getAutoEvent
public AutoEvent getAutoEvent(String name)
Deprecated.UseActionEventobjects instead. Access these objects withgetActionEvent(String).Returns the AutoEvent associated with the auto-event-name
-
getSqlStatements
public String[] getSqlStatements()
getSqlStatements
- Returns:
- an array of
Stringobjects.
-
getActionEvent
public ActionEvent getActionEvent(String name)
getActionEvent
- Parameters:
name- aStringobject.- Returns:
- a
ActionEventobject.
-
-