// Path: src/main/java/org/jminix/server/RmiServerConnectionProvider.java
// public class RmiServerConnectionProvider extends AbstractMapServerConnectionProvider {
// 
// 	private String serviceUrl;
// 	
// 	private String username;
// 	
// 	private String password;
// 
//     private Map<String, JMXConnector> jmxcs = new HashMap<String, JMXConnector>();
// 
// 	/**
// 	 * Not explicitly documented.
// 	 * @see org.jminix.server.ServerConnectionProvider#getConnectionKeys()
// 	 */
// 	public List<String> getConnectionKeys() {
// 		String[] parts = serviceUrl.split("/");
// 		return Arrays.asList(new String[] { parts[parts.length-1] });		
// 	}
// 
// 	/**
// 	 * Not explicitly documented.
// 	 * @see org.jminix.server.ServerConnectionProvider#getConnection(java.lang.String)
// 	 */
// 	public MBeanServerConnection getConnection(String name) {
// 
// 		JMXServiceURL url;
// 		try {
// 			url = new JMXServiceURL(serviceUrl);
// 
// 			JMXConnector jmxc = jmxcs.get(serviceUrl);
// 
// 			if(jmxc == null) {
// 				if (username != null && password != null) {
// 					String[] creds = {username, password};
// 					Map<String, Object> env = new HashMap<String, Object>();
// 					env.put(JMXConnector.CREDENTIALS, creds);
// 					jmxc = JMXConnectorFactory.connect(url, env);
// 				} else {
// 					jmxc = JMXConnectorFactory.connect(url, null);
// 				}
// 				jmxcs.put(serviceUrl, jmxc);
// 			} else {
// 				jmxc.connect();
// 			}
// 			return jmxc.getMBeanServerConnection();
// 		} catch (MalformedURLException e) {
// 			throw new RuntimeException(e);
// 		} catch (IOException e) {
// 			throw new RuntimeException(e);
// 		}
// 	} 
// 
// 	/**
// 	 * Sets the attribute serviceUrl.
// 	 * @param serviceUrl The serviceUrl to set.
// 	 */
// 	public void setServiceUrl(String serviceUrl) {
// 		this.serviceUrl = serviceUrl;
// 	}
// 
// 	/**
// 	 * Sets the attribute username.
// 	 * @param username The username to set.
// 	 */
// 	public void setUsername(String username) {
// 		this.username = username;
// 	}
// 
// 	/**
// 	 * Sets the attribute password.
// 	 * @param password The password to set.
// 	 */
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// 
// }
// 
// Path: src/main/java/org/jminix/server/ServerConnectionProvider.java
// public interface ServerConnectionProvider
// {
//     /**
//      * List of connections. The clients are not intended to cache them, but query them before each use.
//      * The ordering is guaranteed to be unchanged over time (e.g. after reboot).
//      * 
//      * @return the list of connections. 
//      */
//     public List<MBeanServerConnection> getConnections();
// 
// 	/**
// 	 * @return the names of connections. They can be simple numeric identifiers. They are guarantee not to change over
// 	 *         time (e.g. after reboot), though.
// 	 */
//     public List<String> getConnectionKeys();
//     
//     /**
//      * Return a connection by name.
//      * 
//      * @param name key as returned by {@link #getConnectionKeys()}.
//      * @return the connection or null if not found.
//      */
//     public MBeanServerConnection getConnection(String name);
// }


import org.jminix.server.CredentialsHolder;
import org.jminix.server.RmiServerConnectionProvider;
import org.jminix.server.ServerConnectionProvider;
/* 
 * ------------------------------------------------------------------------------------------------
 * Copyright 2011 by Swiss Post, Information Technology Services
 * ------------------------------------------------------------------------------------------------
 * $Id$
 * ------------------------------------------------------------------------------------------------
 *
 */
package org.jminix.server.cluster;


/**
 * A cluster manager managing {{@link RmiServerConnectionProvider} instances. Default registry port is 1099.
 *
 * @author bovetl
 * @version $Revision$
 * @see <script>links('$HeadURL$');</script>
 */
public class RmiClusterManager extends ClusterManager {

	private CredentialsHolder credentials;
	
	public RmiClusterManager() {
		setUrlPattern("service:jmx:rmi://{0}/jndi/rmi://{0}:{1,number,#}/rmi");
		setPort(1099);
	}
	
	/**
	 * Not explicitly documented.
	 * @see org.jminix.server.cluster.ClusterManager#createNodeProvider(org.jminix.server.cluster.ClusterManager.Node)
	 */
	@Override
// Path: src/main/java/org/jminix/server/RmiServerConnectionProvider.java
// public class RmiServerConnectionProvider extends AbstractMapServerConnectionProvider {
// 
// 	private String serviceUrl;
// 	
// 	private String username;
// 	
// 	private String password;
// 
//     private Map<String, JMXConnector> jmxcs = new HashMap<String, JMXConnector>();
// 
// 	/**
// 	 * Not explicitly documented.
// 	 * @see org.jminix.server.ServerConnectionProvider#getConnectionKeys()
// 	 */
// 	public List<String> getConnectionKeys() {
// 		String[] parts = serviceUrl.split("/");
// 		return Arrays.asList(new String[] { parts[parts.length-1] });		
// 	}
// 
// 	/**
// 	 * Not explicitly documented.
// 	 * @see org.jminix.server.ServerConnectionProvider#getConnection(java.lang.String)
// 	 */
// 	public MBeanServerConnection getConnection(String name) {
// 
// 		JMXServiceURL url;
// 		try {
// 			url = new JMXServiceURL(serviceUrl);
// 
// 			JMXConnector jmxc = jmxcs.get(serviceUrl);
// 
// 			if(jmxc == null) {
// 				if (username != null && password != null) {
// 					String[] creds = {username, password};
// 					Map<String, Object> env = new HashMap<String, Object>();
// 					env.put(JMXConnector.CREDENTIALS, creds);
// 					jmxc = JMXConnectorFactory.connect(url, env);
// 				} else {
// 					jmxc = JMXConnectorFactory.connect(url, null);
// 				}
// 				jmxcs.put(serviceUrl, jmxc);
// 			} else {
// 				jmxc.connect();
// 			}
// 			return jmxc.getMBeanServerConnection();
// 		} catch (MalformedURLException e) {
// 			throw new RuntimeException(e);
// 		} catch (IOException e) {
// 			throw new RuntimeException(e);
// 		}
// 	} 
// 
// 	/**
// 	 * Sets the attribute serviceUrl.
// 	 * @param serviceUrl The serviceUrl to set.
// 	 */
// 	public void setServiceUrl(String serviceUrl) {
// 		this.serviceUrl = serviceUrl;
// 	}
// 
// 	/**
// 	 * Sets the attribute username.
// 	 * @param username The username to set.
// 	 */
// 	public void setUsername(String username) {
// 		this.username = username;
// 	}
// 
// 	/**
// 	 * Sets the attribute password.
// 	 * @param password The password to set.
// 	 */
// 	public void setPassword(String password) {
// 		this.password = password;
// 	}
// 
// }
// 
// Path: src/main/java/org/jminix/server/ServerConnectionProvider.java
// public interface ServerConnectionProvider
// {
//     /**
//      * List of connections. The clients are not intended to cache them, but query them before each use.
//      * The ordering is guaranteed to be unchanged over time (e.g. after reboot).
//      * 
//      * @return the list of connections. 
//      */
//     public List<MBeanServerConnection> getConnections();
// 
// 	/**
// 	 * @return the names of connections. They can be simple numeric identifiers. They are guarantee not to change over
// 	 *         time (e.g. after reboot), though.
// 	 */
//     public List<String> getConnectionKeys();
//     
//     /**
//      * Return a connection by name.
//      * 
//      * @param name key as returned by {@link #getConnectionKeys()}.
//      * @return the connection or null if not found.
//      */
//     public MBeanServerConnection getConnection(String name);
// }


// Path: src/main/java/org/jminix/server/cluster/RmiClusterManager.java
import org.jminix.server.CredentialsHolder;
import org.jminix.server.RmiServerConnectionProvider;
import org.jminix.server.ServerConnectionProvider;

/* 
 * ------------------------------------------------------------------------------------------------
 * Copyright 2011 by Swiss Post, Information Technology Services
 * ------------------------------------------------------------------------------------------------
 * $Id$
 * ------------------------------------------------------------------------------------------------
 *
 */
package org.jminix.server.cluster;


/**
 * A cluster manager managing {{@link RmiServerConnectionProvider} instances. Default registry port is 1099.
 *
 * @author bovetl
 * @version $Revision$
 * @see <script>links('$HeadURL$');</script>
 */
public class RmiClusterManager extends ClusterManager {

	private CredentialsHolder credentials;
	
	public RmiClusterManager() {
		setUrlPattern("service:jmx:rmi://{0}/jndi/rmi://{0}:{1,number,#}/rmi");
		setPort(1099);
	}
	
	/**
	 * Not explicitly documented.
	 * @see org.jminix.server.cluster.ClusterManager#createNodeProvider(org.jminix.server.cluster.ClusterManager.Node)
	 */
	@Override
	protected ServerConnectionProvider createNodeProvider(Node node) {