@Singleton @Named(value="HK2TopicDistributionService") @ContractsProvided(value={TopicDistributionService.class,InstanceLifecycleListener.class,DynamicConfigurationListener.class}) public class DefaultTopicDistributionService extends java.lang.Object implements TopicDistributionService, InstanceLifecycleListener, DynamicConfigurationListener
| Modifier and Type | Class and Description |
|---|---|
private static class |
DefaultTopicDistributionService.ActivatorClassKey
This is here to handle the case where a PerLookup Factory (or the like)
could possibly return different classes every time it is looked up.
|
private static class |
DefaultTopicDistributionService.FireResults |
private static class |
DefaultTopicDistributionService.SubscriberInfo |
| Modifier and Type | Field and Description |
|---|---|
private java.util.HashMap<DefaultTopicDistributionService.ActivatorClassKey,java.util.List<DefaultTopicDistributionService.SubscriberInfo>> |
class2Subscribers |
private java.util.HashMap<ActiveDescriptor<?>,java.util.Set<java.lang.Class<?>>> |
descriptor2Classes |
private IterableProvider<DefaultTopicDistributionErrorService> |
errorHandlers |
private ServiceLocator |
locator |
private java.util.concurrent.locks.ReentrantReadWriteLock |
readWriteLock |
private ClassReflectionHelper |
reflectionHelper |
private java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock |
rLock |
private static Filter |
SUBSCRIBER_FILTER |
private java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock |
wLock |
HK2_DEFAULT_TOPIC_DISTRIBUTOR| Constructor and Description |
|---|
DefaultTopicDistributionService() |
| Modifier and Type | Method and Description |
|---|---|
void |
configurationChanged()
This method is called when the set of descriptors
in this service locator has been changed.
|
void |
distributeMessage(Topic<?> topic,
java.lang.Object message)
Must distribute the message to all of the matching topic subscribers.
|
private java.lang.reflect.Method |
findMethodOnDifferentClass(java.lang.Class<?> findOnMe,
java.lang.reflect.Method method) |
private static void |
fire(java.lang.Object message,
java.lang.reflect.Method subscription,
DefaultTopicDistributionService.SubscriberInfo subscriptionInfo,
java.lang.Object target,
ServiceLocator locator) |
private static DefaultTopicDistributionService.SubscriberInfo |
generateSubscriberInfo(ActiveDescriptor<?> injecteeDescriptor,
java.lang.reflect.Method subscriber,
java.lang.reflect.Method useSubscriber,
int subscribeToPosition,
java.lang.annotation.Annotation[][] paramAnnotations) |
Filter |
getFilter()
This returns a filter that tells the system whether a particular descriptor should be handled by this lifecycle
listener.
|
private java.util.List<DefaultTopicDistributionService.FireResults> |
handleDescriptorToClass(ActiveDescriptor<?> descriptor,
java.lang.Class<?> clazz,
java.lang.reflect.Type eventType,
Topic<?> topic) |
void |
lifecycleEvent(InstanceLifecycleEvent lifecycleEvent)
This method will be called when any lifecycle event occurs.
|
private void |
postProduction(InstanceLifecycleEvent lifecycleEvent) |
private void |
preDestruction(InstanceLifecycleEvent lifecycleEvent) |
private static final Filter SUBSCRIBER_FILTER
@Inject private ServiceLocator locator
@Inject private IterableProvider<DefaultTopicDistributionErrorService> errorHandlers
private final ClassReflectionHelper reflectionHelper
private final java.util.HashMap<ActiveDescriptor<?>,java.util.Set<java.lang.Class<?>>> descriptor2Classes
private final java.util.HashMap<DefaultTopicDistributionService.ActivatorClassKey,java.util.List<DefaultTopicDistributionService.SubscriberInfo>> class2Subscribers
private final java.util.concurrent.locks.ReentrantReadWriteLock readWriteLock
private final java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock wLock
private final java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock rLock
private static void fire(java.lang.Object message,
java.lang.reflect.Method subscription,
DefaultTopicDistributionService.SubscriberInfo subscriptionInfo,
java.lang.Object target,
ServiceLocator locator)
throws java.lang.Throwable
java.lang.Throwableprivate java.util.List<DefaultTopicDistributionService.FireResults> handleDescriptorToClass(ActiveDescriptor<?> descriptor, java.lang.Class<?> clazz, java.lang.reflect.Type eventType, Topic<?> topic)
public void distributeMessage(Topic<?> topic, java.lang.Object message)
TopicDistributionServicedistributeMessage in interface TopicDistributionServicetopic - The topic to which to distribute the message. Must not be nullmessage - The message to send to the topic. Must not be nullpublic Filter getFilter()
InstanceLifecycleListenergetFilter in interface InstanceLifecycleListenerprivate void postProduction(InstanceLifecycleEvent lifecycleEvent)
private java.lang.reflect.Method findMethodOnDifferentClass(java.lang.Class<?> findOnMe,
java.lang.reflect.Method method)
private static DefaultTopicDistributionService.SubscriberInfo generateSubscriberInfo(ActiveDescriptor<?> injecteeDescriptor, java.lang.reflect.Method subscriber, java.lang.reflect.Method useSubscriber, int subscribeToPosition, java.lang.annotation.Annotation[][] paramAnnotations)
private void preDestruction(InstanceLifecycleEvent lifecycleEvent)
public void lifecycleEvent(InstanceLifecycleEvent lifecycleEvent)
InstanceLifecycleListenerlifecycleEvent in interface InstanceLifecycleListenerlifecycleEvent - The event that has occurred, will not be nullpublic void configurationChanged()
DynamicConfigurationListenerDynamicConfiguration.commit() so care should be taken
to do any work quickly. Any exception thrown from this method
will be ignored. A commit that failed will not be reported to
this methodconfigurationChanged in interface DynamicConfigurationListener