Document Properties
Kbid2968P4
Last Modified21-Dec-2020
Added to KB29-Oct-2020
Public AccessEveryone
StatusOnline
Doc TypeGuidelines, Concepts & Cookbooks
ProductICM 7.10

Concept - Features Framework

Product Version

7.10

Product To Version


Status

final

1 Introduction

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.

1.1 References

2 Overview

The following class diagram visualizes the main components and their dependencies:

Features Framework Overview

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.

3 Example

The following diagram shows example feature implementations:

Feature Example

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).

Disclaimer

The information provided in the Knowledge Base may not be applicable to all systems and situations. Intershop Communications will not be liable to any party for any direct or indirect damages resulting from the use of the Customer Support section of the Intershop Corporate Web site, including, without limitation, any lost profits, business interruption, loss of programs or other data on your information handling system.

Customer Support
Knowledge Base
Product Resources
Tickets