KickJava   Java API By Example, From Geeks To Geeks.

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


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  * $Header: /cvs/glassfish/admin-core/mbeanapi/src/java/com/sun/appserv/management/util/jmx/JMXConnectorConnectionSource.java,v 1.3 2005/12/25 03:51:22 tcfujii Exp $
26  * $Revision: 1.3 $
27  * $Date: 2005/12/25 03:51:22 $
28  */

29
30 package com.sun.appserv.management.util.jmx;
31
32 import java.io.IOException JavaDoc;
33
34 import javax.management.MBeanServer JavaDoc;
35 import javax.management.MBeanServerConnection JavaDoc;
36 import javax.management.remote.JMXConnector JavaDoc;
37
38 import com.sun.appserv.management.client.ConnectionSource;
39
40
41 /**
42     A ConnectionSource for in-process access where the MBeanServer is actually
43     known and where later access to it may be desired.
44  */

45 public final class JMXConnectorConnectionSource
46     implements ConnectionSource
47 {
48     protected JMXConnector JavaDoc mJMXConnector;
49     
50         public
51     JMXConnectorConnectionSource( final JMXConnector JavaDoc connector )
52         throws IOException JavaDoc
53     {
54         if ( connector == null )
55         {
56             throw new IllegalArgumentException JavaDoc();
57         }
58         
59         mJMXConnector = connector;
60         
61         // make sure it's good, now
62
getMBeanServerConnection( false );
63     }
64     
65     
66     
67         public MBeanServerConnection JavaDoc
68     getExistingMBeanServerConnection( )
69     {
70         try
71         {
72             return( mJMXConnector.getMBeanServerConnection() );
73         }
74         catch( IOException JavaDoc e )
75         {
76         }
77         return( null );
78     }
79     
80         public MBeanServerConnection JavaDoc
81     getMBeanServerConnection( boolean forceNew )
82         throws IOException JavaDoc
83     {
84         return( mJMXConnector.getMBeanServerConnection() );
85     }
86     
87     /**
88         @return the existing JMXConnector
89      */

90         public JMXConnector JavaDoc
91     getJMXConnector( final boolean forceNew )
92         throws IOException JavaDoc
93     {
94         // all we have is what is already present; no way to create a new one
95
return( mJMXConnector );
96     }
97 }
98
Popular Tags