com.neeve.managed.toa.hk2
Class AbstractHK2TopicOrientedApplication

java.lang.Object
  extended by com.neeve.toa.TopicOrientedApplication
      extended by com.neeve.managed.toa.hk2.AbstractHK2TopicOrientedApplication
All Implemented Interfaces:
MessageInjector, MessageSender

public abstract class AbstractHK2TopicOrientedApplication
extends TopicOrientedApplication

The AbstractHK2TopicOrientedApplication is the base class for TOA Applications that want to leverage the HK2 Dependency Injection Framework. HK2 provides a light-weight but powerful dependency injection mechanism. The AbstractHK2TopicOrientedApplication integrates HK2 with Talon Application Server and the Hornet Application Framework so that HK2 can be used to discover Talon Managed Objects and Hornet Applications gain access to a Application ServiceLocator. Hornet Applications that want to leverage HK2 must extend this class and not TopicOrientedApplication.

See Also:
com.neeve.managed.toa.hk2

Nested Class Summary
 
Nested classes/interfaces inherited from class com.neeve.toa.TopicOrientedApplication
TopicOrientedApplication.ChannelJoin
 
Field Summary
 
Fields inherited from class com.neeve.toa.TopicOrientedApplication
_tracer, PROP_ALERT_TRACE_LEVEL, PROP_ALERT_TRACE_LEVEL_DEFAULT, PROP_DEFAULT_INJECTION_DELAY, PROP_DEFAULT_INJECTION_DELAY_DEFAULT, PROP_DISABLE_COMPAT_CHECK, PROP_DISABLE_COMPAT_CHECK_DEFAULT, PROP_GENERIC_HANDLER_JOINS_ALL, PROP_GENERIC_HANDLER_JOINS_ALL_DEFAULT, PROP_IGNORE_UNMAPPED_CHANNELS, PROP_IGNORE_UNMAPPED_CHANNELS_DEFAULT
 
Constructor Summary
AbstractHK2TopicOrientedApplication()
           
 
Method Summary
protected abstract  List<Binder> getApplicationModules()
          Get the Application Modules.
protected  ServiceLocator getApplicationServiceLocator()
          Return the Application ServiceLocator.
protected  ManagedObjectLocator getManagedObjectLocator()
          Subclasses may override this method to change the strategy for locating an application's managed objects.
protected abstract  String getName()
          Get the Application Name.
protected  void onEngineDescriptorInjected(AepEngineDescriptor engineDescriptor)
          The AbstractHK2TopicOrientedApplication extends the life-cycle of the TopicOrientedApplication to allow for the creation of an HK2 ServiceLocator.
 
Methods inherited from class com.neeve.toa.TopicOrientedApplication
addAppCommandHandlerContainers, addAppStatContainers, addChannelFilterProviders, addChannelInitialKeyResolutionTableProviders, addChannelJoinProviders, addChannelQosProviders, addConfiguredContainers, addHandlerContainers, addPostdispatchMessageHandler, addPredispatchMessageHandler, addTopicResolverProviders, getChannelFilter, getChannelJoin, getChannelQos, getConfigurer, getEngine, getEngineClock, getInitialChannelKeyResolutionTable, getMessageInjector, getMessageSender, getServiceDefinitionLocator, getServiceModel, getServiceModels, getTopicResolver, injectMessage, injectMessage, injectMessage, onAppFinalized, onAppInitialized, onAppLoaderInjected, onConfigured, onEngineInjected, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractHK2TopicOrientedApplication

public AbstractHK2TopicOrientedApplication()
Method Detail

onEngineDescriptorInjected

protected void onEngineDescriptorInjected(AepEngineDescriptor engineDescriptor)
                                   throws Exception
The AbstractHK2TopicOrientedApplication extends the life-cycle of the TopicOrientedApplication to allow for the creation of an HK2 ServiceLocator. The construction of the Application ServiceLocator happens early, during the AepEngineDescriptor customization phase so that components and/or services can be given the chance to participate in the initialization of the Application and the AEP Engine. Specifically, when this method is invoked two things happen (after the standard TopicOrientedApplication life-cycle):

4.1 Application ServiceLocator Creation

When the AepEngineDescriptor is injected the AbstractHK2TopicOrientedApplication will construct the Application ServiceLocator. After this point the Application may use the Application Service Locator to retrieve Services or other information (such as Configuration) from the ServiceLocator.

4.2 Application Service Injection

Once Application ServiceLocator has been constructed the Application object may have dependencies injected into this instance. These injected dependencies will be satisfied based upon the standard HK2 injection strategy. Note that only after this point will injected dependencies be available.

Overrides:
onEngineDescriptorInjected in class TopicOrientedApplication
Parameters:
engineDescriptor - the AepEngineDescriptor
Throws:
Exception - An application throwing an exception from this method will cause loading of the application to fail.

getManagedObjectLocator

protected ManagedObjectLocator getManagedObjectLocator()
Description copied from class: TopicOrientedApplication
Subclasses may override this method to change the strategy for locating an application's managed objects.

The default implementation returns a new instance of DefaultManagedObjectLocator.

This is called prior to locating and parsing an application's service model and also prior to construction of the application's underlying AepEngine At this point the SrvAppLoader will have been injected via TopicOrientedApplication.onAppLoaderInjected(SrvAppLoader) and the AepEngineDescriptor will have been injected via TopicOrientedApplication.onEngineDescriptorInjected(AepEngineDescriptor) so they may be used to figure out information about the application's identity.

Overrides:
getManagedObjectLocator in class TopicOrientedApplication
Returns:
The ManagedObjectLocator to use to load the application's services.
See Also:
DefaultManagedObjectLocator

getApplicationServiceLocator

protected ServiceLocator getApplicationServiceLocator()
Return the Application ServiceLocator. Every TOA HK2 Application is associated with a single HK2 ServiceLocator. The Application ServiceLocator has a name that is the same as the Application Name. All the the Application Modules will be bound into the Application ServiceLocator. The Application ServiceLocator can be used (via the standard HK2 API) to retrieve any services or components that are configured in any of the Application Modules.

Returns:
the Application ServiceLocator
Throws:
IllegalStateException - if the Application ServiceLocator is not available. This may happen if onEngineDescriptorInjected(AepEngineDescriptor) has not been invoked yet or if the Application has been shutdown

getApplicationModules

protected abstract List<Binder> getApplicationModules()
Get the Application Modules. The Application Modules is a list of HK2 Binders that will be bound to the Application ServiceLocator. This list may be empty but it must not be null.

Returns:
the Application Modules

getName

protected abstract String getName()
Get the Application Name. The Application Name is a short, human-readable string that uniquely identifies an Application in the Talon Server. Note that the name must be unique; two Applications running in the same Talon Server must not have the same Application Name. The Application Name will be used to construct a unique ServiceLocator for the Application. The Application Name will be made available to components and services and can also be used to support qualified injection. The Application Name must not be null and must not be an empty string or a string that contains only whitespace.

Returns:
the Application Name


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.