planet.generic.commonapi.factory
Class NodeHandleFactoryImpl

java.lang.Object
  extended by planet.generic.commonapi.factory.NodeHandleFactoryImpl
All Implemented Interfaces:
java.io.Serializable, NodeHandleFactory

public class NodeHandleFactoryImpl
extends java.lang.Object
implements NodeHandleFactory

This is a specific implementation of NodeHandleFactory that permits build any class of NodeHandle with any type of Id. It is possible by identifies this parameter in properties file:

  1. DEFAULT_NODEHANDLECLASS: Class which identifies the NodeHandle to build.
It can be modified too by invoking method to this class. In any case, the properties file only can be modified by programmer.

IMPORTANT: The concrete implementation of NodeHandle must have one constructor:
  1. The constructor with the related Node Id in its first parameter, and a boolean to show if the Node is alive, at the sencod argument.
    1. Author:
      Jordi Pujol Date: 13/05/04
      See Also:
      Serialized Form

      Constructor Summary
      NodeHandleFactoryImpl(java.lang.Class nodeHandleClass)
                Initializes a new instance of NodeHandleFactory with the nodeHandleClass specified by parameter.
      NodeHandleFactoryImpl(java.lang.String propertiesFile)
                This constructor reads the properties' file and initializes the Class for new NodeHandles.
       
      Method Summary
       NodeHandle buildNodeHandle(Id id, boolean alive)
                Builds a NodeHandle with the actual implementation class of NodeHandle and specifieds id and alive flag.
       java.lang.Class getNodeHandleClass()
                Gets the actual class of implementation of NodeHandle returned by this factory.
       void setNodeHandleClass(java.lang.Class nodeHandleClass)
                Sets the class of an implementation of NodeHandle to return by this factory in the future.
       
      Methods inherited from class java.lang.Object
      clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
       

      Constructor Detail

      NodeHandleFactoryImpl

      public NodeHandleFactoryImpl(java.lang.String propertiesFile)
                            throws InitializationException
      This constructor reads the properties' file and initializes the Class for new NodeHandles. If occur any problem with this initialization, throws a InitializationException exception with short description for the problem.

      Parameters:
      propertiesFile - File of properties with the DEFAULT_NODEHANDLECLASS property.
      Throws:
      InitializationException - If occur any problem during initialization steps.

      NodeHandleFactoryImpl

      public NodeHandleFactoryImpl(java.lang.Class nodeHandleClass)
                            throws InitializationException
      Initializes a new instance of NodeHandleFactory with the nodeHandleClass specified by parameter. If exists any problem with this class an exception is thrown with a short description for the problem.

      Parameters:
      nodeHandleClass - Class for new NodeHandles.
      Throws:
      InitializationException - If exists any problem with initialization of class.
      See Also:
      Id
      Method Detail

      buildNodeHandle

      public NodeHandle buildNodeHandle(Id id,
                                        boolean alive)
                                 throws InitializationException
      Builds a NodeHandle with the actual implementation class of NodeHandle and specifieds id and alive flag.

      Specified by:
      buildNodeHandle in interface NodeHandleFactory
      Parameters:
      id - Id of the related Node, to assign to the new instance of NodeNandle.
      alive - true if the related Node is alive. false in other case.
      Returns:
      An instance of actual implementation class of NodeHandle.
      Throws:
      InitializationException
      See Also:
      NodeHandleFactory.buildNodeHandle(planet.commonapi.Id, boolean), Id

      getNodeHandleClass

      public java.lang.Class getNodeHandleClass()
      Gets the actual class of implementation of NodeHandle returned by this factory.

      Specified by:
      getNodeHandleClass in interface NodeHandleFactory
      Returns:
      The actual class of implementation of NodeHandle.
      See Also:
      NodeHandleFactory.getNodeHandleClass()

      setNodeHandleClass

      public void setNodeHandleClass(java.lang.Class nodeHandleClass)
                              throws InitializationException
      Sets the class of an implementation of NodeHandle to return by this factory in the future.

      Specified by:
      setNodeHandleClass in interface NodeHandleFactory
      Parameters:
      nodeHandleClass - Class of an implementation of NodeHandle to return by this factory.
      Throws:
      InitializationException
      See Also:
      NodeHandleFactory.setNodeHandleClass(java.lang.Class)