org/objectweb/proactive/jmx/client/ClientConnector.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.jmx.client;
00032 
00033 import java.io.IOException;
00034 import java.io.Serializable;
00035 import java.net.MalformedURLException;
00036 
00037 import javax.management.remote.JMXConnector;
00038 import javax.management.remote.JMXConnectorFactory;
00039 import javax.management.remote.JMXServiceURL;
00040 
00041 import org.objectweb.proactive.jmx.ProActiveConnection;
00042 import org.objectweb.proactive.jmx.ProActiveJMXConstants;
00043 
00044 
00050 public class ClientConnector implements Serializable{
00051 
00052         private static final long serialVersionUID = 7966471528807607476L;
00053         private ProActiveConnection connection;
00054     private JMXConnector connector;
00055     private String url;
00056 
00061     public ClientConnector(String url) {
00062         this.url = url;
00063         connect();
00064     }
00065 
00066     /*
00067      *  Connect to the ProActive Connector
00068      */
00069     private void connect() {
00070         try {
00071             /*  build the jmx Url */
00072             this.url = "service:jmx:proactive://" + this.url +
00073                 ProActiveJMXConstants.SERVER_REGISTERED_NAME;
00074             JMXServiceURL jmxUrl = new JMXServiceURL(url);
00075             /* connect to the connector server  */
00076             this.connector = JMXConnectorFactory.connect(jmxUrl,
00077                     ProActiveJMXConstants.PROACTIVE_JMX_ENV);
00078             /* retrieve the ProActive Connection that will enable the remote calls onto the remote MBean server */
00079             this.connection = (ProActiveConnection) this.connector.getMBeanServerConnection();
00080         } catch (MalformedURLException e) {
00081             e.printStackTrace();
00082         } catch (IOException e) {
00083             e.printStackTrace();
00084         }
00085     }
00086 
00091     public ProActiveConnection getConnection() {
00092         return this.connection;
00093     }
00094 
00099     public JMXConnector getConnector() {
00100         return this.connector;
00101     }
00102 }

Generated on Mon Jan 22 15:16:11 2007 for ProActive by  doxygen 1.5.1