KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > server > core > jmx > MBeanServerImpl


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.enterprise.admin.server.core.jmx;
24
25 //JDK imports
26
import java.lang.reflect.Method JavaDoc;
27 import java.util.Set JavaDoc;
28 import java.util.HashSet JavaDoc;
29 import java.io.ObjectOutputStream JavaDoc;
30 import java.io.ObjectInputStream JavaDoc;
31
32 //JMX imports
33
import javax.management.MBeanServer JavaDoc;
34 import javax.management.QueryExp JavaDoc;
35 import javax.management.ObjectInstance JavaDoc;
36 import javax.management.ObjectName JavaDoc;
37 import javax.management.Attribute JavaDoc;
38 import javax.management.AttributeList JavaDoc;
39 import javax.management.InstanceAlreadyExistsException JavaDoc;
40 import javax.management.InvalidAttributeValueException JavaDoc;
41 import javax.management.InstanceNotFoundException JavaDoc;
42 import javax.management.AttributeNotFoundException JavaDoc;
43 import javax.management.ReflectionException JavaDoc;
44 import javax.management.MBeanException JavaDoc;
45 import javax.management.IntrospectionException JavaDoc;
46 import javax.management.ListenerNotFoundException JavaDoc;
47 import javax.management.MBeanInfo JavaDoc;
48 import javax.management.MBeanRegistrationException JavaDoc;
49 import javax.management.NotificationListener JavaDoc;
50 import javax.management.NotificationFilter JavaDoc;
51 import javax.management.NotCompliantMBeanException JavaDoc;
52 import javax.management.OperationsException JavaDoc;
53 import javax.management.MBeanRegistrationException JavaDoc;
54 import javax.management.NotCompliantMBeanException JavaDoc;
55
56 //Admin imports
57
import com.sun.enterprise.admin.common.ObjectNames;
58
59 //i18n import
60
import com.sun.enterprise.util.i18n.StringManager;
61
62 public class MBeanServerImpl implements MBeanServer JavaDoc
63 {
64     protected IRepository mMBeanRepository = null;
65
66     private static boolean kDynamicMBeansOnly = true;
67     private static String JavaDoc kGetMBeanInfoMethodName = "getMBeanInfo";
68     
69     private static String JavaDoc kAllMBeansPattern = "*";
70
71     // i18n StringManager
72
private static StringManager localStrings =
73         StringManager.getManager( MBeanServerImpl.class );
74     
75     /**
76         The private constructor so that only the factory method is called.
77         Also makes sure that there is single instance of MBeanServer in the JVM.
78
79         @param defaultDomainName represents the domain of the MBeanServer.
80         @throws InitException in case the System Mbeans can't be registered. The
81         System MBeans are ServerController and GenericConfigurator.
82     */

83
84     protected MBeanServerImpl(String JavaDoc defaultDomainName) throws InitException
85     {
86         mMBeanRepository = new DomainRepository();
87     }
88
89     /**
90         The private constructor so that only the factory method is called.
91         Also makes sure that there is single instance of MBeanServer in the JVM.
92         The default domain of this MBeanServer will be "ias".
93
94         @throws InitException in case the System Mbeans can't be registered. The
95         System MBeans are ServerController and GenericConfigurator.
96     */

97
98         protected MBeanServerImpl() throws InitException
99     {
100         this(ServiceName.DOMAIN);
101     }
102     
103     public ObjectInstance JavaDoc registerMBean(Object JavaDoc object, ObjectName JavaDoc objectName)
104         throws InstanceAlreadyExistsException JavaDoc, MBeanRegistrationException JavaDoc,
105                 NotCompliantMBeanException JavaDoc
106     {
107         if (object == null || objectName == null)
108         {
109             throw new IllegalArgumentException JavaDoc();
110         }
111         if (mMBeanRepository.contains(objectName))
112         {
113             throw new InstanceAlreadyExistsException JavaDoc(objectName.toString());
114         }
115         mMBeanRepository.add(objectName, object);
116         
117         return ( new ObjectInstance JavaDoc(objectName, object.getClass().getName()) );
118     }
119     
120     public Object JavaDoc invoke(ObjectName JavaDoc objectName, String JavaDoc operationName,
121         Object JavaDoc[] params, String JavaDoc[] signature)
122         throws ReflectionException JavaDoc, InstanceNotFoundException JavaDoc, MBeanException JavaDoc
123     {
124     Object JavaDoc implObject = mMBeanRepository.find(objectName);
125         if (implObject == null )
126         {
127             throw new InstanceNotFoundException JavaDoc(objectName.toString());
128         }
129         Class JavaDoc implClass = implObject.getClass();
130         Introspector reflector = new Introspector(implClass);
131         Object JavaDoc value = null;
132         try
133         {
134             Method JavaDoc method = reflector.getMethod(operationName, signature);
135             value = reflector.invokeMethodOn(method, implObject, params);
136         }
137         catch (java.lang.ClassNotFoundException JavaDoc cnfe)
138         {
139             throw new javax.management.ReflectionException JavaDoc(cnfe);
140         }
141         catch (java.lang.NoSuchMethodException JavaDoc nsme)
142         {
143             throw new javax.management.ReflectionException JavaDoc(nsme);
144         }
145         catch (java.lang.SecurityException JavaDoc se)
146         {
147             throw new javax.management.ReflectionException JavaDoc(se);
148         }
149         catch (java.lang.reflect.InvocationTargetException JavaDoc ite)
150         {
151             Throwable JavaDoc t = ite.getTargetException();
152             if (t instanceof MBeanException JavaDoc)
153             {
154                 throw (MBeanException JavaDoc)t;
155             }
156             else
157                 if (t instanceof Exception JavaDoc)
158                 {
159                     throw new MBeanException JavaDoc((Exception JavaDoc) t);
160                 }
161                 else //if an error
162
{
163                     String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.error_from_mbean", t.getMessage() );
164                     RuntimeException JavaDoc re = new RuntimeException JavaDoc( msg );
165                     throw new MBeanException JavaDoc(re);
166                     //Do what?
167
}
168         }
169         catch (java.lang.IllegalAccessException JavaDoc iae)
170         {
171             throw new javax.management.ReflectionException JavaDoc(iae);
172         }
173         catch (Exception JavaDoc e)
174         {
175             throw new MBeanException JavaDoc(e);
176         }
177         return value;
178     }
179     
180     public Object JavaDoc getAttribute(ObjectName JavaDoc objectName, String JavaDoc attributeName)
181         throws InstanceNotFoundException JavaDoc, AttributeNotFoundException JavaDoc,
182                MBeanException JavaDoc, ReflectionException JavaDoc
183     {
184         Object JavaDoc implObject = mMBeanRepository.find(objectName);
185         if (implObject == null )
186         {
187             throw new InstanceNotFoundException JavaDoc(objectName.toString());
188         }
189         Class JavaDoc implClass = implObject.getClass();
190         Object JavaDoc value = null;
191         try
192         {
193             MBeanIntrospector introspector = new MBeanIntrospector(implClass);
194             if (introspector.isDynamicMBean())
195             {
196                 Method JavaDoc method = introspector.getMethod("getAttribute",
197                                     new String JavaDoc[] {"java.lang.String"});
198                 value = introspector.invokeMethodOn(method, implObject,
199                                                  new Object JavaDoc[] {attributeName});
200             }
201         }
202         catch (javax.management.NotCompliantMBeanException JavaDoc e)
203         {
204             /*
205              * This check is not necessary as a noncompliant mbean should not
206              * be allowed to register by the MBeanServer.
207              */

208             value = null;
209         }
210         catch (java.lang.ClassNotFoundException JavaDoc cnfe)
211         {
212             throw new javax.management.ReflectionException JavaDoc(cnfe);
213         }
214         catch (java.lang.NoSuchMethodException JavaDoc nsme)
215         {
216             throw new javax.management.ReflectionException JavaDoc(nsme);
217         }
218         catch (java.lang.SecurityException JavaDoc se)
219         {
220             throw new javax.management.ReflectionException JavaDoc(se);
221         }
222         catch (java.lang.reflect.InvocationTargetException JavaDoc ite)
223         {
224             Throwable JavaDoc t = ite.getTargetException();
225             if (t instanceof javax.management.AttributeNotFoundException JavaDoc)
226             {
227                 throw (javax.management.AttributeNotFoundException JavaDoc) t;
228             }
229             else if (t instanceof Exception JavaDoc)
230             {
231                 throw new MBeanException JavaDoc((Exception JavaDoc) t);
232             }
233             else //if an error
234
{
235                 //Do what?
236
}
237         }
238         catch (java.lang.IllegalAccessException JavaDoc iae)
239         {
240             throw new javax.management.ReflectionException JavaDoc(iae);
241         }
242         catch (Exception JavaDoc e)
243         {
244             throw new MBeanException JavaDoc(e);
245         }
246         return value;
247     }
248     
249     public void setAttribute(ObjectName JavaDoc objectName, Attribute JavaDoc attribute) throws
250         InstanceNotFoundException JavaDoc, AttributeNotFoundException JavaDoc,
251         MBeanException JavaDoc, ReflectionException JavaDoc, InvalidAttributeValueException JavaDoc
252     {
253         Object JavaDoc implObject = mMBeanRepository.find(objectName);
254         if (implObject == null )
255         {
256             throw new InstanceNotFoundException JavaDoc(objectName.toString());
257         }
258         Class JavaDoc implClass = implObject.getClass();
259         Object JavaDoc value = null;
260         try
261         {
262             MBeanIntrospector introspector = new MBeanIntrospector(implClass);
263             if (introspector.isDynamicMBean())
264             {
265                 Method JavaDoc method = introspector.getMethod("setAttribute",
266                                 new String JavaDoc[] {"javax.management.Attribute"});
267                 value = introspector.invokeMethodOn(method, implObject,
268                                                  new Object JavaDoc[] {attribute});
269             }
270         }
271         catch (NotCompliantMBeanException JavaDoc e)
272         {
273             /*
274              * This check is not necessary as a noncompliant mbean should not
275              * be allowed to register by the MBeanServer.
276              */

277             value = null;
278         }
279         catch (java.lang.ClassNotFoundException JavaDoc cnfe)
280         {
281             throw new javax.management.ReflectionException JavaDoc(cnfe);
282         }
283         catch (java.lang.NoSuchMethodException JavaDoc nsme)
284         {
285             throw new javax.management.ReflectionException JavaDoc(nsme);
286         }
287         catch (java.lang.SecurityException JavaDoc se)
288         {
289             throw new javax.management.ReflectionException JavaDoc(se);
290         }
291         catch (java.lang.reflect.InvocationTargetException JavaDoc ite)
292         {
293             Throwable JavaDoc t = ite.getTargetException();
294             if (t instanceof javax.management.AttributeNotFoundException JavaDoc)
295             {
296                 throw (javax.management.AttributeNotFoundException JavaDoc) t;
297             }
298             if (t instanceof javax.management.InvalidAttributeValueException JavaDoc)
299             {
300                 throw (javax.management.InvalidAttributeValueException JavaDoc) t;
301             }
302             else if (t instanceof Exception JavaDoc)
303             {
304                 throw new MBeanException JavaDoc((Exception JavaDoc) t);
305             }
306             else //if an error
307
{
308                 //Do what?
309
}
310         }
311         catch (IllegalAccessException JavaDoc iae)
312         {
313             throw new ReflectionException JavaDoc(iae);
314         }
315         catch (Exception JavaDoc e)
316         {
317             throw new MBeanException JavaDoc(e);
318         }
319     }
320     
321     public void unregisterMBean(ObjectName JavaDoc objectName)
322         throws InstanceNotFoundException JavaDoc, MBeanRegistrationException JavaDoc
323     {
324         if (! mMBeanRepository.contains(objectName))
325         {
326             throw new InstanceNotFoundException JavaDoc(objectName.toString());
327         }
328         mMBeanRepository.remove(objectName);
329     }
330     
331     public Integer JavaDoc getMBeanCount()
332     {
333         return ( new Integer JavaDoc(mMBeanRepository.getTotalCount()) );
334     }
335     
336     /**
337      * Note: Currently the QueryExp is being ignored.
338     */

339     public Set JavaDoc queryMBeans(ObjectName JavaDoc name, QueryExp JavaDoc exp)
340     {
341         Set JavaDoc mbeans = new HashSet JavaDoc();
342         /*
343         if (! name.getDomain().equals(kAllMBeansPattern) )
344         {
345             String msg = localStrings.getString( "admin.server.core.jmx.yet_to_implement" );
346             throw new RuntimeException( msg );
347         }
348         mbeans = mMBeanRepository.getAllMBeans();
349         */

350         mbeans = mMBeanRepository.query(name);
351         return ( mbeans );
352     }
353     
354     public MBeanInfo JavaDoc getMBeanInfo(ObjectName JavaDoc objName) throws
355         InstanceNotFoundException JavaDoc, IntrospectionException JavaDoc, ReflectionException JavaDoc
356     {
357         MBeanInfo JavaDoc info = null;
358         
359         if (! kDynamicMBeansOnly)
360         {
361             String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.assert" );
362             throw new IntrospectionException JavaDoc( msg );
363         }
364         try
365         {
366             String JavaDoc operationName = kGetMBeanInfoMethodName;
367             String JavaDoc[] signature = null;
368             Object JavaDoc[] params = null;
369             info = (MBeanInfo JavaDoc) this.invoke(objName, operationName, params, signature);
370         }
371         catch(MBeanException JavaDoc e)
372         {
373             throw new IntrospectionException JavaDoc(e.getMessage());
374         }
375         
376         return ( info );
377     }
378
379     public boolean isRegistered(ObjectName JavaDoc name)
380     {
381         return mMBeanRepository.contains(name);
382     }
383
384     public void addNotificationListener(ObjectName JavaDoc objectName,
385         NotificationListener JavaDoc notificationListener,
386         NotificationFilter JavaDoc notificationFilter, Object JavaDoc obj)
387         throws InstanceNotFoundException JavaDoc
388     {
389         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_addnotificationlistener" );
390         throw new UnsupportedOperationException JavaDoc( msg );
391     }
392
393     public void addNotificationListener (ObjectName JavaDoc objectName,
394         ObjectName JavaDoc objectName1, NotificationFilter JavaDoc notificationFilter,
395         Object JavaDoc obj) throws InstanceNotFoundException JavaDoc
396     {
397         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_addnotificationlistener" );
398         throw new UnsupportedOperationException JavaDoc( msg );
399     }
400
401     public ObjectInstance JavaDoc createMBean (String JavaDoc str, ObjectName JavaDoc objectName)
402         throws ReflectionException JavaDoc, InstanceAlreadyExistsException JavaDoc,
403         MBeanRegistrationException JavaDoc, MBeanException JavaDoc,
404         NotCompliantMBeanException JavaDoc
405     {
406         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_creatembean" );
407         throw new UnsupportedOperationException JavaDoc( msg );
408     }
409
410     public ObjectInstance JavaDoc createMBean (String JavaDoc str, ObjectName JavaDoc objectName,
411         ObjectName JavaDoc objectName2) throws ReflectionException JavaDoc,
412         InstanceAlreadyExistsException JavaDoc, MBeanRegistrationException JavaDoc, javax.management.MBeanException JavaDoc, javax.management.NotCompliantMBeanException JavaDoc, javax.management.InstanceNotFoundException JavaDoc
413     {
414         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_creatembean" );
415         throw new UnsupportedOperationException JavaDoc( msg );
416     }
417
418     public ObjectInstance JavaDoc createMBean (String JavaDoc str, ObjectName JavaDoc objectName,
419         Object JavaDoc[] obj, String JavaDoc[] str3)
420         throws ReflectionException JavaDoc, InstanceAlreadyExistsException JavaDoc,
421         MBeanRegistrationException JavaDoc, MBeanException JavaDoc, NotCompliantMBeanException JavaDoc
422     {
423         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_creatembean" );
424         throw new UnsupportedOperationException JavaDoc( msg );
425     }
426
427     public ObjectInstance JavaDoc createMBean (String JavaDoc str, ObjectName JavaDoc objectName,
428         ObjectName JavaDoc objectName2, Object JavaDoc[] obj, String JavaDoc[] str4)
429         throws ReflectionException JavaDoc, InstanceAlreadyExistsException JavaDoc,
430         MBeanRegistrationException JavaDoc, MBeanException JavaDoc,
431         NotCompliantMBeanException JavaDoc, InstanceNotFoundException JavaDoc
432     {
433         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_creatembean" );
434         throw new UnsupportedOperationException JavaDoc( msg );
435     }
436
437     public ObjectInputStream JavaDoc deserialize (String JavaDoc str, byte[] values)
438         throws OperationsException JavaDoc, ReflectionException JavaDoc
439     {
440         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_deserialize" );
441         throw new UnsupportedOperationException JavaDoc( msg );
442     }
443
444     public ObjectInputStream JavaDoc deserialize (ObjectName JavaDoc objectName, byte[] values)
445         throws InstanceNotFoundException JavaDoc, OperationsException JavaDoc
446     {
447         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_deserialize" );
448         throw new UnsupportedOperationException JavaDoc( msg );
449     }
450
451     public ObjectInputStream JavaDoc deserialize (String JavaDoc str, ObjectName JavaDoc objectName,
452         byte[] values) throws InstanceNotFoundException JavaDoc, OperationsException JavaDoc,
453         ReflectionException JavaDoc
454     {
455         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_deserialize" );
456         throw new UnsupportedOperationException JavaDoc( msg );
457     }
458
459     public AttributeList JavaDoc getAttributes(ObjectName JavaDoc objectName, String JavaDoc[] attrNames)
460         throws InstanceNotFoundException JavaDoc, ReflectionException JavaDoc //, RuntimeOperationsException
461
{
462         //Debug.println("*MBeanServerImpl.getAttributes");
463
Object JavaDoc implObject = mMBeanRepository.find(objectName);
464         if (implObject == null )
465         {
466             throw new InstanceNotFoundException JavaDoc(objectName.toString());
467         }
468         Class JavaDoc implClass = implObject.getClass();
469         AttributeList JavaDoc list = new AttributeList JavaDoc();
470         try
471         {
472             MBeanIntrospector introspector = new MBeanIntrospector(implClass);
473             if (introspector.isDynamicMBean())
474             {
475                 Method JavaDoc method = introspector.getMethod("getAttributes",
476                                     new String JavaDoc[] {"[Ljava.lang.String;"});
477                 list = (AttributeList JavaDoc)introspector.invokeMethodOn(method, implObject,
478                                                  new Object JavaDoc[] {attrNames});
479             }
480         }
481         catch (javax.management.NotCompliantMBeanException JavaDoc e)
482         {
483             /*
484              * This check is not necessary as a noncompliant mbean should not
485              * be allowed to register by the MBeanServer.
486              */

487         }
488         catch (java.lang.ClassNotFoundException JavaDoc cnfe)
489         {
490             throw new javax.management.ReflectionException JavaDoc(cnfe);
491         }
492         catch (java.lang.NoSuchMethodException JavaDoc nsme)
493         {
494             throw new javax.management.ReflectionException JavaDoc(nsme);
495         }
496         catch (java.lang.SecurityException JavaDoc se)
497         {
498             throw new javax.management.ReflectionException JavaDoc(se);
499         }
500         catch (java.lang.IllegalAccessException JavaDoc iae)
501         {
502             throw new javax.management.ReflectionException JavaDoc(iae);
503 // throw new javax.management.RuntimeOperationsException(iae);
504
}
505         catch (java.lang.reflect.InvocationTargetException JavaDoc ite)
506         {
507             Throwable JavaDoc t = ite.getTargetException();
508             String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.getattributes_error_from_mbean", t.getMessage() );
509             throw new RuntimeException JavaDoc( msg );
510         }
511         return list;
512
513     }
514
515     public String JavaDoc getDefaultDomain ()
516     {
517         return ( ServiceName.DOMAIN );
518     }
519
520     public ObjectInstance JavaDoc getObjectInstance (ObjectName JavaDoc objectName)
521         throws InstanceNotFoundException JavaDoc
522     {
523         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_getobjectinstance" );
524         throw new UnsupportedOperationException JavaDoc( msg );
525     }
526
527     public Object JavaDoc instantiate (String JavaDoc str) throws ReflectionException JavaDoc,
528         MBeanException JavaDoc
529     {
530         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_instantiate" );
531         throw new UnsupportedOperationException JavaDoc( msg );
532     }
533
534     public Object JavaDoc instantiate (String JavaDoc str, ObjectName JavaDoc objectName)
535         throws ReflectionException JavaDoc, MBeanException JavaDoc, InstanceNotFoundException JavaDoc
536     {
537         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_instantiate" );
538         throw new UnsupportedOperationException JavaDoc( msg );
539     }
540
541     public Object JavaDoc instantiate (String JavaDoc str, Object JavaDoc[] obj, String JavaDoc[] str2)
542         throws ReflectionException JavaDoc, MBeanException JavaDoc
543     {
544         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_instantiate" );
545         throw new UnsupportedOperationException JavaDoc( msg );
546     }
547
548     public Object JavaDoc instantiate (String JavaDoc str, ObjectName JavaDoc objectName,
549         Object JavaDoc[] obj, String JavaDoc[] str3)
550         throws ReflectionException JavaDoc, MBeanException JavaDoc, InstanceNotFoundException JavaDoc
551     {
552         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_instantiate" );
553         throw new UnsupportedOperationException JavaDoc( msg );
554     }
555
556     public boolean isInstanceOf (ObjectName JavaDoc objectName, String JavaDoc str)
557     throws InstanceNotFoundException JavaDoc
558     {
559         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_isinstanceof" );
560         throw new UnsupportedOperationException JavaDoc( msg );
561     }
562
563     public Set JavaDoc queryNames (ObjectName JavaDoc objectName, QueryExp JavaDoc queryExp)
564     {
565         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_querynames" );
566         throw new UnsupportedOperationException JavaDoc( msg );
567     }
568
569     public void removeNotificationListener (ObjectName JavaDoc objectName, ObjectName JavaDoc objectName1)
570         throws InstanceNotFoundException JavaDoc, ListenerNotFoundException JavaDoc
571     {
572         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_removenotificationlistener" );
573         throw new UnsupportedOperationException JavaDoc( msg );
574     }
575
576     public void removeNotificationListener (ObjectName JavaDoc objectName,
577         NotificationListener JavaDoc notificationListener)
578         throws InstanceNotFoundException JavaDoc, ListenerNotFoundException JavaDoc
579     {
580         String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.mbeanserver_removenotificationlistener" );
581         throw new UnsupportedOperationException JavaDoc( msg );
582     }
583
584     public AttributeList JavaDoc setAttributes (ObjectName JavaDoc objectName, AttributeList JavaDoc attributeList)
585         throws InstanceNotFoundException JavaDoc, ReflectionException JavaDoc //, RuntimeOperationsException
586
{
587         //Debug.println("*MBeanServerImpl.setAttributes");
588
Object JavaDoc implObject = mMBeanRepository.find(objectName);
589         if (implObject == null )
590         {
591             throw new InstanceNotFoundException JavaDoc(objectName.toString());
592         }
593         Class JavaDoc implClass = implObject.getClass();
594         AttributeList JavaDoc list = new AttributeList JavaDoc();
595         try
596         {
597             MBeanIntrospector introspector = new MBeanIntrospector(implClass);
598             if (introspector.isDynamicMBean())
599             {
600                 Method JavaDoc method = introspector.getMethod("setAttributes",
601                                     new String JavaDoc[] {list.getClass().getName()});
602                 list = (AttributeList JavaDoc)introspector.invokeMethodOn(method, implObject,
603                                                  new Object JavaDoc[] {attributeList});
604             }
605         }
606         catch (javax.management.NotCompliantMBeanException JavaDoc e)
607         {
608             /*
609              * This check is not necessary as a noncompliant mbean should not
610              * be allowed to register by the MBeanServer.
611              */

612         }
613         catch (java.lang.ClassNotFoundException JavaDoc cnfe)
614         {
615             throw new javax.management.ReflectionException JavaDoc(cnfe);
616         }
617         catch (java.lang.NoSuchMethodException JavaDoc nsme)
618         {
619             throw new javax.management.ReflectionException JavaDoc(nsme);
620         }
621         catch (java.lang.SecurityException JavaDoc se)
622         {
623             throw new javax.management.ReflectionException JavaDoc(se);
624         }
625         catch (java.lang.IllegalAccessException JavaDoc iae)
626         {
627             throw new javax.management.ReflectionException JavaDoc(iae);
628 // throw new javax.management.RuntimeOperationsException(iae);
629
}
630         catch (java.lang.reflect.InvocationTargetException JavaDoc ite)
631         {
632             Throwable JavaDoc t = ite.getTargetException();
633             String JavaDoc msg = localStrings.getString( "admin.server.core.jmx.setattributes_error_from_mbean", t.getMessage() );
634             throw new RuntimeException JavaDoc( msg );
635         }
636         return list;
637
638     }
639
640     /*New JMX 1.2 MBeanServer Interface Methods - not supported. */
641     public String JavaDoc[] getDomains() {
642         final String JavaDoc msg = "getDomains";
643
644         throw new UnsupportedOperationException JavaDoc(msg);
645     }
646     
647     public void removeNotificationListener(ObjectName JavaDoc name,
648             ObjectName JavaDoc listener, NotificationFilter JavaDoc filter, Object JavaDoc handback) {
649         final String JavaDoc msg = "removeNotificationListener";
650
651         throw new UnsupportedOperationException JavaDoc(msg);
652     }
653
654     public void removeNotificationListener(ObjectName JavaDoc name,
655             NotificationListener JavaDoc listener, NotificationFilter JavaDoc filter,
656             Object JavaDoc handback) {
657         final String JavaDoc msg = "removeNotificationListener";
658
659         throw new UnsupportedOperationException JavaDoc(msg);
660     }
661     
662     public ClassLoader JavaDoc getClassLoaderFor(ObjectName JavaDoc oName) {
663         final String JavaDoc msg = "getClassLoaderFor";
664
665         throw new UnsupportedOperationException JavaDoc(msg);
666     }
667
668     public ClassLoader JavaDoc getClassLoader(ObjectName JavaDoc oName) {
669         final String JavaDoc msg = "getClassLoader";
670
671         throw new UnsupportedOperationException JavaDoc(msg);
672     }
673     
674     public javax.management.loading.ClassLoaderRepository JavaDoc getClassLoaderRepository() {
675         final String JavaDoc msg = "getClassLoaderRepository";
676
677         throw new UnsupportedOperationException JavaDoc(msg);
678     }
679             
680     /*New JMX 1.2 MBeanServer Interface Methods - not supported. */
681 }
682
Popular Tags