Class NotificationServiceManager

java.lang.Object
org.apache.nifi.bootstrap.NotificationServiceManager

public class NotificationServiceManager extends Object
  • Field Details

  • Constructor Details

    • NotificationServiceManager

      public NotificationServiceManager()
  • Method Details

    • setMaxNotificationAttempts

      public void setMaxNotificationAttempts(int maxAttempts)
    • loadNotificationServices

      public void loadNotificationServices(File servicesFile) throws IOException
      Loads the Notification Services from the given XML configuration file. File is expected to have the following format:
       <services>
         <service>
           <id>service-identifier</id>
           <class>org.apache.nifi.MyNotificationService</class>
           <property name="My First Property">Property Value</property>
         </service>
         <service>
           <id>other-service</id>
           <class>org.apache.nifi.MyOtherNotificationService</class>
           <property name="Another Property">Property Value 2</property>
         </service>
         ...
         <service>
           <id>service-identifier-2</id>
           <class>org.apache.nifi.FinalNotificationService</class>
           <property name="Yet Another Property">3rd Prop Value</property>
         </service>
       </services>
       
      Note that as long as the file can be interpreted properly, a misconfigured service will result in a warning or error being logged and the service will be unavailable but will not prevent the rest of the services from loading.
      Parameters:
      servicesFile - the XML file to load services from.
      Throws:
      IOException - if unable to read from the given file
    • notify

      public void notify(NotificationType type, String subject, String message)
    • buildNotificationContext

    • registerNotificationService

      public void registerNotificationService(NotificationType type, String serviceId)
      Registers the service that has the given identifier to respond to notifications of the given type
      Parameters:
      type - the type of notification to register the service for
      serviceId - the identifier of the service
    • createService

      private NotificationServiceManager.ConfiguredNotificationService createService(Element serviceElement)
      Creates a Notification Service and initializes it. Then returns the service and its configured properties
      Parameters:
      serviceElement - the XML element from which to build the Notification Service
      Returns:
      a Tuple with the NotificationService as the key and the configured properties as the value, or null if unable to create the service
    • getChild

      public static Element getChild(Element element, String tagName)
    • getChildElementsByTagName

      public static List<Element> getChildElementsByTagName(Element element, String tagName)