org.qtunes.main
Class ServiceContextImpl

java.lang.Object
  extended by org.qtunes.main.ServiceContextImpl
All Implemented Interfaces:
ServiceContext

public class ServiceContextImpl
extends java.lang.Object
implements ServiceContext


Constructor Summary
ServiceContextImpl(QTunes qtunes, Service service, java.lang.String servicename, org.qtunes.main.PropertyManager props)
           
 
Method Summary
 void addListener(Listener listener)
          Add a Listener to the Server, it will be notified of events
 ServiceContext addService(java.lang.Class<?>[] classes, Service service, java.util.Map<java.lang.String,java.lang.String> properties, boolean permanent)
          Add a service
 void debug(java.lang.String message)
           
 void debug(java.lang.String message, java.lang.Throwable e)
           
 void error(java.lang.String message, java.lang.Throwable e)
           
 void fireEvent(java.lang.String topic, java.lang.Object[] o)
          Fire an event - the Listeners registered with the server will be notified.
 java.lang.String getGlobalProperty(java.lang.String key)
          Get a system-wide property
 java.lang.String getProperty(java.lang.String key)
          Get a property of this Service
 java.lang.String[] getPropertyNames()
          Return a list of properties of this Service
 java.util.Date getServerBuildDate()
          Return the build date of the Server
 java.lang.String getServerName()
          Return the logical name of the Server
 Service getService()
          Get the Service for this ServiceContext
<E extends Service>
E
getService(java.lang.Class<E> type)
          Get the first Service object of the specified type
<E extends Service>
E
getService(java.lang.Class<E> type, java.lang.String filter)
          Get the first Service object of the specified type
 java.lang.String getServiceName()
          Return the unique logical name of this Service
 java.lang.String[] getServiceNames()
          Return the list of Service names
<E extends Service>
E[]
getServices(java.lang.Class<E> type, java.lang.String filter)
          Get a list of all Service objects of the specified type
 java.lang.String getSoftwareName()
          Return the name and version of the Software
 void info(java.lang.String message)
           
 boolean isActive()
          Return true if the Service has been started
 void putProperty(java.lang.String key, java.lang.String value)
          Set a property of this Service
 void quit()
           
 void removeListener(Listener listener)
          Remove a Listener to the Server, it will be notified of events
 void removeService()
          Remove a service
 void start()
           
 void stop()
           
 void warn(java.lang.String message, java.lang.Throwable e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceContextImpl

public ServiceContextImpl(QTunes qtunes,
                          Service service,
                          java.lang.String servicename,
                          org.qtunes.main.PropertyManager props)
Method Detail

getService

public Service getService()
Description copied from interface: ServiceContext
Get the Service for this ServiceContext

Specified by:
getService in interface ServiceContext

getServiceName

public java.lang.String getServiceName()
Description copied from interface: ServiceContext
Return the unique logical name of this Service

Specified by:
getServiceName in interface ServiceContext

debug

public void debug(java.lang.String message)
Specified by:
debug in interface ServiceContext

debug

public void debug(java.lang.String message,
                  java.lang.Throwable e)
Specified by:
debug in interface ServiceContext

info

public void info(java.lang.String message)
Specified by:
info in interface ServiceContext

warn

public void warn(java.lang.String message,
                 java.lang.Throwable e)
Specified by:
warn in interface ServiceContext

error

public void error(java.lang.String message,
                  java.lang.Throwable e)
Specified by:
error in interface ServiceContext

getServerName

public java.lang.String getServerName()
Description copied from interface: ServiceContext
Return the logical name of the Server

Specified by:
getServerName in interface ServiceContext

getSoftwareName

public java.lang.String getSoftwareName()
Description copied from interface: ServiceContext
Return the name and version of the Software

Specified by:
getSoftwareName in interface ServiceContext

getServerBuildDate

public java.util.Date getServerBuildDate()
Description copied from interface: ServiceContext
Return the build date of the Server

Specified by:
getServerBuildDate in interface ServiceContext

addListener

public void addListener(Listener listener)
Add a Listener to the Server, it will be notified of events

Specified by:
addListener in interface ServiceContext

removeListener

public void removeListener(Listener listener)
Remove a Listener to the Server, it will be notified of events

Specified by:
removeListener in interface ServiceContext

fireEvent

public void fireEvent(java.lang.String topic,
                      java.lang.Object[] o)
Fire an event - the Listeners registered with the server will be notified. Properties can be specified easily with the second parameter, which is a sequence of [key, value] entries - eg
  qtunes.fireEvent("stateChanged", new Object[] { "track", track, "user", user });
 

Specified by:
fireEvent in interface ServiceContext
Parameters:
o - an array of [key, value]

getPropertyNames

public java.lang.String[] getPropertyNames()
Description copied from interface: ServiceContext
Return a list of properties of this Service

Specified by:
getPropertyNames in interface ServiceContext

getGlobalProperty

public java.lang.String getGlobalProperty(java.lang.String key)
Description copied from interface: ServiceContext
Get a system-wide property

Specified by:
getGlobalProperty in interface ServiceContext

getProperty

public java.lang.String getProperty(java.lang.String key)
Description copied from interface: ServiceContext
Get a property of this Service

Specified by:
getProperty in interface ServiceContext

putProperty

public void putProperty(java.lang.String key,
                        java.lang.String value)
Description copied from interface: ServiceContext
Set a property of this Service

Specified by:
putProperty in interface ServiceContext

getService

public <E extends Service> E getService(java.lang.Class<E> type)
Description copied from interface: ServiceContext
Get the first Service object of the specified type

Specified by:
getService in interface ServiceContext

getService

public <E extends Service> E getService(java.lang.Class<E> type,
                                        java.lang.String filter)
Description copied from interface: ServiceContext
Get the first Service object of the specified type

Specified by:
getService in interface ServiceContext

getServices

public <E extends Service> E[] getServices(java.lang.Class<E> type,
                                           java.lang.String filter)
Description copied from interface: ServiceContext
Get a list of all Service objects of the specified type

Specified by:
getServices in interface ServiceContext

start

public void start()
Specified by:
start in interface ServiceContext

stop

public void stop()
Specified by:
stop in interface ServiceContext

isActive

public boolean isActive()
Description copied from interface: ServiceContext
Return true if the Service has been started

Specified by:
isActive in interface ServiceContext

addService

public ServiceContext addService(java.lang.Class<?>[] classes,
                                 Service service,
                                 java.util.Map<java.lang.String,java.lang.String> properties,
                                 boolean permanent)
Description copied from interface: ServiceContext
Add a service

Specified by:
addService in interface ServiceContext

removeService

public void removeService()
Description copied from interface: ServiceContext
Remove a service

Specified by:
removeService in interface ServiceContext

getServiceNames

public java.lang.String[] getServiceNames()
Description copied from interface: ServiceContext
Return the list of Service names

Specified by:
getServiceNames in interface ServiceContext

quit

public void quit()