org.lyra.Host
Class Updater

java.lang.Object
  extended by org.lyra.Host.Updater
All Implemented Interfaces:
java.lang.Runnable, LossListener

public class Updater
extends java.lang.Object
implements java.lang.Runnable, LossListener

This class will notify various clients on updates originating from the host itself. In order to create segregation the Updater will run in its own thread and using another connection to the host.

Version:
1.0.5, %Revision, 174%, %LastChangedDate, 27/10/12 3:33PM%
Author:
Martin Foster
See Also:
UpdateEvent, UpdateListener, Terminus, LossListener

Field Summary
private static java.lang.String CLASS
           
(package private)  java.util.List<UpdateListener> Clients
           
(package private)  java.util.List<UpdateListener> Core
           
(package private)  java.util.Map<java.lang.String,java.lang.String> Details
           
(package private)  Terminus Host
           
(package private)  Status Information
           
(package private)  java.util.Map<java.lang.String,java.lang.String> Lang
           
(package private)  Ledger Logger
           
private  boolean Process
           
 
Constructor Summary
Updater(Ledger logger, java.util.Map<java.lang.String,java.lang.String> details, java.util.Map<java.lang.String,java.lang.String> lang)
          Core constructor which will should be making use of its own instance of Host
 
Method Summary
 void addCoreListener(UpdateListener l)
          Adds an UpdateListener to the updater, a core client will always be executed first.
 void addUpdateListener(UpdateListener l)
          Adds an UpdateListener to the updater.
protected  void fireUpdateRequired(UpdateEvent update)
          Notifies all listeners that have registered interest for notification on this event type.
 UpdateListener[] getCoreListeners()
          Returns an array of all the UpdateListeners added to this class with addCoreListener(), a core client will always be executed first.
 UpdateListener[] getUpdateListeners()
          Returns an array of all the UpdateListeners added to this class with addUpdateListener().
 void hostLost(LossEvent e)
          Notifies a client that the connection to the Music Player Daemon (MPD) has been interrupted.
 void removeCoreListener(UpdateListener l)
          Removes an UpdateListener from the updater, a core client will always be executed first.
 void removeUpdateListener(UpdateListener l)
          Removes an UpdateListener from the updater.
 void run()
           
 Status startUpdate()
          There is no sense in continuing with the process unless we can actually perform our task.
 void stopUpdate()
          External process ability to kill off the thread cleanly and without issue used primarily for when the application is closing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Clients

java.util.List<UpdateListener> Clients

Core

java.util.List<UpdateListener> Core

Logger

Ledger Logger

Host

Terminus Host

Information

Status Information

Lang

java.util.Map<java.lang.String,java.lang.String> Lang

Details

java.util.Map<java.lang.String,java.lang.String> Details

CLASS

private static final java.lang.String CLASS
See Also:
Constant Field Values

Process

private boolean Process
Constructor Detail

Updater

public Updater(Ledger logger,
               java.util.Map<java.lang.String,java.lang.String> details,
               java.util.Map<java.lang.String,java.lang.String> lang)
Core constructor which will should be making use of its own instance of Host

Parameters:
logger - Ledger instance to track updates in log.
details - Host connection details.
lang - Language map.
Method Detail

startUpdate

public Status startUpdate()
There is no sense in continuing with the process unless we can actually perform our task. So we will make sure the connection is valid.

Returns:
Instance of status enabling the application to extract information.

stopUpdate

public void stopUpdate()
External process ability to kill off the thread cleanly and without issue used primarily for when the application is closing.


run

public void run()
Specified by:
run in interface java.lang.Runnable

hostLost

public void hostLost(LossEvent e)
Description copied from interface: LossListener
Notifies a client that the connection to the Music Player Daemon (MPD) has been interrupted.

Specified by:
hostLost in interface LossListener
Parameters:
e - Update notification method.
See Also:
UpdateEvent

addCoreListener

public void addCoreListener(UpdateListener l)
Adds an UpdateListener to the updater, a core client will always be executed first. Establishing baselines prior to the application clients.

Parameters:
l - Class implementing the UpdateListener interface.

removeCoreListener

public void removeCoreListener(UpdateListener l)
Removes an UpdateListener from the updater, a core client will always be executed first. Establishing baselines prior to the application clients.

Parameters:
l - Instance of class implementing the UpdateListener interface.

getCoreListeners

public UpdateListener[] getCoreListeners()
Returns an array of all the UpdateListeners added to this class with addCoreListener(), a core client will always be executed first. Establishing baselines prior to the application clients.

Returns:
All of the UpdateListeners added or an empty array if no listeners have been added.

addUpdateListener

public void addUpdateListener(UpdateListener l)
Adds an UpdateListener to the updater.

Parameters:
l - Class implementing the UpdateListener interface.

removeUpdateListener

public void removeUpdateListener(UpdateListener l)
Removes an UpdateListener from the updater.

Parameters:
l - Instance of class implementing the UpdateListener interface.

getUpdateListeners

public UpdateListener[] getUpdateListeners()
Returns an array of all the UpdateListeners added to this class with addUpdateListener().

Returns:
All of the UpdateListeners added or an empty array if no listeners have been added.

fireUpdateRequired

protected void fireUpdateRequired(UpdateEvent update)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the event parameter.

Parameters:
update - The UpdateEvent object.