Package com.saperion.connector.events
Interface CustomEventBuilder
-
public interface CustomEventBuilderA 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
EventManager. For this one needs an already authenticated classic connector:
After that one can obtain a CustomEventBuilder from theEventManagermanager =EventManager.newEventManager(myClassicConnector); ...EventManagerby specifying the events name:
Now one may give as many attributes as necessary to the event. This may happen attribute by attribute:... CustomEventBuilder builder =manager.newCustomEvent("my.name"); ...
Alternatively one may add an already prepared map of strings:... builder.setAttribute("key1", "value1"); builder.setAttribute("key2", "value2"); builder.setAttribute("key3", "value3"); builder.setAttribute("key4", "value4"); ...
One may also add the attributes as an instance of java.util.Properties:... Map<String, String> myStringMap = getMyPreparedAttributes(); builder.addAll(myStringMap); ...Finally the event can be fired:... Properties properties = new Properties(); properties.load(myFileReader); builder.addAll(properties); ...
This may also be done fluently:... builder.fire();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 CustomEventBuilderaddAll(java.util.Map<java.lang.String,java.lang.String> attributes)Adds every entry of the given map as an attributeCustomEventBuilderaddAll(java.util.Properties properties)Convenience method to add a properties object as attributes.voidfire()Fires the custom event defined by this builder.CustomEventBuildersetAttribute(java.lang.String key, java.lang.String value)Sets an attribute.<SerializableMap extends java.util.Map<java.lang.String,java.lang.String>,Serializable>
CustomEventBuildersetAttributes(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 asvalue- 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 bothMapandCustomEventBuilder- Returns:
- The event builder with the attributes added
-
fire
void fire() throws SaAuthenticationException, SaSystemException
Fires the custom event defined by this builder.
-
-