Skip to content

Commit

Permalink
Removal of deprecated APIs: @New
Browse files Browse the repository at this point in the history
  • Loading branch information
manovotn committed Apr 13, 2021
1 parent a45dc96 commit 54fd2c6
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 200 deletions.
3 changes: 1 addition & 2 deletions api/src/main/java/jakarta/enterprise/inject/Any.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
* </p>
*
* <p>
* Every bean has the qualifier <code>&#064;Any</code>, even if it does not explicitly declare this qualifier, except for the
* special {@link New &#064;New qualified beans}.
* Every bean has the qualifier <code>&#064;Any</code>, even if it does not explicitly declare this qualifier.
* </p>
*
* <p>
Expand Down
5 changes: 0 additions & 5 deletions api/src/main/java/jakarta/enterprise/inject/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@
* Instance&lt;PaymentProcessor&gt; anyPaymentProcessor;
* </pre>
*
* <p>
* Finally, the {@link New &#064;New} qualifier may be used, allowing the application to obtain a
* {@link New &#064;New} qualified bean:
* </p>
*
* <pre>
* &#064;Inject
* &#064;New(ChequePaymentProcessor.class)
Expand Down
115 changes: 0 additions & 115 deletions api/src/main/java/jakarta/enterprise/inject/New.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package jakarta.enterprise.inject.spi;

import jakarta.enterprise.inject.New;
import jakarta.enterprise.inject.spi.configurator.BeanAttributesConfigurator;

/**
Expand All @@ -26,9 +25,6 @@
* registering the {@link Bean} object.
* </p>
* <p>
* No event is fired for {@link New} qualified beans.
* </p>
* <p>
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion spec/src/main/asciidoc/core/definition.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<new>>.
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_.

Expand Down
51 changes: 0 additions & 51 deletions spec/src/main/asciidoc/core/implementation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<enablement>>, 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 <<enablement>>, or if the bean class is deployed outside of a bean archive, as defined in <<bean_archive>>, and is therefore not discovered during the bean discovery process defined in <<packaging_deployment>>.
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
Expand Down
6 changes: 0 additions & 6 deletions spec/src/main/asciidoc/core/injectionandresolution.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ A bean is said to be _enabled_ if:

Otherwise, the bean is said to be disabled.

Note that <<new>> 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
Expand Down Expand Up @@ -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 <<new>>:

[source, java]
----
@Inject @New(ChequePaymentProcessor.class) Instance<PaymentProcessor> chequePaymentProcessor;
Expand Down Expand Up @@ -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`
Expand Down
2 changes: 0 additions & 2 deletions spec/src/main/asciidoc/core/spi.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<new>>, or,
* beans added programmatically using `AfterBeanDiscovery.addBean()`, or,
* for any built-in beans.

Expand Down Expand Up @@ -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 <<new>>.

The event object type in the package `jakarta.enterprise.inject.spi` depends upon what kind of bean was discovered:

Expand Down
6 changes: 0 additions & 6 deletions spec/src/main/asciidoc/javaee/implementation_ee.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<new>> to EJB session beans.

0 comments on commit 54fd2c6

Please sign in to comment.