[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jakartabatch-dev] CDI based job instantiation
|
Not sure what CDI mode you're using, but in Open Liberty, at least, you'd typically need to add a bean-defining annotation like @Dependent since batch artifacts aren't "specially" scanned automatically.
Wouldn't be surprised if JBeret is the same.
And yes, @Dependent is a bit weird since batch defines its own lifecycle for artifacts.. but CDI does fit in in a bit of a unique way.
------------------------------------------------------
Scott Kurz
WebSphere Batch and Developer Experience
skurz@xxxxxxxxxx
--------------------------------------------------------
Martijn Dashorst ---02/11/2020 09:44:12 AM---All, Not sure if this is the right list, but given my current experience, a
From: Martijn Dashorst <martijn.dashorst@xxxxxxxxx>
To: jakartabatch-dev@xxxxxxxxxxx
Date: 02/11/2020 09:44 AM
Subject: [EXTERNAL] [jakartabatch-dev] CDI based job instantiation
Sent by: jakartabatch-dev-bounces@xxxxxxxxxxx
All,
Not sure if this is the right list, but given my current experience, a batch job has some but not all capabilities of CDI injection at its disposal.
@Named
public class ExampleBatchlet extends AbstractBatchlet {
@Inject
private ExampleService service;
@Override
public String process() {
service.doSomething(); // <-- NullPointerException
}
}
@ApplicationScoped
public class ExampleService {
public void doSomething() {}
}
This should IMO work, but my Jakarta Batch implementation, jberet, only injects artifacts that are JobContext, StepContext or BatchProperty [1].
Now this can be a bug in JBeret, or a bug in the specification, where it doesn't explicitly require full injectability of CDI beans. (The factory also doesn't take into account setter and constructor based injection).
Martijn
[1]
https://github.com/jberet/jsr352/blob/master/jberet-core/src/main/java/org/jberet/creation/AbstractArtifactFactory.java#L67--
Become a Wicket expert, learn from the best:
http://wicketinaction.com_______________________________________________
jakartabatch-dev mailing list
jakartabatch-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jakartabatch-dev