edu.UCL.satin.impl.container
Class Core

java.lang.Object
  extended byedu.UCL.satin.arch.components.Component
      extended byedu.UCL.satin.arch.components.Reflective
          extended byedu.UCL.satin.arch.components.container.Container
              extended byedu.UCL.satin.impl.container.Core
All Implemented Interfaces:
ComponentFacet, ContainerFacet, DiscoveryFacet, Facet

public class Core
extends Container
implements DiscoveryFacet

The CORE is a container that uses a hashtable to store all components.

Author:
Stefanos Zachariadis

Field Summary
private  Registrar defaultRegistrar
           
private  java.util.Vector listeners
           
private  java.util.Hashtable repo
           
 
Fields inherited from class edu.UCL.satin.arch.components.container.Container
 
Fields inherited from class edu.UCL.satin.arch.components.Reflective
ACCEPT, FAIL, HANDLER_INSTANTIATION, PARTIAL_ACCEPT, REJECT
 
Fields inherited from class edu.UCL.satin.arch.components.Component
immutable, properties
 
Fields inherited from interface edu.UCL.satin.arch.facets.ComponentFacet
DISABLED, ENABLED
 
Constructor Summary
Core()
           
 
Method Summary
 short acceptLMU(LMU lmu)
          Allows the Reflective component to inspect a given LMU and receive parts of it
 void addListener(ComponentListener c)
          Adds a listener that will be notified when any new component is discovered.
 void addListener(ComponentListener c, java.util.Hashtable filter)
          Adds a listener that will be notified when any new component matching the filter given is discovered.
 Component getComponent(java.lang.Object id)
          Returns a component found with the given ID attribute
 Component[] getComponents(java.util.Hashtable properties)
          Returns an array of Components found that match the given property set
 Registrar getDefaultRegistrar()
          Returns the default registrar of the container
 boolean isEnabled()
          Checks whether this component is enabled or not.
 void removeListener(ComponentListener c)
          Removes all instances of the given listener (including any different filters) from the list of listeners to be notified.
 void removeListener(ComponentListener c, java.util.Hashtable filter)
          Removes the particular listener+filter pair from the list of listeners to be notified.
 void setDefaultRegistrar(Registrar registrar)
          Sets the default registrar of the container
 void setEnabled(boolean enabled)
          Enables or disables the component
private static boolean subset(java.util.Hashtable a, java.util.Hashtable b)
          Returns true if a is a subset of b
 
Methods inherited from class edu.UCL.satin.arch.components.container.Container
getContainer
 
Methods inherited from class edu.UCL.satin.arch.components.Component
addAttribute, construct, destroy, getAttribute, getProperties, hasAttribute, match, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.UCL.satin.arch.facets.ComponentFacet
addAttribute, construct, destroy, getAttribute, getProperties, hasAttribute
 

Field Detail

repo

private java.util.Hashtable repo

defaultRegistrar

private Registrar defaultRegistrar

listeners

private java.util.Vector listeners
Constructor Detail

Core

public Core()
Method Detail

setDefaultRegistrar

public void setDefaultRegistrar(Registrar registrar)
Description copied from class: Container
Sets the default registrar of the container

Specified by:
setDefaultRegistrar in interface ContainerFacet
Specified by:
setDefaultRegistrar in class Container
Parameters:
registrar -

getDefaultRegistrar

public Registrar getDefaultRegistrar()
Description copied from class: Container
Returns the default registrar of the container

Specified by:
getDefaultRegistrar in interface ContainerFacet
Specified by:
getDefaultRegistrar in class Container
Returns:
Returns the default registrar of the container

addListener

public void addListener(ComponentListener c)
Description copied from interface: DiscoveryFacet
Adds a listener that will be notified when any new component is discovered.

Specified by:
addListener in interface DiscoveryFacet
Parameters:
c - the listener that will be notified

addListener

public void addListener(ComponentListener c,
                        java.util.Hashtable filter)
Description copied from interface: DiscoveryFacet
Adds a listener that will be notified when any new component matching the filter given is discovered.

Specified by:
addListener in interface DiscoveryFacet
Parameters:
c - the listener to be notified
filter - The filter, as a hashtable of attributes

removeListener

public void removeListener(ComponentListener c)
Description copied from interface: DiscoveryFacet
Removes all instances of the given listener (including any different filters) from the list of listeners to be notified.

Specified by:
removeListener in interface DiscoveryFacet
Parameters:
c - The listener to be removed.

removeListener

public void removeListener(ComponentListener c,
                           java.util.Hashtable filter)
Description copied from interface: DiscoveryFacet
Removes the particular listener+filter pair from the list of listeners to be notified.

Specified by:
removeListener in interface DiscoveryFacet
Parameters:
c - The listener to be removed
filter - The filter matches of which this listener will not be notified any more.

getComponent

public Component getComponent(java.lang.Object id)
Description copied from class: Container
Returns a component found with the given ID attribute

Specified by:
getComponent in class Container
Returns:
The latest version of the component found, or null if the component does not exist

getComponents

public Component[] getComponents(java.util.Hashtable properties)
Description copied from interface: DiscoveryFacet
Returns an array of Components found that match the given property set

Specified by:
getComponents in interface DiscoveryFacet
Parameters:
properties - The properties that the returned components need to match
Returns:
The components that match the given properties

subset

private static boolean subset(java.util.Hashtable a,
                              java.util.Hashtable b)
Returns true if a is a subset of b

Returns:
true if a is a subset of b, or false otherwise

isEnabled

public boolean isEnabled()
Description copied from interface: ComponentFacet
Checks whether this component is enabled or not.

Specified by:
isEnabled in interface ComponentFacet
Overrides:
isEnabled in class Component
Returns:

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: ComponentFacet
Enables or disables the component

Specified by:
setEnabled in interface ComponentFacet
Overrides:
setEnabled in class Component
Parameters:
enabled -

acceptLMU

public short acceptLMU(LMU lmu)
Description copied from class: Reflective
Allows the Reflective component to inspect a given LMU and receive parts of it

Specified by:
acceptLMU in class Reflective
Parameters:
lmu - received which is targetted at this component
Returns:
true, if this component accepted all or parts of the lmu, false if the lmu was rejected