Listener Pattern Vs OSGI Service
Hello,
I remember reading in an article (I guess in OSGI.org), about using traditional design patterns that we use in other Java projects, may not be suitable for embedded environments. So that is why this question?
I have the following classes and listed are their responsibilities, I am trying to use the Listener pattern (notification paradigm), in order to log the commands/actions that are initiated in my application..this serves as a debug tool also. Here is the list
ActionHelper (addListeners, handleAction, fireEvent)
ActionThread (which has a handle to the ActionHelper, its run method invokes handleAction() on ActionHelper)
ActionListener (processEvent which logs the data)
ActionEvent (eventType, message)
MainClass, which gets called for different operations.
Basically, this class lazy intialiazes ActionHelper, invokes addListeners.
When each operation happens, the MainClass, creates a new ActionThread, sets the ActionHelper to the Thread and Start the thread.
The Thread's run method, now calls back to the handleAction, which knows to delegate the fireEvent.
Note: I am creating a new thread for each operation, so that I don't lock the current process time. Please advise on this.
Well, I hope this explains the situation.
I am thinking WHY NOT USE OSGI SERVICES?
In general, what would be the advantages in using OSGI services instead of ActionListeners, ActionEvents and If there are advantages, how would the pattern be. ?

