KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > cli > jmx > spi > JMXMPDefaultConnectorProvider


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-cli/cli-api/src/java/com/sun/cli/jmx/spi/JMXMPDefaultConnectorProvider.java,v 1.3 2005/12/25 03:45:42 tcfujii Exp $
26  * $Revision: 1.3 $
27  * $Date: 2005/12/25 03:45:42 $
28  */

29  
30 package com.sun.cli.jmx.spi;
31
32 import javax.management.remote.JMXConnector JavaDoc;
33 import javax.management.remote.JMXServiceURL JavaDoc;
34 import javax.management.remote.JMXConnectorFactory JavaDoc;
35
36 public final class JMXMPDefaultConnectorProvider
37     implements JMXConnectorProvider
38 {
39         public
40     JMXMPDefaultConnectorProvider()
41     {
42     }
43     
44     static class Info implements JMXConnectorProviderInfo
45     {
46         private static final String JavaDoc DESCRIPTION =
47             "Implements the standard JSR 160 connector.";
48         private static final String JavaDoc USAGE =
49             "connect --host <host> --port port --protocol jmxmp " +
50             "[--user <user> --password <pass>] [connection-name]";
51         
52             public String JavaDoc
53         getDescription()
54         {
55             return( DESCRIPTION );
56         }
57             public String JavaDoc
58         getUsage()
59         {
60             return( USAGE );
61         }
62     }
63     
64         public static JMXConnectorProviderInfo
65     getInfo()
66     {
67         return( new Info() );
68     }
69         
70     
71         public JMXConnector JavaDoc
72     connect( java.util.Map JavaDoc m )
73         throws java.io.IOException JavaDoc
74     {
75         final String JavaDoc host = (String JavaDoc)m.get( HOST );
76         final String JavaDoc port = (String JavaDoc)m.get( PORT );
77         
78         final String JavaDoc urlString = "service:jmx:jmxmp://" + host + ":" + port;
79         final JMXServiceURL JavaDoc url = new JMXServiceURL JavaDoc( urlString );
80         
81         final JMXConnector JavaDoc conn = JMXConnectorFactory.connect( url );
82         
83         return( conn );
84     }
85     
86     public final static String JavaDoc MY_PROTOCOL = "jmxmp";
87     
88         public boolean
89     isSupported( java.util.Map JavaDoc m )
90     {
91         boolean supports = false;
92         
93         final String JavaDoc protocol = (String JavaDoc)m.get( PROTOCOL );
94         if ( MY_PROTOCOL.equals( protocol ) )
95         {
96             supports = m.get( HOST ) != null && m.get( PORT ) != null;
97         }
98         return( supports );
99     }
100 }
101
102
103
104
105
Popular Tags