KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > jmx > AppServerMBeanServerBuilder


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

23
24 /*
25  * MBeanServerBuilder.java
26  *
27  * Created on January 26, 2003, 12:14 PM
28  */

29
30 package com.sun.enterprise.admin.jmx;
31
32 import javax.management.MBeanServer JavaDoc;
33 import javax.management.MBeanServerDelegate JavaDoc;
34 import com.sun.jmx.mbeanserver.JmxMBeanServer;
35 import com.sun.jmx.interceptor.ForwardingMBeanServerInterceptor;
36
37 /**
38  *
39  * @author sridatta
40  */

41 public class AppServerMBeanServerBuilder extends javax.management.MBeanServerBuilder JavaDoc {
42     
43     /** Creates a new instance of MBeanServerBuilder */
44     public AppServerMBeanServerBuilder() {
45     }
46     
47     /**
48     This method creates a new MBeanServerDelegate for a new MBeanServer.
49      When creating a new MBeanServer the MBeanServerFactory first calls
50      this method in order to create a new MBeanServerDelegate.
51      Then it calls newMBeanServer(defaultDomain,outer,delegate) passing the delegate
52      that should be used by the MBeanServer implementation.
53      Note that the passed delegate might not be directly the MBeanServerDelegate that
54      was returned by this method. It could be, for instance, a new object wrapping
55      the previously returned object.
56
57      */

58     
59      public MBeanServer JavaDoc newMBeanServer(String JavaDoc defaultDomain,
60                                     MBeanServer JavaDoc outer,
61                                     MBeanServerDelegate JavaDoc delegate) {
62          JmxMBeanServer jmxMBS = (JmxMBeanServer)JmxMBeanServer.newMBeanServer(defaultDomain,outer,delegate,
63                          true);
64          ForwardingMBeanServerInterceptor appServerInterceptor =
65                                     new AppServerMBeanServerInterceptor();
66          try {
67             appServerInterceptor.insertFirst(jmxMBS);
68          } catch(Exception JavaDoc e) {
69             e.printStackTrace();
70          }
71          return jmxMBS;
72      }
73        
74      /**
75       This method creates a new MBeanServer implementation object. When creating a new
76       MBeanServer the MBeanServerFactory first calls newMBeanServerDelegate() in
77       order to obtain a new MBeanServerDelegate for the new MBeanServer. Then it
78       calls newMBeanServer(defaultDomain,outer,delegate) passing the delegate that
79       should be used by the MBeanServer implementation.
80       Note that the passed delegate might not be directly the MBeanServerDelegate that
81       was returned by this implementation. It could be, for instance, a new object
82       wrapping the previously returned delegate.
83
84       The outer parameter is a pointer to the MBeanServer that should be passed
85       to the MBeanRegistration interface when registering MBeans inside the
86       MBeanServer. If outer is null, then the MBeanServer implementation must
87       use its own this reference when invoking the MBeanRegistration interface.
88
89       This makes it possible for a MBeanServer implementation to wrap another MBeanServer
90       implementation, in order to implement, e.g, security checks, or to prevent
91       access to the actual MBeanServer implementation by returning a pointer to a wrapping object.
92
93         Parameters:
94         defaultDomain - Default domain of the new MBeanServer.
95         outer - A pointer to the MBeanServer object that must be passed to the MBeans when invoking their MBeanRegistration interface.
96         delegate - A pointer to the MBeanServerDelegate associated with the new MBeanServer. The new MBeanServer must register this MBean in its MBean repository.
97         Returns:
98         A new private implementation of an MBeanServer.
99       
100       */

101     public MBeanServerDelegate JavaDoc newMBeanServerDelegate() {
102         return JmxMBeanServer.newMBeanServerDelegate();
103      }
104 }
105
Popular Tags