KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > excalibur > component > servlet > ComponentManagerReferenceProxy


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.avalon.excalibur.component.servlet;
18
19 import org.apache.avalon.framework.component.Component;
20 import org.apache.avalon.framework.component.ComponentException;
21 import org.apache.avalon.framework.component.ComponentManager;
22
23 /**
24  * Reference Proxy to a ComponentManager
25  *
26  * @deprecated The ComponentManager interface has been deprecated in favor
27  * of the ServiceManager.
28  *
29  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
30  * @version CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:16 $
31  * @since 4.2
32  */

33 final class ComponentManagerReferenceProxy
34     extends AbstractReferenceProxy
35     implements ComponentManager
36 {
37     private ComponentManager m_componentManager;
38     
39     /*---------------------------------------------------------------
40      * Constructors
41      *-------------------------------------------------------------*/

42     /**
43      * Create a new proxy.
44      *
45      * @param componentManager ComponentManager being proxied.
46      * @param latch Latch wich will be notified when this proxy is finalized.
47      * @param name Name of the proxy.
48      */

49     ComponentManagerReferenceProxy( ComponentManager componentManager,
50                                     AbstractReferenceProxyLatch latch,
51                                     String JavaDoc name )
52     {
53         super( latch, name );
54         m_componentManager = componentManager;
55     }
56     
57     /*---------------------------------------------------------------
58      * ComponentManager Methods
59      *-------------------------------------------------------------*/

60     /**
61      * Get the <code>Component</code> associated with the given role. For
62      * instance, If the <code>ComponentManager</code> had a
63      * <code>LoggerComponent</code> stored and referenced by role, I would use
64      * the following call:
65      * <pre>
66      * try
67      * {
68      * MyComponent log;
69      * myComponent = (MyComponent) manager.lookup(MyComponent.ROLE);
70      * }
71      * catch (...)
72      * {
73      * ...
74      * }
75      * </pre>
76      *
77      * @param role The role name of the <code>Component</code> to retrieve.
78      * @return the desired component
79      * @throws ComponentException if an error occurs
80      */

81     public Component lookup( String JavaDoc role )
82         throws ComponentException
83     {
84         return m_componentManager.lookup( role );
85     }
86
87     /**
88      * Check to see if a <code>Component</code> exists for a role.
89      *
90      * @param role a string identifying the role to check.
91      * @return True if the component exists, False if it does not.
92      */

93     public boolean hasComponent( String JavaDoc role )
94     {
95         return m_componentManager.hasComponent( role );
96     }
97
98     /**
99      * Return the <code>Component</code> when you are finished with it. This
100      * allows the <code>ComponentManager</code> to handle the End-Of-Life Lifecycle
101      * events associated with the Component. Please note, that no Exceptions
102      * should be thrown at this point. This is to allow easy use of the
103      * ComponentManager system without having to trap Exceptions on a release.
104      *
105      * @param component The Component we are releasing.
106      */

107     public void release( Component component )
108     {
109         m_componentManager.release( component );
110     }
111 }
112
Popular Tags