Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: API
-
Labels:None
-
Number of attachments :
Description
The interfaces BatchExtension and ServerExtension will be required only on components which are deployed on a single side, not both.
It allows to define components without depending on API.
It's difficult to remove the requirement to implement these interfaces because objects will be kept alive during the whole lifecycle of both batch and server. So, in order to know on which side these components must be loaded, the ExtensionProvider must be used :
public class MyBatchExtensions extends ExtensionProvider implements BatchExtension { public List provide() { return Arrays.asList(new MyBatchObject()); } }The ExtensionProvider class must be improved in order to accept pure POJOs.
Note that this mechanism can also be used to instantiate components on conditional state (NOT RECOMMENDED) :
// advanced optimization ! public class MyBatchExtensions extends ExtensionProvider implements BatchExtension { private boolean isJava; public MyBatchExtensions(Project project /* IoC deps */) { isJava = project.getLanguage().equals(.....); } public List provide() { return isJava ? Arrays.asList(new MyBatchObject()) : Collections.emptyList()); } }