Previous Topic

Next Topic

Book Contents

Book Index

Functional Item Events

Description of the Functional Item Events subscription mechanism.

Overview

Functional Items Management uses the OSGi Event Admin service to publish events asynchronously on:

Each event contains the properties describing the event and all the Functional Item attributes also.

The FunctionalItemEventConstants interface defines a set of constants related to FunctionalItem events.

Event Topic Constants

Additional Property Constants

Other Constants Related to FunctionalItem Events

FunctionalItemEvent Utility

The FunctionalItemEvent is a utility, part of the com.prosyst.mbs.services.fim.util package, that wraps a Functional Item Management event under the com/prosyst/mbs/services/fim/FunctionalItemEvent/ event topic. The constructor creates a FunctionalItemEvent for an event which topic is part of FunctionalItemEventConstants.FIM_PACKAGE, and the utility can be used for simple access to the added event properties.

Bellow you can find an example how to get the UID, old and new value of the property when using the FunctionalItemEvent.

    ...
    FunctionalItemEvent stateEvent = new FunctionalItemEvent(event);
    final String uid = stateEvent.getUID();
    final State oldState = stateEvent.getPropertyChangedOldValue();
    final State newState = stateEvent.getPropertyChangedNewValue();

    System.out.println("Binary switch '" + uid + "' state was changed from '"
      + oldState + "' to '" + newState + '\'');
  }

Examples

If Functional Item access is set to eventable in case of Operation executions it throws information for the event (to be able to view the event information one must be subscribed for events):

The OSGi EventAdmin service is used to send events when a new group is added, removed, group items are changed, etc. For example, to receive events when functional item is added as subgroup of a group, the application must register EventHandler with topic FunctionalItemEventConstants.TOPIC_PROPERTY_CHANGED and event property Constants.OBJECTCLASS that has value com.prosyst.mbs.services.fim.groups.Group. If a group is successfully created/removed an operation executed event is fired with topic FunctionalItemEventConstants.TOPIC_OPERATION_EXECUTED.

It contains the properties:

In order to receive the event the subscriber should have FunctionalItemPermission.ACCESS_TYPE_VALUE_READ for Group.ITEMS property. Additionally, Group.ADD_ITEM / Group.REMOVE_ITEM operation executed events are fired for each group that the created/removed group is added to/removed from.

fim>$FI EVENT HANDLER: 1
-----------------------------------------------------------------------------------------------------------------------
FI EVENT                    REGISTERED
event.topics                com/prosyst/mbs/services/fim/FunctionalItemEvent/REGISTERED
factory.uid                 fim:group:admin
objectClass                 {com.prosyst.mbs.services.fim.groups.Group,com.prosyst.mbs.services.fim.FunctionalItem}
timestamp                   1428044123721
uid                         fim:group:24
FI EVENT HANDLER: 1
-----------------------------------------------------------------------------------------------------------------------
FI EVENT                    OPERATION_EXECUTED
event.topics                com/prosyst/mbs/services/fim/FunctionalItemEvent/OPERATION_EXECUTED
item                        fim:group:24
name                        Group Admin
objectClass                 {com.prosyst.mbs.services.fim.groups.GroupAdmin,com.prosyst.mbs.services.fim.FunctionalItemFactory,com.prosyst.mbs.services.fim.FunctionalItem}
operation.name              create
supportedClasses            {com.prosyst.mbs.services.fim.groups.Group}
timestamp                   1428044123721
uid                         fim:group:admin