Top Description Inners Methods
javax.enterprise.inject

public @Interface New

extends Annotation
Known Direct Implementers
javax.enterprise.inject.New.Literal
Annotations
@Target:FIELD, PARAMETER, METHOD, TYPE
@Retention:RUNTIME
@Documented
@Qualifier
Static Imports
java.lang.annotation.ElementType.FIELD, .ElementType.METHOD, .ElementType.PARAMETER, .ElementType.TYPE, .RetentionPolicy.RUNTIME

The New qualifier was deprecated in CDI 1.1. CDI applications are encouraged to inject Dependent scoped beans instead.

The @New qualifier allows the application to obtain a new instance of a bean which is not bound to the declared scope, but has had dependency injection performed.

@Produces @ConversationScoped
@Special Order getSpecialOrder(@New(Order.class) Order order) {
   ...
   return order;
}

When the @New qualifier is specified at an injection point and no value member is explicitly specified, the container defaults the value to the declared type of the injection point. So the following injection point has qualifier @New(Order.class):

@Produces @ConversationScoped
@Special Order getSpecialOrder(@New Order order) { ... }
Authors
Gavin King, Pete Muir

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
New.Literal

Supports inline instantiation of the New qualifier.

Method Summary

Modifier and TypeMethod and Description
public Class<?>

Returns:

the bean class of the new instance
value
()

Specifies the bean class of the new instance.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public Class<?> value()

Specifies the bean class of the new instance. The class must be the bean class of an enabled or disabled bean. The bean class need not be deployed in a bean archive.

Defaults to the declared type of the injection point if not specified.

Returns:Class<?>

the bean class of the new instance

javax.enterprise.inject back to summary

public final Class New.Literal

extends AnnotationLiteral<New>
implements New
Class Inheritance
All Implemented Interfaces
javax.enterprise.inject.New, java.lang.annotation.Annotation

Supports inline instantiation of the New qualifier.
Author
Martin Kouba
Since
2.0

Field Summary

Modifier and TypeField and Description
public static final New.Literal
private static final long
private final Class<?>

Constructor Summary

AccessConstructor and Description
private
Literal(Class<?> value)

Method Summary

Modifier and TypeMethod and Description
public static New.Literal
of(Class<?> value)

public Class<?>
value()

Implements javax.enterprise.inject.New.value.

Specifies the bean class of the new instance.

Inherited from javax.enterprise.util.AnnotationLiteral:
annotationTypeequalshashCodetoString

Field Detail

INSTANCEback to summary
public static final New.Literal INSTANCE
serialVersionUIDback to summary
private static final long serialVersionUID

Hides javax.enterprise.util.AnnotationLiteral.serialVersionUID.

valueback to summary
private final Class<?> value

Constructor Detail

Literalback to summary
private Literal(Class<?> value)

Method Detail

ofback to summary
public static New.Literal of(Class<?> value)
valueback to summary
public Class<?> value()

Implements javax.enterprise.inject.New.value.

Doc from javax.enterprise.inject.New.value.

Specifies the bean class of the new instance. The class must be the bean class of an enabled or disabled bean. The bean class need not be deployed in a bean archive.

Defaults to the declared type of the injection point if not specified.

Returns:Class<?>

the bean class of the new instance