"Kelvin Tan" <[EMAIL PROTECTED]> writes:

> I submitted a patch a couple of days back, but it kinda fixed only what
> needed fixing (shutdown mechanism), not the code clean-up.

Sorry, I missed that patch.

> getServiceInstance(String name) attempts to retrieve a service by
> services.get(name), failing which, it retrieves the classname from mapping
> and then tries services.get(className)?
>
> I don't see how it is possible that services.get(className) will return the
> services in any scenario, so I actually skipped the checking stage and
> directly went for Class.forName(className).newInstance().
>
> Am I missing something here?

Though I don't know the original reasoning, I would assume the two
hash lookups before using Class.forName() are there to avoid a race
condition where another instance of BaseServiceBroker (BSB) had its
getServiceInstance() method called with the same parameter and manages
to sneak in and create the service instance in between our two
lookups.

Anyhow, after the second hash check, the Service implementation is
instantiated, setup, and added to the services hash (keyed by name).

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to