Package javax.decorator

Annotations relating to decorators.


Annotation Types Summary
Decorator Specifies that a class is a decorator.
Delegate Identifies the delegate injection point of a decorator.

Package javax.decorator Description

Annotations relating to decorators.

A decorator implements one or more bean types and intercepts business method invocations of beans which implement those bean types. These bean types are called decorated types.

A decorator is a managed bean annotated @Decorator.

Decorators are superficially similar to interceptors, but because they directly implement operations with business semantics, they are able to implement business logic and, conversely, unable to implement the cross-cutting concerns for which interceptors are optimized. Decorators are called after interceptors.

Decorated types

The set of decorated types of a decorator includes all bean types of the managed bean that are Java interfaces, except for Serializable. The decorator bean class and its superclasses are not decorated types of the decorator. The decorator class may be abstract.

A decorator intercepts every method:

A decorator may be an abstract class, and is not required to implement every method of every decorated type.

Delegate injection points

All decorators have a delegate injection point. A delegate injection point is an injection point of the bean class annotated @Delegate.

The type of the delegate injection point must implement or extend every decorated type. A decorator is not required to implement the type of the delegate injection point.

Enabled decorators

By default, a bean archive has no enabled decorators. A decorator must be explicitly enabled by listing its bean class under the <decorators> element of the beans.xml file of the bean archive. The order of the decorator declarations determines the decorator ordering. Decorators which occur earlier in the list are called first.

A decorator is bound to a bean if:

If a managed bean class is declared final, it may not have decorators. If a managed bean has a non-static, non-private, final method, it may not have any decorator which implements that method.

A decorator instance is a dependent object of the object it decorates.

See Also:
javax.enterprise.inject, Decorator, Delegate

Submit a bug or feature

Copyright © 2009-2011, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms.

Generated on 10-February-2011 12:41

Scripting on this page tracks web page traffic, but does not change the content in any way.