Skip to content

Commit

Permalink
Remove mention of CDI#select() as option to access batch property per j…
Browse files Browse the repository at this point in the history
…akartaee/batch-tck#71

Signed-off-by: Scott Kurz <[email protected]>
  • Loading branch information
scottkurz committed Mar 28, 2024
1 parent 0246190 commit 3668b9f
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions spec/src/main/asciidoc/batch_programming_model.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1387,20 +1387,40 @@ parameters. Note that only the first example using field injection into the 'p
without an explicit 'name' attribute.


===== Consequences And Suggested Patterns
===== Consequences And Suggested Patterns - Batch Properties

As a consequence of the previous section, an application must be able to get a CDI Bean with a correct view of a batch property by either:

* Injecting the batch property Bean into a @Dependent-scoped CDI Bean via any standard CDI mechanism, (e.g. via a field injection of type: `@Inject @BatchProperty String` within a batch artifact loaded as a CDI Bean). This assumes the artifact loading will occur on the execution thread.
OR
* Dynamically accessing the batch property bean via `jakarta.enterprise.inject.Instance#get()` or `javax.enterprise.inject.spi.CDI#select()` from the batch execution thread.
* Dynamically accessing the batch property bean via `jakarta.enterprise.inject.Instance#get()` from the batch execution thread.

On the other hand if a batch property Bean is statically injected into a normal-scoped Bean like an @ApplicationScoped batch artifact, the batch property Bean
values may not accurately reflect the property based on the JSL scope associated with the current batch artifact.

It is possible that the batch runtime will provide its batch property Beans with @Dependent-scope in order to implement the above, but strictly
speaking that is an implementation detail.

Example:

----
[source,java]
----

@ApplicationScoped
public class ApplicationScopedBatchlet implements Batchlet {

// Inject when bean instance is created (only once, for application scoped bean)
@Inject @BatchProperty(name="prop1") Instance<String> p1;

@Override
public String process() throws Exception {

// Dynamically resolves based on current batch thread, each time it is accessed
String val = p1.get();
}
----
==== Undefined: unmatched property or empty property value does not necessarily get Java default value
Expand Down Expand Up @@ -1512,7 +1532,7 @@ Example:
}
----
===== Consequences And Suggested Patterns
===== Consequences And Suggested Patterns - Batch Contexts
As a consequence of the previous section, an application must be able to get a CDI Bean with a correct view of the current contexts by either:
Expand Down

0 comments on commit 3668b9f

Please sign in to comment.