com.maverick.ssh.components
Class ComponentFactory<T extends SshComponent>

java.lang.Object
  extended by com.maverick.ssh.components.ComponentFactory<T>
All Implemented Interfaces:
java.lang.Cloneable

public class ComponentFactory<T extends SshComponent>
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<java.lang.String> order
           
protected  java.util.Hashtable<java.lang.String,java.lang.Class<T>> 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()
           
 
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  T createInstance(java.lang.String name)
          Override this method to create an instance of the component.
 java.lang.String createNewOrdering(int[] ordering)
           
 T 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
 void removeAllBut(java.lang.String names)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

supported

protected java.util.Hashtable<java.lang.String,java.lang.Class<T extends SshComponent>> 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<java.lang.String> order
Constructor Detail

ComponentFactory

public ComponentFactory()
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 T 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 T createInstance(java.lang.String name)
                                         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 -

removeAllBut

public void removeAllBut(java.lang.String names)

clear

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


clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object


Copyright © 2012. All Rights Reserved.