configuration
Class SimpleConfigurator

java.lang.Object
  |
  +--configuration.SimpleConfigurator

public class SimpleConfigurator
extends java.lang.Object
implements ComponentConfigurator

A class representing the dependencies between Java Objects. It implements the ComponentConfigurator interface. For more information on the ComponentConfigurator concept and ideas related to it, visit the ComponentConfigurator pages.

See Also:
ComponentConfigurator, DependencySpecification

Field Summary
protected  java.util.Vector clientVector_
          A vector containing the clients for this component.
protected  java.util.Vector hookVector_
          A vector containing the hooks for this component.
protected  java.lang.Object implementation_
          The Java object implementating this component.
protected  java.lang.String info_
          Information string about this component.
protected  java.lang.String name_
          The name of this component.
 
Constructor Summary
SimpleConfigurator(java.lang.String name, java.lang.Object implementation)
          Creates a new configurator for the given object.
 
Method Summary
 void addHook(java.lang.String hookName, DependencyAttributes attributes)
          Adds a hook to the configurator.
 void deleteHook(java.lang.String hookName)
          Deletes a hook from the configurator.
 void destroyComponentConfigurator()
          Deletes the references to all internal data structures.
 void eventOnClient(ComponentConfigurator client, ComponentEvent e)
          This implementation simply prints the event to the standard output.
 void eventOnHookedComponent(ComponentConfigurator hookedComponent, ComponentEvent e)
          This implementation simply prints the event to the standard output.
 ComponentConfigurator getHookedComponent(java.lang.String hookName)
          Provides a reference to the component attached to the given hook.
 void hook(java.lang.String hookName, ComponentConfigurator cc)
          Attaches a ComponentConfigurator to the given hook.
 void hook(java.lang.String hookName, ComponentConfigurator cc, DependencyAttributes attributes)
          Attaches a ComponentConfigurator to the given hook changing the attributes associated with the hook.
 java.lang.Object implementation()
          Accessor for getting the component implementation.
 void implementation(java.lang.Object implementation)
          Sets the component implementation.
 java.lang.String info()
          Accessor for the component information string.
 void info(java.lang.String s)
          Sets the information string for this component.
 java.util.Vector listClients()
          Provides a list of the clients of this component.
 java.util.Vector listHooks()
          Provides a list of the hooks in this component.
 java.lang.String name()
          Accessor for the component name.
 void name(java.lang.String s)
          Sets the name of this component.
 int numberOfClients()
           
 void printClients(java.io.PrintStream out)
          Dumps information about the clients of this Component to an output stream.
 void printHooks(java.io.PrintStream out)
          Dumps information about the hooks of this Configurator to an output stream.
 void registerClient(ComponentConfigurator client, java.lang.String hookNameInClient, DependencyAttributes attributes)
          Adds a new component to the list of clients.
 void unhook(java.lang.String hookName)
          Detaches a ComponentConfigurator from the given hook.
 void unregisterClient(ComponentConfigurator client, java.lang.String hookNameInClient)
          Removes a pair (client, hook) from the list of clients.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

implementation_

protected java.lang.Object implementation_
The Java object implementating this component.

hookVector_

protected java.util.Vector hookVector_
A vector containing the hooks for this component.

clientVector_

protected java.util.Vector clientVector_
A vector containing the clients for this component.

name_

protected java.lang.String name_
The name of this component.

info_

protected java.lang.String info_
Information string about this component.
Constructor Detail

SimpleConfigurator

public SimpleConfigurator(java.lang.String name,
                          java.lang.Object implementation)
Creates a new configurator for the given object.
Parameters:
implementation - the object implementation.
See Also:
Object
Method Detail

destroyComponentConfigurator

public void destroyComponentConfigurator()
Deletes the references to all internal data structures.
Specified by:
destroyComponentConfigurator in interface ComponentConfigurator

addHook

public void addHook(java.lang.String hookName,
                    DependencyAttributes attributes)
             throws ElementExists
Adds a hook to the configurator.
Specified by:
addHook in interface ComponentConfigurator
Parameters:
hookName - the name of the hook to be added.
attributes - a vector of attributes (may be null).
Throws:
ElementExists - if the hook already exists.

deleteHook

public void deleteHook(java.lang.String hookName)
                throws NotFound
Deletes a hook from the configurator.
Specified by:
deleteHook in interface ComponentConfigurator
Parameters:
hookName - the name of the hook to be deleted.
Throws:
NotFound - if the hook is not found.

hook

public void hook(java.lang.String hookName,
                 ComponentConfigurator cc,
                 DependencyAttributes attributes)
          throws HookBusy,
                 NotFound
Attaches a ComponentConfigurator to the given hook changing the attributes associated with the hook.
Specified by:
hook in interface ComponentConfigurator
Parameters:
hookName - the name of the hook.
cc - the ComponentConfigurator to be attached to the hook.
attributes - a vector of attributes (may be null).
Throws:
HookBusy - if there is already a component attached to the hook.
NotFound - if the hook does not exist.

hook

public void hook(java.lang.String hookName,
                 ComponentConfigurator cc)
          throws HookBusy,
                 NotFound
Attaches a ComponentConfigurator to the given hook. It does not change the attributes associated with this hook.
Specified by:
hook in interface ComponentConfigurator
Parameters:
hookName - the name of the hook.
cc - the ComponentConfigurator to be attached to the hook.
Throws:
HookBusy - if there is already a component attached to the hook.
NotFound - if the hook does not exist.

unhook

public void unhook(java.lang.String hookName)
            throws HookVacant,
                   NotFound
Detaches a ComponentConfigurator from the given hook.
Specified by:
unhook in interface ComponentConfigurator
Parameters:
hookName - the name of the hook.
cc - the ComponentConfigurator to be detached.
Throws:
HookVacant - if there are no components attached to the hook.
NotFound - if the hook does not exist.

registerClient

public void registerClient(ComponentConfigurator client,
                           java.lang.String hookNameInClient,
                           DependencyAttributes attributes)
                    throws ElementExists
Adds a new component to the list of clients.
Specified by:
registerClient in interface ComponentConfigurator
Parameters:
client - the ComponentConfigurator representing the new client.
hookNameInClient - the name of the hook to which this component is attached.
attributes - a vector of attributes (may be null).
Throws:
ElementExists - if the given pair (client, hookNameInClient) is already present in the client list.

unregisterClient

public void unregisterClient(ComponentConfigurator client,
                             java.lang.String hookNameInClient)
                      throws NotFound
Removes a pair (client, hook) from the list of clients.
Specified by:
unregisterClient in interface ComponentConfigurator
Parameters:
client - the ComponentConfigurator representing the new client.
hookNameInClient - the name of the hook to which this component is attached.
Throws:
NotFound - if the given pair (client, hookNameInClient) is not present in the client list.

eventOnHookedComponent

public void eventOnHookedComponent(ComponentConfigurator hookedComponent,
                                   ComponentEvent e)
This implementation simply prints the event to the standard output.
Specified by:
eventOnHookedComponent in interface ComponentConfigurator
Parameters:
hookedComponent - the ComponentConfigurator that generated the event.
e - the event that was generated.

eventOnClient

public void eventOnClient(ComponentConfigurator client,
                          ComponentEvent e)
This implementation simply prints the event to the standard output.
Specified by:
eventOnClient in interface ComponentConfigurator
Parameters:
client - the ComponentConfigurator that generated the event.
e - the event that was generated.

listHooks

public java.util.Vector listHooks()
Provides a list of the hooks in this component. Note that this implementation trusts its clients because it does not return a copy of the vector, it returns a reference to the vector itself.
Specified by:
listHooks in interface ComponentConfigurator
See Also:
DependencySpecification, Vector

getHookedComponent

public ComponentConfigurator getHookedComponent(java.lang.String hookName)
                                         throws NotFound
Provides a reference to the component attached to the given hook.
Specified by:
getHookedComponent in interface ComponentConfigurator
Returns:
a reference to the ComponentConfigurator.
Throws:
NotFound - if the hook does not exist.

numberOfClients

public int numberOfClients()
Specified by:
numberOfClients in interface ComponentConfigurator
Returns:
the number of clients registered with this component.

listClients

public java.util.Vector listClients()
Provides a list of the clients of this component. Note that this implementation trusts its clients because it does not return a copy of the vector, it returns a reference to the vector itself.
Specified by:
listClients in interface ComponentConfigurator
See Also:
DependencySpecification, Vector

name

public void name(java.lang.String s)
Sets the name of this component.
Specified by:
name in interface ComponentConfigurator

name

public java.lang.String name()
Accessor for the component name.
Specified by:
name in interface ComponentConfigurator
Returns:
a string containing the component name.

info

public void info(java.lang.String s)
Sets the information string for this component.
Specified by:
info in interface ComponentConfigurator

info

public java.lang.String info()
Accessor for the component information string.
Specified by:
info in interface ComponentConfigurator
Returns:
a string containing component information.

implementation

public java.lang.Object implementation()
Accessor for getting the component implementation.
Specified by:
implementation in interface ComponentConfigurator
Returns:
the object implementation.

implementation

public void implementation(java.lang.Object implementation)
Sets the component implementation.
Specified by:
implementation in interface ComponentConfigurator

printHooks

public void printHooks(java.io.PrintStream out)
Dumps information about the hooks of this Configurator to an output stream.
Specified by:
printHooks in interface ComponentConfigurator
Parameters:
out - an output PrintStream in which the information is printed.

printClients

public void printClients(java.io.PrintStream out)
Dumps information about the clients of this Component to an output stream.
Specified by:
printClients in interface ComponentConfigurator
Parameters:
out - an output PrintStream in which the information is printed.