Class NotificationManager
- java.lang.Object
-
- com.unboundid.directory.sdk.ds.api.NotificationManager
-
- All Implemented Interfaces:
Configurable
,ExampleUsageProvider
,Reconfigurable<NotificationManagerConfig>
,UnboundIDExtension
@Extensible @DirectoryServerExtension @ThreadSafety(level=INTERFACE_THREADSAFE) public abstract class NotificationManager extends java.lang.Object implements UnboundIDExtension, Reconfigurable<NotificationManagerConfig>, ExampleUsageProvider
This class defines an API that must be implemented by extensions which wish to deliver notification of changes of interest processed within the server.
Implementing a Notification Manager
Subscription management
A notification manager has one or more notification destinations which determine where notifications are to be delivered. Each notification destination has one or more notification subscriptions which determine which changes should result in a notification for that destination. Destinations and subscriptions each have associated details whose syntax is specific to the notification manager implementation. The notification manager implementation must implement the following methods to keep track of destinations, subscriptions and their associated details:- initializeNotificationDestinations
- areDestinationDetailsAcceptable
- setNotificationDestination
- deleteNotificationDestination
- areSubscriptionDetailsAcceptable
- setNotificationSubscription
- deleteNotificationSubscription
Matching changes with subscriptions
A notification manager must implement the following methods (one for each type of LDAP operation) to determine whether a change matches any notification subscriptions. The notification manager may provide arbitrary properties that it wishes to be included with a notification:- getAddNotificationProperties
- getDeleteNotificationProperties
- getModifyNotificationProperties
- getModifyDNNotificationProperties
Delivering notifications
A notification manager must implement the following method to attempt delivery of a notification to a destination:- attemptDelivery
Configuring a Notification Manager
The LDAP changelog must first be enabled on each server that is to deliver notifications:dsconfig set-backend-prop \ --backend-name changelog \ --set enabled:true
In order to configure a notification manager created using this API, use a command like:dsconfig create-notification-manager \ --manager-name "{manager-ID}" \ --type third-party \ --set enabled:true \ --set "extension-class:{class-name}" \ --set "subscription-base-dn:{subscription-base-dn}" \ --set "extension-argument:{name=value}"
where "{manager-ID}" is the ID to use for the notification manager instance, "{subscription-base-dn}" is the base DN where subscription information for this notification manager is to be stored, "{class-name}" is the fully-qualified name of the Java class that extendscom.unboundid.directory.sdk.ds.api.NotificationManager
, and "{name=value}" represents name-value pairs for any arguments to provide to the notification manager. If multiple arguments should be provided to the notification manager, then the "--set extension-argument:{name=value}
" option should be provided multiple times.
The notification manager must also be associated with a backend using a command like:dsconfig set-backend-prop \ --backend-name "userRoot" \ --set "notification-manager:{manager-ID}"
The {subscription-base-dn} of the notification manager must be within the scope of the base-dn of the backend.
The above configuration should be made on each server that holds a replica of the backend data to enable delivery of notifications for changes to that data.
-
-
Constructor Summary
Constructors Constructor Description NotificationManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ResultCode
applyConfiguration(NotificationManagerConfig config, ArgumentParser parser, java.util.List<java.lang.String> adminActionsRequired, java.util.List<java.lang.String> messages)
Attempts to apply the configuration from the provided argument parser to this extension.abstract boolean
areDestinationDetailsAcceptable(java.lang.String destinationID, java.util.List<ASN1OctetString> destinationDetails, java.util.List<java.lang.String> unacceptableReasons)
Determine whether the provided destination details are acceptable.abstract boolean
areSubscriptionDetailsAcceptable(java.lang.String destinationID, java.lang.String subscriptionID, java.util.List<ASN1OctetString> subscriptionDetails, java.util.List<java.lang.String> unacceptableReasons)
Determine whether the provided subscription details are acceptable.abstract NotificationDeliveryResult
attemptDelivery(Notification notification)
Attempt delivery of a notification and return a result indicating whether delivery was successful, and whether delivery should be retried if this attempt was unsuccessful.void
defineConfigArguments(ArgumentParser parser)
Updates the provided argument parser to define any configuration arguments which may be used by this extension.abstract void
deleteNotificationDestination(java.lang.String destinationID)
Delete a notification destination including any associated subscriptions.abstract void
deleteNotificationSubscription(java.lang.String destinationID, java.lang.String subscriptionID)
Delete a notification subscription.void
finalizeNotificationManager()
Performs any cleanup which may be necessary when this notification manager is to be taken out of service.java.util.List<NotificationProperties>
getAddNotificationProperties(AddRequest addRequest)
Deprecated.Override the other getAddNotificationProperties method instead.java.util.List<NotificationProperties>
getAddNotificationProperties(AddRequest addRequest, Entry addedEntry, OperationContext opContext)
Determine if any notifications are required for the provided add request and return notification properties for each notification destination that requires a notification.java.util.List<NotificationProperties>
getDeleteNotificationProperties(DeleteRequest deleteRequest)
Deprecated.Override the other getDeleteNotificationProperties method instead.java.util.List<NotificationProperties>
getDeleteNotificationProperties(DeleteRequest deleteRequest, Entry deletedEntry, OperationContext opContext)
Determine if any notifications are required for the provided delete request and return notification properties for each notification destination that requires a notification.java.util.Map<java.util.List<java.lang.String>,java.lang.String>
getExamplesArgumentSets()
Retrieves a map containing examples of configurations that may be used for this extension.abstract java.lang.String[]
getExtensionDescription()
Retrieves a human-readable description for this extension.abstract java.lang.String
getExtensionName()
Retrieves a human-readable name for this extension.java.util.List<NotificationProperties>
getModifyDNNotificationProperties(ModifyDNRequest modifyDNRequest)
Deprecated.Override the other getModifyDNNotificationProperties method instead.java.util.List<NotificationProperties>
getModifyDNNotificationProperties(ModifyDNRequest modifyDNRequest, Entry oldEntry, Entry newEntry, OperationContext opContext)
Determine if any notifications are required for the provided modify DN request and return notification properties for each notification destination that requires a notification.java.util.List<NotificationProperties>
getModifyNotificationProperties(ModifyRequest modifyRequest)
Deprecated.Override the other getModifyNotificationProperties method instead.java.util.List<NotificationProperties>
getModifyNotificationProperties(ModifyRequest modifyRequest, Entry oldEntry, Entry newEntry, OperationContext opContext)
Determine if any notifications are required for the provided modify request and return notification properties for each notification destination that requires a notification.abstract void
initializeNotificationDestinations(java.util.List<NotificationDestinationDetails> destinations)
Initializes or re-initializes the notification destinations for this notification manager.void
initializeNotificationManager(DirectoryServerContext serverContext, NotificationManagerConfig config, ArgumentParser parser)
Initializes this notification manager.boolean
isConfigurationAcceptable(NotificationManagerConfig config, ArgumentParser parser, java.util.List<java.lang.String> unacceptableReasons)
Indicates whether the configuration represented by the provided argument parser is acceptable for use by this extension.abstract boolean
isPreferredForDestination(java.lang.String destinationID)
Determine whether the server running this extension is preferred for the given notification destination.abstract void
setNotificationDestination(java.lang.String destinationID, java.util.List<ASN1OctetString> destinationDetails)
Create or update a notification destination.abstract void
setNotificationSubscription(java.lang.String destinationID, java.lang.String subscriptionID, java.util.List<ASN1OctetString> subscriptionDetails)
Create or update a notification subscription.
-
-
-
Constructor Detail
-
NotificationManager
public NotificationManager()
-
-
Method Detail
-
getExtensionName
public abstract java.lang.String getExtensionName()
Retrieves a human-readable name for this extension.- Specified by:
getExtensionName
in interfaceUnboundIDExtension
- Returns:
- A human-readable name for this extension.
-
getExtensionDescription
public abstract java.lang.String[] getExtensionDescription()
Retrieves a human-readable description for this extension. Each element of the array that is returned will be considered a separate paragraph in generated documentation.- Specified by:
getExtensionDescription
in interfaceUnboundIDExtension
- Returns:
- A human-readable description for this extension, or
null
or an empty array if no description should be available.
-
defineConfigArguments
public void defineConfigArguments(ArgumentParser parser) throws ArgumentException
Updates the provided argument parser to define any configuration arguments which may be used by this extension. The argument parser may also be updated to define relationships between arguments (e.g., to specify required, exclusive, or dependent argument sets).- Specified by:
defineConfigArguments
in interfaceConfigurable
- Parameters:
parser
- The argument parser to be updated with the configuration arguments which may be used by this extension.- Throws:
ArgumentException
- If a problem is encountered while updating the provided argument parser.
-
initializeNotificationManager
public void initializeNotificationManager(DirectoryServerContext serverContext, NotificationManagerConfig config, ArgumentParser parser) throws LDAPException
Initializes this notification manager.- Parameters:
serverContext
- A handle to the server context for the server in which this extension is running.config
- The general configuration for this notification manager.parser
- The argument parser which has been initialized from the configuration for this notification manager.- Throws:
LDAPException
- If a problem occurs while initializing this notification manager.
-
initializeNotificationDestinations
public abstract void initializeNotificationDestinations(java.util.List<NotificationDestinationDetails> destinations) throws LDAPException
Initializes or re-initializes the notification destinations for this notification manager. This will be called once after the notification manager has been initialized and any time subsequently.- Parameters:
destinations
- The list of defined notification destinations and their associated subscriptions.- Throws:
LDAPException
- If a problem occurs while initializing the notification destinations for this notification manager.
-
areDestinationDetailsAcceptable
public abstract boolean areDestinationDetailsAcceptable(java.lang.String destinationID, java.util.List<ASN1OctetString> destinationDetails, java.util.List<java.lang.String> unacceptableReasons)
Determine whether the provided destination details are acceptable. If this method returns true then it is expected that a call tosetNotificationDestination
with the same details will not fail due to invalid details.- Parameters:
destinationID
- The notification destination ID.destinationDetails
- The notification destination details.unacceptableReasons
- A list that may be used to hold the reasons that the provided details are not acceptable.- Returns:
true
if the provided details are acceptable.
-
setNotificationDestination
public abstract void setNotificationDestination(java.lang.String destinationID, java.util.List<ASN1OctetString> destinationDetails) throws LDAPException
Create or update a notification destination.- Parameters:
destinationID
- The notification destination ID.destinationDetails
- The notification destination details.- Throws:
LDAPException
- If a problem occurs while creating or updating the notification destination.
-
areSubscriptionDetailsAcceptable
public abstract boolean areSubscriptionDetailsAcceptable(java.lang.String destinationID, java.lang.String subscriptionID, java.util.List<ASN1OctetString> subscriptionDetails, java.util.List<java.lang.String> unacceptableReasons)
Determine whether the provided subscription details are acceptable. If this method returns true then it is expected that a call to setNotificationSubscription with the same details will not fail due to invalid details.- Parameters:
destinationID
- The notification destination ID.subscriptionID
- The notification subscription ID.subscriptionDetails
- The notification subscription details.unacceptableReasons
- A list that may be used to hold the reasons that the provided details are not acceptable.- Returns:
true
if the provided details are acceptable.
-
setNotificationSubscription
public abstract void setNotificationSubscription(java.lang.String destinationID, java.lang.String subscriptionID, java.util.List<ASN1OctetString> subscriptionDetails) throws LDAPException
Create or update a notification subscription.- Parameters:
destinationID
- The notification destination ID.subscriptionID
- The notification subscription ID.subscriptionDetails
- The notification destination details.- Throws:
LDAPException
- If a problem occurs while creating or updating the notification subscription.
-
deleteNotificationDestination
public abstract void deleteNotificationDestination(java.lang.String destinationID)
Delete a notification destination including any associated subscriptions.- Parameters:
destinationID
- The notification destination ID.
-
deleteNotificationSubscription
public abstract void deleteNotificationSubscription(java.lang.String destinationID, java.lang.String subscriptionID)
Delete a notification subscription.- Parameters:
destinationID
- The notification destination ID.subscriptionID
- The notification subscription ID.
-
isPreferredForDestination
public abstract boolean isPreferredForDestination(java.lang.String destinationID)
Determine whether the server running this extension is preferred for the given notification destination. For example, this method could returntrue
if this server is local to the destination.- Parameters:
destinationID
- The notification destination ID.- Returns:
true
if this server is preferred for the given notification destination.
-
getAddNotificationProperties
@Deprecated public java.util.List<NotificationProperties> getAddNotificationProperties(AddRequest addRequest)
Deprecated.Override the other getAddNotificationProperties method instead.This method is only provided for backwards compatibility. Subclasses should implement the alternate version of getAddNotificationProperties below. In which case, this method will not be called. Determine if any notifications are required for the provided add request and return notification properties for each notification destination that requires a notification.- Parameters:
addRequest
- The add request that is being processed.- Returns:
- A list of notification properties with an element for each
notification destination that requires a notification. An
empty or
null
list indicates that the operation does not require any notifications.
-
getAddNotificationProperties
public java.util.List<NotificationProperties> getAddNotificationProperties(AddRequest addRequest, Entry addedEntry, OperationContext opContext)
Determine if any notifications are required for the provided add request and return notification properties for each notification destination that requires a notification.- Parameters:
addRequest
- The add request that is being processed.addedEntry
- The entry that was added.opContext
- The operation context for the current operation.- Returns:
- A list of notification properties with an element for each
notification destination that requires a notification. An
empty or
null
list indicates that the operation does not require any notifications.
-
getDeleteNotificationProperties
@Deprecated public java.util.List<NotificationProperties> getDeleteNotificationProperties(DeleteRequest deleteRequest)
Deprecated.Override the other getDeleteNotificationProperties method instead.This method is only provided for backwards compatibility. Subclasses should implement the alternate version of getDeleteNotificationProperties below. In which case, this method will not be called. Determine if any notifications are required for the provided delete request and return notification properties for each notification destination that requires a notification.- Parameters:
deleteRequest
- The delete request that is being processed.- Returns:
- A list of notification properties with an element for each
notification destination that requires a notification. An
empty or
null
list indicates that the operation does not require any notifications.
-
getDeleteNotificationProperties
public java.util.List<NotificationProperties> getDeleteNotificationProperties(DeleteRequest deleteRequest, Entry deletedEntry, OperationContext opContext)
Determine if any notifications are required for the provided delete request and return notification properties for each notification destination that requires a notification.- Parameters:
deleteRequest
- The delete request that is being processed.deletedEntry
- The entry against which the delete operation was processed, if available, andnull
otherwise.opContext
- The operation context for the current operation.- Returns:
- A list of notification properties with an element for each
notification destination that requires a notification. An
empty or
null
list indicates that the operation does not require any notifications.
-
getModifyNotificationProperties
@Deprecated public java.util.List<NotificationProperties> getModifyNotificationProperties(ModifyRequest modifyRequest)
Deprecated.Override the other getModifyNotificationProperties method instead.This method is only provided for backwards compatibility. Subclasses should implement the alternate version of getModifyNotificationProperties below. In which case, this method will not be called. Determine if any notifications are required for the provided modify request and return notification properties for each notification destination that requires a notification.- Parameters:
modifyRequest
- The modify request that is being processed.- Returns:
- A list of notification properties with an element for each
notification destination that requires a notification. An
empty or
null
list indicates that the operation does not require any notifications.
-
getModifyNotificationProperties
public java.util.List<NotificationProperties> getModifyNotificationProperties(ModifyRequest modifyRequest, Entry oldEntry, Entry newEntry, OperationContext opContext)
Determine if any notifications are required for the provided modify request and return notification properties for each notification destination that requires a notification.- Parameters:
modifyRequest
- The modify request that is being processed.oldEntry
- The entry as it appeared before the modify operation, ornull
if it is not available.newEntry
- The entry as it appeared after the modify operation, ornull
if it is not available.opContext
- The operation context for the current operation.- Returns:
- A list of notification properties with an element for each
notification destination that requires a notification. An
empty or
null
list indicates that the operation does not require any notifications.
-
getModifyDNNotificationProperties
@Deprecated public java.util.List<NotificationProperties> getModifyDNNotificationProperties(ModifyDNRequest modifyDNRequest)
Deprecated.Override the other getModifyDNNotificationProperties method instead.This method is only provided for backwards compatibility. Subclasses should implement the alternate version of getModifyDNNotificationProperties below. In which case, this method will not be called. Determine if any notifications are required for the provided modify DN request and return notification properties for each notification destination that requires a notification.- Parameters:
modifyDNRequest
- The modify DN request that is being processed.- Returns:
- A list of notification properties with an element for each
notification destination that requires a notification. An
empty or
null
list indicates that the operation does not require any notifications.
-
getModifyDNNotificationProperties
public java.util.List<NotificationProperties> getModifyDNNotificationProperties(ModifyDNRequest modifyDNRequest, Entry oldEntry, Entry newEntry, OperationContext opContext)
Determine if any notifications are required for the provided modify DN request and return notification properties for each notification destination that requires a notification.- Parameters:
modifyDNRequest
- The modify DN request that is being processed.oldEntry
- The entry as it appeared before the modify DN operation, ornull
if it is not available.newEntry
- The entry as it appeared after the modify DN operation, ornull
if it is not available.opContext
- The operation context for the current operation.- Returns:
- A list of notification properties with an element for each
notification destination that requires a notification. An
empty or
null
list indicates that the operation does not require any notifications.
-
attemptDelivery
public abstract NotificationDeliveryResult attemptDelivery(Notification notification)
Attempt delivery of a notification and return a result indicating whether delivery was successful, and whether delivery should be retried if this attempt was unsuccessful. Notification manager implementations should be careful not to returnRETRY
when all future attempts of the notification delivery will fail, e.g. a remote change failing due to a schema violation. If the extension can determine that the remote service is completely unavailable, then it is fine to continue to retry, but if the service is available and only failing for some changes, then continuing to retry is dangerous. There are methods on theNotification
interface to determine how many attempts have been made and for how long attempts have been made. Above some threshold, the extension should returnFAILURE
instead ofRETRY
.
This method must be written to be thread-safe because notifications of changes that do not depend on each other are processed in parallel (e.g. when the changes affect unrelated entries).- Parameters:
notification
- The notification to be delivered.- Returns:
- A delivery result indicating whether delivery was successful, and whether delivery should be retried if this attempt was unsuccessful.
-
isConfigurationAcceptable
public boolean isConfigurationAcceptable(NotificationManagerConfig config, ArgumentParser parser, java.util.List<java.lang.String> unacceptableReasons)
Indicates whether the configuration represented by the provided argument parser is acceptable for use by this extension. The parser will have been used to parse any configuration available for this extension, and any automatic validation will have been performed. This method may be used to perform any more complex validation which cannot be performed automatically by the argument parser.- Specified by:
isConfigurationAcceptable
in interfaceReconfigurable<NotificationManagerConfig>
- Parameters:
config
- The general configuration for this extension.parser
- The argument parser that has been used to parse the proposed configuration for this extension.unacceptableReasons
- A list to which messages may be added to provide additional information about why the provided configuration is not acceptable.- Returns:
true
if the configuration in the provided argument parser appears to be acceptable, orfalse
if not.
-
applyConfiguration
public ResultCode applyConfiguration(NotificationManagerConfig config, ArgumentParser parser, java.util.List<java.lang.String> adminActionsRequired, java.util.List<java.lang.String> messages)
Attempts to apply the configuration from the provided argument parser to this extension.- Specified by:
applyConfiguration
in interfaceReconfigurable<NotificationManagerConfig>
- Parameters:
config
- The general configuration for this extension.parser
- The argument parser that has been used to parse the new configuration for this extension.adminActionsRequired
- A list to which messages may be added to provide additional information about any additional administrative actions that may be required to apply some of the configuration changes.messages
- A list to which messages may be added to provide additional information about the processing performed by this method.- Returns:
- A result code providing information about the result of applying
the configuration change. A result of
SUCCESS
should be used to indicate that all processing completed successfully. Any other result will indicate that a problem occurred during processing.
-
finalizeNotificationManager
public void finalizeNotificationManager()
Performs any cleanup which may be necessary when this notification manager is to be taken out of service.
-
getExamplesArgumentSets
public java.util.Map<java.util.List<java.lang.String>,java.lang.String> getExamplesArgumentSets()
Retrieves a map containing examples of configurations that may be used for this extension. The map key should be a list of sample arguments, and the corresponding value should be a description of the behavior that will be exhibited by the extension when used with that configuration.- Specified by:
getExamplesArgumentSets
in interfaceExampleUsageProvider
- Returns:
- A map containing examples of configurations that may be used for
this extension. It may be
null
or empty if there should not be any example argument sets.
-
-