KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > container > jmx > ExoContainerMBean


1 /*****************************************************************************
2  * Copyright (C) NanoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Original code by James Strachan *
9  *****************************************************************************/

10 package org.exoplatform.container.jmx;
11
12 import java.lang.reflect.Method JavaDoc;
13 import java.lang.reflect.Modifier JavaDoc;
14 import java.util.ArrayList JavaDoc;
15 import java.util.Collection JavaDoc;
16 import javax.management.MBeanAttributeInfo JavaDoc;
17 import javax.management.MBeanOperationInfo JavaDoc;
18 import mx4j.AbstractDynamicMBean;
19
20 /**
21  * @author James Strachan
22  * @version $Revision: 1.7 $
23  */

24 public class ExoContainerMBean extends AbstractDynamicMBean {
25
26   public ExoContainerMBean(Object JavaDoc componentInstance) {
27     setResource(componentInstance);
28   }
29
30   /* Method of the second group that is overridden */
31   protected String JavaDoc getMBeanDescription() {
32     return "Dynamic mbean wrapper for instance : " + getResource().toString();
33   }
34
35   protected MBeanAttributeInfo JavaDoc[] createMBeanAttributeInfo() {
36     return super.createMBeanAttributeInfo();
37   }
38
39   protected MBeanOperationInfo JavaDoc[] createMBeanOperationInfo() {
40     Method JavaDoc[] methodArray = getResource().getClass().getDeclaredMethods();
41     Collection JavaDoc cToReturn = new ArrayList JavaDoc();
42     for (int i = 0; i < methodArray.length; i++) {
43       Method JavaDoc method = methodArray[i];
44       if(Modifier.isPublic(method.getModifiers())) {
45         MBeanOperationInfo JavaDoc operationInfo = new MBeanOperationInfo JavaDoc(method.getName(), method) ;
46         cToReturn.add(operationInfo );
47       }
48     }
49     return (MBeanOperationInfo JavaDoc[]) cToReturn.toArray(new MBeanOperationInfo JavaDoc[cToReturn.size()]);
50   }
51 }
52
Popular Tags