Hi Alejandro,
I took another look at this code change and I wonder whether it could
be simplified. The lifecycle methods in QMUX would be more
"symmetrical" if the initService() and destroyService() methods were
given the responsibility of registering and unregistering the QMUX
with the NameRegistrar, while the startService() and stopService()
methods were given the responsibility of adding and removing the QMUX
as a SpaceListener from the LocalSpace. This would also dispense with
the need for the "listenerRegistered" field (with a caveat that I will
discuss below).
So the code would look like this (this won't come out right in the
browser, but hopefully you can see what I'm saying):
public void initService() throws ConfigurationException {
...
// remove the sp.addListener (in, this) line from here
NameRegistrar.register("mux." + getName(), this);
}
public void startService() {
sp.addListener(in, this);
}
public void stopService() {
sp.removeListener(in, this);
}
public void destroyService() {
NameRegistrar.unregister("mux." + getName());
}
This symmetry makes sense to me, since starting and stopping the MUX
will make it start and stop responding to ISOMsgs in the TSpace,
without affecting anything in the NameRegistrar.
Of course, getting rid of the "listenerRegistered" field only works if
the QBean start() method is not going to be called while the QBean is
STARTED, otherwise it will register the SpaceListener twice (or as
many times as the startService() method is invoked). The QBeanSupport
start() method only protects against the method being invoked while
the QBean is in DESTROYED, STOPPED or FAILED states. So currently, it
is possible for startService() to be invoked while the QBean is in
STARTING or STARTED states. Is there any reason for this? It also
makes sense to me that the start() service do nothing if invoked in
the STARTING or STARTED states.
Geoff
On Nov 18, 8:52 am, Alejandro Revilla <
a...@jpos.org> wrote:
> Good point, fixing it right away. Thank you!
>
> > <
jpos-users%2Bunsu...@googlegroups.com<
jpos-users%252Buns...@googlegroups.com>