implements Foo {
27 |
28 | private final String name;
29 |
30 | public FooLiteral(String name) {
31 | this.name = name;
32 | }
33 |
34 | public String name() {
35 | return name;
36 | }
37 |
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/InvokerFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2024 Red Hat and others
3 | *
4 | * This program and the accompanying materials are made available under the
5 | * Apache Software License 2.0 which is available at:
6 | * https://www.apache.org/licenses/LICENSE-2.0.
7 | *
8 | * SPDX-License-Identifier: Apache-2.0
9 | */
10 |
11 | package jakarta.enterprise.inject.build.compatible.spi;
12 |
13 | import jakarta.enterprise.invoke.InvokerBuilder;
14 | import jakarta.enterprise.lang.model.declarations.MethodInfo;
15 |
16 | /**
17 | * Factory for {@link InvokerBuilder}s.
18 | *
19 | * @since 4.1
20 | */
21 | public interface InvokerFactory {
22 | /**
23 | * Returns a new {@link InvokerBuilder} for given method of given bean. The builder
24 | * eventually produces an opaque representation of the generated invoker.
25 | *
26 | * If an invoker may not be built for given {@code bean} or for given {@code method},
27 | * an exception is thrown.
28 | *
29 | * @param bean target bean of the invoker, must not be {@code null}
30 | * @param method target method of the invoker, must not be {@code null}
31 | * @return the invoker builder, never {@code null}
32 | */
33 | InvokerBuilder createInvoker(BeanInfo bean, MethodInfo method);
34 | }
35 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/javase/scopescontext_se.asciidoc:
--------------------------------------------------------------------------------
1 | ////
2 | Copyright (c) 2015 Red Hat, Inc. and others
3 |
4 | This program and the accompanying materials are made available under the
5 | Apache Software License 2.0 which is available at:
6 | https://www.apache.org/licenses/LICENSE-2.0.
7 |
8 | SPDX-License-Identifier: Apache-2.0
9 | ////
10 | [[contexts_se]]
11 |
12 | == Scopes and contexts in Java SE
13 |
14 | [[builtin_contexts_se]]
15 |
16 | === Context management for built-in scopes in Java SE
17 |
18 | When running in Java SE, the container must extend the rules defined in <> and is also required to ensure the following rules for built-in context implementation.
19 |
20 | [[application_context_se]]
21 |
22 | ==== Application context lifecycle in Java SE
23 |
24 | When running in Java SE the container must extend the rules defined in <> and is also required to ensure the following rules.
25 |
26 | The application scope is active:
27 |
28 | * during any method invocation
29 |
30 | The application context is shared between all method invocations that execute within the same container.
31 |
32 | The application context is destroyed when the container is shut down.
33 |
34 | The payload of the event fired when the application context is initialized or destroyed is:
35 |
36 | * any `java.lang.Object`.
37 |
38 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/DisposerInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Red Hat and others
3 | *
4 | * This program and the accompanying materials are made available under the
5 | * Apache Software License 2.0 which is available at:
6 | * https://www.apache.org/licenses/LICENSE-2.0.
7 | *
8 | * SPDX-License-Identifier: Apache-2.0
9 | */
10 |
11 | package jakarta.enterprise.inject.build.compatible.spi;
12 |
13 | import jakarta.enterprise.lang.model.declarations.MethodInfo;
14 | import jakarta.enterprise.lang.model.declarations.ParameterInfo;
15 |
16 | /**
17 | * Disposer methods may exist for producer-based beans. Each disposer method
18 | * has a {@linkplain #disposedParameter() disposed parameter}.
19 | *
20 | * @since 4.0
21 | */
22 | public interface DisposerInfo {
23 | /**
24 | * Returns the {@linkplain MethodInfo declaration} of this disposer method.
25 | *
26 | * @return the {@linkplain MethodInfo declaration} of this disposer method, never {@code null}
27 | */
28 | MethodInfo disposerMethod();
29 |
30 | /**
31 | * Returns the {@linkplain ParameterInfo declaration} of the disposed parameter of this disposer method.
32 | *
33 | * @return the {@linkplain ParameterInfo declaration} of the disposed parameter of this disposer method, never {@code null}
34 | */
35 | ParameterInfo disposedParameter();
36 | }
37 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ScannedClasses.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Red Hat and others
3 | *
4 | * This program and the accompanying materials are made available under the
5 | * Apache Software License 2.0 which is available at:
6 | * https://www.apache.org/licenses/LICENSE-2.0.
7 | *
8 | * SPDX-License-Identifier: Apache-2.0
9 | */
10 |
11 | package jakarta.enterprise.inject.build.compatible.spi;
12 |
13 | /**
14 | * Allows adding additional classes to the set of types discovered during type discovery.
15 | * Such classes will therefore be scanned during bean discovery. Annotations on these classes
16 | * can later be transformed using {@link Enhancement @Enhancement}.
17 | *
18 | * @since 4.0
19 | */
20 | public interface ScannedClasses {
21 | /**
22 | * Adds a class with given name to the set of types discovered during type discovery.
23 | * The class will therefore be scanned during bean discovery.
24 | *
25 | * Adding the same class multiple times, or adding a class that is automatically discovered
26 | * by the container, leads to non-portable behavior.
27 | *
28 | * @param className binary name of the class, as defined by The Java™ Language Specification ;
29 | * in other words, the class name as returned by {@link Class#getName()}
30 | */
31 | void add(String className);
32 | }
33 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/AnnotationBuilderFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Red Hat and others
3 | *
4 | * This program and the accompanying materials are made available under the
5 | * Apache Software License 2.0 which is available at:
6 | * https://www.apache.org/licenses/LICENSE-2.0.
7 | *
8 | * SPDX-License-Identifier: Apache-2.0
9 | */
10 |
11 | package jakarta.enterprise.inject.build.compatible.spi;
12 |
13 | import java.lang.annotation.Annotation;
14 |
15 | import jakarta.enterprise.lang.model.declarations.ClassInfo;
16 |
17 | /**
18 | * Supports instantiating {@link AnnotationBuilder}.
19 | * Should not be called directly by users; the static methods on {@link AnnotationBuilder} are preferred.
20 | *
21 | * @since 4.0
22 | */
23 | public interface AnnotationBuilderFactory {
24 | /**
25 | * Returns a new {@link AnnotationBuilder} for given annotation type.
26 | *
27 | * @param annotationType the annotation type
28 | * @return a new {@link AnnotationBuilder}
29 | */
30 | AnnotationBuilder create(Class extends Annotation> annotationType);
31 |
32 | /**
33 | * Returns a new {@link AnnotationBuilder} for given annotation type.
34 | *
35 | * @param annotationType the annotation type
36 | * @return a new {@link AnnotationBuilder}
37 | */
38 | AnnotationBuilder create(ClassInfo annotationType);
39 | }
40 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/context/spi/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | /**
15 | *
16 | * The custom context SPI.
17 | *
18 | *
19 | *
20 | * Associated with every
21 | * {@linkplain jakarta.enterprise.context scope type} is a
22 | * {@linkplain jakarta.enterprise.context.spi.Context context object}.
23 | * The context object implements the semantics of the scope type.
24 | *
25 | *
26 | *
27 | * The context implementation collaborates with the container via
28 | * the {@link jakarta.enterprise.context.spi.Context Context} and
29 | * {@link jakarta.enterprise.context.spi.Contextual Contextual}
30 | * interfaces to create and destroy contextual instances.
31 | *
32 | *
33 | * @see jakarta.enterprise.context
34 | * @see jakarta.enterprise.inject.spi
35 | */
36 | package jakarta.enterprise.context.spi;
37 |
--------------------------------------------------------------------------------
/api/src/test/java/org/jboss/cdi/api/test/annotated/AnnotatedTypeTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package org.jboss.cdi.api.test.annotated;
16 |
17 | import java.lang.annotation.Annotation;
18 |
19 | import jakarta.enterprise.inject.spi.Annotated;
20 |
21 | public class AnnotatedTypeTest extends AbstractAnnotatedTest {
22 |
23 | @Override
24 | protected Annotated getAnnotated() {
25 | return new AnnotatedTypeHolder<>(RepeatBean.class);
26 | }
27 |
28 | @Override
29 | protected T[] getAnnotationsByType(Class annotationClass) {
30 | return RepeatBean.class.getAnnotationsByType(annotationClass);
31 | }
32 |
33 | @Override
34 | protected T getAnnotation(Class annotationClass) {
35 | return RepeatBean.class.getAnnotation(annotationClass);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/CDIProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013, 2015 Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject.spi;
16 |
17 | /**
18 | * Interface implemented by a CDI provider to provide access to the current container
19 | *
20 | * @author Pete Muir
21 | * @since 1.1
22 | */
23 | public interface CDIProvider extends Prioritized {
24 |
25 | /** The default value for {@linkplain #getPriority()} */
26 | public static final int DEFAULT_CDI_PROVIDER_PRIORITY = 0;
27 |
28 | /**
29 | * Provides access to the current container
30 | *
31 | * @return the CDI instance for the current container
32 | * @throws IllegalStateException if no CDI container is available
33 | */
34 | CDI getCDI();
35 |
36 | @Override
37 | default int getPriority() {
38 | return DEFAULT_CDI_PROVIDER_PRIORITY;
39 | };
40 | }
41 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/core/invokers_full.asciidoc:
--------------------------------------------------------------------------------
1 | ////
2 | Copyright (c) 2023 Red Hat, Inc. and others
3 |
4 | This program and the accompanying materials are made available under the
5 | Apache Software License 2.0 which is available at:
6 | https://www.apache.org/licenses/LICENSE-2.0.
7 |
8 | SPDX-License-Identifier: Apache-2.0
9 | ////
10 | [[method_invokers_full]]
11 | == Method invokers in {cdi_full}
12 |
13 | [[building_invoker_full]]
14 | === Building an `Invoker` in {cdi_full}
15 |
16 | In addition to rules defined in <>, the following rules apply.
17 |
18 | When the target bean is a decorator, attempting to build an invoker leads to a deployment problem.
19 |
20 | [[invoker_builder_full]]
21 | === Using `InvokerBuilder` in {cdi_full}
22 |
23 | In addition to rules defined in <>, the following rules apply.
24 |
25 | `InvokerBuilder` can be obtained in portable extensions from `ProcessManagedBean.createInvoker()`:
26 |
27 | [source,java]
28 | ----
29 | public interface ProcessManagedBean extends ProcessBean {
30 | ...
31 |
32 | InvokerBuilder> createInvoker(AnnotatedMethod super X> method);
33 | }
34 | ----
35 |
36 | The target bean of the created invoker is the bean for which the `ProcessManagedBean` event was fired.
37 | The target method of the created invoker is the method represented by the `AnnotatedMethod` object passed to `createInvoker()`.
38 |
39 | Calling `InvokerBuilder.build()` produces an `Invoker` which should be stored for usage at application runtime.
40 |
--------------------------------------------------------------------------------
/docs/Gemfile:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2021 Red Hat, Inc. and others
2 | #
3 | # This program and the accompanying materials are made available under the
4 | # Apache Software License 2.0 which is available at:
5 | # https://www.apache.org/licenses/LICENSE-2.0.
6 | #
7 | # SPDX-License-Identifier: Apache-2.0
8 |
9 | source "https://rubygems.org"
10 | # Hello! This is where you manage which Jekyll version is used to run.
11 | # When you want to use a different version, change it below, save the
12 | # file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
13 | #
14 | # bundle exec jekyll serve
15 | #
16 | # This will help ensure the proper Jekyll version is running.
17 | # Happy Jekylling!
18 | gem "jekyll", "~> 3.10.0"
19 | # This is the default theme for new Jekyll sites. You may change this to anything you like.
20 | gem "minima", "~> 2.5"
21 | # If you want to use GitHub Pages, remove the "gem "jekyll"" above and
22 | # uncomment the line below. To upgrade, run `bundle update github-pages`.
23 | gem "github-pages", "~> 232", group: :jekyll_plugins
24 | # If you have any plugins, put them here!
25 | group :jekyll_plugins do
26 | end
27 |
28 | # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
29 | # and associated library.
30 | platforms :mingw, :x64_mingw, :mswin, :jruby do
31 | gem "tzinfo", "~> 1.2"
32 | gem "tzinfo-data"
33 | end
34 |
35 | # Performance-booster for watching directories on Windows
36 | gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
37 |
38 |
39 | gem "webrick", "~> 1.9"
40 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/Prioritized.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject.spi;
16 |
17 | /**
18 | *
19 | * This interface allows some SPI implementation to change their priority programmatically.
20 | *
21 | *
22 | *
23 | * For instance {@link ObserverMethod} extends this interface to set the observer priority.
24 | *
25 | * A custom alternative or reserve {@link Bean}, {@link Interceptor} or {@link Decorator} may implement
26 | * this interface to be enabled with a given priority.
27 | *
28 | *
29 | *
30 | * @see Bean
31 | * @author Mark Paluch
32 | * @author Antoine Sabot-Durand
33 | * @since 2.0
34 | */
35 | public interface Prioritized {
36 |
37 | /**
38 | *
39 | * Returns the priority for this SPI element.
40 | *
41 | *
42 | * @return the priority value
43 | */
44 | int getPriority();
45 | }
46 |
--------------------------------------------------------------------------------
/lang-model/src/main/java/jakarta/enterprise/lang/model/types/ClassType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.lang.model.types;
15 |
16 | import jakarta.enterprise.lang.model.declarations.ClassInfo;
17 |
18 | /**
19 | * A class type, including interface types, enum types, annotation types and record types.
20 | * Class types are introduced by class {@linkplain #declaration() declarations}.
21 | *
22 | * @since 4.0
23 | */
24 | public interface ClassType extends Type {
25 | /**
26 | * Returns the {@linkplain ClassInfo declaration} of this class type.
27 | *
28 | * @return the {@linkplain ClassInfo declaration} of this class type
29 | */
30 | ClassInfo declaration();
31 |
32 | // ---
33 |
34 | @Override
35 | default Kind kind() {
36 | return Kind.CLASS;
37 | }
38 |
39 | @Override
40 | default ClassType asClass() {
41 | return this;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/dictionary.txt:
--------------------------------------------------------------------------------
1 | api
2 | APIs
3 | assignability
4 | asynchronicity
5 | callback
6 | callbacks
7 | CDI
8 | changelog
9 | circularities
10 | classloader
11 | classpath
12 | declaratively
13 | decorator
14 | decorators
15 | DoD
16 | EE
17 | EG
18 | Jakarta Enterprise Bean
19 | Jakarta Enterprise Beans
20 | enablement
21 | enum
22 | enums
23 | initializer
24 | injectable
25 | inline
26 | interception
27 | interceptor
28 | interceptors
29 | JavaBean
30 | JavaBeans
31 | JavaServer
32 | javax
33 | jboss
34 | JCP
35 | JDK
36 | JMS
37 | JNDI
38 | JPA
39 | Jakarta Faces
40 | JSP
41 | JSR
42 | JTA
43 | JVM
44 | lead
45 | Lead's
46 | licensor
47 | licensors
48 | lifecycle
49 | LLC
50 | LLC's
51 | login
52 | lookup
53 | metadata
54 | Microsystems
55 | middleware
56 | multi
57 | MVC
58 | namespace
59 | parameterized
60 | passivating
61 | passivation
62 | pluggable
63 | prepended
64 | programmatically
65 | proxied
66 | proxyable
67 | proxying
68 | rar
69 | rars
70 | reassociated
71 | redhat
72 | remoting
73 | rethrown
74 | rethrows
75 | runtime
76 | serializable
77 | servlet
78 | servlets
79 | SPI
80 | startup
81 | stateful
82 | subinterface
83 | subinterfaces
84 | sublicense
85 | sublicensees
86 | subpackages
87 | subparagraph
88 | subtype
89 | superclass
90 | superclasses
91 | superinterfaces
92 | superset
93 | supertype
94 | supertypes
95 | TCK
96 | typesafe
97 | unboxing
98 | underly
99 | uninvoked
100 | unmanaged
101 | unproxyable
102 | unserializable
103 | username
104 | wildcard
105 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/PassivationCapable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject.spi;
16 |
17 | import jakarta.enterprise.context.spi.Contextual;
18 |
19 | /**
20 | * Indicates that a custom implementation of {@link Bean} or
21 | * {@link Contextual} is passivation capable.
22 | *
23 | *
24 | * CDI Lite implementations are not required to provide support for passivation.
25 | *
26 | *
27 | * @author Gavin King
28 | * @author David Allen
29 | *
30 | */
31 | public interface PassivationCapable {
32 | /**
33 | * A string that uniquely identifies the instance of {@link Bean} or
34 | * {@link Contextual}. It is recommended that the string contain the package name of the class
35 | * that implements {@code Bean} or {@code Contextual}.
36 | *
37 | * @return a unique identifier for the {@link Bean} or
38 | * {@link Contextual}
39 | */
40 | public String getId();
41 | }
42 |
--------------------------------------------------------------------------------
/lang-model/src/main/java/jakarta/enterprise/lang/model/declarations/PackageInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.lang.model.declarations;
15 |
16 | /**
17 | * A package, possibly annotated in {@code package-info.java}.
18 | * Obtaining the set of members present in this package is not possible.
19 | *
20 | * @since 4.0
21 | */
22 | public interface PackageInfo extends DeclarationInfo {
23 | /**
24 | * Returns the fully qualified name of this package, as defined by The Java™ Language Specification ;
25 | * in other words, the package name as returned by {@link Package#getName()}.
26 | *
27 | * @return fully qualified name of this package, never {@code null}
28 | */
29 | String name();
30 |
31 | // ---
32 |
33 | @Override
34 | default Kind kind() {
35 | return Kind.PACKAGE;
36 | }
37 |
38 | @Override
39 | default PackageInfo asPackage() {
40 | return this;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/Model.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.inject;
15 |
16 | import static java.lang.annotation.ElementType.FIELD;
17 | import static java.lang.annotation.ElementType.METHOD;
18 | import static java.lang.annotation.ElementType.TYPE;
19 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
20 |
21 | import java.lang.annotation.Documented;
22 | import java.lang.annotation.Retention;
23 | import java.lang.annotation.Target;
24 |
25 | import jakarta.enterprise.context.RequestScoped;
26 | import jakarta.inject.Named;
27 |
28 | /**
29 | *
30 | * The built-in stereotype intended for use with beans that define the model layer of an MVC web application architecture such
31 | * as JSF.
32 | *
33 | *
34 | * @see Stereotype
35 | * @author Gavin King
36 | */
37 |
38 | @Named
39 | @RequestScoped
40 | @Documented
41 | @Stereotype
42 | @Target({ TYPE, METHOD, FIELD })
43 | @Retention(RUNTIME)
44 | public @interface Model {
45 | }
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SkipIfPortableExtensionPresent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Red Hat and others
3 | *
4 | * This program and the accompanying materials are made available under the
5 | * Apache Software License 2.0 which is available at:
6 | * https://www.apache.org/licenses/LICENSE-2.0.
7 | *
8 | * SPDX-License-Identifier: Apache-2.0
9 | */
10 |
11 | package jakarta.enterprise.inject.build.compatible.spi;
12 |
13 | import java.lang.annotation.ElementType;
14 | import java.lang.annotation.Retention;
15 | import java.lang.annotation.RetentionPolicy;
16 | import java.lang.annotation.Target;
17 |
18 | import jakarta.enterprise.inject.spi.Extension;
19 |
20 | /**
21 | * If a {@linkplain BuildCompatibleExtension build compatible extension} is annotated
22 | * {@code @SkipIfPortableExtensionPresent}, it is ignored when the CDI container
23 | * can execute portable extensions and determines that a portable extension
24 | * of {@linkplain #value() given class} is present.
25 | *
26 | * It is expected that the specified portable extension class will mirror the functionality
27 | * of the annotated build compatible extension. This allows portable extensions
28 | * and build compatible extensions to coexist.
29 | *
30 | * @since 4.0
31 | */
32 | @Target(ElementType.TYPE)
33 | @Retention(RetentionPolicy.RUNTIME)
34 | public @interface SkipIfPortableExtensionPresent {
35 | /**
36 | * A class implementing {@link Extension} that is expected to mirror the functionality of the annotated
37 | * build compatible extension.
38 | *
39 | * @return a portable extension class
40 | */
41 | Class extends Extension> value();
42 | }
43 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/AnnotatedField.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.inject.spi;
15 |
16 | import static java.util.Arrays.asList;
17 |
18 | import java.lang.annotation.Annotation;
19 | import java.lang.reflect.Field;
20 | import java.util.LinkedHashSet;
21 | import java.util.Set;
22 |
23 | /**
24 | *
25 | * Represents a field of a Java class.
26 | *
27 | *
28 | * @author Gavin King
29 | * @author Pete Muir
30 | *
31 | * @param the declaring type
32 | * @see Field
33 | */
34 | public interface AnnotatedField extends AnnotatedMember {
35 |
36 | /**
37 | *
38 | * Get the underlying {@link Field}.
39 | *
40 | *
41 | * @return the {@link Field}
42 | */
43 | public Field getJavaMember();
44 |
45 | @Override
46 | default Set getAnnotations(Class annotationType) {
47 | T[] annotationsByType = getJavaMember().getAnnotationsByType(annotationType);
48 | return new LinkedHashSet<>(asList(annotationsByType));
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/InterceptionType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject.spi;
16 |
17 | /**
18 | *
19 | * Identifies the kind of lifecycle callback, EJB timeout method or business method interception.
20 | *
21 | *
22 | * @author Gavin King
23 | * @author Pete Muir
24 | *
25 | */
26 | public enum InterceptionType {
27 |
28 | /**
29 | * Intercepts method invocation
30 | */
31 | AROUND_INVOKE,
32 |
33 | /**
34 | * Intercepts a timeout
35 | */
36 | AROUND_TIMEOUT,
37 |
38 | /**
39 | * Intercepts a constructor invocation
40 | */
41 | AROUND_CONSTRUCT,
42 |
43 | /**
44 | * Intercepts bean construction
45 | */
46 | POST_CONSTRUCT,
47 |
48 | /**
49 | * Intercepts bean destruction
50 | */
51 | PRE_DESTROY,
52 |
53 | /**
54 | * Intercepts bean passivation, only called for EJBs
55 | */
56 | PRE_PASSIVATE,
57 |
58 | /**
59 | * Intercepts bean activation, only called for EJBs
60 | */
61 | POST_ACTIVATE
62 | }
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/AnnotatedMethod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.inject.spi;
15 |
16 | import static java.util.Arrays.asList;
17 |
18 | import java.lang.annotation.Annotation;
19 | import java.lang.reflect.Method;
20 | import java.util.LinkedHashSet;
21 | import java.util.Set;
22 |
23 | /**
24 | *
25 | * Represents a method of a Java type.
26 | *
27 | *
28 | * @author Gavin King
29 | * @author Pete Muir
30 | *
31 | * @param the declaring type
32 | * @see Method
33 | */
34 | public interface AnnotatedMethod extends AnnotatedCallable {
35 |
36 | /**
37 | *
38 | * Get the underlying {@link Method}.
39 | *
40 | *
41 | * @return the {@link Method}
42 | */
43 | public Method getJavaMember();
44 |
45 | @Override
46 | default Set getAnnotations(Class annotationType) {
47 | T[] annotationsByType = getJavaMember().getAnnotationsByType(annotationType);
48 | return new LinkedHashSet<>(asList(annotationsByType));
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/api/src/test/java/org/jboss/cdi/api/test/annotated/AnnotatedFieldTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package org.jboss.cdi.api.test.annotated;
16 |
17 | import java.lang.annotation.Annotation;
18 | import java.lang.reflect.Field;
19 |
20 | import jakarta.enterprise.inject.spi.Annotated;
21 |
22 | import org.testng.annotations.BeforeClass;
23 |
24 | public class AnnotatedFieldTest extends AbstractAnnotatedTest {
25 | private Field field;
26 |
27 | @BeforeClass
28 | public void getField() throws Exception {
29 | field = RepeatBean.class.getDeclaredField("field");
30 | }
31 |
32 | @Override
33 | protected Annotated getAnnotated() {
34 | return new AnnotatedFieldHolder<>(field);
35 | }
36 |
37 | @Override
38 | protected T[] getAnnotationsByType(Class annotationClass) {
39 | return field.getAnnotationsByType(annotationClass);
40 | }
41 |
42 | @Override
43 | protected T getAnnotation(Class annotationClass) {
44 | return field.getAnnotation(annotationClass);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/AnnotatedMember.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject.spi;
16 |
17 | import java.lang.reflect.Member;
18 |
19 | /**
20 | *
21 | * Represents a member of a Java type.
22 | *
23 | *
24 | * @author Gavin King
25 | * @author Pete Muir
26 | *
27 | * @param the declaring type
28 | * @see Member
29 | */
30 | public interface AnnotatedMember extends Annotated {
31 | /**
32 | *
33 | * Get the underlying {@link Member}.
34 | *
35 | *
36 | * @return the {@link Member}
37 | */
38 | public Member getJavaMember();
39 |
40 | /**
41 | *
42 | * Determines if the member is static.
43 | *
44 | *
45 | * @return true if the member is static
46 | */
47 | public boolean isStatic();
48 |
49 | /**
50 | *
51 | * Get the {@linkplain AnnotatedType type} which defines this member.
52 | *
53 | *
54 | * @return the type which defines this member
55 | */
56 | public AnnotatedType getDeclaringType();
57 | }
58 |
--------------------------------------------------------------------------------
/api/src/test/java/org/jboss/cdi/api/test/annotated/AnnotatedMethodTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package org.jboss.cdi.api.test.annotated;
16 |
17 | import java.lang.annotation.Annotation;
18 | import java.lang.reflect.Method;
19 |
20 | import jakarta.enterprise.inject.spi.Annotated;
21 |
22 | import org.testng.annotations.BeforeClass;
23 |
24 | public class AnnotatedMethodTest extends AbstractAnnotatedTest {
25 | private Method method;
26 |
27 | @BeforeClass
28 | public void getMethod() throws Exception {
29 | method = RepeatBean.class.getMethod("doRepeat", RepeatBean.class);
30 | }
31 |
32 | @Override
33 | protected Annotated getAnnotated() {
34 | return new AnnotatedMethodHolder<>(method);
35 | }
36 |
37 | @Override
38 | protected T[] getAnnotationsByType(Class annotationClass) {
39 | return method.getAnnotationsByType(annotationClass);
40 | }
41 |
42 | @Override
43 | protected T getAnnotation(Class annotationClass) {
44 | return method.getAnnotation(annotationClass);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/AnnotatedConstructor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject.spi;
16 |
17 | import static java.util.Arrays.asList;
18 |
19 | import java.lang.annotation.Annotation;
20 | import java.lang.reflect.Constructor;
21 | import java.util.LinkedHashSet;
22 | import java.util.Set;
23 |
24 | /**
25 | *
26 | * Represents a constructor of a Java class.
27 | *
28 | *
29 | * @author Gavin King
30 | * @author Pete Muir
31 | *
32 | * @param the declaring class
33 | * @see Constructor
34 | */
35 | public interface AnnotatedConstructor extends AnnotatedCallable {
36 |
37 | /**
38 | *
39 | * Get the underlying {@link Constructor}.
40 | *
41 | *
42 | * @return the constructor
43 | */
44 | public Constructor getJavaMember();
45 |
46 | @Override
47 | default Set getAnnotations(Class annotationType) {
48 | T[] annotationsByType = getJavaMember().getAnnotationsByType(annotationType);
49 | return new LinkedHashSet<>(asList(annotationsByType));
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/Intercepted.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject;
16 |
17 | import static java.lang.annotation.ElementType.FIELD;
18 | import static java.lang.annotation.ElementType.PARAMETER;
19 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
20 |
21 | import java.lang.annotation.Documented;
22 | import java.lang.annotation.Retention;
23 | import java.lang.annotation.Target;
24 |
25 | import jakarta.inject.Qualifier;
26 |
27 | /**
28 | *
29 | * An interceptor may inject metadata about the bean it is intercepting.
30 | *
31 | *
32 | *
33 | * @Transactional @Interceptor
34 | * public class TransactionInterceptor {
35 | *
36 | * @Inject @Intercepted Bean<?> bean;
37 | *
38 | * @AroundInvoke
39 | * public Object manageTransaction(InvocationContext ctx) throws Exception { ... }
40 | *
41 | * }
42 | *
43 | *
44 | * @author Pete Muir
45 | * @since 1.1
46 | */
47 |
48 | @Target({ PARAMETER, FIELD })
49 | @Retention(RUNTIME)
50 | @Documented
51 | @Qualifier
52 | public @interface Intercepted {
53 | }
54 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/context/spi/CreationalContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.context.spi;
15 |
16 | /**
17 | *
18 | * Provides operations that are used by the {@link Contextual} implementation during instance
19 | * creation and destruction.
20 | *
21 | *
22 | * @author Gavin King
23 | * @author Pete Muir
24 | *
25 | * @param type of the instances on which this CreationalContext operates
26 | */
27 | public interface CreationalContext {
28 |
29 | /**
30 | * Registers an incompletely initialized contextual instance the with the container. A contextual instance is considered
31 | * incompletely initialized until it is returned by
32 | * {@link Contextual#create(CreationalContext)} .
33 | *
34 | * @param incompleteInstance the incompletely initialized instance
35 | */
36 | public void push(T incompleteInstance);
37 |
38 | /**
39 | * Destroys all dependent objects of the instance which is being destroyed, by passing each dependent object to
40 | * {@link Contextual#destroy(Object, CreationalContext)} .
41 | */
42 | public void release();
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/literal/NamedLiteral.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.inject.literal;
15 |
16 | import jakarta.enterprise.util.AnnotationLiteral;
17 | import jakarta.inject.Named;
18 |
19 | /**
20 | * Supports inline instantiation of the {@link Named} qualifier.
21 | *
22 | * @author Pete Muir
23 | * @author Jozef Hartinger
24 | * @since 2.0
25 | */
26 | public final class NamedLiteral extends AnnotationLiteral implements Named {
27 | /** Default Named literal */
28 | public static final Named INSTANCE = of("");
29 |
30 | private static final long serialVersionUID = 1L;
31 |
32 | /** The name */
33 | private final String value;
34 |
35 | /**
36 | * Create a new NamedLiteral for the given name value
37 | *
38 | * @param value the name
39 | * @return new NamedLiteral
40 | */
41 | public static NamedLiteral of(String value) {
42 | return new NamedLiteral(value);
43 | }
44 |
45 | public String value() {
46 | return value;
47 | }
48 |
49 | private NamedLiteral(String value) {
50 | this.value = value;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/api/src/test/java/org/jboss/cdi/api/test/annotated/AnnotatedConstructorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package org.jboss.cdi.api.test.annotated;
16 |
17 | import java.lang.annotation.Annotation;
18 | import java.lang.reflect.Constructor;
19 |
20 | import jakarta.enterprise.inject.spi.Annotated;
21 |
22 | import org.testng.annotations.BeforeClass;
23 |
24 | public class AnnotatedConstructorTest extends AbstractAnnotatedTest {
25 | Constructor constructor;
26 |
27 | @BeforeClass
28 | public void setupConstructor() throws Exception {
29 | this.constructor = RepeatBean.class.getConstructor();
30 | }
31 |
32 | @Override
33 | protected Annotated getAnnotated() {
34 | return new AnnotatedConstructorHolder<>(constructor);
35 | }
36 |
37 | @Override
38 | protected T[] getAnnotationsByType(Class annotationClass) {
39 | return constructor.getAnnotationsByType(annotationClass);
40 | }
41 |
42 | @Override
43 | protected T getAnnotation(Class annotationClass) {
44 | return constructor.getAnnotation(annotationClass);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticObserver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Red Hat and others
3 | *
4 | * This program and the accompanying materials are made available under the
5 | * Apache Software License 2.0 which is available at:
6 | * https://www.apache.org/licenses/LICENSE-2.0.
7 | *
8 | * SPDX-License-Identifier: Apache-2.0
9 | */
10 |
11 | package jakarta.enterprise.inject.build.compatible.spi;
12 |
13 | import jakarta.enterprise.event.ObserverException;
14 | import jakarta.enterprise.inject.spi.EventContext;
15 |
16 | /**
17 | * The event notification function for a synthetic observer defined by {@link SyntheticObserverBuilder}.
18 | * CDI container will create an instance of the event notification function every time when it needs
19 | * to notify the synthetic observer. Implementations must be {@code public} classes with a {@code public}
20 | * zero-parameter constructor; they must not be beans.
21 | *
22 | * @param the observed event type of the synthetic observer
23 | * @since 4.0
24 | */
25 | public interface SyntheticObserver {
26 | /**
27 | * Consumes an event. The {@link EventContext} provides access to the event payload,
28 | * as well as the {@link jakarta.enterprise.inject.spi.EventMetadata EventMetadata}.
29 | *
30 | * The parameter map contains the same values that were passed to
31 | * the {@link SyntheticObserverBuilder} that defined the synthetic observer.
32 | *
33 | * @param event the event context, never {@code null}
34 | * @param params the parameter map, never {@code null}
35 | * @throws Exception checked exception will be wrapped and rethrown as an {@link ObserverException}
36 | */
37 | void observe(EventContext event, Parameters params) throws Exception;
38 | }
39 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/event/Startup.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.event;
15 |
16 | /**
17 | *
18 | * A CDI event with payload of type {@link Startup} and qualifier {@link jakarta.enterprise.inject.Any} is
19 | * synchronously fired by CDI container during application initialization.
20 | * Applications must never manually fire any events with {@link Startup} as payload.
21 | *
22 | *
23 | *
24 | * Implementations have to fire this event after the event with qualifier {@code @Initialized(ApplicationScope.class)}
25 | * but before processing requests.
26 | *
27 | *
28 | *
29 | * This event can be observed by integrators and libraries to perform any kind of early initialization as well as by
30 | * users as a reliable entry point for when the CDI container is ready.
31 | *
32 | *
33 | *
34 | * Observers are encouraged to specify {@code @Priority} to determine ordering with lower priority numbers being
35 | * recommended for platform/framework/library integration and higher numbers for user applications.
36 | *
37 | * See also {@link jakarta.interceptor.Interceptor.Priority}
38 | */
39 | public class Startup {
40 | }
41 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/context/control/ActivateRequestContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.context.control;
16 |
17 | import static java.lang.annotation.ElementType.METHOD;
18 | import static java.lang.annotation.ElementType.TYPE;
19 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
20 |
21 | import java.lang.annotation.Documented;
22 | import java.lang.annotation.Retention;
23 | import java.lang.annotation.Target;
24 |
25 | import jakarta.interceptor.InterceptorBinding;
26 |
27 | /**
28 | * The container provides a built in interceptor that may be used to annotate classes and methods to indicate
29 | * that a request context should be activated when this method is invoked.
30 | *
31 | * The request context will be activated before the method is called, and deactivated when the method invocation is
32 | * complete (regardless of any exceptions being thrown). If the context is already active, it is ignored, neither
33 | * activated nor deactivated.
34 | *
35 | * @since 2.0
36 | * @author John D. Ament
37 | */
38 | @InterceptorBinding
39 | @Target({ METHOD, TYPE })
40 | @Retention(RUNTIME)
41 | @Documented
42 | public @interface ActivateRequestContext {
43 | }
44 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/ProcessSyntheticBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.inject.spi;
15 |
16 | /**
17 | *
18 | * The container fires an event of this type for each custom bean implementation added through
19 | * {@link AfterBeanDiscovery#addBean()} or {@link AfterBeanDiscovery#addBean(Bean)}, before registering the
20 | * {@link Bean} object.
21 | *
22 | *
23 | * If any observer method of a {@code ProcessSyntheticBean} event throws an exception, the exception is treated as a definition
24 | * error by the container.
25 | *
26 | *
27 | *
28 | * CDI Lite implementations are not required to provide support for Portable Extensions.
29 | *
30 | *
31 | * @author Martin Kouba
32 | * @param The class of the bean
33 | * @since 2.0
34 | */
35 | public interface ProcessSyntheticBean extends ProcessBean {
36 |
37 | /**
38 | * Get the extension instance which added the {@link Bean} for which this event is being fired.
39 | *
40 | * @return the extension instance
41 | * @throws IllegalStateException if called outside of the observer method invocation
42 | */
43 | public Extension getSource();
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/NOTICE.md:
--------------------------------------------------------------------------------
1 | # Notices for Jakarta Contexts and Dependency Injection
2 |
3 | This content is produced and maintained by the Jakarta Contexts and Dependency Injection
4 | project.
5 |
6 | * Project home: https://projects.eclipse.org/projects/ee4j.cdi
7 |
8 | ## Trademarks
9 |
10 | Jakarta Contexts and Dependency Injection is a trademark of the Eclipse Foundation.
11 |
12 | ## Copyright
13 |
14 | All content is the property of the respective authors or their employers. For
15 | more information regarding authorship of content, please consult the listed
16 | source code repository logs.
17 |
18 | ## Declared Project Licenses
19 |
20 | This program and the accompanying materials are made available under the terms
21 | of the Apache License v. 2.0 which is available at
22 | http://www.apache.org/licenses/LICENSE-2.0
23 |
24 | SPDX-License-Identifier: Apache-2.0
25 |
26 | ## Source Code
27 |
28 | The project maintains the following source code repositories:
29 |
30 | * https://github.com/jakartaee/cdi
31 | * https://github.com/jakartaee/cdi-tck
32 | * https://github.com/jakartaee/inject
33 | * https://github.com/jakartaee/inject-spec
34 | * https://github.com/jakartaee/inject-tck
35 |
36 | The project also maintains the following legacy CPL licensed source code repositories:
37 |
38 | * https://github.com/eclipse-ee4j/cdi-cpl
39 | * https://github.com/eclipse-ee4j/cdi-tck-cpl
40 |
41 | ## Third-party Content
42 |
43 | ## Cryptography
44 |
45 | Content may contain encryption software. The country in which you are currently
46 | may have restrictions on the import, possession, and use, and/or re-export to
47 | another country, of encryption software. BEFORE using any encryption software,
48 | please check the country's laws, regulations and policies concerning the import,
49 | possession, or use, and re-export of encryption software, to see if this is
50 | permitted.
51 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/ScopeInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Red Hat and others
3 | *
4 | * This program and the accompanying materials are made available under the
5 | * Apache Software License 2.0 which is available at:
6 | * https://www.apache.org/licenses/LICENSE-2.0.
7 | *
8 | * SPDX-License-Identifier: Apache-2.0
9 | */
10 |
11 | package jakarta.enterprise.inject.build.compatible.spi;
12 |
13 | import jakarta.enterprise.lang.model.declarations.ClassInfo;
14 |
15 | /**
16 | * A scope of a bean. Scope type is an {@linkplain #annotation() annotation}, meta-annotated
17 | * {@link jakarta.inject.Scope @Scope} or {@link jakarta.enterprise.context.NormalScope @NormalScope}.
18 | * Lifecycle of beans with given scope is determined by a {@linkplain jakarta.enterprise.context.spi.Context context}.
19 | *
20 | * @since 4.0
21 | */
22 | public interface ScopeInfo {
23 | /**
24 | * Returns the declaration of this scope annotation.
25 | *
26 | * @return declaration of this scope annotation, never {@code null}
27 | */
28 | ClassInfo annotation();
29 |
30 | /**
31 | * Binary name of this scope annotation, as defined by The Java™ Language Specification ;
32 | * in other words, the scope annotation name as returned by {@link Class#getName()}.
33 | * Equivalent to {@code annotation().name()}.
34 | *
35 | * @return binary name of this scope annotation, never {@code null}
36 | */
37 | default String name() {
38 | return annotation().name();
39 | }
40 |
41 | /**
42 | * Returns whether this scope type is normal. In other words, returns whether
43 | * this scope annotation is meta-annotated {@code @NormalScope}.
44 | *
45 | * @return whether this scope type is normal
46 | */
47 | boolean isNormal();
48 | }
49 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/event/Shutdown.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.event;
15 |
16 | /**
17 | *
18 | * A CDI event with payload of type {@link Shutdown} and qualifier {@link jakarta.enterprise.inject.Any} is
19 | * synchronously fired by CDI container during application shutdown.
20 | * Applications must never manually fire any events with {@link Shutdown} as payload.
21 | *
22 | *
23 | *
24 | * Implementations have to fire this event during CDI container shutdown, but not later than the event with qualifier
25 | * {@code @BeforeDestroyed(ApplicationScoped.class)}.
26 | *
27 | *
28 | *
29 | * This event can be observed by integrators and libraries to perform any kind of pre-shutdown operation as well as by
30 | * users as a reliable entry point for when the CDI container is about to shut down.
31 | *
32 | *
33 | *
34 | * Observers are encouraged to specify {@code @Priority} to determine ordering with lower priority numbers being
35 | * recommended for user applications and higher numbers for platform/framework/library integration.
36 | *
37 | * See also {@link jakarta.interceptor.Interceptor.Priority}
38 | */
39 | public class Shutdown {
40 | }
41 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/Bean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject.spi;
16 |
17 | import java.util.Set;
18 |
19 | import jakarta.enterprise.context.spi.Contextual;
20 |
21 | /**
22 | *
23 | * Represents an {@linkplain jakarta.enterprise.inject enabled bean}. This interface defines everything the container needs to
24 | * manage instances of the bean.
25 | *
26 | *
27 | * @author Gavin King
28 | * @author David Allen
29 | * @param the class of the bean instance
30 | */
31 | public interface Bean extends Contextual, BeanAttributes {
32 |
33 | /**
34 | * The bean {@linkplain Class class} of the managed bean or session bean or of the bean that declares the producer method or
35 | * field.
36 | *
37 | * @return the bean {@linkplain Class class}
38 | */
39 | public Class> getBeanClass();
40 |
41 | /**
42 | * Obtains the {@link InjectionPoint} objects representing injection points of the bean, that
43 | * will be validated by the container at initialization time.
44 | *
45 | * @return the set of {@linkplain InjectionPoint injection points} of the bean
46 | */
47 | public Set getInjectionPoints();
48 | }
49 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/AfterDeploymentValidation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.inject.spi;
15 |
16 | /**
17 | *
18 | * The event type of the third event fired by the container after it has validated that there are no deployment problems and
19 | * before creating contexts or processing requests. If any observer method of the {@code AfterDeploymentValidation} event throws
20 | * an exception, the exception is treated as a deployment problem by the container.
21 | *
22 | *
23 | * No requests will be processed by the deployment until all observers of this event return.
24 | *
25 | *
26 | *
27 | * CDI Lite implementations are not required to provide support for Portable Extensions.
28 | *
29 | *
30 | * @author David Allen
31 | */
32 | public interface AfterDeploymentValidation {
33 |
34 | /**
35 | * Registers a deployment problem with the container, causing the container to abort deployment after all observers have
36 | * been notified.
37 | *
38 | * @param t The deployment problem as a {@link java.lang.Throwable}
39 | * @throws IllegalStateException if called outside of the observer method invocation
40 | */
41 | public void addDeploymentProblem(Throwable t);
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/relocation/spec/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
17 | 4.0.0
18 |
19 |
20 | jakarta.enterprise
21 | jakarta.enterprise.cdi-parent
22 | 5.0.0.Alpha4-SNAPSHOT
23 |
24 |
25 | jakarta.enterprise.cdi-spec-doc
26 | pom
27 |
28 | CDI Specification (Relocation)
29 | CDI Specification documentation
30 |
31 |
32 |
33 | Apache License 2.0
34 | https://apache.org/licenses/LICENSE-2.0.txt
35 | repo
36 |
37 |
38 |
39 |
40 |
41 | jakarta.cdi
42 | jakarta.cdi-spec-doc
43 |
44 |
45 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/Decorated.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject;
16 |
17 | import static java.lang.annotation.ElementType.FIELD;
18 | import static java.lang.annotation.ElementType.PARAMETER;
19 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
20 |
21 | import java.lang.annotation.Documented;
22 | import java.lang.annotation.Retention;
23 | import java.lang.annotation.Target;
24 |
25 | import jakarta.inject.Qualifier;
26 |
27 | /**
28 | *
29 | * A decorator may inject metadata about the bean it is decorating
30 | *
31 | *
32 | *
33 | * @Decorator
34 | * class TimestampLogger implements Logger {
35 | * @Inject
36 | * @Delegate
37 | * @Any
38 | * Logger logger;
39 | *
40 | * @Inject
41 | * @Decorated
42 | * Bean<Logger> bean;
43 | *
44 | * void log(String message) {
45 | * ...
46 | * }
47 | * }
48 | *
49 | *
50 | *
51 | * CDI Lite implementations are not required to provide support for decorators.
52 | *
53 | *
54 | * @author Pete Muir
55 | * @since 1.1
56 | */
57 |
58 | @Target({ PARAMETER, FIELD })
59 | @Retention(RUNTIME)
60 | @Documented
61 | @Qualifier
62 | public @interface Decorated {
63 | }
64 |
--------------------------------------------------------------------------------
/api/src/test/java/org/jboss/cdi/api/test/annotated/AnnotatedParameterTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package org.jboss.cdi.api.test.annotated;
16 |
17 | import java.lang.annotation.Annotation;
18 | import java.lang.reflect.Method;
19 | import java.lang.reflect.Parameter;
20 |
21 | import jakarta.enterprise.inject.spi.Annotated;
22 |
23 | import org.testng.annotations.BeforeClass;
24 |
25 | public class AnnotatedParameterTest extends AbstractAnnotatedTest {
26 | private Method method;
27 | private Parameter parameter;
28 |
29 | @BeforeClass
30 | public void getMethod() throws Exception {
31 | this.method = RepeatBean.class.getMethod("doRepeat", RepeatBean.class);
32 | this.parameter = method.getParameters()[0];
33 | }
34 |
35 | @Override
36 | protected Annotated getAnnotated() {
37 | return new AnnotatedParameterHolder<>(new AnnotatedMethodHolder<>(method));
38 | }
39 |
40 | @Override
41 | protected T[] getAnnotationsByType(Class annotationClass) {
42 | return parameter.getAnnotationsByType(annotationClass);
43 | }
44 |
45 | @Override
46 | protected T getAnnotation(Class annotationClass) {
47 | return parameter.getAnnotation(annotationClass);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/relocation/api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
17 | 4.0.0
18 |
19 |
20 | jakarta.enterprise
21 | jakarta.enterprise.cdi-parent
22 | 5.0.0.Alpha4-SNAPSHOT
23 |
24 |
25 | jakarta.enterprise.cdi-api
26 | pom
27 |
28 | CDI APIs (Relocation)
29 | APIs for CDI (Contexts and Dependency Injection for Java)
30 |
31 |
32 |
33 | Apache License 2.0
34 | https://repository.jboss.org/licenses/apache-2.0.txt
35 | repo
36 |
37 |
38 |
39 |
40 |
41 | jakarta.cdi
42 | jakarta.cdi-api
43 |
44 |
45 |
--------------------------------------------------------------------------------
/relocation/el/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
17 | 4.0.0
18 |
19 |
20 | jakarta.enterprise
21 | jakarta.enterprise.cdi-parent
22 | 5.0.0.Alpha4-SNAPSHOT
23 |
24 |
25 | jakarta.enterprise.cdi-el-api
26 | pom
27 |
28 | CDI EL integration API (Relocation)
29 | API for integrating CDI with Unified EL
30 |
31 |
32 |
33 | Apache License 2.0
34 | https://repository.jboss.org/licenses/apache-2.0.txt
35 | repo
36 |
37 |
38 |
39 |
40 |
41 | jakarta.cdi
42 | jakarta.cdi-el-api
43 |
44 |
45 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/InjectionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject;
16 |
17 | /**
18 | * Indicates a problem relating to dependency injection.
19 | *
20 | * @author Pete Muir
21 | */
22 | public class InjectionException extends RuntimeException {
23 |
24 | private static final long serialVersionUID = -2132733164534544788L;
25 |
26 | /**
27 | * Creates the exception with no detail message or cause.
28 | */
29 | public InjectionException() {
30 | }
31 |
32 | /**
33 | * Creates the exception with given detail message and cause.
34 | *
35 | * @param message the detail message
36 | * @param cause the cause
37 | */
38 | public InjectionException(String message, Throwable cause) {
39 | super(message, cause);
40 | }
41 |
42 | /**
43 | * Creates the exception with given detail message.
44 | *
45 | * @param message the detail message
46 | */
47 | public InjectionException(String message) {
48 | super(message);
49 | }
50 |
51 | /**
52 | * Creates the exception with given cause.
53 | *
54 | * @param cause the cause
55 | */
56 | public InjectionException(Throwable cause) {
57 | super(cause);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/context/NormalScope.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.context;
16 |
17 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
18 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
19 |
20 | import java.lang.annotation.Documented;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | *
26 | * Specifies that an annotation type is a normal scope type.
27 | *
28 | *
29 | * @author Gavin King
30 | * @author Pete Muir
31 | *
32 | * @see jakarta.inject.Scope @Scope is used to declare pseudo-scopes.
33 | */
34 | @Target(ANNOTATION_TYPE)
35 | @Retention(RUNTIME)
36 | @Documented
37 | public @interface NormalScope {
38 |
39 | /**
40 | *
41 | * Determines whether the normal scope type is a passivating scope.
42 | *
43 | *
44 | *
45 | * A bean is called passivation capable if the container is able to temporarily transfer the state of any idle instance to
46 | * secondary storage. A passivating scope requires that beans with the scope are passivation capable.
47 | *
48 | *
49 | * @return true if the scope type is a passivating scope type
50 | */
51 | boolean passivating() default false;
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/api/src/main/java/module-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | /**
15 | * The {@code jakarta.cdi} module; defines the CDI API exported packages, dependencies and services.
16 | */
17 | module jakarta.cdi {
18 | exports jakarta.decorator;
19 | exports jakarta.enterprise.context;
20 | exports jakarta.enterprise.context.control;
21 | exports jakarta.enterprise.context.spi;
22 | exports jakarta.enterprise.event;
23 | exports jakarta.enterprise.inject;
24 | exports jakarta.enterprise.inject.build.compatible.spi;
25 | exports jakarta.enterprise.inject.literal;
26 | exports jakarta.enterprise.inject.se;
27 | exports jakarta.enterprise.inject.spi;
28 | exports jakarta.enterprise.inject.spi.configurator;
29 | exports jakarta.enterprise.invoke;
30 | exports jakarta.enterprise.util;
31 |
32 | requires transitive jakarta.annotation;
33 | requires transitive jakarta.interceptor;
34 | requires transitive jakarta.cdi.lang.model;
35 | requires transitive jakarta.inject;
36 | // For javadoc
37 | requires static java.naming;
38 | //TODO: requires static jakarta.transation;
39 |
40 | uses jakarta.enterprise.inject.se.SeContainerInitializer;
41 | uses jakarta.enterprise.inject.spi.CDIProvider;
42 | uses jakarta.enterprise.inject.build.compatible.spi.BuildServices;
43 | }
44 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/ResolutionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.inject;
15 |
16 | /**
17 | * Indicates a problem relating to typesafe resolution.
18 | *
19 | * @author Gavin King
20 | */
21 | public class ResolutionException extends InjectionException {
22 |
23 | private static final long serialVersionUID = -6280627846071966243L;
24 |
25 | /**
26 | * Creates the exception with no detail message or cause.
27 | */
28 | public ResolutionException() {
29 | super();
30 | }
31 |
32 | /**
33 | * Creates the exception with given detail message and cause.
34 | *
35 | * @param message the detail message
36 | * @param cause the cause
37 | */
38 | public ResolutionException(String message, Throwable cause) {
39 | super(message, cause);
40 | }
41 |
42 | /**
43 | * Creates the exception with given detail message.
44 | *
45 | * @param message the detail message
46 | */
47 | public ResolutionException(String message) {
48 | super(message);
49 | }
50 |
51 | /**
52 | * Creates the exception with given cause.
53 | *
54 | * @param cause the cause
55 | */
56 | public ResolutionException(Throwable cause) {
57 | super(cause);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/relocation/lang-model/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
17 | 4.0.0
18 |
19 |
20 | jakarta.enterprise
21 | jakarta.enterprise.cdi-parent
22 | 5.0.0.Alpha4-SNAPSHOT
23 |
24 |
25 | jakarta.enterprise.lang-model
26 | pom
27 |
28 | CDI Language Model (Relocation)
29 | Build Compatible (Reflection-Free) Java Language Model for CDI
30 |
31 |
32 |
33 | Apache License 2.0
34 | https://apache.org/licenses/LICENSE-2.0.txt
35 | repo
36 |
37 |
38 |
39 |
40 |
41 | jakarta.cdi
42 | jakarta.cdi-lang-model-api
43 |
44 |
45 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanDisposer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Red Hat and others
3 | *
4 | * This program and the accompanying materials are made available under the
5 | * Apache Software License 2.0 which is available at:
6 | * https://www.apache.org/licenses/LICENSE-2.0.
7 | *
8 | * SPDX-License-Identifier: Apache-2.0
9 | */
10 |
11 | package jakarta.enterprise.inject.build.compatible.spi;
12 |
13 | import jakarta.enterprise.inject.Instance;
14 |
15 | /**
16 | * Destruction function for a synthetic bean defined by {@link SyntheticBeanBuilder}.
17 | * CDI container will create an instance of the destruction function every time when it needs
18 | * to destroy an instance of the synthetic bean. Implementations must be {@code public}
19 | * classes with a {@code public} zero-parameter constructor; they must not be beans.
20 | *
21 | * @param the bean class of the synthetic bean
22 | * @since 4.0
23 | */
24 | public interface SyntheticBeanDisposer {
25 | /**
26 | * Destroys an instance of the synthetic bean.
27 | *
28 | * The {@link Instance} parameter may be used to simulate disposer method parameter injection.
29 | * All {@code @Dependent} bean instances obtained from the {@code Instance} during execution
30 | * are destroyed when execution completes.
31 | *
32 | * Trying to look up {@code InjectionPoint} from the {@code Instance} parameter is invalid.
33 | *
34 | * The parameter map contains the same values that were passed to the {@link SyntheticBeanBuilder}
35 | * that defined the synthetic bean.
36 | *
37 | * @param instance the synthetic bean instance, never {@code null}
38 | * @param lookup an {@link Instance} that can be used to lookup other beans, never {@code null}
39 | * @param params the parameter map, never {@code null}
40 | */
41 | void dispose(T instance, Instance lookup, Parameters params);
42 | }
43 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/event/Reception.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.event;
15 |
16 | import jakarta.enterprise.context.Dependent;
17 |
18 | /**
19 | *
20 | * Distinguishes conditional {@linkplain Observes observer methods} from observer methods which are
21 | * always notified.
22 | *
23 | *
24 | *
25 | * A conditional observer method is an observer method which is notified of an event only if an instance of the bean that
26 | * defines the observer method already exists in the current context.
27 | *
28 | *
29 | *
30 | * Beans with scope {@link Dependent @Dependent} may not have conditional observer methods.
31 | *
32 | *
33 | * @author Gavin King
34 | * @author Dan Allen
35 | * @author David Allen
36 | */
37 | public enum Reception {
38 | /**
39 | *
40 | * Specifies that an observer method is only called if the current instance of the bean declaring the observer method
41 | * already exists.
42 | *
43 | *
44 | * If there is no active context for the scope to which the bean declaring this observer method belongs, then the observer
45 | * method is not called.
46 | *
47 | */
48 | IF_EXISTS,
49 |
50 | /**
51 | * Specifies that an observer method always receives event notifications.
52 | */
53 | ALWAYS
54 | }
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/InjectionPointInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Red Hat and others
3 | *
4 | * This program and the accompanying materials are made available under the
5 | * Apache Software License 2.0 which is available at:
6 | * https://www.apache.org/licenses/LICENSE-2.0.
7 | *
8 | * SPDX-License-Identifier: Apache-2.0
9 | */
10 |
11 | package jakarta.enterprise.inject.build.compatible.spi;
12 |
13 | import java.util.Collection;
14 |
15 | import jakarta.enterprise.lang.model.AnnotationInfo;
16 | import jakarta.enterprise.lang.model.declarations.DeclarationInfo;
17 | import jakarta.enterprise.lang.model.types.Type;
18 |
19 | /**
20 | * An injection point defined on some bean. Injection points may be fields
21 | * or method parameters.
22 | *
23 | * @since 4.0
24 | */
25 | public interface InjectionPointInfo {
26 | /**
27 | * Returns the {@link Type type} of this injection point.
28 | *
29 | * @return the type of this injection point, never {@code null}
30 | */
31 | Type type();
32 |
33 | /**
34 | * Returns a collection of qualifiers declared on this injection point, represented as {@link AnnotationInfo}.
35 | *
36 | * @return collection of qualifiers, never {@code null}
37 | */
38 | Collection qualifiers();
39 |
40 | /**
41 | * Returns the declaration of this injection point.
42 | * That is a {@link jakarta.enterprise.lang.model.declarations.FieldInfo FieldInfo} for field injection,
43 | * or {@link jakarta.enterprise.lang.model.declarations.ParameterInfo ParameterInfo} for:
44 | *
45 | * constructor injection,
46 | * initializer method,
47 | * disposer method,
48 | * producer method,
49 | * observer method.
50 | *
51 | *
52 | * @return the declaration of this injection point, never {@code null}
53 | */
54 | DeclarationInfo declaration();
55 | }
56 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/context/ContextException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.context;
16 |
17 | /**
18 | *
19 | * Indicates a problem relating to context management.
20 | *
21 | *
22 | * @author Pete Muir
23 | * @author Shane Bryzak
24 | */
25 | public class ContextException extends RuntimeException {
26 |
27 | private static final long serialVersionUID = -3599813072560026919L;
28 |
29 | /**
30 | * Creates the exception with no detail message or cause.
31 | */
32 | public ContextException() {
33 | super();
34 | }
35 |
36 | /**
37 | * Creates the exception with given detail message.
38 | *
39 | * @param message the detail message
40 | */
41 | public ContextException(String message) {
42 | super(message);
43 | }
44 |
45 | /**
46 | * Creates the exception with given cause.
47 | *
48 | * @param cause the cause
49 | */
50 | public ContextException(Throwable cause) {
51 | super(cause);
52 | }
53 |
54 | /**
55 | * Creates the exception with given detail message and cause.
56 | *
57 | * @param message the detail message
58 | * @param cause the cause
59 | */
60 | public ContextException(String message, Throwable cause) {
61 | super(message, cause);
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/decorator/Decorator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.decorator;
16 |
17 | import static java.lang.annotation.ElementType.TYPE;
18 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
19 |
20 | import java.lang.annotation.Documented;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.Target;
23 |
24 | import jakarta.enterprise.inject.Stereotype;
25 |
26 | /**
27 | *
28 | * Specifies that a class is a decorator. May be applied to a managed bean class.
29 | *
30 | *
31 | *
32 | * @Decorator
33 | * class TimestampLogger implements Logger { ... }
34 | *
35 | *
36 | *
37 | * Decorators of a session bean must comply with the bean provider programming restrictions defined by the EJB specification.
38 | * Decorators of a stateful session bean must comply with the rules for instance passivation and conversational state defined by
39 | * the EJB specification.
40 | *
41 | *
42 | *
43 | * CDI Lite implementations are not required to provide support for decorators.
44 | *
45 | *
46 | * @see Delegate @Delegate identifies the delegate injection point of a decorator.
47 | *
48 | * @author Gavin King
49 | * @author Pete Muir
50 | */
51 | @Target(TYPE)
52 | @Retention(RUNTIME)
53 | @Documented
54 | @Stereotype
55 | public @interface Decorator {
56 | }
57 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/CreationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject;
16 |
17 | /**
18 | *
19 | * Indicates that a checked exception was thrown during creation of a bean.
20 | *
21 | *
22 | * @author Pete Muir
23 | * @author Gavin King
24 | */
25 | public class CreationException extends InjectionException {
26 |
27 | private static final long serialVersionUID = 1002854668862145298L;
28 |
29 | /**
30 | * Creates the exception with no detail message or cause.
31 | */
32 | public CreationException() {
33 |
34 | }
35 |
36 | /**
37 | * Creates the exception with given detail message.
38 | *
39 | * @param message the detail message
40 | */
41 | public CreationException(String message) {
42 | super(message);
43 | }
44 |
45 | /**
46 | * Creates the exception with given cause.
47 | *
48 | * @param cause the cause
49 | */
50 | public CreationException(Throwable cause) {
51 | super(cause);
52 | }
53 |
54 | /**
55 | * Creates the exception with given detail message and cause.
56 | *
57 | * @param message the detail message
58 | * @param cause the cause
59 | */
60 | public CreationException(String message, Throwable cause) {
61 | super(message, cause);
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/Extension.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject.spi;
16 |
17 | import jakarta.enterprise.event.Observes;
18 | import jakarta.enterprise.inject.Default;
19 |
20 | /**
21 | *
22 | * Service interface implemented by extensions. An extension is a service provider declared in META-INF/services.
23 | *
24 | *
25 | *
26 | * Service providers may have {@linkplain Observes observer methods}, which may observe any event,
27 | * including any {@linkplain jakarta.enterprise.inject.spi container lifecycle event}, and obtain an injected
28 | * {@link BeanManager}.
29 | *
30 | *
31 | *
32 | * The container instantiates a single instance of each extension at the beginning of the application initialization process and
33 | * maintains a reference to it until the application shuts down. The container delivers event notifications to this instance by
34 | * calling its observer methods.
35 | *
36 | *
37 | *
38 | * Service providers are made available for injection as beans with the qualifier {@link Default
39 | * @Default}.
40 | *
41 | *
42 | *
43 | * CDI Lite implementations are not required to provide support for Portable Extensions.
44 | *
45 | *
46 | * @author Gavin King
47 | * @author Pete Muir
48 | *
49 | */
50 | public interface Extension {
51 | }
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/event/ObserverException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.event;
16 |
17 | /**
18 | *
19 | * Indicates that a checked exception was thrown by an observer method during event notification.
20 | *
21 | *
22 | * @author Pete Muir
23 | * @author Gavin King
24 | */
25 | public class ObserverException extends RuntimeException {
26 |
27 | private static final long serialVersionUID = -801836224808304381L;
28 |
29 | /**
30 | * Creates the exception with no detail message or cause.
31 | */
32 | public ObserverException() {
33 |
34 | }
35 |
36 | /**
37 | * Creates the exception with given detail message.
38 | *
39 | * @param message the detail message
40 | */
41 | public ObserverException(String message) {
42 | super(message);
43 | }
44 |
45 | /**
46 | * Creates the exception with given cause.
47 | *
48 | * @param cause the cause
49 | */
50 | public ObserverException(Throwable cause) {
51 | super(cause);
52 | }
53 |
54 | /**
55 | * Creates the exception with given detail message and cause.
56 | *
57 | * @param message the detail message
58 | * @param cause the cause
59 | */
60 | public ObserverException(String message, Throwable cause) {
61 | super(message, cause);
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/api/src/test/java/org/jboss/cdi/api/test/annotated/AnnotatedMemberHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package org.jboss.cdi.api.test.annotated;
16 |
17 | import java.lang.annotation.Annotation;
18 | import java.lang.reflect.Member;
19 | import java.lang.reflect.Type;
20 | import java.util.Set;
21 |
22 | import jakarta.enterprise.inject.spi.AnnotatedMember;
23 | import jakarta.enterprise.inject.spi.AnnotatedType;
24 |
25 | public abstract class AnnotatedMemberHolder implements AnnotatedMember {
26 | @Override
27 | public Member getJavaMember() {
28 | return null;
29 | }
30 |
31 | @Override
32 | public boolean isStatic() {
33 | return false;
34 | }
35 |
36 | @Override
37 | public AnnotatedType getDeclaringType() {
38 | return null;
39 | }
40 |
41 | @Override
42 | public Type getBaseType() {
43 | return null;
44 | }
45 |
46 | @Override
47 | public Set getTypeClosure() {
48 | return null;
49 | }
50 |
51 | @Override
52 | public T getAnnotation(Class annotationType) {
53 | return null;
54 | }
55 |
56 | @Override
57 | public Set getAnnotations() {
58 | return null;
59 | }
60 |
61 | @Override
62 | public boolean isAnnotationPresent(Class extends Annotation> annotationType) {
63 | return false;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/lang-model/src/main/java/jakarta/enterprise/lang/model/types/TypeVariable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.lang.model.types;
15 |
16 | import java.util.List;
17 |
18 | /**
19 | * Type variables represent type parameters declared on generic classes or methods.
20 | * All type variables have bounds. A type variable with no bound declared is equivalent to
21 | * a type variable with a single bound of {@code java.lang.Object} and is represented as such.
22 | * If one bound is declared, it is a type variable or a class type, possibly parameterized.
23 | * If more than one bound is declared, the first bound is a class type or an interface type,
24 | * possibly parameterized, and the following bounds are interface types, possibly parameterized.
25 | */
26 | public interface TypeVariable extends Type {
27 | /**
28 | * Returns the name of this type variable.
29 | *
30 | * @return the name of this type variable, never {@code null}
31 | */
32 | String name();
33 |
34 | /**
35 | * Returns the bounds declared for this type variable.
36 | *
37 | * @return the bounds declared for this type variable, never {@code null} or empty
38 | */
39 | List bounds();
40 |
41 | // ---
42 |
43 | @Override
44 | default Kind kind() {
45 | return Kind.TYPE_VARIABLE;
46 | }
47 |
48 | @Override
49 | default TypeVariable asTypeVariable() {
50 | return this;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/api/src/test/java/org/jboss/cdi/api/test/annotated/AbstractAnnotatedTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package org.jboss.cdi.api.test.annotated;
16 |
17 | import static java.util.Arrays.asList;
18 |
19 | import java.lang.annotation.Annotation;
20 | import java.util.Collections;
21 | import java.util.LinkedHashSet;
22 | import java.util.Set;
23 |
24 | import jakarta.enterprise.inject.spi.Annotated;
25 |
26 | import org.testng.Assert;
27 | import org.testng.annotations.Test;
28 |
29 | public abstract class AbstractAnnotatedTest {
30 |
31 | @Test
32 | public void shouldFindAnnotationsOnAnnotated() {
33 | Annotated annotated = getAnnotated();
34 |
35 | Set repeaters = annotated.getAnnotations(Repeater.class);
36 |
37 | Assert.assertEquals(repeaters, new LinkedHashSet<>(asList(getAnnotationsByType(Repeater.class))));
38 | }
39 |
40 | @Test
41 | public void shouldReturnSingletonForNonRepeatableAnnotation() {
42 | Annotated annotated = getAnnotated();
43 |
44 | Set repeaters = annotated.getAnnotations(Repeaters.class);
45 |
46 | Assert.assertEquals(repeaters, Collections.singleton(getAnnotation(Repeaters.class)));
47 | }
48 |
49 | protected abstract Annotated getAnnotated();
50 |
51 | protected abstract T[] getAnnotationsByType(Class annotationClass);
52 |
53 | protected abstract T getAnnotation(Class annotationClass);
54 | }
55 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/ProcessSyntheticObserverMethod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject.spi;
16 |
17 | /**
18 | *
19 | * The container fires an event of this type for each custom implementation of {@link ObserverMethod} added through
20 | * {@link AfterBeanDiscovery#addObserverMethod(ObserverMethod)} or {@link AfterBeanDiscovery#addObserverMethod()}, before
21 | * registering the {@link ObserverMethod} object.
22 | *
23 | *
24 | * If any observer method of a {@code ProcessSyntheticObserverMethod} event throws an exception, the exception is treated as a
25 | * definition error by the container.
26 | *
27 | *
28 | *
29 | * CDI Lite implementations are not required to provide support for Portable Extensions.
30 | *
31 | *
32 | * @see ObserverMethod
33 | * @author Martin Kouba
34 | * @param The type of the event being observed
35 | * @param The bean type containing the observer method, i.e. {@link ObserverMethod#getBeanClass()}
36 | * @since 2.0
37 | */
38 | public interface ProcessSyntheticObserverMethod extends ProcessObserverMethod {
39 |
40 | /**
41 | * Get the extension instance which added the {@link ObserverMethod} for which this event is being fired.
42 | *
43 | * @return the extension instance
44 | * @throws IllegalStateException if called outside of the observer method invocation
45 | */
46 | public Extension getSource();
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/AmbiguousResolutionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.inject;
15 |
16 | /**
17 | *
18 | * Indicates that multiple beans match a certain combination of required type and required qualifiers and are eligible for
19 | * injection into a certain class.
20 | *
21 | *
22 | * @author Pete Muir
23 | * @author Gavin King
24 | */
25 | public class AmbiguousResolutionException extends ResolutionException {
26 |
27 | private static final long serialVersionUID = -2132733164534544788L;
28 |
29 | /**
30 | * Creates the exception with no detail message or cause.
31 | */
32 | public AmbiguousResolutionException() {
33 | }
34 |
35 | /**
36 | * Creates the exception with given detail message and cause.
37 | *
38 | * @param message the detail message
39 | * @param cause the cause
40 | */
41 | public AmbiguousResolutionException(String message, Throwable cause) {
42 | super(message, cause);
43 | }
44 |
45 | /**
46 | * Creates the exception with given detail message.
47 | *
48 | * @param message the detail message
49 | */
50 | public AmbiguousResolutionException(String message) {
51 | super(message);
52 | }
53 |
54 | /**
55 | * Creates the exception with given cause.
56 | *
57 | * @param cause the cause
58 | */
59 | public AmbiguousResolutionException(Throwable cause) {
60 | super(cause);
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/IllegalProductException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.inject;
15 |
16 | import jakarta.enterprise.context.Dependent;
17 |
18 | /**
19 | *
20 | * Indicates that a producer method returned a null value or a producer field contained a null value, and the scope of the
21 | * producer method or field was not {@link Dependent}.
22 | *
23 | */
24 | public class IllegalProductException extends InjectionException {
25 |
26 | private static final long serialVersionUID = -6280627846071966243L;
27 |
28 | /**
29 | * Creates the exception with no detail message or cause.
30 | */
31 | public IllegalProductException() {
32 | super();
33 | }
34 |
35 | /**
36 | * Creates the exception with given detail message and cause.
37 | *
38 | * @param message the detail message
39 | * @param cause the cause
40 | */
41 | public IllegalProductException(String message, Throwable cause) {
42 | super(message, cause);
43 | }
44 |
45 | /**
46 | * Creates the exception with given detail message.
47 | *
48 | * @param message the detail message
49 | */
50 | public IllegalProductException(String message) {
51 | super(message);
52 | }
53 |
54 | /**
55 | * Creates the exception with given cause.
56 | *
57 | * @param cause the cause
58 | */
59 | public IllegalProductException(Throwable cause) {
60 | super(cause);
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/api/src/test/java/org/jboss/cdi/api/test/annotated/AnnotatedParameterHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package org.jboss.cdi.api.test.annotated;
16 |
17 | import java.lang.annotation.Annotation;
18 | import java.lang.reflect.Type;
19 | import java.util.Set;
20 |
21 | import jakarta.enterprise.inject.spi.AnnotatedCallable;
22 | import jakarta.enterprise.inject.spi.AnnotatedParameter;
23 |
24 | public class AnnotatedParameterHolder implements AnnotatedParameter {
25 | private final AnnotatedCallable annotatedCallable;
26 |
27 | public AnnotatedParameterHolder(AnnotatedCallable annotatedCallable) {
28 | this.annotatedCallable = annotatedCallable;
29 | }
30 |
31 | @Override
32 | public int getPosition() {
33 | return 0;
34 | }
35 |
36 | @Override
37 | public AnnotatedCallable getDeclaringCallable() {
38 | return this.annotatedCallable;
39 | }
40 |
41 | @Override
42 | public Type getBaseType() {
43 | return null;
44 | }
45 |
46 | @Override
47 | public Set getTypeClosure() {
48 | return null;
49 | }
50 |
51 | @Override
52 | public T getAnnotation(Class annotationType) {
53 | return null;
54 | }
55 |
56 | @Override
57 | public Set getAnnotations() {
58 | return null;
59 | }
60 |
61 | @Override
62 | public boolean isAnnotationPresent(Class extends Annotation> annotationType) {
63 | return false;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/context/ContextNotActiveException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.context;
16 |
17 | import jakarta.enterprise.context.spi.Context;
18 |
19 | /**
20 | *
21 | * Indicates that a context is not active.
22 | *
23 | *
24 | * @see Context
25 | *
26 | * @author Pete Muir
27 | * @author Shane Bryzak
28 | * @author Gavin King
29 | */
30 |
31 | public class ContextNotActiveException extends ContextException {
32 |
33 | private static final long serialVersionUID = -3599813072560026919L;
34 |
35 | /**
36 | * Creates the exception with no detail message or cause.
37 | */
38 | public ContextNotActiveException() {
39 | super();
40 | }
41 |
42 | /**
43 | * Creates the exception with given detail message.
44 | *
45 | * @param message the detail message
46 | */
47 | public ContextNotActiveException(String message) {
48 | super(message);
49 | }
50 |
51 | /**
52 | * Creates the exception with given cause.
53 | *
54 | * @param cause the cause
55 | */
56 | public ContextNotActiveException(Throwable cause) {
57 | super(cause);
58 | }
59 |
60 | /**
61 | * Creates the exception with given detail message and cause.
62 | *
63 | * @param message the detail message
64 | * @param cause the cause
65 | */
66 | public ContextNotActiveException(String message, Throwable cause) {
67 | super(message, cause);
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/UnsatisfiedResolutionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.inject;
15 |
16 | /**
17 | *
18 | * Indicates that no bean matches a certain combination of required type and required qualifiers and is eligible for injection
19 | * into a certain class.
20 | *
21 | *
22 | * @author Pete Muir
23 | * @author Gavin King
24 | */
25 | public class UnsatisfiedResolutionException extends ResolutionException {
26 |
27 | private static final long serialVersionUID = 5350603312442756709L;
28 |
29 | /**
30 | * Creates the exception with no detail message or cause.
31 | */
32 | public UnsatisfiedResolutionException() {
33 | super();
34 | }
35 |
36 | /**
37 | * Creates the exception with given detail message and cause.
38 | *
39 | * @param message the detail message
40 | * @param cause the cause
41 | */
42 | public UnsatisfiedResolutionException(String message, Throwable cause) {
43 | super(message, cause);
44 | }
45 |
46 | /**
47 | * Creates the exception with given detail message.
48 | *
49 | * @param message the detail message
50 | */
51 | public UnsatisfiedResolutionException(String message) {
52 | super(message);
53 | }
54 |
55 | /**
56 | * Creates the exception with given cause.
57 | *
58 | * @param cause the cause
59 | */
60 | public UnsatisfiedResolutionException(Throwable cause) {
61 | super(cause);
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/EventMetadata.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013, 2015 Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject.spi;
16 |
17 | import java.lang.annotation.Annotation;
18 | import java.lang.reflect.Type;
19 | import java.util.Set;
20 |
21 | import jakarta.enterprise.event.Event;
22 | import jakarta.enterprise.event.Observes;
23 |
24 | /**
25 | *
26 | * Provides access to metadata about an observed event payload.
27 | *
28 | *
29 | * {@link EventMetadata} may only be injected into an observer method. For example:
30 | *
31 | *
32 | *
33 | * public void afterLogin(@Observes LoggedInEvent event, EventMetadata eventMetadata) { ... }
34 | *
35 | *
36 | * @see Observes
37 | *
38 | * @author Lincoln Baxter, III
39 | * @author Pete Muir
40 | * @author Antoine Sabot-Durand
41 | * @since 1.1
42 | */
43 | public interface EventMetadata {
44 | /**
45 | * @return the qualifiers for which event payload was fired.
46 | */
47 | public Set getQualifiers();
48 |
49 | /**
50 | * Get the {@link InjectionPoint} representing the injected {@link Event} instance which fired the event
51 | *
52 | * @return InjectionPoint of the Event
53 | */
54 | public InjectionPoint getInjectionPoint();
55 |
56 | /**
57 | * Get the type representing runtime class of the event object with type variables resolved.
58 | *
59 | *
60 | * @return the runtime type of the event object
61 | */
62 | public Type getType();
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/Reserve.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025, Contributors to the Eclipse Foundation
3 | *
4 | * This program and the accompanying materials are made available under the
5 | * Apache Software License 2.0 which is available at:
6 | * https://www.apache.org/licenses/LICENSE-2.0.
7 | *
8 | * SPDX-License-Identifier: Apache-2.0
9 | */
10 |
11 | package jakarta.enterprise.inject;
12 |
13 | import static java.lang.annotation.ElementType.FIELD;
14 | import static java.lang.annotation.ElementType.METHOD;
15 | import static java.lang.annotation.ElementType.TYPE;
16 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
17 |
18 | import java.lang.annotation.Documented;
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.Target;
21 |
22 | import jakarta.annotation.Priority;
23 | import jakarta.enterprise.util.AnnotationLiteral;
24 |
25 | /**
26 | *
27 | * Specifies that a bean is a reserve. May be applied to a bean class, producer method or field or
28 | * {@linkplain Stereotype stereotype}.
29 | *
30 | *
31 | *
32 | * @Reserve
33 | * @Priority(1)
34 | * @Dependent
35 | * public class DefaultOrder extends Order { ... }
36 | *
37 | *
38 | *
39 | * During typesafe resolution, non-reserve beans take precedence over reserve beans.
40 | *
41 | *
42 | *
43 | * A reserve is not available for injection, lookup or name resolution in a module unless
44 | * the reserve is selected for the application (by adding the {@link Priority} annotation).
45 | *
46 | *
47 | *
48 | * Unlike {@linkplain Alternative alternatives}, reserves cannot be selected for a bean archive in {@code beans.xml}.
49 | *
50 | */
51 | @Target({ TYPE, METHOD, FIELD })
52 | @Retention(RUNTIME)
53 | @Documented
54 | public @interface Reserve {
55 | /**
56 | * Supports inline instantiation of the {@link Reserve} annotation.
57 | */
58 | final class Literal extends AnnotationLiteral implements Reserve {
59 | public static final Literal INSTANCE = new Literal();
60 |
61 | private static final long serialVersionUID = 1L;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/UnproxyableResolutionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject;
16 |
17 | /**
18 | *
19 | * Indicates that a contextual reference for a bean with a normal scope and a certain bean type cannot be obtained because the
20 | * bean type cannot be proxied by the container.
21 | *
22 | *
23 | * @author Pete Muir
24 | * @author Gavin King
25 | */
26 | public class UnproxyableResolutionException extends ResolutionException {
27 |
28 | private static final long serialVersionUID = 1667539354548135465L;
29 |
30 | /**
31 | * Creates the exception with no detail message or cause.
32 | */
33 | public UnproxyableResolutionException() {
34 | super();
35 | }
36 |
37 | /**
38 | * Creates the exception with given detail message and cause.
39 | *
40 | * @param message the detail message
41 | * @param cause the cause
42 | */
43 | public UnproxyableResolutionException(String message, Throwable cause) {
44 | super(message, cause);
45 | }
46 |
47 | /**
48 | * Creates the exception with given detail message.
49 | *
50 | * @param message the detail message
51 | */
52 | public UnproxyableResolutionException(String message) {
53 | super(message);
54 | }
55 |
56 | /**
57 | * Creates the exception with given cause.
58 | *
59 | * @param cause the cause
60 | */
61 | public UnproxyableResolutionException(Throwable cause) {
62 | super(cause);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/lang-model/src/main/java/jakarta/enterprise/lang/model/types/WildcardType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.lang.model.types;
15 |
16 | /**
17 | * A wildcard type. May have 3 forms:
18 | *
19 | * {@code ? extends Number}: has an upper bound
20 | * {@code ? super Number}: has a lower bound
21 | * {@code ?}: unbounded, has an implicit upper bound of {@code java.lang.Object}
22 | *
23 | * Note that {@code ?} is equivalent to {@code ? extends Object} and is represented as such.
24 | * Therefore, either {@link #upperBound()} or {@link #lowerBound()} always returns non-{@code null}.
25 | */
26 | public interface WildcardType extends Type {
27 | /**
28 | * Returns the upper bound of this wildcard type.
29 | * Returns {@code null} if this wildcard type does not have an upper bound.
30 | *
31 | * @return upper bound of this wildcard type, or {@code null} if this wildcard type does not have an upper bound
32 | */
33 | Type upperBound();
34 |
35 | /**
36 | * Returns the lower bound of this wildcard type.
37 | * Returns {@code null} if this wildcard type does not have a lower bound.
38 | *
39 | * @return lower bound of this wildcard type, or {@code null} if this wildcard type does not have a lower bound
40 | */
41 | Type lowerBound();
42 |
43 | // ---
44 |
45 | @Override
46 | default Kind kind() {
47 | return Kind.WILDCARD_TYPE;
48 | }
49 |
50 | @Override
51 | default WildcardType asWildcardType() {
52 | return this;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/lang-model/src/main/java/jakarta/enterprise/lang/model/declarations/ParameterInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.lang.model.declarations;
15 |
16 | import jakarta.enterprise.lang.model.types.Type;
17 |
18 | /**
19 | * A method parameter or a constructor parameter, {@linkplain #declaringMethod() declared} in some method
20 | * or constructor.
21 | *
22 | * @since 4.0
23 | */
24 | public interface ParameterInfo extends DeclarationInfo {
25 | /**
26 | * Returns the name of this parameter, if it is known. Method parameter names may not always be known,
27 | * in which case a synthetic name of the form {@code argN}, where {@code N} is zero-based parameter position
28 | * in the method declaration, is returned.
29 | *
30 | * @return the name of this parameter, or a synthetic name, never {@code null}
31 | */
32 | String name();
33 |
34 | /**
35 | * Returns the {@linkplain Type type} of this parameter.
36 | *
37 | * @return the {@linkplain Type type} of this parameter, never {@code null}
38 | */
39 | Type type();
40 |
41 | /**
42 | * Returns the {@linkplain MethodInfo method} that declares this parameter.
43 | *
44 | * @return the {@linkplain MethodInfo method} that declares this parameter, never {@code null}
45 | */
46 | MethodInfo declaringMethod();
47 |
48 | // ---
49 |
50 | @Override
51 | default Kind kind() {
52 | return Kind.PARAMETER;
53 | }
54 |
55 | @Override
56 | default ParameterInfo asParameter() {
57 | return this;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/api/src/test/java/org/jboss/cdi/api/test/event/NotificationOptionsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package org.jboss.cdi.api.test.event;
15 |
16 | import static org.testng.Assert.assertEquals;
17 | import static org.testng.Assert.assertNotNull;
18 | import static org.testng.Assert.assertNull;
19 |
20 | import java.time.Duration;
21 | import java.util.concurrent.Executor;
22 |
23 | import jakarta.enterprise.event.NotificationOptions;
24 |
25 | import org.testng.annotations.Test;
26 |
27 | /**
28 | *
29 | * @author Martin Kouba
30 | */
31 | public class NotificationOptionsTest {
32 |
33 | @Test
34 | public void testBuilder() {
35 | Duration timeout = Duration.ofDays(1);
36 | NotificationOptions options = NotificationOptions.of("timeout", timeout);
37 | assertEquals(timeout, options.get("timeout"));
38 | assertNull(options.getExecutor());
39 | assertNull(options.get("alpha"));
40 | options = NotificationOptions.builder().set("foo", "bar").setExecutor(new Executor() {
41 | @Override
42 | public void execute(Runnable command) {
43 | }
44 | }).build();
45 | assertEquals("bar", options.get("foo"));
46 | assertNotNull(options.getExecutor());
47 | options = NotificationOptions.ofExecutor(new Executor() {
48 | @Override
49 | public void execute(Runnable command) {
50 | }
51 | });
52 | Executor executor = options.getExecutor();
53 | assertNotNull(executor);
54 | assertNull(options.get("timeout"));
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/core/lifecycle_full.asciidoc:
--------------------------------------------------------------------------------
1 | ////
2 | Copyright (c) 2021 Red Hat, Inc. and others
3 |
4 | This program and the accompanying materials are made available under the
5 | Apache Software License 2.0 which is available at:
6 | https://www.apache.org/licenses/LICENSE-2.0.
7 |
8 | SPDX-License-Identifier: Apache-2.0
9 | ////
10 | [[lifecycle_full]]
11 |
12 | == Lifecycle of contextual instances in {cdi_full}
13 |
14 | [[biz_method_full]]
15 |
16 | === Container invocations and interception in {cdi_full}
17 |
18 | Instead of the rules in <>, the following rules apply in {cdi_full}.
19 |
20 | When the application invokes:
21 |
22 | * a method of a bean via a contextual reference to the bean, as defined in <>,
23 | * a method of a bean via a non-contextual reference to the bean, if the instance was created by the container (e.g. using `InjectionTarget.produce()` or `UnmanagedInstance.produce()`, or
24 | * a method of a bean via a non-contextual reference to the bean, if the instance was enhanced with the `InterceptionFactory` interface as defined in <>,
25 |
26 | the invocation is treated as a _business method invocation_.
27 |
28 | When the container invokes a method of a bean, the invocation may or may not be treated as a business method invocation:
29 |
30 | * Invocations of initializer methods by the container are not business method invocations.
31 | * Invocations of producer, disposer and observer methods by the container are business method invocations and are intercepted by method interceptors and decorators.
32 | * Invocation of lifecycle callbacks by the container are not business method invocations, but are intercepted by interceptors for lifecycle callbacks.
33 | * Invocations of interceptors and decorator methods during method or lifecycle callback interception are not business method invocations, and therefore no recursive interception occurs.
34 | * Invocations of methods declared by `java.lang.Object` are not business method invocations.
35 |
36 | A method invocation passes through method interceptors and decorators if, and only if, it is a business method invocation.
37 |
38 | Otherwise, the invocation is treated as a normal Java method call and is not intercepted by the container.
--------------------------------------------------------------------------------
/api/src/test/java/org/jboss/cdi/api/test/annotated/AnnotatedCallableHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package org.jboss.cdi.api.test.annotated;
16 |
17 | import java.lang.annotation.Annotation;
18 | import java.lang.reflect.Member;
19 | import java.lang.reflect.Type;
20 | import java.util.List;
21 | import java.util.Set;
22 |
23 | import jakarta.enterprise.inject.spi.AnnotatedCallable;
24 | import jakarta.enterprise.inject.spi.AnnotatedParameter;
25 | import jakarta.enterprise.inject.spi.AnnotatedType;
26 |
27 | public abstract class AnnotatedCallableHolder implements AnnotatedCallable {
28 | @Override
29 | public List> getParameters() {
30 | return null;
31 | }
32 |
33 | @Override
34 | public Member getJavaMember() {
35 | return null;
36 | }
37 |
38 | @Override
39 | public boolean isStatic() {
40 | return false;
41 | }
42 |
43 | @Override
44 | public AnnotatedType getDeclaringType() {
45 | return null;
46 | }
47 |
48 | @Override
49 | public Type getBaseType() {
50 | return null;
51 | }
52 |
53 | @Override
54 | public Set getTypeClosure() {
55 | return null;
56 | }
57 |
58 | @Override
59 | public T getAnnotation(Class annotationType) {
60 | return null;
61 | }
62 |
63 | @Override
64 | public Set getAnnotations() {
65 | return null;
66 | }
67 |
68 | @Override
69 | public boolean isAnnotationPresent(Class extends Annotation> annotationType) {
70 | return false;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/el/src/main/java/jakarta/enterprise/inject/spi/el/ELAwareBeanManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.inject.spi.el;
15 |
16 | import jakarta.el.ELResolver;
17 | import jakarta.el.ExpressionFactory;
18 | import jakarta.enterprise.context.Dependent;
19 | import jakarta.enterprise.inject.spi.BeanManager;
20 |
21 | /**
22 | * A {@link BeanManager} that allows integrators to obtain Unified EL objects that are
23 | * integrated with the CDI container as described in the Jakarta EE Platform specification.
24 | *
25 | * @since 4.1
26 | */
27 | public interface ELAwareBeanManager extends BeanManager {
28 | /**
29 | * Returns a {@link jakarta.el.ELResolver} that resolves beans by bean name.
30 | *
31 | * @return the {@link jakarta.el.ELResolver}
32 | */
33 | public ELResolver getELResolver();
34 |
35 | /**
36 | * Returns a wrapper {@link jakarta.el.ExpressionFactory} that delegates {@link jakarta.el.MethodExpression} and
37 | * {@link jakarta.el.ValueExpression} creation to the given {@link jakarta.el.ExpressionFactory}. When a Unified EL
38 | * expression is evaluated using a {@link jakarta.el.MethodExpression} or {@link jakarta.el.ValueExpression} returned by the
39 | * wrapper {@link jakarta.el.ExpressionFactory}, the container handles destruction of objects with scope {@link Dependent}.
40 | *
41 | * @param expressionFactory the {@link jakarta.el.ExpressionFactory} to wrap
42 | * @return the wrapped {@link jakarta.el.ExpressionFactory}
43 | */
44 | public ExpressionFactory wrapExpressionFactory(ExpressionFactory expressionFactory);
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/ProcessProducerMethod.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.inject.spi;
15 |
16 | /**
17 | *
18 | * The container fires an event of this type for each enabled producer method, before registering the
19 | * {@link Bean} object.
20 | *
21 | *
22 | * If any observer method of a {@code ProcessProducerMethod} event throws an exception, the exception is treated as a definition
23 | * error by the container.
24 | *
25 | *
26 | *
27 | * CDI Lite implementations are not required to provide support for Portable Extensions.
28 | *
29 | *
30 | * @author David Allen
31 | * @param The return type of the producer method
32 | * @param The class of the bean declaring the producer method
33 | */
34 | public interface ProcessProducerMethod extends ProcessBean {
35 | /**
36 | * Returns the {@link AnnotatedMethod} representing the producer method.
37 | *
38 | * @return the {@link AnnotatedMethod} for the producer method being registered
39 | * @throws IllegalStateException if called outside of the observer method invocation
40 | */
41 | public AnnotatedMethod getAnnotatedProducerMethod();
42 |
43 | /**
44 | * Returns the {@link AnnotatedParameter} for any matching injection point of the same type as
45 | * the producer method return type found on a disposal method.
46 | *
47 | * @return the disposal method's {@link AnnotatedParameter}
48 | * @throws IllegalStateException if called outside of the observer method invocation
49 | */
50 | public AnnotatedParameter getAnnotatedDisposedParameter();
51 | }
52 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/TransientReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject;
16 |
17 | import static java.lang.annotation.ElementType.PARAMETER;
18 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
19 |
20 | import java.lang.annotation.Documented;
21 | import java.lang.annotation.Retention;
22 | import java.lang.annotation.Target;
23 |
24 | import jakarta.enterprise.event.Event;
25 | import jakarta.enterprise.util.AnnotationLiteral;
26 |
27 | /**
28 | *
29 | * If a parameter annotated with @TransientReference resolves to a dependent scoped bean, then the bean will
30 | * be
31 | * destroyed after the invocation completes.
32 | *
33 | *
34 | *
35 | * public class OrderManager {
36 | *
37 | * @Inject
38 | * public OrderManager(@TransientReference Order order) {
39 | * ...
40 | *
41 | * }
42 | * }
43 | *
44 | *
45 | * @author Pete Muir
46 | * @since 1.1
47 | */
48 |
49 | @Target(PARAMETER)
50 | @Retention(RUNTIME)
51 | @Documented
52 | public @interface TransientReference {
53 |
54 | /**
55 | * Supports inline instantiation of the {@link TransientReference} annotation.
56 | *
57 | * @author Martin Kouba
58 | * @since 2.0
59 | * @see Instance
60 | * @see Event
61 | */
62 | public static final class Literal extends AnnotationLiteral implements TransientReference {
63 |
64 | private static final long serialVersionUID = 1L;
65 | /** Default TransientReference literal */
66 | public static final Literal INSTANCE = new Literal();
67 |
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanCreator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Red Hat and others
3 | *
4 | * This program and the accompanying materials are made available under the
5 | * Apache Software License 2.0 which is available at:
6 | * https://www.apache.org/licenses/LICENSE-2.0.
7 | *
8 | * SPDX-License-Identifier: Apache-2.0
9 | */
10 |
11 | package jakarta.enterprise.inject.build.compatible.spi;
12 |
13 | import jakarta.enterprise.inject.Instance;
14 |
15 | /**
16 | * Creation function for a synthetic bean defined by {@link SyntheticBeanBuilder}.
17 | * CDI container will create an instance of the creation function every time when it needs
18 | * to obtain an instance of the synthetic bean. Implementations must be {@code public}
19 | * classes with a {@code public} zero-parameter constructor; they must not be beans.
20 | *
21 | * @param the bean class of the synthetic bean
22 | * @since 4.0
23 | */
24 | public interface SyntheticBeanCreator {
25 | /**
26 | * Creates an instance of the synthetic bean.
27 | * May only return {@code null} if the synthetic bean is {@code @Dependent}.
28 | *
29 | * The {@link Instance} parameter may be used to simulate producer method parameter injection.
30 | * However, {@code @Dependent} bean instances obtained from the {@code Instance} during execution
31 | * remain managed until the synthetic bean instance is destroyed. Therefore, implementations
32 | * are encouraged to destroy unneeded {@code @Dependent} bean instances obtained from the {@code Instance}.
33 | *
34 | * If the synthetic bean is {@code @Dependent}, the {@code InjectionPoint} to which it is injected
35 | * may be looked up from the {@code Instance} parameter.
36 | *
37 | * The parameter map contains the same values that were passed to the {@link SyntheticBeanBuilder}
38 | * that defined the synthetic bean.
39 | *
40 | * @param lookup an {@link Instance} that can be used to lookup other beans, never {@code null}
41 | * @param params the parameter map, never {@code null}
42 | * @return an instance of the bean, may only be {@code null} if the synthetic bean is {@code @Dependent}
43 | */
44 | T create(Instance lookup, Parameters params);
45 | }
46 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/ProcessSessionBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject.spi;
16 |
17 | /**
18 | *
19 | * The container fires an event of this type for each enabled session bean, before registering the
20 | * {@link Bean} object.
21 | *
22 | *
23 | *
24 | * If any observer method of a {@code ProcessSessionBean} event throws an exception, the exception is treated as a definition
25 | * error by the container.
26 | *
27 | *
28 | *
29 | * Note that the type parameter of the super-interface of {@link ProcessSessionBean} is {@link Object} as {@link ProcessBean}
30 | * allows you access to the {@link Bean}, which in turn allows you to instantiate an instance, which, for interface-view EJBs
31 | * will not be an instance of X.
32 | *
33 | *
34 | *
35 | * CDI Lite implementations are not required to provide support for Portable Extensions.
36 | *
37 | *
38 | * @author David Allen
39 | * @param session bean type
40 | */
41 | public interface ProcessSessionBean extends ProcessManagedBean {
42 | /**
43 | * Returns the EJB name of the session bean.
44 | *
45 | * @return the name of the EJB
46 | * @throws IllegalStateException if called outside of the observer method invocation
47 | */
48 | public String getEjbName();
49 |
50 | /**
51 | * Returns a {@link SessionBeanType} representing the kind of session bean.
52 | *
53 | * @return the {@link SessionBeanType}
54 | * @throws IllegalStateException if called outside of the observer method invocation
55 | */
56 | public SessionBeanType getSessionBeanType();
57 | }
58 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/util/Nonbinding.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.util;
16 |
17 | import static java.lang.annotation.ElementType.METHOD;
18 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
19 |
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.Target;
22 |
23 | /**
24 | *
25 | * Excludes a member of an annotation type (such as a {@linkplain jakarta.inject.Qualifier qualifier type} or
26 | * {@linkplain jakarta.interceptor.InterceptorBinding interceptor binding type}) from consideration when the container compares
27 | * two annotation instances.
28 | *
29 | *
30 | *
31 | * @Qualifier
32 | * @Retention(RUNTIME)
33 | * @Target({ METHOD, FIELD, PARAMETER, TYPE })
34 | * public @interface PayBy {
35 | * PaymentMethod value();
36 | *
37 | * @Nonbinding
38 | * String comment();
39 | * }
40 | *
41 | *
42 | * @author Gavin King
43 | *
44 | * @see jakarta.inject.Qualifier @Qualifier
45 | * @see jakarta.interceptor.InterceptorBinding @InterceptorBinding
46 | *
47 | */
48 | @Retention(RUNTIME)
49 | @Target(METHOD)
50 | public @interface Nonbinding {
51 |
52 | /**
53 | * Supports inline instantiation of the {@link Nonbinding} annotation.
54 | *
55 | * @author Martin Kouba
56 | * @since 2.0
57 | */
58 | public static final class Literal extends AnnotationLiteral implements Nonbinding {
59 | /** Default Nonbinding literal */
60 | public static final Literal INSTANCE = new Literal();
61 |
62 | private static final long serialVersionUID = 1L;
63 |
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/core/definition_full.asciidoc:
--------------------------------------------------------------------------------
1 | ////
2 | Copyright (c) 2021 Red Hat, Inc. and others
3 |
4 | This program and the accompanying materials are made available under the
5 | Apache Software License 2.0 which is available at:
6 | https://www.apache.org/licenses/LICENSE-2.0.
7 |
8 | SPDX-License-Identifier: Apache-2.0
9 | ////
10 | [partintro]
11 | --
12 | {cdi_full} contains all the functionality defined in {cdi_lite} and adds some additional features such as specialization, decorators, session scope or conversation scope.
13 | Some of these concepts were briefly mentioned in the previous {cdi_lite} chapter and this section of specification defines them in depth.
14 |
15 | All rules from the {cdi_lite} specification apply to {cdi_full}, unless the {cdi_full} specification says otherwise.
16 | Most sections of the {cdi_full} specification add new rules on top of the {cdi_lite} specification, but some override the corresponding section of the {cdi_lite} specification and provide a replacing set of rules.
17 | --
18 |
19 | [[scopes_full]]
20 |
21 | == Scopes in {cdi_full}
22 |
23 | [[builtin_scopes_full]]
24 |
25 | === Built-in scope types in {cdi_full}
26 |
27 | In addition to built-in scope types defined in <>, the following two built-in scopes are present:
28 |
29 | * The `@SessionScoped` annotation represents the session scope defined in <>.
30 | * The `@ConversationScoped` annotation represents the conversation scope defined in <>.
31 |
32 | In addition to rules defined in <>, the following rules apply.
33 |
34 | If a decorator has any scope other than `@Dependent`, non-portable behavior results.
35 |
36 | [[bean_defining_annotations_full]]
37 |
38 | === Bean defining annotations in {cdi_full}
39 |
40 | In addition to bean defining annotations defined in <>, the following bean defining annotations are present:
41 |
42 | * `@SessionScoped` and `@ConversationScoped` annotations,
43 | * `@Decorator` annotation.
44 |
45 | [[builtin_stereotypes_full]]
46 |
47 | ==== Built-in stereotypes in {cdi_full}
48 |
49 | In addition to built-in stereotypes defined in <>, the following built-in stereotype is present.
50 |
51 | The special-purpose `@Decorator` stereotype is defined in <>.
52 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/event/ImmutableNotificationOptions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.event;
15 |
16 | import java.util.HashMap;
17 | import java.util.Map;
18 | import java.util.concurrent.Executor;
19 |
20 | /**
21 | * The immutable implementation of {@link NotificationOptions}.
22 | *
23 | * @author Martin Kouba
24 | *
25 | */
26 | class ImmutableNotificationOptions implements NotificationOptions {
27 |
28 | private final Executor executor;
29 |
30 | private final Map options;
31 |
32 | private ImmutableNotificationOptions(Executor executor, Map options) {
33 | this.executor = executor;
34 | this.options = new HashMap<>(options);
35 | }
36 |
37 | @Override
38 | public Executor getExecutor() {
39 | return executor;
40 | }
41 |
42 | @Override
43 | public Object get(String name) {
44 | return options.get(name);
45 | }
46 |
47 | static class Builder implements NotificationOptions.Builder {
48 |
49 | private Executor executor;
50 |
51 | private Map options;
52 |
53 | Builder() {
54 | this.options = new HashMap<>();
55 | }
56 |
57 | public Builder setExecutor(Executor executor) {
58 | this.executor = executor;
59 | return this;
60 | }
61 |
62 | public Builder set(String name, Object value) {
63 | options.put(name, value);
64 | return this;
65 | }
66 |
67 | public ImmutableNotificationOptions build() {
68 | return new ImmutableNotificationOptions(executor, options);
69 | }
70 |
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/ProcessProducerField.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.inject.spi;
15 |
16 | /**
17 | *
18 | * The container fires an event of this type for each enabled producer field, before registering the
19 | * {@link Bean} object. Resources are considered to be producer fields.
20 | *
21 | *
22 | * If any observer method of a {@code ProcessProducerField} event throws an exception, the exception is treated as a definition
23 | * error by the container.
24 | *
25 | *
26 | *
27 | * CDI Lite implementations are not required to provide support for Portable Extensions.
28 | *
29 | *
30 | * @author David Allen
31 | * @param The type of the producer field
32 | * @param The class of the bean declaring the producer field
33 | *
34 | */
35 | public interface ProcessProducerField extends ProcessBean {
36 | /**
37 | * Returns the {@link AnnotatedField} representing the producer field.
38 | *
39 | * @return the {@link AnnotatedField} for the producer field being registered
40 | * @throws IllegalStateException if called outside of the observer method invocation
41 | */
42 | public AnnotatedField getAnnotatedProducerField();
43 |
44 | /**
45 | * Returns the {@link AnnotatedParameter} for any matching injection point of the same type as
46 | * the producer field return type found on a disposal method.
47 | *
48 | * @return the disposal method's {@link AnnotatedParameter}
49 | * @throws IllegalStateException if called outside of the observer method invocation
50 | * @since 1.1
51 | */
52 | public AnnotatedParameter getAnnotatedDisposedParameter();
53 | }
54 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/enterprise/inject/spi/ProducerFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package jakarta.enterprise.inject.spi;
16 |
17 | /**
18 | *
19 | * An {@link ProducerFactory} can create an {@link Producer} for a given bean.
20 | *
21 | *
22 | *
23 | * The {@link ProducerFactory} obtained from {@link BeanManager#getProducerFactory(AnnotatedMethod, Bean)} or
24 | * {@link BeanManager#getProducerFactory(AnnotatedField, Bean)} is capable of providing container created
25 | * producers. This factory can be wrapped to add behavior to container created producers.
26 | *
27 | *
28 | *
29 | * For example:
30 | *
31 | *
32 | *
33 | * BeanAttributes<MyBean> myBeanAttributes = beanManager.createBeanAttributes(myBeanAnnotatedFieldField);
34 | * beanManager.createBean(myBeanAttributes, MyBean.class, new ProducerFactory() {
35 | *
36 | * public <T> Producer<T> createProducer(Bean<T> bean) {
37 | * return new WrappingProducer<T>(beanManager.getProducerFactory(myBeanAnnotatedField).createProducer(bean));
38 | * }
39 | * });
40 | *
41 | *
42 | *
43 | * CDI Lite implementations are not required to provide support for {@code ProducerFactory}.
44 | *
45 | *
46 | * @author Pete Muir
47 | * @since 1.1
48 | * @param type of the bean containing the producer
49 | */
50 | public interface ProducerFactory {
51 |
52 | /**
53 | * Create a new producer for a bean.
54 | *
55 | * @param bean type
56 | * @param bean the bean to create the producer for, or null if creating a non-contextual object
57 | * @return the producer
58 | */
59 | public Producer createProducer(Bean bean);
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/lang-model/src/main/java/jakarta/enterprise/lang/model/declarations/RecordComponentInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021, Red Hat, Inc., and individual contributors
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 | package jakarta.enterprise.lang.model.declarations;
15 |
16 | import jakarta.enterprise.lang.model.types.Type;
17 |
18 | /**
19 | * A record component, {@linkplain #declaringRecord() declared} in some record.
20 | *
21 | * @since 4.0
22 | */
23 | public interface RecordComponentInfo extends DeclarationInfo {
24 | /**
25 | * Returns the name of this record component.
26 | *
27 | * @return the name of this record component, never {@code null}
28 | */
29 | String name();
30 |
31 | /**
32 | * Returns the {@linkplain Type type} of this record component.
33 | *
34 | * @return the {@linkplain Type type} of this record component, never {@code null}
35 | */
36 | Type type();
37 |
38 | /**
39 | * Returns the field corresponding to this record component.
40 | *
41 | * @return the field, never {@code null}
42 | */
43 | FieldInfo field();
44 |
45 | /**
46 | * Returns the accessor method corresponding to this record component.
47 | *
48 | * @return the accessor method, never {@code null}
49 | */
50 | MethodInfo accessor();
51 |
52 | /**
53 | * Returns the {@linkplain ClassInfo record} that declares this component.
54 | *
55 | * @return the {@linkplain ClassInfo record} that declares this component, never {@code null}
56 | */
57 | ClassInfo declaringRecord();
58 |
59 | // ---
60 |
61 | @Override
62 | default Kind kind() {
63 | return Kind.RECORD_COMPONENT;
64 | }
65 |
66 | @Override
67 | default RecordComponentInfo asRecordComponent() {
68 | return this;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------