KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > util > jmx > MBeanServerConnection_Hook


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 package com.sun.appserv.management.util.jmx;
24
25 import javax.management.*;
26 import java.io.IOException JavaDoc;
27 import java.util.Set JavaDoc;
28
29 import com.sun.appserv.management.util.stringifier.ArrayStringifier;
30 import com.sun.appserv.management.util.misc.TypeCast;
31
32
33 /**
34     This class wraps an MBeanServerConnection and provides hooks on each method call
35     via its Hook interface.
36     
37     Typical used would be for a subclass to
38  */

39 public class MBeanServerConnection_Hook implements MBeanServerConnection
40 {
41     private final MBeanServerConnection mConn;
42     
43     /**
44         Prior to a method being called, preHook() is called; the 2 variants
45         correspond to either no arguments or 1 or more arguments.
46         
47         After a method is called, postHook() is called; the 3 variants
48         correspond to no-arguments-no-return-value, arguments-no-return-value, and
49         arguments-and-return-value methods.
50         
51         The callNameHook() is supplied to see just the ObjectName being used for
52         methods that accept a fully-qualifed ObjectName (but not methods that take
53         a pattern). The callNameHook() may return a different ObjectName which will
54         be used for the invocation.
55         
56         preHook() must return a unique call ID, which will be passed to nameHook() and
57         postHook(). The id identifies the particular calls (useful in a threaded
58         environment).
59      */

60     public interface Hook
61     {
62         public long preHook( String JavaDoc methodName );
63         public long preHook( String JavaDoc methodName, Object JavaDoc [] args );
64         public void postHook( long id, String JavaDoc methodName );
65         public void postHook( long id, String JavaDoc methodName, Object JavaDoc [] args );
66         public void postHook( long id, String JavaDoc methodName, Object JavaDoc [] args, Object JavaDoc result );
67         public ObjectName nameHook( long id, ObjectName methodName ) throws IOException JavaDoc;
68         
69
70         /**
71             Should throw the exception 'e'
72          */

73         public void IOExceptionHook( long id, IOException JavaDoc e,
74                             String JavaDoc operationName, ObjectName objectName, Object JavaDoc[] allArgs )
75                             throws IOException JavaDoc;
76                             
77         public void InstanceNotFoundExceptionHook( String JavaDoc methodName, long id, InstanceNotFoundException e)
78                             throws InstanceNotFoundException;
79     }
80     
81     static public class HookImpl
82         implements Hook
83     {
84         public static final HookImpl HOOK = new HookImpl();
85         
86         long mID;
87             public
88         HookImpl()
89         {
90             mID = 0;
91         }
92         
93             synchronized long
94         getNewID()
95         {
96             return( mID++ );
97         }
98
99         public long preHook( String JavaDoc methodName ) { return( getNewID() ); }
100         public long preHook( String JavaDoc methodName, Object JavaDoc [] args ) { return( getNewID() ); }
101         public void postHook( long id, String JavaDoc methodName ) {}
102         public void postHook( long id, String JavaDoc methodName, Object JavaDoc [] args ) {}
103         public void postHook( long id, String JavaDoc methodName, Object JavaDoc [] args, Object JavaDoc result ) {}
104         public ObjectName nameHook( long id, ObjectName methodName ) throws IOException JavaDoc { return( methodName ); }
105         
106         public void IOExceptionHook( long id, IOException JavaDoc e,
107                             String JavaDoc operationName, ObjectName objectName, Object JavaDoc[] allArgs )
108                             throws IOException JavaDoc
109                                 { throw e; }
110                                 
111         public void InstanceNotFoundExceptionHook( String JavaDoc methodName, long id, InstanceNotFoundException e)
112                             throws InstanceNotFoundException
113                         { throw e; }
114                         
115             
116             String JavaDoc
117         getInvocationString( String JavaDoc methodName, final Object JavaDoc [] args )
118         {
119             assert( methodName != null );
120             
121             String JavaDoc msg = methodName + "(";
122             
123             if ( args != null )
124             {
125                 for( int i = 0; i < args.length; ++i )
126                 {
127                     final Object JavaDoc arg = args[ i ];
128                     
129                     String JavaDoc s = "";
130                     if ( arg == null )
131                     {
132                         s = "null";
133                     }
134                     else if ( arg instanceof String JavaDoc || arg instanceof ObjectName )
135                     {
136                         s = "\"" + arg + "\"";
137                     }
138                     else
139                     {
140                         s = arg.toString();
141                     }
142                     
143                     msg = msg + s;
144                     if ( i != args.length - 1 )
145                     {
146                         msg = msg + ",";
147                     }
148                 }
149             }
150             
151             msg = msg + ")";
152             
153             return( msg );
154         }
155         
156             String JavaDoc
157         getInvocationString( final long id, String JavaDoc methodName, final Object JavaDoc [] args )
158         {
159             return "" + id + getInvocationString( methodName, args );
160         }
161     }
162     
163         Hook
164     getHook()
165     {
166         return( HookImpl.HOOK );
167     }
168
169         public
170     MBeanServerConnection_Hook( MBeanServerConnection conn )
171     {
172         mConn = conn;
173         
174         assert( getConn() != null );
175         
176     }
177     
178         MBeanServerConnection
179     getConn()
180     {
181         return( mConn );
182     }
183     
184         void
185     callIOExceptionHook(
186         long id,
187         IOException JavaDoc e,
188         String JavaDoc operationName,
189         ObjectName objectName,
190         Object JavaDoc[] allArgs ) throws IOException JavaDoc
191     {
192         getHook().IOExceptionHook( id, e, operationName, objectName, allArgs );
193     }
194     
195         long
196     callPreHook( String JavaDoc name, Object JavaDoc [] args )
197     {
198         return( getHook().preHook( name, args ) );
199     }
200     
201         long
202     callPreHook( String JavaDoc name )
203     {
204         return( getHook().preHook( name ) );
205     }
206     
207         void
208     callPostHook( long id, String JavaDoc name, Object JavaDoc [] args, Object JavaDoc result )
209     {
210         getHook().postHook( id, name, args, result );
211     }
212     
213         void
214     callPostHook( long id, String JavaDoc name, Object JavaDoc [] args )
215     {
216         getHook().postHook( id, name, args );
217     }
218     
219         void
220     callPostHook( long id, String JavaDoc name )
221     {
222         getHook().postHook( id, name );
223     }
224     
225         ObjectName
226     callNameHook( long id, ObjectName objectName )
227         throws IOException JavaDoc
228     {
229         return( getHook().nameHook( id, objectName ) );
230     }
231     
232     public static final String JavaDoc CREATE_MBEAN = "createMBean";
233     public static final String JavaDoc UNREGISTER_MBEAN = "unregisterMBean";
234     public static final String JavaDoc REGISTER_MBEAN = "registerMBean";
235     public static final String JavaDoc GET_OBJECT_INSTANCE = "getObjectInstance";
236     public static final String JavaDoc QUERY_MBEANS = "queryMBeans";
237     public static final String JavaDoc QUERY_NAMES = "queryNames";
238     public final static String JavaDoc GET_DOMAINS = "getDomains";
239     public static final String JavaDoc IS_REGISTERED = "isRegistered";
240     public static final String JavaDoc GET_MBEAN_COUNT = "getMBeanCount";
241     public static final String JavaDoc GET_ATTRIBUTE = "getAttribute";
242     public static final String JavaDoc GET_ATTRIBUTES = "getAttributes";
243     public static final String JavaDoc SET_ATTRIBUTE = "setAttribute";
244     public static final String JavaDoc SET_ATTRIBUTES = "setAttributes";
245     public static final String JavaDoc INVOKE = "invoke";
246     public static final String JavaDoc GET_DEFAULT_DOMAIN = "getDefaultDomain";
247     public final static String JavaDoc ADD_NOTIFICATION_LISTENER = "addNotificationListener";
248     public final static String JavaDoc REMOVE_NOTIFICATION_LISTENER = "removeNotificationListener";
249     public final static String JavaDoc GET_MBEAN_INFO = "getMBeanInfo";
250     public final static String JavaDoc IS_INSTANCE_OF = "isInstanceOf";
251
252     
253     
254     public ObjectInstance createMBean(String JavaDoc className, ObjectName name)
255         throws ReflectionException, InstanceAlreadyExistsException,
256            MBeanRegistrationException, MBeanException,
257            NotCompliantMBeanException, IOException JavaDoc
258     {
259         final Object JavaDoc [] args = new Object JavaDoc [] { className, name };
260         
261         final long id = callPreHook( CREATE_MBEAN, args );
262         
263         ObjectInstance result = null;
264         try
265         {
266             result = getConn().createMBean( className, name );
267             callPostHook( id, CREATE_MBEAN, args, result );
268         }
269         catch( IOException JavaDoc e )
270         {
271             callIOExceptionHook( id, e, CREATE_MBEAN, name, args );
272         }
273         
274         return( result );
275     }
276
277     public ObjectInstance createMBean(String JavaDoc className, ObjectName name, ObjectName loaderName)
278         throws ReflectionException, InstanceAlreadyExistsException,
279            MBeanRegistrationException, MBeanException,
280            NotCompliantMBeanException, InstanceNotFoundException,
281            IOException JavaDoc
282     {
283         final Object JavaDoc [] args = new Object JavaDoc [] { className, name, loaderName };
284         final long id = callPreHook( CREATE_MBEAN, args );
285         
286         ObjectInstance result = null;
287         try
288         {
289             result = getConn().createMBean( className, name, loaderName );
290             callPostHook( id, CREATE_MBEAN, args, result );
291         }
292         catch( IOException JavaDoc e )
293         {
294             callIOExceptionHook( id, e, CREATE_MBEAN, name, args );
295         }
296         catch( InstanceNotFoundException e )
297         {
298             getHook().InstanceNotFoundExceptionHook( CREATE_MBEAN, id, e );
299         }
300         
301         return( result );
302     }
303
304
305
306     public ObjectInstance createMBean(String JavaDoc className, ObjectName name,
307                       Object JavaDoc params[], String JavaDoc signature[])
308         throws ReflectionException, InstanceAlreadyExistsException,
309                MBeanRegistrationException, MBeanException,
310                NotCompliantMBeanException, IOException JavaDoc
311     {
312         final Object JavaDoc [] args = new Object JavaDoc [] { className, name, params, signature };
313         final long id = callPreHook( CREATE_MBEAN, args );
314         
315         ObjectInstance result = null;
316         try
317         {
318             result = getConn().createMBean( className, name, params, signature );
319             callPostHook( id, CREATE_MBEAN, args, result );
320         }
321         catch( IOException JavaDoc e )
322         {
323             callIOExceptionHook( id, e, CREATE_MBEAN, name, args );
324         }
325         
326         return( result );
327     }
328
329
330     public ObjectInstance createMBean(String JavaDoc className, ObjectName name,
331                       ObjectName loaderName, Object JavaDoc params[],
332                       String JavaDoc signature[])
333         throws ReflectionException, InstanceAlreadyExistsException,
334                MBeanRegistrationException, MBeanException,
335                NotCompliantMBeanException, InstanceNotFoundException,
336                IOException JavaDoc
337     {
338         final Object JavaDoc [] args = new Object JavaDoc [] { className, name, loaderName, params, signature };
339         final long id = callPreHook( CREATE_MBEAN, args );
340         
341         ObjectInstance result = null;
342         try
343         {
344             result = getConn().createMBean( className, name, loaderName, params, signature);
345             
346             callPostHook( id, CREATE_MBEAN, args, result );
347         }
348         catch( IOException JavaDoc e )
349         {
350             callIOExceptionHook( id, e, CREATE_MBEAN, name, args );
351         }
352         catch( InstanceNotFoundException e )
353         {
354             getHook().InstanceNotFoundExceptionHook( CREATE_MBEAN, id, e );
355         }
356         
357         return( result );
358     }
359
360     
361     public void unregisterMBean(ObjectName name)
362         throws InstanceNotFoundException, MBeanRegistrationException,
363                IOException JavaDoc
364     {
365         final Object JavaDoc [] args = new Object JavaDoc [] { name };
366         final long id = callPreHook( UNREGISTER_MBEAN, args );
367         
368         try
369         {
370             getConn().unregisterMBean( callNameHook( id, name ) );
371             
372             callPostHook( id, UNREGISTER_MBEAN, args );
373         }
374         catch( IOException JavaDoc e )
375         {
376             callIOExceptionHook( id, e, UNREGISTER_MBEAN, name, args );
377         }
378         catch( InstanceNotFoundException e )
379         {
380             getHook().InstanceNotFoundExceptionHook( UNREGISTER_MBEAN, id, e );
381         }
382     }
383
384
385     public ObjectInstance getObjectInstance(ObjectName name)
386         throws InstanceNotFoundException, IOException JavaDoc
387     {
388         final Object JavaDoc [] args = new Object JavaDoc [] { name };
389         final long id = callPreHook( GET_OBJECT_INSTANCE, args );
390         
391         ObjectInstance result = null;
392         try
393         {
394             result = getConn().getObjectInstance( callNameHook( id, name ) );
395             
396             callPostHook( id, GET_OBJECT_INSTANCE, args, result );
397         }
398         catch( IOException JavaDoc e )
399         {
400             callIOExceptionHook( id, e, GET_OBJECT_INSTANCE, name, args );
401         }
402         catch( InstanceNotFoundException e )
403         {
404             getHook().InstanceNotFoundExceptionHook( GET_OBJECT_INSTANCE, id, e );
405         }
406         
407         return( result );
408     }
409
410
411     public Set JavaDoc<ObjectName> queryMBeans(ObjectName name, QueryExp query)
412         throws IOException JavaDoc
413     {
414         final Object JavaDoc [] args = new Object JavaDoc [] { name, query };
415         final long id = callPreHook( QUERY_MBEANS, args );
416         
417         Set JavaDoc<ObjectName> result = null;
418         try
419         {
420             result = TypeCast.asSet( getConn().queryMBeans( name, query ) );
421         }
422         catch( IOException JavaDoc e )
423         {
424             callIOExceptionHook( id, e, QUERY_MBEANS, name, args );
425         }
426         
427         callPostHook( id, QUERY_MBEANS, args, result );
428         
429         return( result );
430     }
431
432
433     public Set JavaDoc<ObjectName> queryNames(ObjectName name, QueryExp query)
434         throws IOException JavaDoc
435     {
436         final Object JavaDoc [] args = new Object JavaDoc [] { name, query };
437         final long id = callPreHook( QUERY_NAMES, args );
438         
439         Set JavaDoc<ObjectName> result = null;
440         try
441         {
442             result = JMXUtil.queryNames( getConn(), name, query );
443         }
444         catch( IOException JavaDoc e )
445         {
446             callIOExceptionHook( id, e, QUERY_NAMES, name, args );
447         }
448         
449         callPostHook( id, QUERY_NAMES, args, result );
450         
451         return( result );
452     }
453
454
455     
456     public boolean isRegistered(ObjectName name)
457         throws IOException JavaDoc
458     {
459         final Object JavaDoc [] args = new Object JavaDoc [] { name };
460         final long id = callPreHook( IS_REGISTERED, args );
461         
462         boolean registered = false;
463         
464         try
465         {
466             registered = getConn().isRegistered( callNameHook( id, name) );
467             
468             callPostHook( id, IS_REGISTERED, args, registered ? Boolean.TRUE : Boolean.FALSE );
469         }
470         catch( IOException JavaDoc e )
471         {
472             callIOExceptionHook( id, e, IS_REGISTERED, name, args );
473         }
474         
475         return( registered );
476     }
477
478
479
480     public Integer JavaDoc getMBeanCount()
481         throws IOException JavaDoc
482     {
483         final long id = callPreHook( GET_MBEAN_COUNT, null );
484         
485         Integer JavaDoc result = null;
486         try
487         {
488             result = getConn().getMBeanCount( );
489             
490             callPostHook( id, GET_MBEAN_COUNT, null, result );
491         }
492         catch( IOException JavaDoc e )
493         {
494             callIOExceptionHook( id, e, GET_MBEAN_COUNT, null, null );
495         }
496         
497         return( result );
498     }
499
500
501     public Object JavaDoc getAttribute(ObjectName name, String JavaDoc attribute)
502         throws MBeanException, AttributeNotFoundException,
503                InstanceNotFoundException, ReflectionException,
504                IOException JavaDoc
505     {
506         final Object JavaDoc [] args = new Object JavaDoc [] { name, attribute };
507         final long id = callPreHook( GET_ATTRIBUTE, args );
508         
509         Object JavaDoc result = null;
510         try
511         {
512             result = getConn().getAttribute( callNameHook( id, name ), attribute );
513             
514             callPostHook( id, GET_ATTRIBUTE, args, result );
515         }
516         catch( IOException JavaDoc e )
517         {
518             callIOExceptionHook( id, e, GET_ATTRIBUTE, name, args );
519         }
520         
521         return( result );
522     }
523
524
525
526     public AttributeList getAttributes(ObjectName name, String JavaDoc[] attributes)
527         throws InstanceNotFoundException, ReflectionException,
528            IOException JavaDoc
529     {
530         final Object JavaDoc [] args = new Object JavaDoc [] { name, attributes };
531         final long id = callPreHook( GET_ATTRIBUTES, args );
532         
533         AttributeList result = null;
534         try
535         {
536             final ObjectName actualName = callNameHook( id, name );
537             
538             result = getConn().getAttributes(actualName , attributes );
539             
540             callPostHook( id, GET_ATTRIBUTES, args, result );
541         }
542         catch( IOException JavaDoc e )
543         {
544             callIOExceptionHook( id, e, GET_ATTRIBUTES, name, args );
545         }
546         
547         return( result );
548     }
549
550
551     public void setAttribute(ObjectName name, Attribute attribute)
552         throws InstanceNotFoundException, AttributeNotFoundException,
553            InvalidAttributeValueException, MBeanException,
554            ReflectionException, IOException JavaDoc
555     {
556         final Object JavaDoc [] args = new Object JavaDoc [] { name, attribute };
557         final long id = callPreHook( SET_ATTRIBUTE, args );
558         
559         try
560         {
561             getConn().setAttribute( callNameHook( id, name ), attribute );
562             
563             callPostHook( id, SET_ATTRIBUTE, args );
564         }
565         catch( IOException JavaDoc e )
566         {
567             callIOExceptionHook( id, e, SET_ATTRIBUTE, name, args );
568         }
569     }
570
571
572
573
574     public AttributeList setAttributes(ObjectName name, AttributeList attributes)
575         throws InstanceNotFoundException, ReflectionException, IOException JavaDoc
576     {
577         final Object JavaDoc [] args = new Object JavaDoc [] { name, attributes };
578         final long id = callPreHook( SET_ATTRIBUTES, args );
579         
580         AttributeList result = null;
581         
582         try
583         {
584             result = getConn().setAttributes( callNameHook( id, name ), attributes );
585         
586             callPostHook( id, SET_ATTRIBUTES, args );
587         }
588         catch( IOException JavaDoc e )
589         {
590             callIOExceptionHook( id, e, SET_ATTRIBUTES, name, args );
591         }
592         
593         return( result );
594     }
595
596     public Object JavaDoc invoke(ObjectName name, String JavaDoc operationName,
597              Object JavaDoc params[], String JavaDoc signature[])
598         throws InstanceNotFoundException, MBeanException,
599            ReflectionException, IOException JavaDoc
600     {
601         final Object JavaDoc [] args = new Object JavaDoc [] { name, operationName, params, signature };
602         final long id = callPreHook( INVOKE, args );
603         
604         Object JavaDoc result = null;
605         try
606         {
607             result = getConn().invoke( callNameHook( id, name ), operationName, params, signature);
608         
609             callPostHook( id, INVOKE, args );
610         }
611         catch( IOException JavaDoc e )
612         {
613             callIOExceptionHook( id, e, INVOKE, name, args );
614         }
615         return( result );
616     }
617
618  
619
620   
621     public String JavaDoc getDefaultDomain()
622         throws IOException JavaDoc
623     {
624         final long id = callPreHook( GET_DEFAULT_DOMAIN );
625         
626         String JavaDoc result = null;
627         try
628         {
629             result = getConn().getDefaultDomain();
630                 
631             callPostHook( id, GET_DEFAULT_DOMAIN );
632         }
633         catch( IOException JavaDoc e )
634         {
635             callIOExceptionHook( id, e, GET_DEFAULT_DOMAIN, null, null );
636         }
637         
638         return( result );
639     }
640
641
642     public String JavaDoc[] getDomains()
643         throws IOException JavaDoc
644     {
645         final long id = callPreHook( GET_DOMAINS );
646         
647         String JavaDoc[] result = null;
648         try
649         {
650             result = getConn().getDomains( );
651                 
652             callPostHook( id, GET_DOMAINS, result );
653         }
654         catch( IOException JavaDoc e )
655         {
656             callIOExceptionHook( id, e, GET_DOMAINS, null, null );
657         }
658         
659         return( result );
660     }
661
662
663     public void addNotificationListener(ObjectName name,
664                     NotificationListener listener,
665                     NotificationFilter filter,
666                     Object JavaDoc handback)
667         throws InstanceNotFoundException, IOException JavaDoc
668     {
669         final Object JavaDoc [] args = new Object JavaDoc [] { name, listener, filter, handback };
670         final long id = callPreHook( ADD_NOTIFICATION_LISTENER, args );
671         
672         try
673         {
674             getConn().addNotificationListener( callNameHook( id, name ), listener, filter, handback );
675             
676             callPostHook( id, ADD_NOTIFICATION_LISTENER, args );
677         }
678         catch( IOException JavaDoc e )
679         {
680             callIOExceptionHook( id, e, ADD_NOTIFICATION_LISTENER, name, args );
681         }
682     }
683
684
685
686     public void addNotificationListener(ObjectName name,
687                     ObjectName listener,
688                     NotificationFilter filter,
689                     Object JavaDoc handback)
690         throws InstanceNotFoundException, IOException JavaDoc
691     {
692         final Object JavaDoc [] args = new Object JavaDoc [] { name, listener, filter, handback };
693         final long id = callPreHook( ADD_NOTIFICATION_LISTENER, args );
694         
695         try
696         {
697             getConn().addNotificationListener( callNameHook( id, name ), listener, filter, handback );
698             
699             callPostHook( id, ADD_NOTIFICATION_LISTENER, args );
700         }
701         catch( IOException JavaDoc e )
702         {
703             callIOExceptionHook( id, e, ADD_NOTIFICATION_LISTENER, name, args );
704         }
705     }
706
707
708
709     public void removeNotificationListener(ObjectName name,
710                        ObjectName listener)
711     throws InstanceNotFoundException, ListenerNotFoundException,
712            IOException JavaDoc
713     {
714         final Object JavaDoc [] args = new Object JavaDoc [] { listener };
715         final long id = callPreHook( REMOVE_NOTIFICATION_LISTENER, args );
716         
717         try
718         {
719             getConn().removeNotificationListener( callNameHook( id, name ), listener );
720             
721             callPostHook( id, REMOVE_NOTIFICATION_LISTENER, args );
722         }
723         catch( IOException JavaDoc e )
724         {
725             callIOExceptionHook( id, e, REMOVE_NOTIFICATION_LISTENER, name, args );
726         }
727     }
728
729
730     public void removeNotificationListener(ObjectName name,
731                        ObjectName listener,
732                        NotificationFilter filter,
733                        Object JavaDoc handback)
734         throws InstanceNotFoundException, ListenerNotFoundException,
735            IOException JavaDoc
736     {
737         final Object JavaDoc [] args = new Object JavaDoc [] { name, listener, filter, handback };
738         final long id = callPreHook( REMOVE_NOTIFICATION_LISTENER, args );
739         
740         try
741         {
742             getConn().removeNotificationListener( callNameHook( id, name ), listener, filter, handback );
743             
744             callPostHook( id, REMOVE_NOTIFICATION_LISTENER, args );
745         }
746         catch( IOException JavaDoc e )
747         {
748             callIOExceptionHook( id, e, REMOVE_NOTIFICATION_LISTENER, name, args );
749         }
750     }
751
752
753
754     public void removeNotificationListener(ObjectName name,
755                        NotificationListener listener)
756         throws InstanceNotFoundException, ListenerNotFoundException,
757            IOException JavaDoc
758     {
759         final Object JavaDoc [] args = new Object JavaDoc [] { name, listener };
760         final long id = callPreHook( REMOVE_NOTIFICATION_LISTENER, args );
761         
762         try
763         {
764             getConn().removeNotificationListener( callNameHook( id, name ), listener );
765             
766             callPostHook( id, REMOVE_NOTIFICATION_LISTENER, args );
767         }
768         catch( IOException JavaDoc e )
769         {
770             callIOExceptionHook( id, e, REMOVE_NOTIFICATION_LISTENER, name, args );
771         }
772     }
773
774
775     public void removeNotificationListener(ObjectName name,
776                        NotificationListener listener,
777                        NotificationFilter filter,
778                        Object JavaDoc handback)
779         throws InstanceNotFoundException, ListenerNotFoundException,
780            IOException JavaDoc
781     {
782         final Object JavaDoc [] args = new Object JavaDoc [] { name, listener, filter, handback };
783         final long id = callPreHook( REMOVE_NOTIFICATION_LISTENER, args );
784         
785         try
786         {
787             getConn().removeNotificationListener( callNameHook( id, name ), listener, filter, handback );
788             
789             callPostHook( id, REMOVE_NOTIFICATION_LISTENER, args );
790         }
791         catch( IOException JavaDoc e )
792         {
793             callIOExceptionHook( id, e, REMOVE_NOTIFICATION_LISTENER, name, args );
794         }
795     }
796
797     
798     public MBeanInfo getMBeanInfo(ObjectName name)
799         throws InstanceNotFoundException, IntrospectionException,
800                ReflectionException, IOException JavaDoc
801     {
802         final Object JavaDoc [] args = new Object JavaDoc [] { name };
803         final long id = callPreHook( GET_MBEAN_INFO, args );
804         
805         MBeanInfo result = null;
806         try
807         {
808             result = getConn().getMBeanInfo( callNameHook( id, name ) );
809             
810             callPostHook( id, GET_MBEAN_INFO, args );
811         }
812         catch( IOException JavaDoc e )
813         {
814             callIOExceptionHook( id, e, GET_MBEAN_INFO, name, args );
815         }
816         
817         return( result );
818     }
819
820
821  
822     public boolean isInstanceOf(ObjectName name, String JavaDoc className)
823         throws InstanceNotFoundException, IOException JavaDoc
824     {
825         final Object JavaDoc [] args = new Object JavaDoc [] { name, className };
826         final long id = callPreHook( IS_INSTANCE_OF, args );
827         
828         boolean isInstance = false;
829         try
830         {
831             isInstance = getConn().isInstanceOf( callNameHook( id, name ), className );
832             
833             callPostHook( id, IS_INSTANCE_OF, args, isInstance ? Boolean.TRUE : Boolean.FALSE );
834         }
835         catch( IOException JavaDoc e )
836         {
837             callIOExceptionHook( id, e, IS_INSTANCE_OF, name, args );
838         }
839         
840         return( isInstance );
841     }
842
843 };
844
845
Popular Tags