com.maverick.ssh.components
Class ComponentFactory

java.lang.Object
  extended bycom.maverick.ssh.components.ComponentFactory
All Implemented Interfaces:
java.lang.Cloneable

public class ComponentFactory
extends java.lang.Object
implements java.lang.Cloneable

A 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.Vector order
           
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
ComponentFactory(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.
 java.lang.String changePositionofAlgorithm(java.lang.String name, int position)
           
 void clear()
          Clear all of the entries in this component factory.
 java.lang.Object clone()
           
 boolean contains(java.lang.String name)
          Determine whether the factory supports a given component type.
protected  java.lang.Object createInstance(java.lang.String name, java.lang.Class cls)
          Override this method to create an instance of the component.
 java.lang.String createNewOrdering(int[] ordering)
           
 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
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.


order

protected java.util.Vector order
Constructor Detail

ComponentFactory

public ComponentFactory(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

changePositionofAlgorithm

public java.lang.String changePositionofAlgorithm(java.lang.String name,
                                                  int position)
                                           throws SshException
Throws:
SshException

createNewOrdering

public java.lang.String createNewOrdering(int[] ordering)
                                   throws SshException
Throws:
SshException

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 unordered.

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 overridden.

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

getInstance

public java.lang.Object getInstance(java.lang.String name)
                             throws SshException
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
SshException

createInstance

protected java.lang.Object createInstance(java.lang.String name,
                                          java.lang.Class cls)
                                   throws java.lang.Throwable
Override 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.


clone

public java.lang.Object clone()


Copyright © 2003-2008 SSHTools LTD. All Rights Reserved.