The ApplicationServlet stores the created registry as an attribute in the servlet context.

After it's initialized you can simply ask for it back and store it wherever you want.


  public void init(ServletConfig config) throws ServletException {
    super.init(config);

    String name = config.getServletName();
    String registryKey = "org.apache.tapestry.Registry:" + name;

Registry registry = (Registry) config.getServletContext ().getAttribute(registryKey);
    HiveAccess hiveAccess = HiveAccessor.getInstance();
    hiveAccess.initialize(registry);

    log.debug("Portal initialized.");
  }

This works for Tapestry 4.0, at least. The HiveAccessor is a convenience singleton which holds a reference to the registry for me.

Nick



On 20/03/2006, at 6:31 PM, Ovidiu Hurducas wrote:

Greetings,

I’m using Hivemind+Tapestry+Hibernate to build a site. I have a javax.servlet.Filter object where I need to do some operations with a Hivemind service that uses Hibernate.

To access the registry from the filter I’m using the example from the Hivemind documentation:

Registry registry = RegistryBuilder.constructDefaultRegistry();

MyService service = (MyService) registry.getService ("com.mypackage.MyService", MyService.class);


However this is not good. The registry is recreated and the Hibernate configuration is read again.

There is a way to access an existing registry that is already initialized? I don’t want to recreate the registry twice.

Thank you,

Ovidiu

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


Nick Faiz,
Developer
www.q9software.com



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

Reply via email to