verinec.adaptation
Class PropDistFactory

java.lang.Object
  extended by verinec.adaptation.PropDistFactory
All Implemented Interfaces:
IDistributorFactory

public class PropDistFactory
extends Object
implements IDistributorFactory

Creates distributors for given targets, based on the name of the distributor. This factory is configured by a properties file either specified upon instantiation or read from /res/distributormap.properties within the classpath. The file contains a mapping from distributor names (i.e. cp, scp) to fully qualified class names of IDistributor instances.

Version:
$Revision: 824 $
Author:
david.buchmann at unifr.ch

Field Summary
private  Properties map
           
 
Constructor Summary
PropDistFactory()
          Initializes the mapping with the file /res/distributormap.properties.
PropDistFactory(InputStream propertiesFile)
          Initializes the mapping with the stream specified as parameter.
 
Method Summary
 IDistributor createDistributor(Element target)
          Create a distributor suitable for the given target.
protected  void init(InputStream propertiesFile)
          Initialize the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

private Properties map
Constructor Detail

PropDistFactory

public PropDistFactory()
                throws VerinecException
Initializes the mapping with the file /res/distributormap.properties.

Throws:
VerinecException - if the default properties can not be read

PropDistFactory

public PropDistFactory(InputStream propertiesFile)
                throws VerinecException
Initializes the mapping with the stream specified as parameter. If you want it to read a file, you can use new FileInputStream(file) as argument.

Parameters:
propertiesFile - an opened file containing the mapping between distribution names and fully qualified class names.
Throws:
VerinecException - if the properties file can not be read
Method Detail

init

protected void init(InputStream propertiesFile)
             throws VerinecException
Initialize the map.

Parameters:
propertiesFile - file resouce to load mapping from, in the format of java.util.Properties
Throws:
VerinecException - if the inputstream is not a valid properties file.

createDistributor

public IDistributor createDistributor(Element target)
                               throws VerinecException
Create a distributor suitable for the given target.

Reads the class name from the mapping, loads that class and sets the target.

Specified by:
createDistributor in interface IDistributorFactory
Parameters:
target - The tr:target element of the service configuration to be distributed.
Returns:
Instance of the distributor to be used with the configuration data having this target.
Throws:
VerinecException - if no distributor can be found or loading it fails.

Copyright © 2005 Verinec, DIUF