jhomenet.hw.management
Class JHomenetRegistry

java.lang.Object
  extended by jhomenet.hw.management.JHomenetRegistry
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener
Direct Known Subclasses:
DummyHardwareRegistry, HardwareRegistry

public abstract class JHomenetRegistry
extends java.lang.Object
implements java.beans.PropertyChangeListener

ID: $Id$ Description:


Field Summary
protected  AbstractDriverManager driverManager
          Reference to the hardware driver manager.
protected  java.util.concurrent.locks.Lock lock
          Used for synchronization purposes.
protected  java.util.concurrent.ConcurrentHashMap<java.lang.String,HomenetHardware> registeredHardware
          Maintains the list of current registered hardware.
protected  java.util.ArrayList<java.lang.String> unregisteredHardware
          Maintains the list of currently unregistered hardware.
 
Constructor Summary
JHomenetRegistry()
           
 
Method Summary
 void addListener(HardwareRegistryListener listener)
          Add a HardwareRegistery listening object.
 HomenetHardware addOrUpdateHardware(HomenetHardware hw, boolean updateDatabase)
          Add/Register or update hardware in the hardware registry.
 void capture(java.lang.String hardwareID)
          Capture data for a specified hardware object.
 void detectHardware()
          This method detects any hardware currently installed on the local 1-Wire network.
protected  void fireRegistryEvent(HardwareRegistryEvent event)
          Fire a hardware registry event.
 int getNumRegisteredHardware()
          Get the number of registered hardware objects.
 int getNumUnregisteredHardware()
          Get the number of unregistered hardware objects.
 HomenetHardware getRegisteredHardware(java.lang.String hardwareID)
          Get a reference to a hardware object.
 java.util.concurrent.ConcurrentHashMap<java.lang.String,HomenetHardware> getRegisteredHardwareList()
          Get a list of registered hardware.
 java.util.ArrayList<java.lang.String> getUnregisteredHardwareList()
          Return a list of unregistered hardware IDs.
 void initializeRegistry()
          Initialize the hardware registry.
 boolean isRegistered(java.lang.String hardwareId)
          Determines whether a particular piece of hardware is registered.
 void printAllHardware()
          Prints the current list of registered hardware.
 void printRegisteredHardware()
          Print the list of registered hardware.
 void printUnregisteredHardware()
          Print the list of unregistered hardware.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Listen for changes in hardware properties.
 void removeListener(HardwareRegistryListener listener)
          Remove a HardwareRegistry listening object.
protected  void restoreHardware()
          This method restores registered hardware from the database.
 void setHardwareConfiguration(java.lang.String hardwareID, java.lang.String config)
          Set a register hardware's configuration.
 void setHardwareDriverManager(AbstractDriverManager driverManager)
          Set the hardware driver manager.
 void unregisterHardware(HomenetHardware hw)
          Unregister currently registered hardware in the hardware registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

driverManager

protected AbstractDriverManager driverManager
Reference to the hardware driver manager.


registeredHardware

protected java.util.concurrent.ConcurrentHashMap<java.lang.String,HomenetHardware> registeredHardware
Maintains the list of current registered hardware. Uses's the hardware's ID as the key to map datastructure. Updated to concurrent hash map to provide thread safety while accessing.


unregisteredHardware

protected java.util.ArrayList<java.lang.String> unregisteredHardware
Maintains the list of currently unregistered hardware.


lock

protected final java.util.concurrent.locks.Lock lock
Used for synchronization purposes.

Constructor Detail

JHomenetRegistry

public JHomenetRegistry()
Method Detail

setHardwareDriverManager

public void setHardwareDriverManager(AbstractDriverManager driverManager)
Set the hardware driver manager.

Parameters:
driverManager -

initializeRegistry

public void initializeRegistry()
                        throws HardwareRegistryException
Initialize the hardware registry. NOTE: Be sure to set the hardware driver manager prior to calling this method.

Throws:
HardwareRegistryException

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Listen for changes in hardware properties.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)

detectHardware

public void detectHardware()
This method detects any hardware currently installed on the local 1-Wire network. If the hardware hasn't been detected in the past, it is added to the list of unregistered hardware. If detected hardware is currently registered, then its 1-Wire container reference is updated.


restoreHardware

protected void restoreHardware()
                        throws HardwareRegistryException
This method restores registered hardware from the database. The process of restoring the hardware is as follows: 1) Read in the 1-Wire hardware address from the database 2) Check if the 1-Wire address is currently on the 1-Wire network 3) If the hardware is present on the network, read the remaining hardware information from the database, create the hardware, and store the hardware in the current list of registered hardware.

Throws:
HardwareRegistryException

addOrUpdateHardware

public HomenetHardware addOrUpdateHardware(HomenetHardware hw,
                                           boolean updateDatabase)
                                    throws HardwareRegistryException
Add/Register or update hardware in the hardware registry.

Parameters:
hw - Hardware to be registered or updated.
Throws:
HardwareRegistryException

unregisterHardware

public void unregisterHardware(HomenetHardware hw)
                        throws HardwareRegistryException
Unregister currently registered hardware in the hardware registry.

Parameters:
hw - Hardware to be unregistered
Throws:
HardwareRegistryException

isRegistered

public boolean isRegistered(java.lang.String hardwareId)
                     throws HardwareRegistryException
Determines whether a particular piece of hardware is registered.

Parameters:
hardwareId - The hardware ID to check
Returns:
Whether the hardware is currently registered
Throws:
HardwareRegistryException

printAllHardware

public void printAllHardware()
Prints the current list of registered hardware.

Parameters:
printSelection - The hardware printing selection.

printRegisteredHardware

public void printRegisteredHardware()
Print the list of registered hardware.


printUnregisteredHardware

public void printUnregisteredHardware()
Print the list of unregistered hardware.


getRegisteredHardwareList

public java.util.concurrent.ConcurrentHashMap<java.lang.String,HomenetHardware> getRegisteredHardwareList()
Get a list of registered hardware.

Returns:
Map of registered hardware

getRegisteredHardware

public HomenetHardware getRegisteredHardware(java.lang.String hardwareID)
Get a reference to a hardware object.

Parameters:
hardwareID -
Returns:
A reference to a hardware object

getUnregisteredHardwareList

public java.util.ArrayList<java.lang.String> getUnregisteredHardwareList()
Return a list of unregistered hardware IDs.

Returns:
A list of the unregistered hardware IDs.

getNumRegisteredHardware

public int getNumRegisteredHardware()
Get the number of registered hardware objects.

Returns:
The number of currently registered hardware.

getNumUnregisteredHardware

public int getNumUnregisteredHardware()
Get the number of unregistered hardware objects.

Returns:
The number of currently unregistered hardware.

setHardwareConfiguration

public void setHardwareConfiguration(java.lang.String hardwareID,
                                     java.lang.String config)
Set a register hardware's configuration.

Parameters:
hardwareID -
config -

capture

public void capture(java.lang.String hardwareID)
Capture data for a specified hardware object.

Parameters:
hardwareID -

addListener

public void addListener(HardwareRegistryListener listener)
Add a HardwareRegistery listening object.

Parameters:
listener - A HardwareRegistery listener.

removeListener

public void removeListener(HardwareRegistryListener listener)
Remove a HardwareRegistry listening object.

Parameters:
listener - Remove this listener from the list of HardwareRegistery listeners

fireRegistryEvent

protected void fireRegistryEvent(HardwareRegistryEvent event)
Fire a hardware registry event.

Parameters:
event -


Copyright © 2004-2005 David Irwin. All Rights Reserved.