KickJava   Java API By Example, From Geeks To Geeks.

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


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.service.ServiceException;
20 import org.apache.avalon.framework.service.ServiceManager;
21
22 /**
23  * Reference Proxy to a ServiceManager
24  *
25  * @deprecated ECM is no longer supported
26  *
27  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
28  * @version CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:16 $
29  * @since 4.2
30  */

31 final class ServiceManagerReferenceProxy
32     extends AbstractReferenceProxy
33     implements ServiceManager
34 {
35     private ServiceManager m_serviceManager;
36
37     /*---------------------------------------------------------------
38      * Constructors
39      *-------------------------------------------------------------*/

40     /**
41      * Create a new proxy.
42      *
43      * @param serviceManager ServiceManager being proxied.
44      * @param latch Latch wich will be notified when this proxy is finalized.
45      * @param name Name of the proxy.
46      */

47     ServiceManagerReferenceProxy( ServiceManager serviceManager,
48                                   AbstractReferenceProxyLatch latch,
49                                   String JavaDoc name )
50     {
51         super( latch, name );
52         m_serviceManager = serviceManager;
53     }
54
55     /*---------------------------------------------------------------
56      * ServiceManager Methods
57      *-------------------------------------------------------------*/

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

79     public Object JavaDoc lookup( String JavaDoc role )
80         throws ServiceException
81     {
82         return m_serviceManager.lookup( role );
83     }
84
85     /**
86      * Check to see if a <code>Object</code> exists for a role.
87      *
88      * @param role a string identifying the role to check.
89      * @return True if the object exists, False if it does not.
90      */

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

105     public void release( Object JavaDoc service )
106     {
107         m_serviceManager.release( service );
108     }
109 }
110
Popular Tags