Info
This document is valid from 7.10.26.0.
For most circumstances injecting a dependency using Google Guice will fulfill all requirements. However, when it is necessary to select a concrete implementation by context (containing certain values) plain Guice will not help. The features framework fills this gap. A feature implementation is selected by its type and the actual context at runtime.
Additionally the features framework allows to customize/extends standard functionality which is also addressed by Java extension points. But the features framework integrate with Guice and is therefore easier to use.
The following class diagram visualizes the main components and their dependencies:
The key component is the class com.intershop.beehive.core.internal.feature.FeatureProviderImpl
. It is bound to the global and the application type specific Guice object graph to have access to features and local (application-type-specific) features.
The FeatureProvider
#getFeature-
methods do the actual feature lookup by executing the isApplicable
-method of the bound features. In prior the features are sorted by the @javax.annotation.Priority
annotation. This priority sorting allows custom feature implementations to overrule ICM standard implementations because the feature with the highest priority is returned by the lookup.
Additionally, local features overrule global features. So an application-type-specific (local) feature implementation can replace a global feature implementation.
The Feature
#getFeature(Class<S>, T)
-method is designed to be a factory method and is therefore executed as last step during the lookup. A feature implementation may overwrite this default implementation if the actual feature is implemented by another class.
The following diagram shows example feature implementations:
Both implementations implement the same business interface which defines the business API of the feature. The GlobalImplementation
implements the Feature
interface and has to be bound to the global object graph. The LocalImplementation
implements the LocalFeature
interface and has to be bound to the (local) application type specific object graph. The feature implementations may overwrite the default isApplicable
-method, whose conditions (e.g. value-content) have to be fulfilled to choose this particular implementation. For example, the feature lookup is executed using FeatureProvider#getFeature(BusinessInterface.class, value)
which returns an instance of BusinessInterface
that can be used afterwards to execute doSomething(input)
.