diff --git a/api/src/main/java/jakarta/enterprise/inject/Any.java b/api/src/main/java/jakarta/enterprise/inject/Any.java index f4e6e74b5..887e97275 100644 --- a/api/src/main/java/jakarta/enterprise/inject/Any.java +++ b/api/src/main/java/jakarta/enterprise/inject/Any.java @@ -37,8 +37,7 @@ *
* *
- * Every bean has the qualifier @Any
, even if it does not explicitly declare this qualifier, except for the
- * special {@link New @New qualified beans}.
+ * Every bean has the qualifier @Any
, even if it does not explicitly declare this qualifier.
*
diff --git a/api/src/main/java/jakarta/enterprise/inject/Instance.java b/api/src/main/java/jakarta/enterprise/inject/Instance.java index 88c27f1cf..053842f76 100644 --- a/api/src/main/java/jakarta/enterprise/inject/Instance.java +++ b/api/src/main/java/jakarta/enterprise/inject/Instance.java @@ -71,11 +71,6 @@ * Instance<PaymentProcessor> anyPaymentProcessor; * * - *
- * Finally, the {@link New @New} qualifier may be used, allowing the application to obtain a - * {@link New @New} qualified bean: - *
- * ** @Inject * @New(ChequePaymentProcessor.class) diff --git a/api/src/main/java/jakarta/enterprise/inject/New.java b/api/src/main/java/jakarta/enterprise/inject/New.java deleted file mode 100644 index 705599f15..000000000 --- a/api/src/main/java/jakarta/enterprise/inject/New.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2010, Red Hat, Inc., and individual contributors - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package jakarta.enterprise.inject; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import jakarta.enterprise.context.Dependent; -import jakarta.enterprise.util.AnnotationLiteral; -import jakarta.inject.Qualifier; - -/** - *- * The {@link New} qualifier was deprecated in CDI 1.1. CDI applications are encouraged to inject {@link 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 {@link New#value() - * value} member is explicitly specified, the container defaults the {@link New#value() 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) { ... } - *- * - * @author Gavin King - * @author Pete Muir - */ - -@Target({ FIELD, PARAMETER, METHOD, TYPE }) -@Retention(RUNTIME) -@Documented -@Qualifier -public @interface New { - /** - *- * 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. - *
- * - * @return the bean class of the new instance - */ - Class> value() default New.class; - - /** - * Supports inline instantiation of the {@link New} qualifier. - * - * @author Martin Kouba - * @since 2.0 - */ - public final static class Literal extends AnnotationLiteralimplements New { - - public static final Literal INSTANCE = of(New.class); - - private static final long serialVersionUID = 1L; - - private final Class> value; - - public static Literal of(Class> value) { - return new Literal(value); - } - - private Literal(Class> value) { - this.value = value; - } - - public Class> value() { - return value; - } - } - - -} diff --git a/api/src/main/java/jakarta/enterprise/inject/spi/ProcessBeanAttributes.java b/api/src/main/java/jakarta/enterprise/inject/spi/ProcessBeanAttributes.java index 8c21e4482..565a89368 100644 --- a/api/src/main/java/jakarta/enterprise/inject/spi/ProcessBeanAttributes.java +++ b/api/src/main/java/jakarta/enterprise/inject/spi/ProcessBeanAttributes.java @@ -17,7 +17,6 @@ package jakarta.enterprise.inject.spi; -import jakarta.enterprise.inject.New; import jakarta.enterprise.inject.spi.configurator.BeanAttributesConfigurator; /** @@ -26,9 +25,6 @@ * registering the {@link Bean} object. * * - * No event is fired for {@link New} qualified beans. - *
- ** Any observer of this event is permitted to wrap and/or replace the {@link BeanAttributes} by calling either {@link #setBeanAttributes(BeanAttributes)} or {@link #configureBeanAttributes()}. * If both methods are called within an observer notification an {@link IllegalStateException} is thrown. * The container must use the final value of this property, after all observers have been called, to manage instances of the bean. diff --git a/api/src/test/java/org/jboss/cdi/api/test/AnnotationLiteralTest.java b/api/src/test/java/org/jboss/cdi/api/test/AnnotationLiteralTest.java index ca0f9cd02..70652fd63 100644 --- a/api/src/test/java/org/jboss/cdi/api/test/AnnotationLiteralTest.java +++ b/api/src/test/java/org/jboss/cdi/api/test/AnnotationLiteralTest.java @@ -14,7 +14,6 @@ import jakarta.enterprise.inject.Alternative; import jakarta.enterprise.inject.Any; import jakarta.enterprise.inject.Default; -import jakarta.enterprise.inject.New; import jakarta.enterprise.inject.Specializes; import jakarta.enterprise.inject.TransientReference; import jakarta.enterprise.inject.Typed; @@ -55,13 +54,6 @@ public void testNullMemberValueOnToString() { new FooLiteral(null).hashCode(); } - @Test - public void testNewLiteral() { - New literal = New.Literal.INSTANCE; - assertEquals(literal.value(), New.class); - assertEquals(New.Literal.of(Boolean.class).value(), Boolean.class); - } - @SuppressWarnings("serial") @Test public void testDefaultLiteral() { diff --git a/spec/src/main/asciidoc/core/definition.asciidoc b/spec/src/main/asciidoc/core/definition.asciidoc index d770819d3..0b41e9827 100644 --- a/spec/src/main/asciidoc/core/definition.asciidoc +++ b/spec/src/main/asciidoc/core/definition.asciidoc @@ -215,7 +215,7 @@ Qualifier types are also used as event selectors by event consumers, as defined Three standard qualifier types are defined in the package `jakarta.enterprise.inject`. In addition, the built-in qualifier type `@Named` is defined by the package `jakarta.inject`. -Every bean has the built-in qualifier `@Any`, even if it does not explicitly declare this qualifier, except for the special `@New` qualified beans defined in <
>. +Every bean has the built-in qualifier `@Any`, even if it does not explicitly declare this qualifier. If a bean does not explicitly declare a qualifier other than `@Named` or `@Any`, the bean has exactly one additional qualifier, of type `@Default`. This is called the _default qualifier_. diff --git a/spec/src/main/asciidoc/core/implementation.asciidoc b/spec/src/main/asciidoc/core/implementation.asciidoc index dc97b129a..09a54a119 100644 --- a/spec/src/main/asciidoc/core/implementation.asciidoc +++ b/spec/src/main/asciidoc/core/implementation.asciidoc @@ -697,57 +697,6 @@ For example, the following field has the qualifier `@Named("paymentService")`: If any other injection point declares a `@Named` annotation that does not specify the `value` member, the container automatically detects the problem and treats it as a definition error. -[[new]] - -=== `@New` qualified beans - -_The @New qualifier was deprecated in CDI 1.1. -CDI applications are encouraged to inject @Dependent scoped beans instead._ - -For each managed bean, a second bean exists which: - -* has the same bean class, -* has the same bean types, -* has the same bean constructor, initializer methods and injected fields, and -* has the same interceptor bindings. - - -However, this second bean: - -* has scope `@Dependent`, -* has exactly one qualifier: `@jakarta.enterprise.inject.New(X.class)` where `X` is the bean class, -* has no bean name, -* has no stereotypes, -* has no observer methods, producer methods or fields or disposer methods, and -* is not an alternative, and -* is enabled, in the sense of < >, if and only if some other enabled bean has an injection point with the qualifier `@New(X.class)` where `X` is the bean class. - - -This bean is called the _@New qualified bean_ for the class `X`. - -Note that this second bean exists - and may be enabled and available for injection - even if the first bean is disabled, as defined by < >, or if the bean class is deployed outside of a bean archive, as defined in < >, and is therefore not discovered during the bean discovery process defined in < >. -The container discovers `@New` qualified beans by inspecting injection points of other enabled beans. - -This 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. - -[source, java] ----- -@Produces @ConversationScoped -@Special Order getSpecialOrder(@New(Order.class) Order order) { - ... - return order; -} ----- - -When the qualifier `@New` 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)`: - -[source, java] ----- -@Produces @ConversationScoped -@Special Order getSpecialOrder(@New Order order) { ... } ----- - [[unproxyable]] === Unproxyable bean types diff --git a/spec/src/main/asciidoc/core/injectionandresolution.asciidoc b/spec/src/main/asciidoc/core/injectionandresolution.asciidoc index 9acedde64..ed60bd439 100644 --- a/spec/src/main/asciidoc/core/injectionandresolution.asciidoc +++ b/spec/src/main/asciidoc/core/injectionandresolution.asciidoc @@ -106,9 +106,6 @@ A bean is said to be _enabled_ if: Otherwise, the bean is said to be disabled. -Note that < > defines a special rule that determines whether a `@New` qualified bean is enabled or disabled. -This rule applies as only to `@New` qualified beans, as an exception to the normal rule defined here. - [[inconsistent_specialization]] ==== Inconsistent specialization @@ -650,8 +647,6 @@ PaymentProcessor pp = anyPaymentProcessor.select(qualifier).get().process(paymen In this example, the returned bean has qualifier `@Synchronous` or `@Asynchronous` depending upon the value of `synchronously`. -Finally, the `@New` qualifier may be used, allowing the application to obtain a `@New` qualified bean, as defined in < >: - [source, java] ---- @Inject @New(ChequePaymentProcessor.class) Instance chequePaymentProcessor; @@ -807,7 +802,6 @@ The following built-in annotations define a `Literal` static nested class to sup * `jakarta.enterprise.inject.Any` * `jakarta.enterprise.inject.Default` -* `jakarta.enterprise.inject.New` * `jakarta.enterprise.inject.Specializes` * `jakarta.enterprise.inject.Vetoed` * `jakarta.enterprise.util.Nonbinding` diff --git a/spec/src/main/asciidoc/core/spi.asciidoc b/spec/src/main/asciidoc/core/spi.asciidoc index 9f4158f68..d5b6b40ff 100644 --- a/spec/src/main/asciidoc/core/spi.asciidoc +++ b/spec/src/main/asciidoc/core/spi.asciidoc @@ -1426,7 +1426,6 @@ If any `ProcessInjectionTarget` method is called outside of the observer method The container must fire an event for each managed bean, producer, interceptor or decorator deployed in a bean archive, before registering the `Bean` object. No event is fired for any: -* `@New` qualified bean, defined in < >, or, * beans added programmatically using `AfterBeanDiscovery.addBean()`, or, * for any built-in beans. @@ -1499,7 +1498,6 @@ With `BeanAttributesConfigurator` you can perform the following operations : ==== `ProcessBean` event The container must fire an event for each bean, interceptor or decorator deployed in a bean archive, after firing the `ProcessBeanAttributes` for the bean and before registering the `Bean` object. -No event is fired for any `@New` qualified bean, defined in < >. The event object type in the package `jakarta.enterprise.inject.spi` depends upon what kind of bean was discovered: diff --git a/spec/src/main/asciidoc/javaee/implementation_ee.asciidoc b/spec/src/main/asciidoc/javaee/implementation_ee.asciidoc index e088171dd..20c066e68 100644 --- a/spec/src/main/asciidoc/javaee/implementation_ee.asciidoc +++ b/spec/src/main/asciidoc/javaee/implementation_ee.asciidoc @@ -331,9 +331,3 @@ When running in Jakarta EE, the container must extend the rules defined for bean The container must also ensure that: * An initializer method defined in an EJB session bean is _not_ required to be a business method of the session bean. - -[[new_ee]] - -=== `@New` qualified beans in Jakarta EE - -When running in Jakarta EE, the container must extend the rules defined for managed beans in < > to EJB session beans.