Why can't you create a class that holds the registry as a singleton
yourself?  One reason why the current implementation doesn't cache is
because then it'd have to be thread-safe and therefore synchronized in some
manner.  You could avoid that by using something like the following...

public class RegistrySingleton 
{
  private static final Registry registry =
RegistryBuilder.constructDefaultRegistry();
  public Registry getRegistry()
  {
    return registry;
  }
}

This class doesn't require thread synchronization, but it does require that
the default instance be created whenever the RegistrySingleton class is
loaded.  This might solve your problem. 





-----Original Message-----
From: Steve Gibson [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 20, 2004 12:52 PM
To: [email protected]
Subject: RegistryBuilder.constructDefaultRegistry storing a registry
instance...

I have had a recurring issue migrating to HiveMind.
Our old code made it simple to get a service instance by calling a
static method on a particular class.

In HiveMind, this is not as easy, at least not with the constraint that
our code should be deployable/runnable both inside and outside a servlet
container.

My idea is that RegistryBuilder.constructDefaultRegistry could store the
registry instance it creates, with subsequent calls returning the same
instance. In fact, that's what I thought it did originally, and didn't
find out until in my test case for my security service, a user would log
in, but the log out test would fail, as a new registry was being
created, resulting in a new singleton of my service.

This static method is supposed to be a convenience method, so I don't
think this would reduce functionality. If you need to be able to build
multiple registries, the extra work of grabbing the Locale shouldn't be
a big deal.

Steve Gibson
Software Engineer
COWWW Software

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




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

Reply via email to