Comments (3)
I think the same API can be used for both purely dynamic configuration and registration during application startup, if a configuration object is passed to a CDI bean at application startup and could be also passed to a method that defines the job dynamically.
With a CDI bean, a job could be defined with e.g. a CDI event as follows (as described by @rmannibucau here):
void defineBatches(@Observes JobRegistrationCallback cb, JobOperator op, MyService service) {
cb.defineJob("my-job")
.batchlet("exec-sql", () -> service.executeBulkQuery().then(service::flush));
}
The CDI event would be fired at application startup, only once. This would be similar as when job is defined in a XML, which is also evaluated at startup.
And the same job definition could be applied on an instance of a JobOperator
with a lambda argument as follows:
@Inject JobOperator op;
@Inject MyService service;
op.defineJob( (JobRegistrationCallback cb) -> {
cb.defineJob("my-job")
.batchlet("exec-sql", () -> service.executeBulkQuery().then(service::flush));
});
The defineJob
method could even return the created Job definition instance that could be referenced to start a job instead of using the job name:
JobDefinition jobdef = op.defineJob( (JobRegistrationCallback cb) -> {
return cb.defineJob("my-job");
// the `return` statement here isn't even necessary,
// the `defineJob` method would get the definition from `cb` and return it
});
op.start( jobdef, new Properties() );
from batch.
If you make it a bean instead of an event it will remove the indirection in the API:
void defineBatches(@Observes @Initialized(ApplicationScoped.class) Object startup, JobRegistrationCallback cb /* optionally other services */) {
cb.defineJob("my-job")
.batchlet("exec-sql", () -> service.executeBulkQuery().then(service::flush));
}
and
@Inject JobRegistrationCallback cb;
@Inject MyService service;
cb.defineJob("my-job")
.batchlet("exec-sql", () -> service.executeBulkQuery().then(service::flush));
Then no need to change JobOperator#start method signature since the job is named anyway (required to keep job operator reporting features).
from batch.
Seems we're not going to get to this in 2.1.
from batch.
Related Issues (20)
- Batch TCK separation and integration with Platform TCK HOT 1
- Add module-info.java HOT 2
- Clarify precedence between runtime-provided JobOperator Bean vs. other (app)-provided HOT 1
- Provide well-defined behavior / ordering / etc. in case where ServiceLoader finds >1 JobOperator impl. HOT 4
- Final update for Batch 2.1 spec document
- Certification Request for jbatch v2.1.0-M2 + jakarta batch api v2.1.0 HOT 2
- Loading a batch artifact as a CDI Bean by bean name via @Producer in some other bean class HOT 1
- Finalize Jakarta Batch 2.1 Release HOT 1
- Batch 2.1.0 API JAR OSGi bundle headers are wrongly using 2.0 version values HOT 1
- Version 2.1.1 "specification" artifact released with "2.2" as the spec version in filename, spec header
- Use 'jakartaee' namespace prefix in job.xsd and batch.xsd (the convention used by other Jakarta specs). HOT 2
- Certification Request for JBeret 2.1.0.Final + jakarta batch api 2.1.0 HOT 1
- Consider a beforeSplitFlow/afterSplitFlow listener to give app control on the split-flow thread
- Move this repo to https://github.com/jakartaee HOT 5
- _ characters in some enum values in spec document HOT 1
- Jakarta Batch CDI integration language over-specifies behavior and wrongly describes implementation(Weld)-specific behavior HOT 1
- Question about the plan to support Jakarta EE Platform 11 HOT 2
- Can the `cdi-api` version be updated? HOT 5
- ClassifierCompositeItemWriter use contravariance for items classification, why? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from batch.