de.twenty11.skysail.server.listener
Class UrlMappingServiceListener

java.lang.Object
  extended by de.twenty11.skysail.server.listener.UrlMappingServiceListener
All Implemented Interfaces:
EventListener, org.osgi.framework.ServiceListener

public class UrlMappingServiceListener
extends Object
implements org.osgi.framework.ServiceListener

A service listener which takes care of UrlMapper related services. A UrlMapper provides a Map between a path (like "/components") and a class name. An instance of that class then is expected to "take care" of requests to the path. The UrlMapper needs the osgi bundle context and a RestletOsgiApplication objects the router of which will be updated accordingly in case of matching service events. The constructor of this ServiceListener makes sure to add itself to the bundle context with the appropriate filter.

Author:
carsten

Constructor Summary
UrlMappingServiceListener(org.osgi.framework.BundleContext context, RestletOsgiApplication restletApp)
          Constructor which needs the bundleContext and the RestletOsgiApplication.
UrlMappingServiceListener(org.osgi.framework.BundleContext context, RestletOsgiApplication restletApp, boolean addBundleName)
          Constructor which needs the bundleContext and the RestletOsgiApplication.
UrlMappingServiceListener(RestletOsgiApplication restletApp)
           
 
Method Summary
 Set<String> getMappings()
           
 void serviceChanged(org.osgi.framework.ServiceEvent event)
          This method adds, removes or modifies the URL mappings of the applications router according to the service events fired.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlMappingServiceListener

public UrlMappingServiceListener(RestletOsgiApplication restletApp)

UrlMappingServiceListener

public UrlMappingServiceListener(org.osgi.framework.BundleContext context,
                                 RestletOsgiApplication restletApp)
Constructor which needs the bundleContext and the RestletOsgiApplication. When this Listener is instantiated, the bundleContext is queried for all the already existing serviceReferences to the de.twenty11.skysail.server.UrlMapper class. The mappings provided by those classes are then added to the applications router. This is done to make sure that all the mappings from running bundles are taken into account even though the restletosgi bundle might have been started later.

Parameters:
context - the osgi bundle context
restletApp - the restletOsgiApplication

UrlMappingServiceListener

public UrlMappingServiceListener(org.osgi.framework.BundleContext context,
                                 RestletOsgiApplication restletApp,
                                 boolean addBundleName)
Constructor which needs the bundleContext and the RestletOsgiApplication. When this Listener is instantiated, the bundleContext is queried for all the already existing serviceReferences to the de.twenty11.skysail.server.UrlMapper class. The mappings provided by those classes are then added to the applications router. This is done to make sure that all the mappings from running bundles are taken into account even though the restletosgi bundle might have been started later.

Parameters:
context - the osgi bundle context
restletApp - the restletOsgiApplication
Method Detail

serviceChanged

public final void serviceChanged(org.osgi.framework.ServiceEvent event)
This method adds, removes or modifies the URL mappings of the applications router according to the service events fired.

Specified by:
serviceChanged in interface org.osgi.framework.ServiceListener
Parameters:
event - the serviceEvent

getMappings

public Set<String> getMappings()


Copyright © 2011-2013. All Rights Reserved.