jSyncManager Simple Java Server

org.jSyncManager.SJS
Class Server

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by org.jSyncManager.SJS.Server
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, ServerRemoteInterface

public class Server
extends java.rmi.server.UnicastRemoteObject
implements ServerRemoteInterface

The Simple Java Server Internet Server Service. This executable class is used to start the Simple Java Server Internet Server Service. It takes as its sole parameter an XML data file name which it will parse to configure the server. If this parameter is not specified, the name "server.xml" will be assumed.

Version:
0.1
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
Server(java.io.File file)
          Creates a new instance of the Server.
Server(java.lang.String filename)
          Creates a new instance of the Server.
 
Method Summary
 void acceptAllIncomingRequests()
          Causes the server to accept all incoming requests in all services.
 void acceptIncomingRequests(java.net.SocketAddress address)
          A method to accept incoming requests to the specified service.
 void acceptIncomingRequests(java.lang.String serviceName)
          A method to accept incoming requests to the specified service.
 void acceptIncomingRequests(java.lang.String address, int port)
          A method to accept incoming requests to the specified service.
 void createService(java.lang.String name, java.net.SocketAddress address, java.lang.String adapterName)
          Creates the specified service.
 void createService(java.lang.String name, java.lang.String address, int port, java.lang.String adapterName)
          Creates the specified service.
 void denyAllIncomingRequests()
          Causes the server to deny all incoming requests in all services.
 void denyIncomingRequests(java.net.SocketAddress address)
          A method to deny incoming requests to the specified service.
 void denyIncomingRequests(java.lang.String serviceName)
          A method to deny incoming requests to the specified service.
 void denyIncomingRequests(java.lang.String address, int port)
          A method to deny incoming requests to the specified service.
 java.lang.String describeAllServices()
          Describes all the services running on this server.
 java.lang.String describeAllServicesWithParameter(java.lang.String param)
          Describes all the services with the specified parameter running on this server.
 java.lang.String describeService(java.net.SocketAddress address)
          A method to describe the specified service.
 java.lang.String describeService(java.lang.String serviceName)
          A method to describe the specified service.
 java.lang.String describeService(java.lang.String address, int port)
          A method to describe the specified service.
 java.lang.String describeServiceParameter(java.net.SocketAddress address, java.lang.String param)
          A method to describe the specified service parameter.
 java.lang.String describeServiceParameter(java.lang.String address, int port, java.lang.String param)
          A method to describe the specified service parameter.
 java.lang.String describeServiceParameter(java.lang.String serviceName, java.lang.String param)
          A method to describe the specified service parameter.
 java.lang.String getAllStatus()
          Retrieves the status for all services running on this server.
 java.lang.String getStatus(java.net.SocketAddress address)
          A method to query the status of the specified service.
 java.lang.String getStatus(java.lang.String serviceName)
          A method to query the status of the specified service.
 java.lang.String getStatus(java.lang.String address, int port)
          A method to query the status of the specified service.
static void main(java.lang.String[] args)
          The application main entry point.
 void removeAllServices()
          Removes all services from the server.
 void removeParameterInAllServices(java.lang.String param)
          A method to remove the specified parameter from all services.
 void removeService(java.net.SocketAddress address)
          A method to remove the specified service.
 void removeService(java.lang.String serviceName)
          A method to remove the specified service.
 void removeService(java.lang.String address, int port)
          A method to remove the specified service.
 void removeServiceParameter(java.net.SocketAddress address, java.lang.String param)
          A method to remove the specified service.
 void removeServiceParameter(java.lang.String address, int port, java.lang.String param)
          A method to remove the specified service parameter.
 void removeServiceParameter(java.lang.String serviceName, java.lang.String param)
          A method to remove the specified service parameter.
 void setParameterInAllServices(java.lang.String param, java.lang.String value)
          Sets the specified parameter to the specified value in all services running on this system.
 void setServiceParameter(java.net.SocketAddress address, java.lang.String param, java.lang.String value)
          A method to set the specified service parameter.
 void setServiceParameter(java.lang.String address, int port, java.lang.String param, java.lang.String value)
          A method to set the specified service parameter.
 void setServiceParameter(java.lang.String serviceName, java.lang.String param, java.lang.String value)
          A method to set the specified service parameter.
 void shutdownNicely()
          A method to shutdown the entire Internet Service Server as soon as all existing connections have ended.
 void shutdownNow()
          A method to shutdown the entire Internet Service Server.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Server

public Server(java.lang.String filename)
       throws java.lang.Exception
Creates a new instance of the Server.

Parameters:
filename - the path and filename to the XML data to construct this object from.
Throws:
java.lang.Exception - in the event an exception we can't handle is thrown.

Server

public Server(java.io.File file)
       throws java.lang.Exception
Creates a new instance of the Server.

Parameters:
file - the file object of the XML data to construct this object from.
Throws:
java.lang.Exception - in the event an exception we can't handle is thrown.
Method Detail

describeService

public java.lang.String describeService(java.lang.String address,
                                        int port)
                                 throws java.rmi.RemoteException,
                                        java.net.UnknownHostException,
                                        ConnectionManagerNotFoundException
A method to describe the specified service.

Specified by:
describeService in interface ServerRemoteInterface
Parameters:
address - the host name or IP address the service to describe is bound to.
port - the port the service to describe is bound to.
Returns:
a String describing the service requested.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
java.net.UnknownHostException - if the specified hostname is unknown.
ConnectionManagerNotFoundException - if the requested service can't be found.

describeService

public java.lang.String describeService(java.lang.String serviceName)
                                 throws java.rmi.RemoteException,
                                        ConnectionManagerNotFoundException
A method to describe the specified service.

Specified by:
describeService in interface ServerRemoteInterface
Parameters:
serviceName - the service to be described.
Returns:
a String describing the service requested.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

describeService

public java.lang.String describeService(java.net.SocketAddress address)
                                 throws java.rmi.RemoteException,
                                        ConnectionManagerNotFoundException
A method to describe the specified service.

Specified by:
describeService in interface ServerRemoteInterface
Parameters:
address - the SocketAddress of the service to be described.
Returns:
a String describing the service requested.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

describeServiceParameter

public java.lang.String describeServiceParameter(java.lang.String address,
                                                 int port,
                                                 java.lang.String param)
                                          throws java.rmi.RemoteException,
                                                 java.net.UnknownHostException,
                                                 ConnectionManagerNotFoundException
A method to describe the specified service parameter.

Specified by:
describeServiceParameter in interface ServerRemoteInterface
Parameters:
address - the host name or IP address the service to describe is bound to.
port - the port the service to describe is bound to.
param - the name of the parameter to query.
Returns:
a String describing the service parameter requested.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
java.net.UnknownHostException - if the specified hostname is unknown.
ConnectionManagerNotFoundException - if the requested service can't be found.

describeServiceParameter

public java.lang.String describeServiceParameter(java.lang.String serviceName,
                                                 java.lang.String param)
                                          throws java.rmi.RemoteException,
                                                 ConnectionManagerNotFoundException
A method to describe the specified service parameter.

Specified by:
describeServiceParameter in interface ServerRemoteInterface
Parameters:
serviceName - the name of the service to query.
param - the name of the parameter to query.
Returns:
a String describing the service parameter requested.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

describeServiceParameter

public java.lang.String describeServiceParameter(java.net.SocketAddress address,
                                                 java.lang.String param)
                                          throws java.rmi.RemoteException,
                                                 ConnectionManagerNotFoundException
A method to describe the specified service parameter.

Specified by:
describeServiceParameter in interface ServerRemoteInterface
Parameters:
address - the SocketAddress the service to query is bound to.
param - the name of the parameter to query.
Returns:
a String describing the service parameter requested.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

denyIncomingRequests

public void denyIncomingRequests(java.net.SocketAddress address)
                          throws java.rmi.RemoteException,
                                 ConnectionManagerNotFoundException
A method to deny incoming requests to the specified service.

Specified by:
denyIncomingRequests in interface ServerRemoteInterface
Parameters:
address - the SocketAddress the service to query is bound to.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

denyIncomingRequests

public void denyIncomingRequests(java.lang.String serviceName)
                          throws java.rmi.RemoteException,
                                 ConnectionManagerNotFoundException
A method to deny incoming requests to the specified service.

Specified by:
denyIncomingRequests in interface ServerRemoteInterface
Parameters:
serviceName - the name of the service to query.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

acceptIncomingRequests

public void acceptIncomingRequests(java.net.SocketAddress address)
                            throws java.rmi.RemoteException,
                                   ConnectionManagerNotFoundException,
                                   ServiceAlreadyRunningException
A method to accept incoming requests to the specified service.

Specified by:
acceptIncomingRequests in interface ServerRemoteInterface
Parameters:
address - the hostname or IP address of the service to process.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.
ServiceAlreadyRunningException - if the specified service is already running.
java.lang.RuntimeException - exception

acceptIncomingRequests

public void acceptIncomingRequests(java.lang.String serviceName)
                            throws java.rmi.RemoteException,
                                   ConnectionManagerNotFoundException,
                                   ServiceAlreadyRunningException
A method to accept incoming requests to the specified service.

Specified by:
acceptIncomingRequests in interface ServerRemoteInterface
Parameters:
serviceName - the name of the service to process.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.
ServiceAlreadyRunningException - if the specified service is already running.
java.lang.RuntimeException - exception

getStatus

public java.lang.String getStatus(java.net.SocketAddress address)
                           throws java.rmi.RemoteException,
                                  ConnectionManagerNotFoundException
A method to query the status of the specified service.

Specified by:
getStatus in interface ServerRemoteInterface
Parameters:
address - the hostname or IP address of the service to process.
Returns:
the status of the specified service.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

getStatus

public java.lang.String getStatus(java.lang.String serviceName)
                           throws java.rmi.RemoteException,
                                  ConnectionManagerNotFoundException
A method to query the status of the specified service.

Specified by:
getStatus in interface ServerRemoteInterface
Parameters:
serviceName - the name of the service to process.
Returns:
the status of the specified service.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

shutdownNow

public void shutdownNow()
                 throws java.rmi.RemoteException
A method to shutdown the entire Internet Service Server.

Specified by:
shutdownNow in interface ServerRemoteInterface
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.

shutdownNicely

public void shutdownNicely()
                    throws java.rmi.RemoteException
A method to shutdown the entire Internet Service Server as soon as all existing connections have ended.

Specified by:
shutdownNicely in interface ServerRemoteInterface
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.

denyIncomingRequests

public void denyIncomingRequests(java.lang.String address,
                                 int port)
                          throws java.rmi.RemoteException,
                                 java.net.UnknownHostException,
                                 ConnectionManagerNotFoundException
A method to deny incoming requests to the specified service.

Specified by:
denyIncomingRequests in interface ServerRemoteInterface
Parameters:
address - the hostname or IP address of the service to process.
port - the port the service to describe is bound to.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
java.net.UnknownHostException - if the specified hostname is unknown.
ConnectionManagerNotFoundException - if the requested service can't be found.

acceptIncomingRequests

public void acceptIncomingRequests(java.lang.String address,
                                   int port)
                            throws java.rmi.RemoteException,
                                   java.net.UnknownHostException,
                                   ConnectionManagerNotFoundException,
                                   ServiceAlreadyRunningException
A method to accept incoming requests to the specified service.

Specified by:
acceptIncomingRequests in interface ServerRemoteInterface
Parameters:
address - the hostname or IP address of the service to process.
port - the port the service to describe is bound to.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
java.net.UnknownHostException - if the specified hostname is unknown.
ConnectionManagerNotFoundException - if the requested service can't be found.
ServiceAlreadyRunningException - if the specified service is already running.

getStatus

public java.lang.String getStatus(java.lang.String address,
                                  int port)
                           throws java.rmi.RemoteException,
                                  java.net.UnknownHostException,
                                  ConnectionManagerNotFoundException
A method to query the status of the specified service.

Specified by:
getStatus in interface ServerRemoteInterface
Parameters:
address - the name of the service to process.
port - the port the service to describe is bound to.
Returns:
the status of the specified service.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
java.net.UnknownHostException - if the specified hostname is unknown.
ConnectionManagerNotFoundException - if the requested service can't be found.

setServiceParameter

public void setServiceParameter(java.lang.String address,
                                int port,
                                java.lang.String param,
                                java.lang.String value)
                         throws java.rmi.RemoteException,
                                java.net.UnknownHostException,
                                ConnectionManagerNotFoundException
A method to set the specified service parameter.

Specified by:
setServiceParameter in interface ServerRemoteInterface
Parameters:
address - the host name or IP address the service to describe is bound to.
port - the port the service to describe is bound to.
param - the name of the parameter to query.
value - the value to set the parameter to.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
java.net.UnknownHostException - if the specified hostname is unknown.
ConnectionManagerNotFoundException - if the requested service can't be found.

setServiceParameter

public void setServiceParameter(java.lang.String serviceName,
                                java.lang.String param,
                                java.lang.String value)
                         throws java.rmi.RemoteException,
                                ConnectionManagerNotFoundException
A method to set the specified service parameter.

Specified by:
setServiceParameter in interface ServerRemoteInterface
Parameters:
serviceName - the name of the service to query.
param - the name of the parameter to query.
value - the value to set the parameter to.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

setServiceParameter

public void setServiceParameter(java.net.SocketAddress address,
                                java.lang.String param,
                                java.lang.String value)
                         throws java.rmi.RemoteException,
                                ConnectionManagerNotFoundException
A method to set the specified service parameter.

Specified by:
setServiceParameter in interface ServerRemoteInterface
Parameters:
address - the SocketAddress the service to query is bound to.
param - the name of the parameter to query.
value - the value to set the parameter to.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

createService

public void createService(java.lang.String name,
                          java.lang.String address,
                          int port,
                          java.lang.String adapterName)
                   throws java.rmi.RemoteException,
                          java.lang.ClassNotFoundException,
                          java.net.UnknownHostException
Creates the specified service.

Specified by:
createService in interface ServerRemoteInterface
Parameters:
name - the name to assign to the service.
address - the IP address to bind to.
port - the port to listen to.
adapterName - the classname of the adapter to use.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
java.lang.ClassNotFoundException - if the specified adapter cannot be found.
java.net.UnknownHostException - exception

createService

public void createService(java.lang.String name,
                          java.net.SocketAddress address,
                          java.lang.String adapterName)
                   throws java.rmi.RemoteException,
                          java.lang.ClassNotFoundException
Creates the specified service.

Specified by:
createService in interface ServerRemoteInterface
Parameters:
name - the name to assign to the service.
address - the SocketAddress object to bind to.
adapterName - the classname of the adapter to use.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
java.lang.ClassNotFoundException - if the specified adapter cannot be found.

describeAllServices

public java.lang.String describeAllServices()
                                     throws java.rmi.RemoteException
Describes all the services running on this server.

Specified by:
describeAllServices in interface ServerRemoteInterface
Returns:
returned
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.

getAllStatus

public java.lang.String getAllStatus()
                              throws java.rmi.RemoteException
Retrieves the status for all services running on this server.

Specified by:
getAllStatus in interface ServerRemoteInterface
Returns:
returned
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.

describeAllServicesWithParameter

public java.lang.String describeAllServicesWithParameter(java.lang.String param)
                                                  throws java.rmi.RemoteException
Describes all the services with the specified parameter running on this server.

Specified by:
describeAllServicesWithParameter in interface ServerRemoteInterface
Parameters:
param - the name of the parameter to describe.
Returns:
returned
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.

setParameterInAllServices

public void setParameterInAllServices(java.lang.String param,
                                      java.lang.String value)
                               throws java.rmi.RemoteException
Sets the specified parameter to the specified value in all services running on this system.

Specified by:
setParameterInAllServices in interface ServerRemoteInterface
Parameters:
param - the name of the parameter to be set.
value - the value to set the parameter to.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.

denyAllIncomingRequests

public void denyAllIncomingRequests()
                             throws java.rmi.RemoteException
Causes the server to deny all incoming requests in all services.

Specified by:
denyAllIncomingRequests in interface ServerRemoteInterface
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.

acceptAllIncomingRequests

public void acceptAllIncomingRequests()
                               throws java.rmi.RemoteException
Causes the server to accept all incoming requests in all services.

Specified by:
acceptAllIncomingRequests in interface ServerRemoteInterface
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
java.lang.RuntimeException - exception

removeService

public void removeService(java.lang.String address,
                          int port)
                   throws java.rmi.RemoteException,
                          java.net.UnknownHostException,
                          ConnectionManagerNotFoundException
A method to remove the specified service.

Specified by:
removeService in interface ServerRemoteInterface
Parameters:
address - the host name or IP address the service to remove is bound to.
port - the port the service to remove is bound to.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
java.net.UnknownHostException - if the specified hostname is unknown.
ConnectionManagerNotFoundException - if the requested service can't be found.

removeService

public void removeService(java.lang.String serviceName)
                   throws java.rmi.RemoteException,
                          ConnectionManagerNotFoundException
A method to remove the specified service.

Specified by:
removeService in interface ServerRemoteInterface
Parameters:
serviceName - the service to be removed.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

removeService

public void removeService(java.net.SocketAddress address)
                   throws java.rmi.RemoteException,
                          ConnectionManagerNotFoundException
A method to remove the specified service.

Specified by:
removeService in interface ServerRemoteInterface
Parameters:
address - the SocketAddress of the service to be removed.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

removeServiceParameter

public void removeServiceParameter(java.lang.String address,
                                   int port,
                                   java.lang.String param)
                            throws java.rmi.RemoteException,
                                   java.net.UnknownHostException,
                                   ConnectionManagerNotFoundException
A method to remove the specified service parameter.

Specified by:
removeServiceParameter in interface ServerRemoteInterface
Parameters:
address - the host name or IP address the service to remove the parameter from is bound to.
port - the port the service to remove is bound to.
param - parameter value
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
java.net.UnknownHostException - if the specified hostname is unknown.
ConnectionManagerNotFoundException - if the requested service can't be found.

removeServiceParameter

public void removeServiceParameter(java.lang.String serviceName,
                                   java.lang.String param)
                            throws java.rmi.RemoteException,
                                   ConnectionManagerNotFoundException
A method to remove the specified service parameter.

Specified by:
removeServiceParameter in interface ServerRemoteInterface
Parameters:
serviceName - the service to remove the parameter from.
param - parameter value
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

removeServiceParameter

public void removeServiceParameter(java.net.SocketAddress address,
                                   java.lang.String param)
                            throws java.rmi.RemoteException,
                                   ConnectionManagerNotFoundException
A method to remove the specified service.

Specified by:
removeServiceParameter in interface ServerRemoteInterface
Parameters:
address - the SocketAddress of the service to remove the parameter from.
param - parameter value
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.
ConnectionManagerNotFoundException - if the requested service can't be found.

removeAllServices

public void removeAllServices()
                       throws java.rmi.RemoteException
Removes all services from the server.

Specified by:
removeAllServices in interface ServerRemoteInterface
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.

removeParameterInAllServices

public void removeParameterInAllServices(java.lang.String param)
                                  throws java.rmi.RemoteException
A method to remove the specified parameter from all services.

Specified by:
removeParameterInAllServices in interface ServerRemoteInterface
Parameters:
param - the parameter to be removed from all services.
Throws:
java.rmi.RemoteException - if an RMI communication problem is encountered.

main

public static void main(java.lang.String[] args)
The application main entry point.

Parameters:
args - the command-line arguments as passed by the JRE.

jSyncManager Simple Java Server

Copyright (c) 2004 Brad BARCLAY. All Rights Reserved.