Interface CustomEventBuilder


  • public interface CustomEventBuilder
    A builder for custom integration server events. To obtain a builder and fire a custom event one must be aware of the following parameters.
    • a connection to the saperion system to fire the event
    • the name of the custom event
    • the attributes of the custom event
    To fire a custom event one will start by obtaining an EventManager. For this one needs an already authenticated classic connector:
    
         EventManager manager = EventManager.newEventManager(myClassicConnector);
         ... 
     
    After that one can obtain a CustomEventBuilder from the EventManager by specifying the events name:
    
         ...
         CustomEventBuilder builder = manager.newCustomEvent("my.name");  
         ... 
     
    Now one may give as many attributes as necessary to the event. This may happen attribute by attribute:
     
         ... 
         builder.setAttribute("key1", "value1");
         builder.setAttribute("key2", "value2");
         builder.setAttribute("key3", "value3");
         builder.setAttribute("key4", "value4");
         ...
     
    Alternatively one may add an already prepared map of strings:
     
         ...
         Map<String, String> myStringMap = getMyPreparedAttributes(); 
         builder.addAll(myStringMap);
         ...
     
    One may also add the attributes as an instance of java.util.Properties:
         ...
         Properties properties = new Properties(); 
         properties.load(myFileReader); 
         builder.addAll(properties); 
         ... 
     
    Finally the event can be fired:
     
         ... 
         builder.fire(); 
     
    This may also be done fluently:
    
         EventManager.newEventManager(myClassicConnector).newCustomEvent("my.name") 
                      .setAttribute("myFirstKey", "myFirstValue").setAttribute("mySecondKey", "mySecondValue").fire(); 
     
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      CustomEventBuilder addAll​(java.util.Map<java.lang.String,​java.lang.String> attributes)
      Adds every entry of the given map as an attribute
      CustomEventBuilder addAll​(java.util.Properties properties)
      Convenience method to add a properties object as attributes.
      void fire()
      Fires the custom event defined by this builder.
      CustomEventBuilder setAttribute​(java.lang.String key, java.lang.String value)
      Sets an attribute.
      <SerializableMap extends java.util.Map<java.lang.String,​java.lang.String>,​Serializable>
      CustomEventBuilder
      setAttributes​(SerializableMap map)
      Discards the attributes given already and uses the given ones instead.
    • Method Detail

      • setAttribute

        CustomEventBuilder setAttribute​(java.lang.String key,
                                        java.lang.String value)
        Sets an attribute.
        Parameters:
        key - the key to store the attribute as
        value - the value of the attribute
        Returns:
        The event builder with the attribute added
      • addAll

        CustomEventBuilder addAll​(java.util.Map<java.lang.String,​java.lang.String> attributes)
        Adds every entry of the given map as an attribute
        Parameters:
        attributes - the attributes to add
        Returns:
        The event builder with the attributes added
      • addAll

        CustomEventBuilder addAll​(java.util.Properties properties)
        Convenience method to add a properties object as attributes.
        Parameters:
        properties - The properties to add
        Returns:
        The event builder with the properties added as attributes
      • setAttributes

        <SerializableMap extends java.util.Map<java.lang.String,​java.lang.String>,​Serializable> CustomEventBuilder setAttributes​(SerializableMap map)
        Discards the attributes given already and uses the given ones instead.
        Parameters:
        map - The attributes to use. Note that they have to be given in a map that implements both Map and CustomEventBuilder
        Returns:
        The event builder with the attributes added