org.radrails.server.core
Class Server

java.lang.Object
  extended byjava.util.Observable
      extended byorg.radrails.server.core.Server
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
WEBrickServer

public abstract class Server
extends java.util.Observable
implements java.io.Serializable

This class represents a web server that is capable of running Rails applications. It is an observable object, and is observed by the ServersView class. Instead of traditional setXXX methods, updateXXX methods are provided. These update methods will set the attribute and then notify all observers of the change. Subclasses must implement the start and stop methods. Subclasses should also create static factory methods to create instances of themselves, such as createMyServer.

Author:
mkent
See Also:
Serialized Form

Method Summary
 java.lang.String getEnvironment()
           
 java.lang.String getName()
           
 java.lang.String getPort()
           
 java.io.File getProject()
           
 java.lang.String getStatus()
           
 java.lang.String getType()
           
 boolean isStarted()
           
 boolean isStopped()
           
abstract  void start()
          Starts the server.
abstract  void stop()
          Stops the server.
 void touch()
          Sets the changed flag.
 void updateEnvironment(java.lang.String environment)
          Sets the environment of the server and notifies observers of the change.
 void updateName(java.lang.String name)
          Sets the name of the server and notifies observers of the change.
 void updatePort(java.lang.String port)
          Sets the port number of the server and notifies observers of the change.
 void updateStatus(java.lang.String status)
          Sets the status of the server and notifies observers of the change.
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getProject

public java.io.File getProject()
Returns:
the location of the project the server is associated with

getName

public java.lang.String getName()
Returns:
the name of the server

getPort

public java.lang.String getPort()
Returns:
the port number that the server is available on

getType

public java.lang.String getType()
Returns:
the type of the server

getEnvironment

public java.lang.String getEnvironment()
Returns:
the runtime environment of the server

getStatus

public java.lang.String getStatus()
Returns:
the status of the server

updatePort

public void updatePort(java.lang.String port)
Sets the port number of the server and notifies observers of the change.

Parameters:
port - the number of the port the server operates on

updateName

public void updateName(java.lang.String name)
Sets the name of the server and notifies observers of the change.

Parameters:
name - the name of the server

updateEnvironment

public void updateEnvironment(java.lang.String environment)
Sets the environment of the server and notifies observers of the change. Use ENV_XXX

Parameters:
environment - the environment of the server

updateStatus

public void updateStatus(java.lang.String status)
Sets the status of the server and notifies observers of the change. Use IServerConstants.STARTED or IServerConstants.STOPPED

Parameters:
status - the status of the server

touch

public void touch()
Sets the changed flag. Clients should call this method before calling the notifyObservers() method explicitly.


isStarted

public boolean isStarted()
Returns:
true if the server's status is IServerConstants.STARTED, false otherwise.

isStopped

public boolean isStopped()
Returns:
true if the server's status is IServerConstants.STOPPED, false otherwise.

start

public abstract void start()
Starts the server. Subclass implementations must call setChanged and notifyObservers after the server is started. Pass {IServerConstants.UPDATE as the second argument to notifyObservers.


stop

public abstract void stop()
Stops the server. Subclass implementations must call setChanged and notifyObservers after the server is started. Pass IServerConstants.UPDATE as the second argument to notifyObservers.