|
From: Mike H. <he...@us...> - 2003-09-30 21:21:34
|
Update of /cvsroot/jolo/jolo/src/java/jolo/server/jmx
In directory sc8-pr-cvs1:/tmp/cvs-serv1647
Added Files:
JoloServer.java JoloServerMBean.java
Log Message:
Initial add.
--- NEW FILE: JoloServer.java ---
/*
* Created on Sep 29, 2003
*
* Copyright (c) 2003 Mike Heath
*
*/
package jolo.server.jmx;
/**
* @author heathm
*/
public class JoloServer implements JoloServerMBean {
/** Holds the state of the server. */
private int state;
/** Holds the name of the cluster group. */
private String clusterGroup;
/**
* Creates a new Jolo server MBean.
*
* @see jolo.server.jmx.JoloServerMBean#create()
*/
public void create() throws Exception {
state = STOPPED;
}
/**
* Starts the Jolo server.
*
* This starts the server listening for client connections, processing the game, and participating in a cluster.
*
* @see jolo.server.jmx.JoloServerMBean#start()
*/
public void start() throws Exception {
if (state != STARTING && state != STARTED) {
state = STARTING;
// TODO Add some code to make the server go!
state = STARTED;
}
}
/**
* Stops the Jolo server.
*
* @see jolo.server.jmx.JoloServerMBean#stop()
*/
public void stop() {
if (state != STOPPED && state != STOPPING) {
state = STOPPING;
// TODO Add code to stop the server.
state = STOPPED;
}
}
/**
* @see jolo.server.jmx.JoloServerMBean#destroy()
*/
public void destroy() {
// Nothing to destroy.
}
/* (non-Javadoc)
* @see jolo.server.jmx.JoloServerMBean#getClusterGroup()
*/
public String getClusterGroup() {
return clusterGroup;
}
/* (non-Javadoc)
* @see jolo.server.jmx.JoloServerMBean#setClusterGroup(java.lang.String)
*/
public void setClusterGroup(final String clusterGroup) {
stop();
this.clusterGroup = clusterGroup;
try {
start();
} catch (Exception e) {
// If an exception is thrown, pass it back up to the MBean container.
throw new RuntimeException(e);
}
}
}
--- NEW FILE: JoloServerMBean.java ---
/*
* Created on Sep 29, 2003
*
*/
package jolo.server.jmx;
/**
* @author heathm
*/
public interface JoloServerMBean {
public String OBJECT_NAME = "Jolo:service=Server";
public String[] states =
new String[] { "Stopped", "Stopping", "Starting", "Started", "Failed" };
public int STOPPED = 0;
public int STOPPING = 1;
public int STARTING = 2;
public int STARTED = 3;
public int FAILED = 4;
/**
* Method to create this MBean.
*
* @throws Exception Throw Exception to pass any exceptions on to the MBean server.
*/
public void create() throws Exception;
/**
* Method to start this MBean.
*
* @throws Exception Throws Exception to pass any excpetion on to the MBean server.
*/
public void start() throws Exception;
/**
* Method to stop this MBean
*/
public void stop();
/**
* Method to destroy this MBean.
*/
public void destroy();
/**
* Returns the name of the cluster group used by the server. The name of the group is
* what determines what cluster the server belongs to. A unique name can be
* used to place multiple clusters on the same network.
* @return The group name used by the server cluster.
*/
public String getClusterGroup();
public void setClusterGroup(String clusterGroup);
}
|