Class ExtensionApi

  • All Implemented Interfaces:

    
    public abstract class ExtensionApi
    
                        

    Class that defines all the public methods an Extension may call to interface with the AEP SDK.

    • Constructor Detail

      • ExtensionApi

        ExtensionApi()
    • Method Detail

      • registerEventListener

         abstract void registerEventListener(@NonNull() String eventType, @NonNull() String eventSource, @NonNull() ExtensionEventListener eventListener)

        Registers a new event listener for current extension for the provided event type and source.

        Parameters:
        eventType - required parameter, the event type as a valid string (not null or empty)
        eventSource - required parameter, the event source as a valid string (not null or empty)
        eventListener - required parameter, the listener which extends the interface
      • dispatch

         abstract void dispatch(@NonNull() Event event)

        Dispatches an `Event` to the `EventHub`

        Parameters:
        event - An Event to be dispatched to the EventHub
      • startEvents

         abstract void startEvents()

        Starts the `Event` queue for this extension

      • stopEvents

         abstract void stopEvents()

        Stops the `Event` queue for this extension

      • createSharedState

         abstract void createSharedState(@NonNull() Map<String, Object> state, @Nullable() Event event)

        Creates a new shared state for this extension. If event is null, one of two behaviors will be observed:

        • If this extension has not previously published a shared state, shared state will be versioned at 0
        • If this extension has previously published a shared state, shared state will be versioned at the latest
        Parameters:
        state - Map<String, Object> representing current state of this extension
        event - The Event for which the state is being set.
      • createPendingSharedState

        @Nullable() abstract SharedStateResolver createPendingSharedState(@Nullable() Event event)

        Creates a pending shared state for this extension.

        • If this extension has not previously published a shared state, shared state will be versioned at 0
        • If this extension has previously published a shared state, shared state will be versioned at the latest
        Parameters:
        event - The Event for which pending shared state is being set.
        Returns:

        SharedStateResolver that should be called with the shared state data when it is ready

      • createXDMSharedState

         abstract void createXDMSharedState(@NonNull() Map<String, Object> state, @Nullable() Event event)

        Creates a new XDM shared state for this extension. The state passed to this API needs to be mapped to known XDM mixins. If an extension uses multiple mixins, the current data for all of them should be provided when the XDM shared state is set. If event is null, one of two behaviors will be observed:

        • If this extension has not previously published a shared state, shared state will be versioned at 0
        • If this extension has previously published a shared state, shared state will be versioned at the latest
        Parameters:
        state - Map<String, Object> representing current state of this extension
        event - The Event for which the state is being set.
      • createPendingXDMSharedState

        @Nullable() abstract SharedStateResolver createPendingXDMSharedState(@Nullable() Event event)

        Creates a pending XDM shared state for this extension.

        • If this extension has not previously published a shared state, shared state will be versioned at 0
        • If this extension has previously published a shared state, shared state will be versioned at the latest
        Parameters:
        event - The Event for which pending shared state is being set.
        Returns:

        SharedStateResolver that should be called with the shared state data when it is ready

      • getXDMSharedState

        @Nullable() abstract SharedStateResult getXDMSharedState(@NonNull() String extensionName, @Nullable() Event event, boolean barrier, @NonNull() SharedStateResolution resolution)

        Gets the XDM shared state data for a specified extension. If the stateName extension populates multiple mixins in their shared state, all the data will be returned at once and it can be accessed using path discovery.

        Parameters:
        extensionName - extension name for which to retrieve data.
        event - the Event for which the state is being requested.
        barrier - If true, the EventHub will only return set if extensionName has moved past event.
        resolution - the SharedStateResolution to resolve for return SharedStateResult for the requested extensionName and event
      • unregisterExtension

         abstract void unregisterExtension()

        Unregisters current extension. This method executes asynchronously, unregistering the extension on the event hub thread. onUnregistered method will be called at the end of this operation.