org.qtunes.core
Class OSGIServiceContext

java.lang.Object
  extended by org.qtunes.core.OSGIServiceContext
All Implemented Interfaces:
ServiceContext

public final class OSGIServiceContext
extends Object
implements ServiceContext


Field Summary
 
Fields inherited from interface org.qtunes.core.ServiceContext
EVENTPREFIX
 
Constructor Summary
OSGIServiceContext(org.osgi.service.component.ComponentContext context, Service service)
           
 
Method Summary
 void addListener(Listener listener)
          Add a Listener to the Server, it will be notified of events
 ServiceContext addService(Class<?>[] classes, Service service, Map<?,?> properties)
          Add a service
 void debug(String message)
           
 void debug(String message, Throwable e)
           
 void error(String message, Throwable e)
           
 void fireEvent(String name)
          Fire an event - the Listeners registered with the server will be notified
 void fireEvent(String topic, Object[] o)
          Fire an event - the Listeners registered with the server will be notified.
 org.osgi.service.component.ComponentContext getComponentContext()
           
 String getProperty(String key)
           
 String[] getPropertyNames()
           
 String getServerName()
          Return the logical name of the Server
 Service getService()
          Get the Service for this ServiceContext
<E extends Service>
E
getService(Class<E> clazz)
          Get the first Service object of the specified type
 Service getServiceByShortName(String shortname)
          Get the first Service object with the specified shortname
<E extends Service>
E[]
getServices(Class<E> clazz)
          Get a list of all Service objects of the specified type
 String[] getServiceShortNames()
           
 String getSoftwareName()
          Return the name and version of the Software
 void info(String message)
           
 Object load()
           
 void removeListener(Listener listener)
          Remove a Listener to the Server, it will be notified of events
 void removeService()
          Remove a service
 void save(Object o)
          Add the specified object to the system State and save that state to disk.
 void start()
           
 void stop()
           
 void warn(String message, Throwable e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OSGIServiceContext

public OSGIServiceContext(org.osgi.service.component.ComponentContext context,
                          Service service)
Method Detail

getComponentContext

public org.osgi.service.component.ComponentContext getComponentContext()

getService

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

Specified by:
getService in interface ServiceContext

debug

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

debug

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

info

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

warn

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

error

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

save

public void save(Object o)
Description copied from interface: ServiceContext
Add the specified object to the system State and save that state to disk.

Specified by:
save in interface ServiceContext

load

public Object load()
Specified by:
load in interface ServiceContext

getSoftwareName

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

Specified by:
getSoftwareName in interface ServiceContext

getServerName

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

Specified by:
getServerName 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(String name)
Fire an event - the Listeners registered with the server will be notified

Specified by:
fireEvent in interface ServiceContext

fireEvent

public void fireEvent(String topic,
                      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 String[] getPropertyNames()
Specified by:
getPropertyNames in interface ServiceContext

getProperty

public String getProperty(String key)
Specified by:
getProperty in interface ServiceContext

getService

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

Specified by:
getService in interface ServiceContext

getServiceShortNames

public String[] getServiceShortNames()
Specified by:
getServiceShortNames in interface ServiceContext

getServices

public <E extends Service> E[] getServices(Class<E> clazz)
Description copied from interface: ServiceContext
Get a list of all Service objects of the specified type

Specified by:
getServices in interface ServiceContext

getServiceByShortName

public Service getServiceByShortName(String shortname)
Description copied from interface: ServiceContext
Get the first Service object with the specified shortname

Specified by:
getServiceByShortName in interface ServiceContext

start

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

stop

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

addService

public ServiceContext addService(Class<?>[] classes,
                                 Service service,
                                 Map<?,?> properties)
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