1   /**
2    * Created by IntelliJ IDEA.
3    * User: ROSS
4    * Date: 15/03/2004
5    * Time: 11:37:45
6    * To change this template use File | Settings | File Templates.
7    */
8   package com.atlassian.spring.container;
9   
10  public class ContainerManager
11  {
12      private static ContainerManager instance = new ContainerManager();
13  
14      private ContainerContext containerContext = null;
15  
16      private static boolean containerSetup = false;
17  
18      public static ContainerManager getInstance()
19      {
20          return instance;
21      }
22  
23      private ContainerManager()
24      {
25      }
26  
27      /**
28       * Utility method to get a bean from the current container
29       */
30      public static Object getComponent(String key)
31      {
32          return getInstance().getContainerContext().getComponent(key);
33      }
34  
35      /**
36       * Utility method to autowire a bean
37       * @param component
38       */
39      public static void autowireComponent(Object component)
40      {
41          getInstance().getContainerContext().autowireComponent(component);
42      }
43  
44      /**
45       * @return Returns the containerContext.
46       */
47      public ContainerContext getContainerContext()
48      {
49          return containerContext;
50      }
51  
52      /**
53       * @param containerContext The containerContext to set.
54       */
55      public void setContainerContext(ContainerContext containerContext)
56      {
57          this.containerContext = containerContext;
58      }
59  
60      public static void resetInstance()
61      {
62          instance = new ContainerManager();
63          containerSetup = false;
64      }
65  
66      public static boolean isContainerSetup()
67      {
68          return getInstance().containerContext != null && getInstance().containerContext.isSetup();
69      }
70  }