KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sape > carbon > core > component > Lookup


1 /*
2  * The contents of this file are subject to the Sapient Public License
3  * Version 1.0 (the "License"); you may not use this file except in compliance
4  * with the License. You may obtain a copy of the License at
5  * http://carbon.sf.net/License.html.
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is The Carbon Component Framework.
12  *
13  * The Initial Developer of the Original Code is Sapient Corporation
14  *
15  * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
16  */

17
18 package org.sape.carbon.core.component;
19
20 import org.sape.carbon.core.bootstrap.BootStrapper;
21
22 /**
23  * <p>This class provides a singleton interface to the component subsystem.
24  * This class should be used by any client that needs a reference to a
25  * component</p>
26  *
27  * Copyright 2002 Sapient
28  * @since carbon 1.0
29  * @author Douglas Voet, January 2002
30  * @version $Revision: 1.13 $($Author: dvoet $ / $Date: 2003/05/05 21:21:11 $)
31  * @stereotype singleton
32  */

33 public class Lookup {
34     /** @link dependency */
35     /*#Component lnkComponent;*/
36
37     /** @link dependency */
38     /*#BootStrapper lnkBootStrapper;*/
39
40     /** Reference to the component keeper. */
41     private ComponentKeeper componentKeeper;
42
43     /**
44      * Private constructor to ensure singleton.
45      */

46     private Lookup() { }
47
48     /**
49      * <p>Fetches a reference to a component. Delegates to the system's
50      * <code>ComponentKeeper</code>. If the <code>ComponentKeeper</code> has
51      * not been created yet, it calls the <code>BootStrapper</code>
52      * to get it.</p>
53      *
54      * @param logicalComponentName the name of the component
55      * @return a reference to the component specified by name
56      */

57     public Component fetchComponent(String JavaDoc logicalComponentName) {
58         return getComponentKeeper().fetchComponent(logicalComponentName);
59     }
60
61     /**
62      * Gets the <code>ComponentKeeper</code> for the system.
63      * @return the <code>ComponentKeeper</code>
64      */

65     public ComponentKeeper getComponentKeeper() {
66         if (this.componentKeeper == null) {
67             this.componentKeeper =
68                 BootStrapper.getInstance().fetchComponentKeeper();
69         }
70
71         return this.componentKeeper;
72     }
73
74     /** Single statically instantiated instance of lookup. */
75     private static final Lookup INSTANCE = new Lookup();
76
77     /**
78      * <p>
79      * Static factory method for getting a reference to the singleton
80      * <code>Lookup</code>.
81      * </p>
82      *
83      * @return Lookup
84      */

85     public static Lookup getInstance() {
86         return Lookup.INSTANCE;
87     }
88 }
89
Popular Tags