Package com.saperion.connector.events
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
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
Modifier and TypeMethodDescriptionAdds every entry of the given map as an attributeaddAll
(Properties properties) Convenience method to add a properties object as attributes.void
fire()
Fires the custom event defined by this builder.setAttribute
(String key, String value) Sets an attribute.<SerializableMap extends Map<String,
String>, Serializable>
CustomEventBuildersetAttributes
(SerializableMap map) Discards the attributes given already and uses the given ones instead.
-
Method Details
-
setAttribute
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
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
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 Map<String,String>, CustomEventBuilder setAttributesSerializable> (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 bothMap
andCustomEventBuilder
- Returns:
- The event builder with the attributes added
-
fire
Fires the custom event defined by this builder.
-