org.xngr.context
Class ServiceContextManager

java.lang.Object
  extended by org.xngr.context.ServiceContextManager

public class ServiceContextManager
extends java.lang.Object

Manages the association of services and actions with URIs and Nodes.

Version:
$Revision: 91 $, $Date: 2009-05-07 21:45:40 +0100 (Thu, 07 May 2009) $
Author:
Edwin Dankert

Nested Class Summary
 class ServiceContextManager.RootElementFoundException
           
 class ServiceContextManager.SimpleErrorHandler
           
 
Constructor Summary
protected ServiceContextManager()
           
  ServiceContextManager(org.osgi.framework.BundleContext context)
          Initialises the service manager.
 
Method Summary
protected  void add(Action action)
          Adds an action to the manager.
protected  void add(Marker marker)
          Adds a marker to the manager.
protected  void add(Service service)
          Adds a service to the manager.
 void dispose()
          Releases all the resources.
protected  void fireActionsChanged(Action source, ServiceContextEvent.Type type)
          Called when actions have been changed.
protected  void fireMarkersChanged(Marker source, ServiceContextEvent.Type type)
          Called when markers have been changed.
protected  void fireServicesChanged(Service source, ServiceContextEvent.Type type)
          Called when services have been changed.
 ServiceContext getContext(java.net.URI uri)
           
protected  void remove(Action action)
          Calls close on the service and removes it from the manager.
protected  void remove(Marker marker)
          Removes a marker from the manager.
protected  void remove(Service service)
          Calls close on the service and removes it from the manager.
 void start()
          Starts the tracking of Services and Actions, only needs to be used after a stop() has been called.
 void stop()
          Stops the tracking of Services and Actions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceContextManager

public ServiceContextManager(org.osgi.framework.BundleContext context)
Initialises the service manager.


ServiceContextManager

protected ServiceContextManager()
Method Detail

add

protected void add(Service service)
Adds a service to the manager.

Parameters:
service - the to be added service.

add

protected void add(Action action)
Adds an action to the manager.

Parameters:
action - the to be added action.

add

protected void add(Marker marker)
Adds a marker to the manager.

Parameters:
marker - the to be added marker.

remove

protected void remove(Service service)
Calls close on the service and removes it from the manager. Only use this to remove services which have not been registered using the OSGI bundle-context.

Parameters:
service - the service to be removed from the manager.

remove

protected void remove(Action action)
Calls close on the service and removes it from the manager. Only use this to remove services which have not been registered using the OSGI bundle-context.

Parameters:
service - the service to be removed from the manager.

remove

protected void remove(Marker marker)
Removes a marker from the manager.

Parameters:
marker - the to be removed marker.

getContext

public ServiceContext getContext(java.net.URI uri)
                          throws java.io.IOException
Parameters:
uri - the uri to find the service-context for, cannot be null.
Returns:
a service-context (directory-context, document-context, file-context) providing the services and actions mapped for the URI and stream.
Throws:
java.io.IOException - when no stream can be opened (or closed) for the URI.

stop

public void stop()
Stops the tracking of Services and Actions.


start

public void start()
Starts the tracking of Services and Actions, only needs to be used after a stop() has been called.


dispose

public void dispose()
Releases all the resources.


fireServicesChanged

protected void fireServicesChanged(Service source,
                                   ServiceContextEvent.Type type)
Called when services have been changed.

Parameters:
source - the changed service
type - the type of change, ADDED, REMOVED or CHANGED.

fireMarkersChanged

protected void fireMarkersChanged(Marker source,
                                  ServiceContextEvent.Type type)
Called when markers have been changed.

Parameters:
source - the changed marker
type - the type of change, ADDED, REMOVED or CHANGED.

fireActionsChanged

protected void fireActionsChanged(Action source,
                                  ServiceContextEvent.Type type)
Called when actions have been changed.

Parameters:
source - the changed action
type - the type of change, ADDED, REMOVED or CHANGED.


Copyright © 2002-2009 Edwin Dankert. All Rights Reserved.