I have a osgi component and i have added java watch service (as a listener to watch directories) in it. So once bundle is installed, component goes to satisfied state.(but main bundle will be in active state)
Because of this, other components will be disabled. I am forced to enable them manually.
If I remove watch service from osgi component, it works fine. Please let me know if i am missing anything.
as PuzanovsP pointed out, you are likely to block the thread, which is reponsible to startup the system (this would also explain the described behavior). Do not block threads in the activate methods, they should be fast. If you need to have a thread to run the WatchService, either use a Sling Threadpool for it or create and manage your own thread.
I see no error as such. bundle works fine. functionality is working even in satisfied state. Only issue is, its making other osgi comppnents disabled on installing bundle. I will have to enable them manually.
If my service is active instead of statisfied, i see all components enabled by default on installing osgi bundle. So i am trying to figure iout how java watch service is making this difference.
Thank you for the response. This blog is helpful, but my requirement is quite different.
User added new document to watcher folder, and he will wait till processing of document is completed and later he will be notified with response.
I am trying to use Java Watch service because, i want event to get triggered on adding any new document to folder.if i use schedular, i will have to keep polling for every interval, so i cant send notification to user while he adds document to watched folder( as i will not know his specific file)
Thank for the response. I have to keep watching a shared folder. If there is any new document added to it, i will be processing it and uploading to aem. Java WatchService acts as a listener, So I activate watchservice from osgi component activate method.
We can get instance of watchservice only from file systems i feel. I need to figure it out if there are other ways.
Bundle becomes satisfied when i include watchservice else it will be in active state.