planet.generic.commonapi.factory
Class NetworkFactoryImpl

java.lang.Object
  extended byplanet.generic.commonapi.factory.NetworkFactoryImpl
All Implemented Interfaces:
NetworkFactory

public class NetworkFactoryImpl
extends java.lang.Object
implements NetworkFactory

This class allows the ability of build networks of different topologies, size and Nodes. This implementation offers network building with:

  1. Any topology specified at planet.generic.commonapi.factory.Topology class.
  2. Any positive network size [0..INTEGER_MAX].
  3. Any current and future node implementation.

Author:
Jordi Pujol 07-jul-2005

Field Summary
protected  java.lang.Class network
          The default Class reference for the current Network implementation.
protected  int networkSize
          The default network size to use for build a network.
protected  NodeFactory nodeFactory
          The default NodeFactory.
protected  java.lang.String topology
          The default topology to use for build a network.
 
Constructor Summary
NetworkFactoryImpl()
          Builds a NetworkFactoryImpl instance.
 
Method Summary
protected  Network _buildNetwork(int size, NodeFactory nodeFactory, java.lang.String topology)
          Builds a network with the specified parameters.
 Network buildNetwork()
          Builds a network with the actual specified properties.
 Network buildNetwork(int size)
          Builds a network with the actual specified properties, but overwriting the number of nodes to build within.
 Network buildNetwork(int size, NodeFactory nodeFactory)
          Builds a new network with the specified size and this concrete nodeFactory.
 Network buildNetwork(int size, NodeFactory nodeFactory, java.lang.String topology)
          Builds a new network with the specified size, this concrete nodeFactory and network topology.
 Network buildNetwork(int size, java.lang.String topology)
          Builds a network with the specified size for the network, building it under this concrete topology.
 NetworkFactory setValues(java.lang.Class network, int size, NodeFactory nodeFactory, java.lang.String topology)
          Sets the initial values for the NetworkFactory instance with the specified values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

network

protected java.lang.Class network
The default Class reference for the current Network implementation.


nodeFactory

protected NodeFactory nodeFactory
The default NodeFactory.


networkSize

protected int networkSize
The default network size to use for build a network.


topology

protected java.lang.String topology
The default topology to use for build a network.

Constructor Detail

NetworkFactoryImpl

public NetworkFactoryImpl()
Builds a NetworkFactoryImpl instance. Does nothing. Requires the setValues(...) invokation to set the initial values.

Method Detail

setValues

public NetworkFactory setValues(java.lang.Class network,
                                int size,
                                NodeFactory nodeFactory,
                                java.lang.String topology)
                         throws InitializationException
Sets the initial values for the NetworkFactory instance with the specified values.

Specified by:
setValues in interface NetworkFactory
Parameters:
network - The Class reference for the current Network implementation.
size - Desired network size.
nodeFactory - The NodeFactory implementation to be used.
topology - Desired network topology.
Returns:
The same instance once it has been updated.
Throws:
InitializationException - if any error occurs during the initialization process.
See Also:
NetworkFactory.setValues(java.lang.Class, int, planet.commonapi.factory.NodeFactory, java.lang.String)

buildNetwork

public Network buildNetwork()
                     throws InitializationException
Builds a network with the actual specified properties. It is, NodeFactory, size of network, number of bits and topology.

Specified by:
buildNetwork in interface NetworkFactory
Returns:
A network with the specified number of Nodes.
Throws:
InitializationException - if occurs any problem during the process to build the network.
See Also:
NetworkFactory.buildNetwork()

buildNetwork

public Network buildNetwork(int size)
                     throws InitializationException
Builds a network with the actual specified properties, but overwriting the number of nodes to build within.

Specified by:
buildNetwork in interface NetworkFactory
Parameters:
size - The number of Nodes for the new Network
Returns:
A network with the specified size of Nodes.
Throws:
InitializationException - if occurs any problem during the process to build the network.
See Also:
NetworkFactory.buildNetwork(int)

buildNetwork

public Network buildNetwork(int size,
                            java.lang.String topology)
                     throws InitializationException
Builds a network with the specified size for the network, building it under this concrete topology. The rest of properties are used the actually ones in use.

Specified by:
buildNetwork in interface NetworkFactory
Parameters:
size - The number of Nodes for the new Network
topology - The network topology to constructs new network.
Returns:
A network with the specified size of Nodes.
Throws:
InitializationException - if occurs any problem during the process to build the network.
See Also:
NetworkFactory.buildNetwork(int, java.lang.String)

buildNetwork

public Network buildNetwork(int size,
                            NodeFactory nodeFactory)
                     throws InitializationException
Builds a new network with the specified size and this concrete nodeFactory. The rest of properties are used the actually ones in use.

Specified by:
buildNetwork in interface NetworkFactory
Parameters:
size - The number of Nodes for the new Network
nodeFactory - The NodeFactory to use to build Nodes for the new network.
Returns:
A network with the specified size of Nodes.
Throws:
InitializationException - if occurs any problem during the process to build the network.
See Also:
NetworkFactory.buildNetwork(int, planet.commonapi.factory.NodeFactory)

buildNetwork

public Network buildNetwork(int size,
                            NodeFactory nodeFactory,
                            java.lang.String topology)
                     throws InitializationException
Builds a new network with the specified size, this concrete nodeFactory and network topology. The rest of properties are used the actually ones in use.

Specified by:
buildNetwork in interface NetworkFactory
Parameters:
size - The number of Nodes for the new Network
nodeFactory - The NodeFactory to use to build Nodes for the new network.
topology - The network topology to constructs new network.
Returns:
A network with the specified size of Nodes.
Throws:
InitializationException - if occurs any problem during the process to build the network.
See Also:
NetworkFactory.buildNetwork(int, planet.commonapi.factory.NodeFactory, java.lang.String)

_buildNetwork

protected Network _buildNetwork(int size,
                                NodeFactory nodeFactory,
                                java.lang.String topology)
                         throws InitializationException
Builds a network with the specified parameters. If the topology is Topology.SERIALIZED, it loads the network state from the a file, found in Properties.SERIALIZATION_INPUT_FILE.

Parameters:
size - Number of nodes to build under in the network.
nodeFactory - NodeFactory to use to build new Nodes.
topology - Topology of the new network.
Returns:
An instance of a Network. This network is a deserialized Network if topology is a Topology.SERIALIZED, o a new instance in other case, with those parameters.
Throws:
InitializationException - if occurs any problem during the initialization process.
See Also:
Topology, Properties