chberger commented on issue #2: Batchee 139
URL: https://github.com/apache/geronimo-batchee/pull/2#issuecomment-613583033
 
 
   No I did not run mvn install. Reason was an issue related to my local 
machine. Anyway, now I've fixed it and my last commit should be good to go. 
   
   Btw: While testing my code I've figured out that passing an individual 
ServicesManager instance is not working as expected when using this code 
snippet:
   ```
   
   final JobOperator operator = new JobOperatorImpl(new ServicesManager() {{
               init(new Properties() {{
                   setProperty(PersistenceManagerService.class.getSimpleName(), 
MemoryPersistenceManagerService.class.getName());
               }});
           }});
   ```
   
   Actually, the JobOperatorImpl has a static block which initializes a default 
ServicesManager instance  as well. This means we have two ServicesManager 
instances. Although we are passing our instance  (through the operator 
instance) into `waitForEnd(operator, id);` we still access the wrong "default" 
instance when ServicesManager.find() is being called like in 
SimpleJobExecutionCallbackService:83.
   
   Thus we would need to override the find method of ServicesManager as well 
like:
   ```
   public static ServicesManager createServicesManager(Properties properties) {
           /*
            * Surprisingly, this triggers the creation of two instances of
            * ServicesManager. However, the "default" instance is useless since 
it's not
            * initialized with the given properties, but just with values 
coming from
            * batchee.properties. Nevertheless, we cannot pass our 
ServicesManager instance
            * to all framework methods. Sometimes the framework just calls
            * ServicesManager.find(). In that particular scenario the framework 
would grab
            * the "default" instance, which of course needs to be avoided.
            */
           final ServicesManager servicesManager = new ServicesManager();
           servicesManager.init(properties);
           /*
            * Use our ServicesManager instance even if the framework just calls
            * ServicesManager.find()
            */
           ServicesManager.setServicesManagerLocator(new 
ServicesManagerLocator() {
               @Override
               public ServicesManager find() {
                   return servicesManager;
               }
           });
           return servicesManager;
       }
   ```
   Maybe we should provide a factory class for this which can be re-used in all 
different test cases. Anyway, I guess it should be done within a different 
issue .. Shall I raise a new issue?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to