com.maverick.ssh2
Class AbstractComponentFactory

java.lang.Object
  extended bycom.maverick.ssh2.AbstractComponentFactory

public abstract class AbstractComponentFactory
extends java.lang.Object

An abstract utility class used to store the available transport components and provide delimited listing as required in the key exchange initialization process.

Author:
Lee David Painter

Field Summary
protected  java.util.Hashtable supported
          The supported components stored in a Hashtable with a String key as the component name such as "3des-cbc" and a Class value storing the implementation class.
 
Constructor Summary
AbstractComponentFactory(java.lang.Class type)
          Create a component factory with the base class supplied.
 
Method Summary
 void add(java.lang.String name, java.lang.Class cls)
          Add a new component type to the factory.
 void clear()
          Clear all of the entries in this component factory.
 boolean contains(java.lang.String name)
          Determine whether the factory supports a given component type.
protected abstract  java.lang.Object createInstance(java.lang.String name, java.lang.Class cls)
          Overide this method to create an instance of the component.
 java.lang.Object getInstance(java.lang.String name)
          Get a new instance of a supported component.
 java.lang.String list(java.lang.String preferred)
          List the types of components supported by this factory.
 void remove(java.lang.String name)
          Remove a supported component
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

supported

protected java.util.Hashtable supported
The supported components stored in a Hashtable with a String key as the component name such as "3des-cbc" and a Class value storing the implementation class.

Constructor Detail

AbstractComponentFactory

public AbstractComponentFactory(java.lang.Class type)
Create a component factory with the base class supplied.

Parameters:
type -
Throws:
java.lang.ClassNotFoundException - Thrown if the class cannot be resolved.
Method Detail

contains

public boolean contains(java.lang.String name)
Determine whether the factory supports a given component type.

Parameters:
name -
Returns:
true if the component is supported otherwise false

list

public java.lang.String list(java.lang.String preferred)
List the types of components supported by this factory. Returns the list as a comma delimited string with the preferred value as the first entry in the list. If the preferred value is "" then the list is returned unorded.

Parameters:
preferred - The preferred component type.
Returns:
A comma delimited String of component types; for example "3des-cbc,blowfish-cbc"

add

public void add(java.lang.String name,
                java.lang.Class cls)
Add a new component type to the factory. This method throws an exception if the class cannot be resolved. The name of the component IS NOT verified to allow component implementations to be overriden.

Parameters:
name -
cls -
Throws:
java.lang.ClassNotFoundException

getInstance

public java.lang.Object getInstance(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Get a new instance of a supported component.

Parameters:
name - The name of the component; for example "3des-cbc"
Returns:
the newly instantiated object
Throws:
java.lang.ClassNotFoundException

createInstance

protected abstract java.lang.Object createInstance(java.lang.String name,
                                                   java.lang.Class cls)
                                            throws java.lang.Throwable
Overide this method to create an instance of the component.

Parameters:
cls -
Returns:
the newly instantiated object
Throws:
java.lang.Throwable

remove

public void remove(java.lang.String name)
Remove a supported component

Parameters:
name -

clear

public void clear()
Clear all of the entries in this component factory.



Copyright © 2003 3SP LTD. All Rights Reserved.