org.radrails.server.core
Class ServerManager

java.lang.Object
  extended byorg.radrails.server.core.ServerManager
All Implemented Interfaces:
java.util.EventListener, org.eclipse.core.resources.IResourceChangeListener, java.io.Serializable

public class ServerManager
extends java.lang.Object
implements java.io.Serializable, org.eclipse.core.resources.IResourceChangeListener

Manages a collection of all servers. Operations on servers should be called through this class, because it notifies any listening views of changes to the server. The ServerManager manages all of the servers in the workspace. It is also the model represented by ServersView. When a new Server has been created, it should be added to ServerManager using addServer method. Similarly, to remove a Server, use the removeServer method. The ServerManager also maintains a list of Observer objects. These are conceptually the observers of the ServerManager, but actually the observers of the Servers maintained by the ServerManager. As such, the addServerObserver and deleteServerObserver methods should be used instead of the addObserver and deleteObserver methods on Server.

Author:
mkent
See Also:
Serialized Form

Method Summary
 void addServer(Server server)
          Adds a Server to the ServerManager.
 void addServerObserver(java.util.Observer ob)
          Adds an Observer to the list of current server observers.
 void deleteServerObserver(java.util.Observer ob)
          Deletes an Observer from the list of current server observers.
static ServerManager getInstance()
           
 java.lang.String getNextAvailablePort()
           
 boolean portInUse(java.lang.String port)
          Determines if the given port is currently in use by a Server.
 boolean projectHasServer(java.lang.String projectName, java.lang.String type)
          Determines if the given project has a Server of the given type.
 void removeServer(Server server)
          Removes a Server from the ServerManager.
 void resourceChanged(org.eclipse.core.resources.IResourceChangeEvent event)
           
static void restore(ServerManager manager)
          Restores the state of the ServerManager.
 void stopAll()
          Convenience method to stop all servers in the ServerManager.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ServerManager getInstance()
Returns:
the singleton instance of ServerManager.

restore

public static void restore(ServerManager manager)
Restores the state of the ServerManager. This method should not be called by clients.

Parameters:
manager - the ServerManager to update from.

stopAll

public void stopAll()
Convenience method to stop all servers in the ServerManager.


getNextAvailablePort

public java.lang.String getNextAvailablePort()
Returns:
the next available server port

portInUse

public boolean portInUse(java.lang.String port)
Determines if the given port is currently in use by a Server.

Parameters:
port - the port to check
Returns:
true if the port is in use, false otherwise

projectHasServer

public boolean projectHasServer(java.lang.String projectName,
                                java.lang.String type)
Determines if the given project has a Server of the given type.

Parameters:
projectName - the name of the Server to check
type - the type of Server to check for
Returns:
true if the project has the Server, false otherwise

addServer

public void addServer(Server server)
Adds a Server to the ServerManager.

Parameters:
server - the Server to add

removeServer

public void removeServer(Server server)
Removes a Server from the ServerManager.

Parameters:
server - the Server to remove

addServerObserver

public void addServerObserver(java.util.Observer ob)
Adds an Observer to the list of current server observers.

Parameters:
ob - the observer to add

deleteServerObserver

public void deleteServerObserver(java.util.Observer ob)
Deletes an Observer from the list of current server observers.

Parameters:
ob - the observer to delete

resourceChanged

public void resourceChanged(org.eclipse.core.resources.IResourceChangeEvent event)
Specified by:
resourceChanged in interface org.eclipse.core.resources.IResourceChangeListener
See Also:
IResourceChangeListener.resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)