org.objectweb.jac.core.dist
Class Distd

java.lang.Object
  |
  +--org.objectweb.jac.core.dist.Distd
Direct Known Subclasses:
RMIDistd

public abstract class Distd
extends Object

Distd is an abstract class for all daemon objects. Its implementation is protocol dependent (eg CORBA or RMI). This is an abstract class that needs to be subclassed (see org.objectweb.jac.dist.rmi.RMIDistd). Daemons hold containers which themselves hold remote objects.

Author:
Lionel Seinturier
See Also:
init(), newContainer(String), newContainer(String,String), run()

Field Summary
protected static Hashtable containers
          Containers hold by the current daemon.
protected static String[] flags
          Registered flags.
static long inputCount
          The number of bytes that have been transmitted to the input of this deamon.
protected static String localContainerName
          Store the local container name.
protected static String[] options
          Registered options.
static long outputCount
          The number of bytes that have been transmitted to the output of this deamon.
static String referenceContainerName
          Store the reference container.
protected static boolean verbose
          verbose tells whether information message should be printed or not
 
Constructor Summary
Distd(String[] args)
          The is the main constructor of Distd.
 
Method Summary
static boolean containsContainer(RemoteContainer container)
          Test whether the daemon contains a given container.
static String getFullHostName(String name)
          Get the full host name from an incomplete host name.
static String getLocalContainerName()
          Get the local container name.
abstract  void init()
          This abstract method initializes the underlying communication protocol.
protected abstract  RemoteContainer newContainer(String name)
          This abstract method creates a new container.
protected abstract  RemoteContainer newContainer(String name, String className)
          This abstract method creates a new container and instantiates a given class.
protected static Hashtable parseArguments(String[] args, String[] flags, String[] options)
          Parse command line arguments composed of flags, options and files.
abstract  void run()
          This abstract method enters the event loop of the underlying communication protocol.
static Hashtable stringArrayToHashtable(String[] strs)
          Store a string array into a hashtable.
protected static void usage()
          Display command line arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outputCount

public static long outputCount
The number of bytes that have been transmitted to the output of this deamon.


inputCount

public static long inputCount
The number of bytes that have been transmitted to the input of this deamon.


referenceContainerName

public static String referenceContainerName
Store the reference container.


localContainerName

protected static String localContainerName
Store the local container name.


flags

protected static final String[] flags
Registered flags.


options

protected static final String[] options
Registered options.


verbose

protected static boolean verbose
verbose tells whether information message should be printed or not


containers

protected static Hashtable containers
Containers hold by the current daemon.

Constructor Detail

Distd

public Distd(String[] args)
The is the main constructor of Distd.

Parameters:
args - command line arguments
Method Detail

stringArrayToHashtable

public static Hashtable stringArrayToHashtable(String[] strs)
Store a string array into a hashtable.

Parameters:
strs - the string array
Returns:
the hashtable

init

public abstract void init()
This abstract method initializes the underlying communication protocol.


newContainer

protected abstract RemoteContainer newContainer(String name)
                                         throws Exception
This abstract method creates a new container.

Parameters:
name - the container name
Returns:
the container reference
Exception

newContainer

protected abstract RemoteContainer newContainer(String name,
                                                String className)
                                         throws Exception
This abstract method creates a new container and instantiates a given class.

Parameters:
name - the container name
className - the name of the class to instantiate
Returns:
the container reference
Exception

run

public abstract void run()
This abstract method enters the event loop of the underlying communication protocol.


getFullHostName

public static String getFullHostName(String name)
Get the full host name from an incomplete host name.

For instance, if the local host name is h1:

Parameters:
name - the incomplete host name
Returns:
the complete host name

getLocalContainerName

public static String getLocalContainerName()
Get the local container name.


usage

protected static void usage()
Display command line arguments.


parseArguments

protected static Hashtable parseArguments(String[] args,
                                          String[] flags,
                                          String[] options)
Parse command line arguments composed of flags, options and files.

Parameters:
args - command line arguments
flags - registered flags (e.g. -verbose, -quiet, etc.)
options - registered options (e.g. -d classes, etc.)
Returns:
a hashtable containing 3 types of entries: one for each flag and option, and one for the files. If an unregistered flag or option is encountered the usage method is called. The value associated to the entries is a empty string for flags, and the option value (e.g. classes/) for options. Files are stored with an entry whose key is "_files", and whose value is an array of strings.

containsContainer

public static boolean containsContainer(RemoteContainer container)
Test whether the daemon contains a given container.

Parameters:
container - the container's name
Returns:
true if the container is contained in the current daemon