org.eclipse.osgi.framework.internal.protocol
Class ContentHandlerProxy

java.lang.Object
  extended by java.net.ContentHandler
      extended by org.eclipse.osgi.framework.internal.protocol.ContentHandlerProxy
All Implemented Interfaces:
ServiceTrackerCustomizer

public class ContentHandlerProxy
extends java.net.ContentHandler
implements ServiceTrackerCustomizer

The ContentHandlerProxy is a ContentHandler that acts as a proxy for registered ContentHandlers. When a ContentHandler is requested from the ContentHandlerFactory and it exists in the service registry, a ContentHandlerProxy is created which will pass all the requests from the requestor to the real ContentHandler. We can't return the real ContentHandler from the ContentHandlerFactory because the JVM caches ContentHandlers and therefore would not support a dynamic environment of ContentHandlers being registered and unregistered.


Field Summary
protected  ServiceReference contentHandlerServiceReference
           
protected  ServiceTracker contentHandlerServiceTracker
           
protected  java.lang.String contentType
           
protected  BundleContext context
           
protected  int ranking
           
protected  java.net.ContentHandler realHandler
           
 
Constructor Summary
ContentHandlerProxy(java.lang.String contentType, ServiceReference reference, BundleContext context)
           
 
Method Summary
 java.lang.Object addingService(ServiceReference reference)
          A service is being added to the ServiceTracker object.
 java.lang.Object getContent(java.net.URLConnection uConn)
           
 void modifiedService(ServiceReference reference, java.lang.Object service)
          A service tracked by the ServiceTracker object has been modified.
 void removedService(ServiceReference reference, java.lang.Object service)
          A service tracked by the ServiceTracker object has been removed.
 
Methods inherited from class java.net.ContentHandler
getContent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

realHandler

protected java.net.ContentHandler realHandler

contentHandlerServiceTracker

protected ServiceTracker contentHandlerServiceTracker

context

protected BundleContext context

contentHandlerServiceReference

protected ServiceReference contentHandlerServiceReference

contentType

protected java.lang.String contentType

ranking

protected int ranking
Constructor Detail

ContentHandlerProxy

public ContentHandlerProxy(java.lang.String contentType,
                           ServiceReference reference,
                           BundleContext context)
Method Detail

addingService

public java.lang.Object addingService(ServiceReference reference)
Description copied from interface: ServiceTrackerCustomizer
A service is being added to the ServiceTracker object.

This method is called before a service which matched the search parameters of the ServiceTracker object is added to it. This method should return the service object to be tracked for this ServiceReference object. The returned service object is stored in the ServiceTracker object and is available from the getService and getServices methods.

Specified by:
addingService in interface ServiceTrackerCustomizer
Parameters:
reference - Reference to service being added to the ServiceTracker object.
Returns:
The service object to be tracked for the ServiceReference object or null if the ServiceReference object should not be tracked.
See Also:
ServiceTrackerCustomizer.addingService(ServiceReference)

modifiedService

public void modifiedService(ServiceReference reference,
                            java.lang.Object service)
Description copied from interface: ServiceTrackerCustomizer
A service tracked by the ServiceTracker object has been modified.

This method is called when a service being tracked by the ServiceTracker object has had it properties modified.

Specified by:
modifiedService in interface ServiceTrackerCustomizer
Parameters:
reference - Reference to service that has been modified.
service - The service object for the modified service.
See Also:
ServiceTrackerCustomizer.modifiedService(ServiceReference, Object)

removedService

public void removedService(ServiceReference reference,
                           java.lang.Object service)
Description copied from interface: ServiceTrackerCustomizer
A service tracked by the ServiceTracker object has been removed.

This method is called after a service is no longer being tracked by the ServiceTracker object.

Specified by:
removedService in interface ServiceTrackerCustomizer
Parameters:
reference - Reference to service that has been removed.
service - The service object for the removed service.
See Also:
ServiceTrackerCustomizer.removedService(ServiceReference, Object)

getContent

public java.lang.Object getContent(java.net.URLConnection uConn)
                            throws java.io.IOException
Specified by:
getContent in class java.net.ContentHandler
Throws:
java.io.IOException
See Also:
ContentHandler.getContent(URLConnection)