KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > cli > jmx > support > CLISupportMBeanProxy


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /*
25  * $Header: /cvs/glassfish/admin-cli/cli-api/src/java/com/sun/cli/jmx/support/CLISupportMBeanProxy.java,v 1.3 2005/12/25 03:45:46 tcfujii Exp $
26  * $Revision: 1.3 $
27  * $Date: 2005/12/25 03:45:46 $
28  */

29  
30  
31 package com.sun.cli.jmx.support;
32
33 import javax.management.ObjectName JavaDoc;
34 import javax.management.NotificationListener JavaDoc;
35 import javax.management.NotificationFilter JavaDoc;
36 import javax.management.MBeanServerConnection JavaDoc;
37 import javax.management.MBeanServerInvocationHandler JavaDoc;
38
39 import com.sun.cli.jmx.support.AliasMgrHashMapImpl;
40 import com.sun.cli.jmx.support.AliasMgr;
41
42
43 /*
44     Supplies the CLISupportMBean and AliasMgrMBean methods in a single proxy.
45     
46     Refer to CLISupportMBean and AliasMgrMBean for details.
47  */

48 public class CLISupportMBeanProxy implements CLISupportMBean, AliasMgrMBean
49 {
50     final AliasMgrMBean mAliasMgrProxy;
51     final CLISupportMBean mCLIProxy;
52     
53     /*
54         public static AliasMgrMBean
55     createAliasMgrProxy( MBeanServerConnection conn ) throws Exception
56     {
57         final ObjectName aliasMgrObjectName = new ObjectName( CLISupportStrings.ALIAS_MGR_TARGET );
58         
59         final AliasMgrMBean proxy = (AliasMgrMBean)MBeanServerInvocationHandler.newProxyInstance( conn,
60                                 aliasMgrObjectName, AliasMgrMBean.class, false );
61         return( proxy );
62     }
63     
64         public static CLISupportMBean
65     createCLISupportProxy( MBeanServerConnection conn ) throws Exception
66     {
67         final ObjectName cliSupportObjectName = new ObjectName( CLISupportStrings.CLI_SUPPORT_TARGET );
68         
69         final CLISupportMBean proxy = (CLISupportMBean)MBeanServerInvocationHandler.newProxyInstance( conn,
70                         cliSupportObjectName, CLISupportMBean.class, false );
71                         
72         return( proxy );
73     }
74     */

75     
76     /*
77         CLISupport and AliasMgr are anywhere; precreated for this constructor
78      */

79         public
80     CLISupportMBeanProxy(
81         AliasMgrMBean aliasMgr,
82         CLISupportMBean cliSupport ) throws Exception JavaDoc
83     {
84         mAliasMgrProxy = aliasMgr;
85         mCLIProxy = cliSupport;
86     }
87     
88     
89
90 //------------------------------ CLI --------------------------------------------
91

92         public ResultsForGetSet []
93     mbeanGet( String JavaDoc attrs, String JavaDoc [] targets) throws Exception JavaDoc
94     {
95         return( mCLIProxy.mbeanGet( attrs, targets ) );
96     }
97
98         public ResultsForGetSet []
99     mbeanSet( String JavaDoc attrs, String JavaDoc [] targets ) throws Exception JavaDoc
100     {
101         return( mCLIProxy.mbeanSet( attrs, targets ) );
102     }
103
104         public InvokeResult []
105     mbeanInvoke(
106         String JavaDoc operation,
107         String JavaDoc args,
108         String JavaDoc [] targets ) throws Exception JavaDoc
109     {
110         return( mCLIProxy.mbeanInvoke( operation, args, targets ) );
111     }
112
113         public InvokeResult []
114     mbeanInvoke(
115         String JavaDoc operation,
116         String JavaDoc [] targets ) throws Exception JavaDoc
117     {
118         return( mbeanInvoke( operation, null, targets ) );
119     }
120     
121     
122         public ObjectName JavaDoc []
123     mbeanFind( String JavaDoc [] targets )
124         throws Exception JavaDoc
125     {
126         return( mCLIProxy.mbeanFind( targets ) );
127     }
128     
129         public ObjectName JavaDoc []
130     mbeanFind( String JavaDoc target )
131         throws Exception JavaDoc
132     {
133         return( mbeanFind( new String JavaDoc[] { target } ));
134     }
135     
136         public ObjectName JavaDoc []
137     mbeanFind( String JavaDoc [] targets, String JavaDoc regex)
138         throws Exception JavaDoc
139     {
140         return( mCLIProxy.mbeanFind( targets, regex ) );
141     }
142
143
144         public InspectResult
145     mbeanInspect( InspectRequest request, ObjectName JavaDoc name ) throws Exception JavaDoc
146     {
147         return( mCLIProxy.mbeanInspect( request, name ) );
148     }
149     
150         public InspectResult []
151     mbeanInspect( InspectRequest request, String JavaDoc [] targets ) throws Exception JavaDoc
152     {
153         return( mCLIProxy.mbeanInspect( request, targets ) );
154     }
155     
156         public void
157     mbeanCreate( String JavaDoc name, String JavaDoc theClass, String JavaDoc args ) throws Exception JavaDoc
158     {
159         mCLIProxy.mbeanCreate( name, theClass, args );
160     }
161     
162         public void
163     mbeanUnregister( String JavaDoc name ) throws Exception JavaDoc
164     {
165         mCLIProxy.mbeanUnregister( name );
166     }
167     
168         public int
169     mbeanCount( ) throws Exception JavaDoc
170     {
171         return( mCLIProxy.mbeanCount( ) );
172     }
173     
174         public String JavaDoc []
175     mbeanDomains( ) throws Exception JavaDoc
176     {
177         return( mCLIProxy.mbeanDomains( ) );
178     }
179     
180         public void
181     mbeanListen(
182         boolean start,
183         String JavaDoc [] targets,
184         NotificationListener JavaDoc listener,
185         NotificationFilter JavaDoc filter,
186         Object JavaDoc handback ) throws Exception JavaDoc
187     {
188         mCLIProxy.mbeanListen( start, targets, listener, filter, handback );
189     }
190     
191     
192         public ObjectName JavaDoc []
193     resolveTargets( String JavaDoc [] targets ) throws Exception JavaDoc
194     {
195         return( mCLIProxy.resolveTargets( targets ) );
196     }
197     
198     
199 //------------------------------ AliasMgr --------------------------------------------
200

201     
202         public void
203     createAlias( String JavaDoc aliasName, String JavaDoc objectName ) throws Exception JavaDoc
204     {
205         mAliasMgrProxy.createAlias( aliasName, objectName );
206     }
207     
208         public void
209     deleteAlias( String JavaDoc aliasName ) throws Exception JavaDoc
210     {
211         mAliasMgrProxy.deleteAlias( aliasName );
212     }
213     
214         public String JavaDoc
215     resolveAlias( String JavaDoc aliasName ) throws Exception JavaDoc
216     {
217         return( (String JavaDoc)mAliasMgrProxy.resolveAlias( aliasName ) );
218     }
219     
220         public String JavaDoc []
221     listAliases( boolean showValues ) throws Exception JavaDoc
222     {
223         return( mAliasMgrProxy.listAliases( showValues ) );
224     }
225     
226         public String JavaDoc []
227     getAliases( ) throws Exception JavaDoc
228     {
229         return( listAliases( false ) );
230     }
231     
232         public AliasMgrMBean
233     getAliasMgr()
234     {
235         return( mAliasMgrProxy );
236     }
237 }
238
239
Popular Tags