Package org.opennms.netmgt.config
Class VacuumdConfigFactory
- java.lang.Object
-
- org.opennms.netmgt.config.VacuumdConfigFactory
-
public final class VacuumdConfigFactory extends java.lang.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(java.io.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 java.util.Optional<Action>
getAction(java.lang.String actionName)
Returns an Action with a name matching the string parmaterActionEvent
getActionEvent(java.lang.String name)
getActionEventjava.util.Collection<ActionEvent>
getActionEvents()
getActionEventsjava.util.Collection<Action>
getActions()
Returns a Collection of actions defined in the configAutoEvent
getAutoEvent(java.lang.String name)
Deprecated.UseActionEvent
objects instead.java.util.Collection<AutoEvent>
getAutoEvents()
Returns a Collection of named events to that may have been configured to be sent after an automation has run.Automation
getAutomation(java.lang.String autoName)
Returns an Automation with a name matching the string parameterjava.util.Collection<Automation>
getAutomations()
Returns a Collection of automations defined in the configstatic VacuumdConfigFactory
getInstance()
Return the singleton instance of this factory.int
getPeriod()
getPeriodjava.lang.String[]
getSqlStatements()
getSqlStatementsjava.util.List<Statement>
getStatements()
getStatementsTrigger
getTrigger(java.lang.String triggerName)
Returns a Trigger with a name matching the string parameterjava.util.Collection<Trigger>
getTriggers()
Returns a Collection of triggers defined in the configstatic void
init()
Load the config from the default config file and create the singleton instance of this factory.static void
reload()
Reload the config from the default config filestatic void
setInstance(VacuumdConfigFactory instance)
Set the singleton instance of this factory.
-
-
-
Constructor Detail
-
VacuumdConfigFactory
public VacuumdConfigFactory(java.io.InputStream stream)
Constructor for VacuumdConfigFactory.
- Parameters:
stream
- aInputStream
object.
-
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 java.io.IOException
Load the config from the default config file and create the singleton instance of this factory.- Throws:
java.io.IOException
- Thrown if the specified config file cannot be readjava.io.IOException
- if any.
-
reload
public static void reload() throws java.io.IOException
Reload the config from the default config file- Throws:
java.io.IOException
- Thrown if the specified config file cannot be read/loadedjava.io.IOException
- if any.
-
getInstance
public static VacuumdConfigFactory getInstance()
Return the singleton instance of this factory.- Returns:
- The current factory instance.
- Throws:
java.lang.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 java.util.Collection<Automation> getAutomations()
Returns a Collection of automations defined in the config- Returns:
- a
Collection
object.
-
getTriggers
public java.util.Collection<Trigger> getTriggers()
Returns a Collection of triggers defined in the config- Returns:
- a
Collection
object.
-
getActions
public java.util.Collection<Action> getActions()
Returns a Collection of actions defined in the config- Returns:
- a
Collection
object.
-
getAutoEvents
public java.util.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
Collection
object.
-
getActionEvents
public java.util.Collection<ActionEvent> getActionEvents()
getActionEvents
- Returns:
- a
Collection
object.
-
getPeriod
public int getPeriod()
getPeriod
- Returns:
- a int.
-
getTrigger
public Trigger getTrigger(java.lang.String triggerName)
Returns a Trigger with a name matching the string parameter- Parameters:
triggerName
- aString
object.- Returns:
- a
Trigger
object.
-
getAction
public java.util.Optional<Action> getAction(java.lang.String actionName)
Returns an Action with a name matching the string parmater- Parameters:
actionName
- aString
object.- Returns:
- a
Action
object.
-
getAutomation
public Automation getAutomation(java.lang.String autoName)
Returns an Automation with a name matching the string parameter- Parameters:
autoName
- aString
object.- Returns:
- a
Automation
object.
-
getAutoEvent
public AutoEvent getAutoEvent(java.lang.String name)
Deprecated.UseActionEvent
objects instead. Access these objects withgetActionEvent(String)
.Returns the AutoEvent associated with the auto-event-name- Parameters:
name
- aString
object.- Returns:
- a
AutoEvent
object.
-
getSqlStatements
public java.lang.String[] getSqlStatements()
getSqlStatements
- Returns:
- an array of
String
objects.
-
getStatements
public java.util.List<Statement> getStatements()
getStatements
- Returns:
- a
List
object.
-
getActionEvent
public ActionEvent getActionEvent(java.lang.String name)
getActionEvent
- Parameters:
name
- aString
object.- Returns:
- a
ActionEvent
object.
-
-