edu.UCL.satin.arch.components
Class Component

java.lang.Object
  extended byedu.UCL.satin.arch.components.Component
All Implemented Interfaces:
ComponentFacet, Facet
Direct Known Subclasses:
AdvertisingServer, CentralAdvertising, Debug, Discovery, Reflective, Registrar, RemoteComponent, SimpleLocalHost

public abstract class Component
extends java.lang.Object
implements ComponentFacet

The SATIN component generalisation

Author:
Stefanos Zachariadis

Field Summary
protected  boolean immutable
           
protected  java.util.Hashtable properties
           
 
Fields inherited from interface edu.UCL.satin.arch.facets.ComponentFacet
DISABLED, ENABLED
 
Constructor Summary
Component(java.lang.Object id)
          Creates a new changeable component
Component(java.lang.Object id, boolean immutable, java.util.Hashtable properties)
          Creates a new component with the given identifier.
 
Method Summary
 boolean addAttribute(GenericAttribute attr)
          Adds a new attribute to this component if it is not immutable
 boolean construct()
          The component constructor.
 void destroy()
          Destroys the component.
 GenericAttribute getAttribute(java.lang.Object key)
          Returns the attribute matching the given key.
 java.util.Hashtable getProperties()
          Returns a hashtable of all component attributes
 boolean hasAttribute(java.lang.Object id)
          Checks whether this component has the given attribute
 boolean isEnabled()
          Returns whether this component is enabled/active or not.
 boolean match(java.util.Hashtable properties)
          Checks whether this component satisfies the attributes given
 void setEnabled(boolean enabled)
          Activates or deactivates this component (if applicable).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

properties

protected java.util.Hashtable properties

immutable

protected final boolean immutable
Constructor Detail

Component

public Component(java.lang.Object id)
Creates a new changeable component

Parameters:
id - the identifier of the component

Component

public Component(java.lang.Object id,
                 boolean immutable,
                 java.util.Hashtable properties)
Creates a new component with the given identifier.

Parameters:
id - the identifier of the component
immutable - whether or not the component is immutable. An immutable component cannot be reflective and cannot have any new attributes.
properties - the properties of this component
Method Detail

getAttribute

public GenericAttribute getAttribute(java.lang.Object key)
Returns the attribute matching the given key.

Specified by:
getAttribute in interface ComponentFacet
Parameters:
key - The key of the attribute
Returns:
The attribute matching this key, or null otherwise

hasAttribute

public boolean hasAttribute(java.lang.Object id)
Checks whether this component has the given attribute

Specified by:
hasAttribute in interface ComponentFacet
Parameters:
id - The key of the attribute to check
Returns:
true if the attribute exists, or false otherwise

getProperties

public java.util.Hashtable getProperties()
Returns a hashtable of all component attributes

Specified by:
getProperties in interface ComponentFacet
Returns:
all this component's attributes.

addAttribute

public boolean addAttribute(GenericAttribute attr)
Adds a new attribute to this component if it is not immutable

Specified by:
addAttribute in interface ComponentFacet
Parameters:
attr - The attribute to add
Returns:
true if the operation succeded or false if an attribute with the same key exists or the component is immutable.

toString

public java.lang.String toString()

isEnabled

public boolean isEnabled()
Returns whether this component is enabled/active or not. Note that unless overloaded, the component is assumed to always be enabled

Specified by:
isEnabled in interface ComponentFacet
Returns:

setEnabled

public void setEnabled(boolean enabled)
Activates or deactivates this component (if applicable). Note that unless overloaded, the component is assumed to always be enabled.

Specified by:
setEnabled in interface ComponentFacet
Parameters:
enabled -

match

public boolean match(java.util.Hashtable properties)
Checks whether this component satisfies the attributes given

Returns:
True if the component matches or false otherwise.

construct

public boolean construct()
Description copied from interface: ComponentFacet
The component constructor. This is where the component should obtain any references to other components/resources it needs.

Specified by:
construct in interface ComponentFacet
Returns:
true of the constrution was succesful, or false otherwise.

destroy

public void destroy()
Description copied from interface: ComponentFacet
Destroys the component. Done before removal. This is supposed to free up any resources etc that this component uses.

Specified by:
destroy in interface ComponentFacet