[EMAIL PROTECTED] wrote:
> Something like this:
> if (instance == null)
> {
> synchronized(TurbineServices.class)
> {
> if (instance == null)
> instance = new TurbineServices();
> }
> }
> return instance;
> Would allow subclasses to assign their own service broker implementation to
> the static instance member before getInstance() is called.
This was done exactly this way until revision 1.14 of the Broker. Jon
changed
that to fix doble locking pattern. He posted an URL to an article that
gives
rationale for that.
I think that right now TurbineServices should be the only real singleton
in
the system (correct me if I'm wrong). It is not instantiated
spontaneously
(on first use by the application code) but in precisely controled
conditions.
It is instantiated in Turbine.init() method which is internally
synchronized,
then it is bootstraped with essential services, then real configuration
is
loaded and finally all services are initialzed (in so called early init
phase).
I think that it would be justifable to lift the double locking pattern
from
the BaseServiceBroker class in the following way:
public class BaseServiceBroker
extends BaseInitableBroker
implements ServiceBroker
{
protected static ServiceBroker instance = null;
public static ServiceBroker getInstance()
{
return instance;
}
protected static ServiceBroker newInstance()
{
return (ServiceBroker)BaseServiceBroker();
}
/**
* This method creates new ServiceBroker instance for the system.
*
* If there is an instance of ServiceBroker running, it will be
* shut down.
*
* @param data The implementation dependent data used to create
* the essential services.
*/
public static synchronized ServiceBroker bootstrap(Object data)
{
if(instance != null)
{
instance.shutdown();
}
instance = newInstance();
instance.initPrimaryServices(data);
return instance;
}
public void abstract initPrimaryServices(Object data);
//...
}
Implementations would have to override newInstance() and
initPrimaryServices(Object)
methods. Does this solution adress your concenrs Ilkka?
Rafal
PS. Thank you for the information concerning JMX. What paricular
services in Turine
did you chose to instrument as MBeans? I'm also interested in what
adapters/connectors
are you using, and if threre are any JMX enabled management applications
available,
other than Sun's RI?
Rafal
--
Rafal Krzewski
Senior Internet Developer
mailto:[EMAIL PROTECTED]
+48 22 8534830 http://e-point.pl
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]