KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > jmx > remote > internal > RemoteMBeanServerConnection


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 /* CVS information
25  * $Header: /cvs/glassfish/jmx-remote/rjmx-impl/src/java/com/sun/enterprise/admin/jmx/remote/internal/RemoteMBeanServerConnection.java,v 1.5 2005/12/25 04:26:34 tcfujii Exp $
26  * $Revision: 1.5 $
27  * $Date: 2005/12/25 04:26:34 $
28  */

29
30 package com.sun.enterprise.admin.jmx.remote.internal;
31
32 import java.util.Set JavaDoc;
33 /* BEGIN -- S1WS_MOD */
34 import java.util.Map JavaDoc;
35 /* END -- S1WS_MOD */
36 import java.util.logging.Logger JavaDoc;
37 import java.io.IOException JavaDoc;
38 /* BEGIN -- S1WS_MOD */
39 import com.sun.enterprise.admin.jmx.remote.DefaultConfiguration;
40 /* END -- S1WS_MOD */
41 import com.sun.enterprise.admin.jmx.remote.comm.IConnection;
42 import com.sun.enterprise.admin.jmx.remote.comm.HttpConnectorAddress;
43 import com.sun.enterprise.admin.jmx.remote.comm.ConnectionFactory;
44 import com.sun.enterprise.admin.jmx.remote.comm.MBeanServerMessageConductor;
45 import com.sun.enterprise.admin.jmx.remote.internal.MBeanServerConnectionExceptionThrower;
46 /* BEGIN -- S1WS_MOD */
47 import com.sun.enterprise.admin.jmx.remote.notification.ListenerInfo;
48 import com.sun.enterprise.admin.jmx.remote.notification.ClientNotificationManager;
49 /* END -- S1WS_MOD */
50
51 import javax.management.*;
52 import javax.management.remote.message.MBeanServerRequestMessage;
53 import javax.management.remote.message.MBeanServerResponseMessage;
54 import com.sun.enterprise.admin.jmx.remote.protocol.Version;
55
56 /**Class that represents the proxy to the MBeanServerConnection. The actual MBeanServerConnection is
57  * available remotely. Based on Java Serialization. This is the class
58  * whose instance is used by that all the clients that wish to communicate
59  * over the HTTP channel. As of now, (PE 8.0 FCS) by default a new HTTP connection is
60  * opened for every remote MBeanServerConnection {@link MBeanServerConnection}
61  * method invocation. This can be configured later on if the server happens to
62  * provide persistent HTTP (HTTP 1.1) connections.
63  * The current state of implementation is that the server does not support the
64  * remote notifications. But the client side is not affected by that. In this
65  * implementation, if the clients attempt to add notification listeners, they
66  * would recieve an {@link UnsupportedOperationException}.
67  * @author Kedar Mhaswade
68  * @since S1AS8.0
69  * @version 1.0
70  */

71
72 public class RemoteMBeanServerConnection implements MBeanServerConnection {
73     
74     private IConnection physicalConnection = null;
75     private MBeanServerMessageConductor conductor = null;
76     private HttpConnectorAddress ad = null;
77 /* BEGIN -- S1WS_MOD */
78     private ClientNotificationManager notifMgr = null;
79     private Map JavaDoc env = null;
80 /* END -- S1WS_MOD */
81     
82     private static Version cv;
83     static {
84         try {
85             cv = (Version)Class.forName(Version.CLASS_NAME).newInstance();
86         }
87         catch(Exception JavaDoc e) {
88             throw new RuntimeException JavaDoc(e);
89         }
90     }
91     private final static Object JavaDoc EMPTY = new String JavaDoc();
92     /* Comment about EMPTY - This is an "empty" object that will
93        be sent over the wire in case a null is required. An
94        Object created with new Object() is not Serializable
95        but java.lang.String is and hence it is selected. */

96
97     private final Logger JavaDoc logger = Logger.getLogger(
98         DefaultConfiguration.JMXCONNECTOR_LOGGER);/*,
99         DefaultConfiguration.LOGGER_RESOURCE_BUNDLE_NAME );*/

100     
101     public RemoteMBeanServerConnection(IConnection connectionToServer) {
102         //physicalConnection = connectionToServer;
103
//conductor = new MBeanServerMessageConductor(physicalConnection);
104
}
105     
106     /** Creates a new instance of this class and connects it to the
107      * server resource identified by the argument.
108      */

109 /* BEGIN -- S1WS_MOD */
110 // public RemoteMBeanServerConnection(HttpConnectorAddress ad) throws Exception {
111
public RemoteMBeanServerConnection(HttpConnectorAddress ad, Map JavaDoc env) throws Exception JavaDoc {
112 /* END -- S1WS_MOD */
113         this.ad = ad;
114 /* BEGIN -- S1WS_MOD */
115         this.env = env;
116 /* END -- S1WS_MOD */
117         connect();
118 /* BEGIN -- S1WS_MOD */
119         Boolean JavaDoc enabled = (Boolean JavaDoc) env.get(DefaultConfiguration.NOTIF_ENABLED_PROPERTY_NAME);
120         
121         if (enabled != null && enabled.booleanValue() == true) {
122             notifMgr = new ClientNotificationManager(ad, env);
123         }
124 /* END -- S1WS_MOD */
125         logger.finer("Connected to: Address = " + ad.getHost() + ":" + ad.getPort());
126     }
127
128 /* BEGIN -- S1WS_MOD */
129     public ClientNotificationManager getNotificationManager() {
130         return notifMgr;
131     }
132     
133     private void checkNotifInit() throws IOException JavaDoc {
134         if (notifMgr == null)
135             return;
136         notifMgr.reinit();
137     }
138 /* END -- S1WS_MOD */
139
140     private void connect() throws java.io.IOException JavaDoc {
141         physicalConnection = ConnectionFactory.createConnection(ad);
142         conductor = new MBeanServerMessageConductor(physicalConnection);
143     }
144     
145     public void addNotificationListener(ObjectName objectName,
146     NotificationListener notificationListener,
147     NotificationFilter notificationFilter, Object JavaDoc obj) throws
148     InstanceNotFoundException, IOException JavaDoc {
149         try {
150 /* BEGIN -- S1WS_MOD */
151             if (notifMgr == null)
152                 return; //XXX: Ideally throw an Unsupportedexception
153
checkNotifInit();
154             String JavaDoc id = notifMgr.addNotificationListener(
155                                               objectName,
156                                               notificationListener,
157                                               notificationFilter,
158                                               obj);
159 /* END -- S1WS_MOD */
160             connect();
161             final MBeanServerResponseMessage response = conductor.invoke(
162             MBeanServerRequestMessage.ADD_NOTIFICATION_LISTENERS,
163 /* BEGIN -- S1WS_MOD */
164             toArray(objectName, notifMgr.getId(), id, null) );
165 // toArray(objectName, notificationListener, notificationFilter, obj) );
166
/* END -- S1WS_MOD */
167             MBeanServerResponseActor.voidOrThrow(response);
168         }
169         catch (Exception JavaDoc e) {
170             MBeanServerConnectionExceptionThrower.addNotificationListenerObjectName(e);
171         }
172     }
173     
174     public void addNotificationListener(ObjectName objectName,
175     ObjectName objectName1, NotificationFilter notificationFilter,
176     Object JavaDoc obj) throws InstanceNotFoundException, IOException JavaDoc {
177         try {
178 /* BEGIN -- S1WS_MOD */
179             checkNotifInit();
180 /* END -- S1WS_MOD */
181             connect();
182             ListenerInfo info = new ListenerInfo(null, notificationFilter, obj);
183             final MBeanServerResponseMessage response = conductor.invoke(
184             MBeanServerRequestMessage.ADD_NOTIFICATION_LISTENER_OBJECTNAME,
185             toArray(objectName, objectName1, notificationFilter, obj, info.computeId()) );
186             MBeanServerResponseActor.voidOrThrow(response);
187         }
188         catch(Exception JavaDoc e) {
189             MBeanServerConnectionExceptionThrower.addNotificationListeners(e);
190         }
191     }
192     
193     public ObjectInstance createMBean(String JavaDoc str, ObjectName objectName) throws
194     ReflectionException, InstanceAlreadyExistsException,
195     MBeanRegistrationException, MBeanException, NotCompliantMBeanException,
196     IOException JavaDoc {
197         try {
198 /* BEGIN -- S1WS_MOD */
199             checkNotifInit();
200 /* END -- S1WS_MOD */
201             connect();
202             final MBeanServerResponseMessage response = conductor.invoke(
203             MBeanServerRequestMessage.CREATE_MBEAN, toArray(str, objectName) );
204             //the server should return the correct object, otherwise a CCE results
205
return ( (ObjectInstance) MBeanServerResponseActor.returnOrThrow(response) );
206         }
207         catch (Exception JavaDoc e) {
208             MBeanServerConnectionExceptionThrower.createMBean(e);
209             return null;
210         }
211     }
212     
213     public ObjectInstance createMBean(String JavaDoc str, ObjectName objectName, ObjectName loaderName)
214     throws ReflectionException, InstanceAlreadyExistsException,
215     MBeanRegistrationException, MBeanException, NotCompliantMBeanException,
216     InstanceNotFoundException, IOException JavaDoc {
217         try {
218 /* BEGIN -- S1WS_MOD */
219             checkNotifInit();
220 /* END -- S1WS_MOD */
221             connect();
222             final MBeanServerResponseMessage response = conductor.invoke(
223             MBeanServerRequestMessage.CREATE_MBEAN_LOADER, toArray(str, objectName, loaderName) );
224             //the server should return the correct object, otherwise a CCE results
225
return ( (ObjectInstance) MBeanServerResponseActor.returnOrThrow(response) );
226         }
227         catch(Exception JavaDoc e) {
228             MBeanServerConnectionExceptionThrower.createMBeanLoader(e);
229             return null;
230         }
231     }
232     
233     public ObjectInstance createMBean(String JavaDoc str, ObjectName objectName,
234     Object JavaDoc[] params, String JavaDoc[] signature) throws ReflectionException,
235     InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException,
236     NotCompliantMBeanException, IOException JavaDoc {
237         try {
238 /* BEGIN -- S1WS_MOD */
239             checkNotifInit();
240 /* END -- S1WS_MOD */
241             connect();
242             final MBeanServerResponseMessage response = conductor.invoke(
243             MBeanServerRequestMessage.CREATE_MBEAN_PARAMS,
244             toArray(str, objectName, params, signature) );
245             //the server should return the correct object, otherwise a CCE results
246
return ( (ObjectInstance) MBeanServerResponseActor.returnOrThrow(response));
247         }
248         catch(Exception JavaDoc e) {
249             MBeanServerConnectionExceptionThrower.createMBeanParams(e);
250             return null;
251         }
252     }
253     
254     public ObjectInstance createMBean(String JavaDoc str, ObjectName objectName,
255     ObjectName loaderName, Object JavaDoc[] params, String JavaDoc[] signature)
256     throws ReflectionException, InstanceAlreadyExistsException,
257     MBeanRegistrationException, MBeanException, NotCompliantMBeanException,
258     InstanceNotFoundException, IOException JavaDoc {
259         try {
260 /* BEGIN -- S1WS_MOD */
261             checkNotifInit();
262 /* END -- S1WS_MOD */
263             connect();
264             final MBeanServerResponseMessage response = conductor.invoke(
265             MBeanServerRequestMessage.CREATE_MBEAN_LOADER_PARAMS,
266             toArray(str, objectName, loaderName, params, signature) );
267             //the server should return the correct object, otherwise a CCE results
268
return ( (ObjectInstance)MBeanServerResponseActor.returnOrThrow(response) );
269         }
270         catch(Exception JavaDoc e) {
271             MBeanServerConnectionExceptionThrower.createMBeanLoaderParams(e);
272             return null;
273         }
274     }
275     
276     public Object JavaDoc getAttribute(ObjectName objectName, String JavaDoc str) throws
277     MBeanException, AttributeNotFoundException, InstanceNotFoundException,
278     ReflectionException, IOException JavaDoc {
279         try {
280 /* BEGIN -- S1WS_MOD */
281             checkNotifInit();
282 /* END -- S1WS_MOD */
283             connect();
284             final MBeanServerResponseMessage response = conductor.invoke(
285             MBeanServerRequestMessage.GET_ATTRIBUTE, toArray(objectName, str) );
286             return ( MBeanServerResponseActor.returnOrThrow(response) );
287         }
288         catch(Exception JavaDoc e) {
289             MBeanServerConnectionExceptionThrower.getAttribute(e);
290             return null;
291         }
292     }
293     
294     public AttributeList getAttributes(ObjectName objectName, String JavaDoc[] attributes)
295     throws InstanceNotFoundException, ReflectionException, IOException JavaDoc {
296         try {
297 /* BEGIN -- S1WS_MOD */
298             checkNotifInit();
299 /* END -- S1WS_MOD */
300             connect();
301             final MBeanServerResponseMessage response = conductor.invoke(
302             MBeanServerRequestMessage.GET_ATTRIBUTES,
303             toArray(objectName, attributes) );
304             //the server should return the correct object, otherwise a CCE results
305
return ( (AttributeList) MBeanServerResponseActor.returnOrThrow(response) );
306         }
307         catch(Exception JavaDoc e) {
308             MBeanServerConnectionExceptionThrower.getAttributes(e);
309             return null;
310         }
311     }
312     
313     public String JavaDoc getDefaultDomain() throws IOException JavaDoc {
314         try {
315 /* BEGIN -- S1WS_MOD */
316             checkNotifInit();
317 /* END -- S1WS_MOD */
318             connect();
319             final MBeanServerResponseMessage response = conductor.invoke(
320             MBeanServerRequestMessage.GET_DEFAULT_DOMAIN, toArray(EMPTY));
321             //the server should return the correct object, otherwise a CCE results
322
return ( (String JavaDoc) MBeanServerResponseActor.returnOrThrow(response) );
323         }
324         catch(Exception JavaDoc e) {
325             MBeanServerConnectionExceptionThrower.getDefaultDomain(e);
326             return null;
327         }
328     }
329     
330     public String JavaDoc[] getDomains() throws IOException JavaDoc {
331         try {
332 /* BEGIN -- S1WS_MOD */
333             checkNotifInit();
334 /* END -- S1WS_MOD */
335             connect();
336             final MBeanServerResponseMessage response = conductor.invoke(
337             MBeanServerRequestMessage.GET_DOMAINS, toArray(EMPTY));
338             //the server should return the correct object, otherwise a CCE results
339
return ( (String JavaDoc[]) MBeanServerResponseActor.returnOrThrow(response) );
340         }
341         catch(Exception JavaDoc e) {
342             MBeanServerConnectionExceptionThrower.getDomains(e);
343             return null;
344         }
345     }
346     
347     public Integer JavaDoc getMBeanCount() throws IOException JavaDoc {
348         try {
349 /* BEGIN -- S1WS_MOD */
350             checkNotifInit();
351 /* END -- S1WS_MOD */
352             connect();
353             final MBeanServerResponseMessage response = conductor.invoke(
354             MBeanServerRequestMessage.GET_MBEAN_COUNT, toArray(EMPTY));
355             //the server should return the correct object, otherwise a CCE results
356
return ( (Integer JavaDoc) MBeanServerResponseActor.returnOrThrow(response) );
357         }
358         catch(Exception JavaDoc e) {
359             MBeanServerConnectionExceptionThrower.getMBeanCount(e);
360             return null;
361         }
362     }
363     
364     public MBeanInfo getMBeanInfo(ObjectName objectName) throws
365     InstanceNotFoundException, IntrospectionException, ReflectionException, IOException JavaDoc {
366         try {
367 /* BEGIN -- S1WS_MOD */
368             checkNotifInit();
369 /* END -- S1WS_MOD */
370             connect();
371             final MBeanServerResponseMessage response = conductor.invoke(
372             MBeanServerRequestMessage.GET_MBEAN_INFO, toArray(objectName));
373             //the server should return the correct object, otherwise a CCE results
374
return ( (MBeanInfo) MBeanServerResponseActor.returnOrThrow(response) );
375         }
376         catch(Exception JavaDoc e) {
377             MBeanServerConnectionExceptionThrower.getMBeanInfo(e);
378             return null;
379         }
380     }
381     
382     public ObjectInstance getObjectInstance(ObjectName objectName) throws
383     InstanceNotFoundException, IOException JavaDoc {
384         try {
385 /* BEGIN -- S1WS_MOD */
386             checkNotifInit();
387 /* END -- S1WS_MOD */
388             connect();
389             final MBeanServerResponseMessage response = conductor.invoke(
390             MBeanServerRequestMessage.GET_OBJECT_INSTANCE, toArray(objectName));
391             //the server should return the correct object, otherwise a CCE results
392
return ( (ObjectInstance) MBeanServerResponseActor.returnOrThrow(response) );
393         }
394         catch(Exception JavaDoc e) {
395             MBeanServerConnectionExceptionThrower.getObjectInstance(e);
396             return null;
397         }
398     }
399     
400     public Object JavaDoc invoke(ObjectName objectName, String JavaDoc methodName,
401     Object JavaDoc[] params, String JavaDoc[] signature) throws InstanceNotFoundException,
402     MBeanException, ReflectionException, IOException JavaDoc {
403         try {
404 /* BEGIN -- S1WS_MOD */
405             checkNotifInit();
406 /* END -- S1WS_MOD */
407             connect();
408             final MBeanServerResponseMessage response = conductor.invoke(
409             MBeanServerRequestMessage.INVOKE,
410             toArray(objectName, methodName, params, signature));
411             return ( MBeanServerResponseActor.returnOrThrow(response) );
412         }
413         catch(Exception JavaDoc e) {
414             MBeanServerConnectionExceptionThrower.invoke(e);
415             return null;
416         }
417     }
418     
419     public boolean isInstanceOf(ObjectName objectName, String JavaDoc className) throws
420     InstanceNotFoundException, IOException JavaDoc {
421         try {
422 /* BEGIN -- S1WS_MOD */
423             checkNotifInit();
424 /* END -- S1WS_MOD */
425             connect();
426             final MBeanServerResponseMessage response = conductor.invoke(
427             MBeanServerRequestMessage.IS_INSTANCE_OF,
428             toArray(objectName, className));
429             //the server should return the correct object, otherwise a CCE results
430
return ( ((Boolean JavaDoc) MBeanServerResponseActor.returnOrThrow(response)).booleanValue() );
431         }
432         catch(Exception JavaDoc e) {
433             MBeanServerConnectionExceptionThrower.isInstanceOf(e);
434             return false;
435         }
436     }
437     
438     public boolean isRegistered(ObjectName objectName) throws IOException JavaDoc {
439         try {
440 /* BEGIN -- S1WS_MOD */
441             checkNotifInit();
442 /* END -- S1WS_MOD */
443             connect();
444             final MBeanServerResponseMessage response = conductor.invoke(
445             MBeanServerRequestMessage.IS_REGISTERED,
446             toArray(objectName));
447             //the server should return the correct object, otherwise a CCE results
448
return ( ((Boolean JavaDoc) MBeanServerResponseActor.returnOrThrow(response)).booleanValue() );
449         }
450         catch(Exception JavaDoc e) {
451             MBeanServerConnectionExceptionThrower.isRegistered(e);
452             return false;
453         }
454     }
455     
456     public Set JavaDoc queryMBeans(ObjectName objectName, QueryExp queryExp)
457     throws IOException JavaDoc {
458         try {
459 /* BEGIN -- S1WS_MOD */
460             checkNotifInit();
461 /* END -- S1WS_MOD */
462             connect();
463             final MBeanServerResponseMessage response = conductor.invoke(
464             MBeanServerRequestMessage.QUERY_MBEANS, toArray(objectName, queryExp));
465             //the server should return the correct object, otherwise a CCE results
466
return ( (Set JavaDoc) MBeanServerResponseActor.returnOrThrow(response));
467         }
468         catch(Exception JavaDoc e) {
469             MBeanServerConnectionExceptionThrower.queryMBeans(e);
470             return null;
471         }
472     }
473     
474     public Set JavaDoc queryNames(ObjectName objectName, QueryExp queryExp)
475     throws IOException JavaDoc {
476         try {
477 /* BEGIN -- S1WS_MOD */
478             checkNotifInit();
479 /* END -- S1WS_MOD */
480             connect();
481             final MBeanServerResponseMessage response = conductor.invoke(
482             MBeanServerRequestMessage.QUERY_NAMES, toArray(objectName, queryExp));
483             //the server should return the correct object, otherwise a CCE results
484
return ( (Set JavaDoc) MBeanServerResponseActor.returnOrThrow(response));
485         }
486         catch(Exception JavaDoc e) {
487             MBeanServerConnectionExceptionThrower.queryNames(e);
488             return null;
489         }
490     }
491     
492     public void removeNotificationListener(ObjectName objectName, NotificationListener notificationListener)
493     throws InstanceNotFoundException, ListenerNotFoundException, java.io.IOException JavaDoc {
494 /* BEGIN -- S1WS_MOD */
495         if (notifMgr == null)
496             return; // XXX: Ideally throw an UnsupportedException
497
/* END -- S1WS_MOD */
498         try {
499 /* BEGIN -- S1WS_MOD */
500             checkNotifInit();
501             String JavaDoc[] ids = notifMgr.removeNotificationListener(
502                                                     objectName,
503                                                     notificationListener);
504 /* END -- S1WS_MOD */
505             connect();
506             final MBeanServerResponseMessage response = conductor.invoke(
507             MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER,
508 /* BEGIN -- S1WS_MOD */
509             toArray(objectName, notifMgr.getId(), ids) );
510 // toArray(objectName, notificationListener, null) );
511
/* END -- S1WS_MOD */
512             MBeanServerResponseActor.voidOrThrow(response);
513         }
514         catch(Exception JavaDoc e) {
515             MBeanServerConnectionExceptionThrower.removeNotificationListener(e);
516         }
517     }
518     
519     public void removeNotificationListener(ObjectName objectName, ObjectName objectName1)
520     throws InstanceNotFoundException, ListenerNotFoundException, java.io.IOException JavaDoc {
521         try {
522 /* BEGIN -- S1WS_MOD */
523             checkNotifInit();
524 /* END -- S1WS_MOD */
525             connect();
526             final MBeanServerResponseMessage response = conductor.invoke(
527 /* BEGIN -- S1WS_MOD */
528 // MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER,
529
MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER_OBJECTNAME,
530 /* END -- S1WS_MOD */
531             toArray(objectName, objectName1) );
532             MBeanServerResponseActor.voidOrThrow(response);
533         }
534         catch(Exception JavaDoc e) {
535             MBeanServerConnectionExceptionThrower.removeNotificationListenerObjectName(e);
536         }
537     }
538     
539     public void removeNotificationListener(ObjectName objectName, ObjectName objectName1,
540     NotificationFilter notificationFilter, Object JavaDoc obj)
541     throws InstanceNotFoundException, ListenerNotFoundException, java.io.IOException JavaDoc {
542         try {
543 /* BEGIN -- S1WS_MOD */
544             checkNotifInit();
545 /* END -- S1WS_MOD */
546             connect();
547             ListenerInfo info = new ListenerInfo(null, notificationFilter, obj);
548             final MBeanServerResponseMessage response = conductor.invoke(
549 /* BEGIN -- S1WS_MOD */
550 /*
551             MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER,
552             toArray(objectName, objectName1, notificationFilter, obj) );
553 */

554             MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER_OBJECTNAME_FILTER_HANDBACK,
555             toArray(objectName, objectName1, null, null, info.computeId()));
556 /* END -- S1WS_MOD */
557             MBeanServerResponseActor.voidOrThrow(response);
558         }
559         catch(Exception JavaDoc e) {
560             MBeanServerConnectionExceptionThrower.removeNotificationListenerObjectNameFilterHandback(e);
561         }
562     }
563     
564     public void removeNotificationListener(ObjectName objectName,
565     NotificationListener notificationListener, NotificationFilter notificationFilter, Object JavaDoc obj)
566     throws InstanceNotFoundException, ListenerNotFoundException, java.io.IOException JavaDoc {
567 /* BEGIN -- S1WS_MOD */
568         if (notifMgr == null)
569             return; //XXX: Ideally throw an UnsupportedException
570
/* END -- S1WS_MOD */
571         try {
572 /* BEGIN -- S1WS_MOD */
573             checkNotifInit();
574             String JavaDoc[] ids = notifMgr.removeNotificationListener(
575                                                  objectName,
576                                                  notificationListener,
577                                                  notificationFilter,
578                                                  obj);
579 /* END -- S1WS_MOD */
580             connect();
581             final MBeanServerResponseMessage response = conductor.invoke(
582 /* BEGIN -- S1WS_MOD */
583 // MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER,
584
MBeanServerRequestMessage.REMOVE_NOTIFICATION_LISTENER_FILTER_HANDBACK,
585             toArray(objectName, notifMgr.getId(), ids.length > 0 ? ids[0] : null, null) );
586 // toArray(objectName, notificationListener, notificationFilter, obj) );
587
/* END -- S1WS_MOD */
588             MBeanServerResponseActor.voidOrThrow(response);
589         }
590         catch(Exception JavaDoc e) {
591             MBeanServerConnectionExceptionThrower.removeNotificationListenerFilterHandback(e);
592         }
593     }
594
595     public void setAttribute(ObjectName objectName, Attribute attribute) throws
596     InstanceNotFoundException, AttributeNotFoundException,
597     InvalidAttributeValueException, MBeanException, ReflectionException, IOException JavaDoc {
598         try {
599 /* BEGIN -- S1WS_MOD */
600             checkNotifInit();
601 /* END -- S1WS_MOD */
602             connect();
603             final MBeanServerResponseMessage response = conductor.invoke(
604             MBeanServerRequestMessage.SET_ATTRIBUTE, toArray(objectName, attribute));
605             //return ( (ObjectInstance) response.getResult() );
606
MBeanServerResponseActor.voidOrThrow(response);
607         }
608         catch(Exception JavaDoc e) {
609             MBeanServerConnectionExceptionThrower.setAttribute(e);
610         }
611     }
612     
613     public AttributeList setAttributes(ObjectName objectName, AttributeList
614     list) throws InstanceNotFoundException, ReflectionException, IOException JavaDoc {
615         try {
616 /* BEGIN -- S1WS_MOD */
617             checkNotifInit();
618 /* END -- S1WS_MOD */
619             connect();
620             final MBeanServerResponseMessage response = conductor.invoke(
621             MBeanServerRequestMessage.SET_ATTRIBUTES, toArray(objectName, list));
622             //the server should return the correct object, otherwise a CCE results
623
return ( (AttributeList) MBeanServerResponseActor.returnOrThrow(response) );
624         }
625         catch(Exception JavaDoc e) {
626             MBeanServerConnectionExceptionThrower.setAttributes(e);
627             return null;
628         }
629     }
630     
631     public void unregisterMBean(ObjectName objectName) throws
632     InstanceNotFoundException, MBeanRegistrationException, IOException JavaDoc {
633         try {
634 /* BEGIN -- S1WS_MOD */
635             checkNotifInit();
636 /* END -- S1WS_MOD */
637             connect();
638             final MBeanServerResponseMessage response = conductor.invoke(
639             MBeanServerRequestMessage.UNREGISTER_MBEAN, toArray(objectName));
640             //return ( (ObjectInstance) response.getResult() );
641
MBeanServerResponseActor.voidOrThrow(response);
642         }
643         catch(Exception JavaDoc e) {
644             MBeanServerConnectionExceptionThrower.unregisterMBean(e);
645         }
646     }
647     
648     private Object JavaDoc[] toArray(Object JavaDoc param1) {
649         final Shifter s = new Shifter (new Object JavaDoc[]{param1});
650         s.shiftRight(cv);
651         return ( s.state() );
652     }
653     private Object JavaDoc[] toArray(Object JavaDoc param1, Object JavaDoc param2) {
654         final Shifter s = new Shifter (new Object JavaDoc[]{param1, param2});
655         s.shiftRight(cv);
656         return ( s.state() );
657     }
658     private Object JavaDoc[] toArray(Object JavaDoc param1, Object JavaDoc param2, Object JavaDoc param3) {
659         final Shifter s = new Shifter (new Object JavaDoc[]{param1, param2, param3});
660         s.shiftRight(cv);
661         return ( s.state() );
662     }
663     private Object JavaDoc[] toArray(Object JavaDoc param1, Object JavaDoc param2, Object JavaDoc param3,
664     Object JavaDoc param4) {
665         final Shifter s = new Shifter (new Object JavaDoc[]{param1, param2, param3, param4});
666         s.shiftRight(cv);
667         return ( s.state() );
668     }
669     private Object JavaDoc[] toArray(Object JavaDoc param1, Object JavaDoc param2, Object JavaDoc param3,
670     Object JavaDoc param4, Object JavaDoc param5) {
671         final Shifter s = new Shifter (new Object JavaDoc[]{param1, param2, param3, param4, param5});
672         s.shiftRight(cv);
673         return ( s.state() );
674     }
675 }
676
Popular Tags