Package org.osgi.framework.hooks.service

# Interface ListenerHook

@ConsumerType public interface ListenerHook
OSGi Framework Service Listener Hook Service.

Bundles registering this service will be called during service listener addition and removal.

## Nested Class Summary

Nested Classes
Modifier and Type
Interface
Description
`static interface`
`ListenerHook.ListenerInfo`
Information about a Service Listener.

## Method Summary

Modifier and Type
Method
Description
`void`
`added(Collection<ListenerHook.ListenerInfo> listeners)`
Added listeners hook method.
`void`
`removed(Collection<ListenerHook.ListenerInfo> listeners)`
Removed listeners hook method.

## Method Details

### added

void added(Collection<ListenerHook.ListenerInfo> listeners)
Added listeners hook method. This method is called to provide the hook implementation with information on newly added service listeners. This method will be called as service listeners are added while this hook is registered. Also, immediately after registration of this hook, this method will be called to provide the current collection of service listeners which had been added prior to the hook being registered.

Parameters:
  `listeners` - A collection of `ListenerHook.ListenerInfo`s for newly added service listeners which are now listening to service events. Attempting to add to or remove from the collection will result in an `UnsupportedOperationException`. The collection is not synchronized.

### removed

void removed(Collection<ListenerHook.ListenerInfo> listeners)
Removed listeners hook method. This method is called to provide the hook implementation with information on newly removed service listeners. This method will be called as service listeners are removed while this hook is registered.

Parameters:
  `listeners` - A collection of `ListenerHook.ListenerInfo`s for newly removed service listeners which are no longer listening to service events. Attempting to add to or remove from the collection will result in an `UnsupportedOperationException`. The collection is not synchronized.