Package 

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

    • 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.
      • getSharedState

        @Nullable() abstract SharedStateResult getSharedState(@NonNull() String extensionName, @Nullable() Event event, boolean barrier, @NonNull() Object resolution)

        Gets the shared state data for a specified extension.

        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
      • 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.
      • getXDMSharedState

        @Nullable() abstract SharedStateResult getXDMSharedState(@NonNull() String extensionName, @Nullable() Event event, boolean barrier, @NonNull() Object 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.

      • registerEventListener

        @Deprecated() abstract <T extends ExtensionListener> boolean registerEventListener(String eventType, String eventSource, Class<T> extensionListenerClass, ExtensionErrorCallback<ExtensionError> errorCallback)

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

        This method executes asynchronously, returning immediately and registering the provided listener on the event hub thread. The provided ExtensionListener's constructor will be called when the registration is completed.

        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)
        extensionListenerClass - required parameter, the listener class which extends the parent class
        errorCallback - optional ExtensionErrorCallback which will be called if any error occurs during registration
      • registerWildcardListener

        @Deprecated() abstract <T extends ExtensionListener> boolean registerWildcardListener(Class<T> extensionListenerClass, ExtensionErrorCallback<ExtensionError> errorCallback)

        Registers a new wildcard event listener for the current extension. This listener will receive all events that are dispatched by the event hub.

        You can register only one wildcard listener for your extension. If this method is called multiple times, the the existing wildcard listener will be unregistered before the new listener is registered.

        This method executes asynchronously, returning immediately and registering the provided listener on the event hub thread. The provided ExtensionListener's constructor will be called when the registration is completed.

        A wildcard listener is intended for debugging purposes only and it is strongly recommended to not use it in a production environment.

        Parameters:
        extensionListenerClass - required parameter, the listener class which extends the parent class
        errorCallback - optional ExtensionErrorCallback which will be called if any error occurs during registration
      • setXDMSharedEventState

        @Deprecated() abstract boolean setXDMSharedEventState(Map<String, Object> state, Event event, ExtensionErrorCallback<ExtensionError> errorCallback)

        Called by extension to set an XDM shared state for itself. Usually called from a listener during event processing. 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.

        Parameters:
        state - Map<String, Object> representing current XDM state of this extension.
        event - The Event for which the state is being set.
        errorCallback - optional ExtensionErrorCallback which will be called if an error occurred
      • getXDMSharedEventState

        @Deprecated() abstract Map<String, Object> getXDMSharedEventState(String stateName, Event event, ExtensionErrorCallback<ExtensionError> errorCallback)

        Called by extension to get another extension's XDM shared state. Usually called from a listener during event processing. 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:
        stateName - extension name for which to retrieve data.
        event - the Event for which the state is being requested.
        errorCallback - optional ExtensionErrorCallback which will be called if an error occurred or if stateName is null