01: /*
02: * $Id: RegistryContext.java 11371 2008-03-15 03:12:09Z tcarlson $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10: package org.mule;
11:
12: import org.mule.api.config.MuleConfiguration;
13: import org.mule.api.registry.Registry;
14: import org.mule.registry.TransientRegistry;
15:
16: /**
17: * A handle to the Mule Registry. We should make no assumptions about the location of the actual Registry
18: * implementation. It might be simply a singleton object in the same JVM, or it might be in another JVM or
19: * even running remotely on another machine.
20: */
21: public class RegistryContext {
22: protected static Registry registry;
23:
24: public static Registry getRegistry() {
25: return registry;
26: }
27:
28: public static synchronized void setRegistry(Registry registry) {
29: RegistryContext.registry = registry;
30: }
31:
32: public static MuleConfiguration getConfiguration() {
33: // TODO Migrate uses to obtain configuration from MuleContext
34: return MuleServer.getMuleContext().getConfiguration();
35: }
36:
37: public static Registry getOrCreateRegistry() {
38: if (registry == null || registry.isDisposed()) {
39: registry = new TransientRegistry();
40: }
41: return registry;
42: }
43: }
|