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.
 java.lang.Object getContent(java.net.URLConnection uConn)
           
 void modifiedService(ServiceReference reference, java.lang.Object service)
          A service tracked by the ServiceTracker has been modified.
 void removedService(ServiceReference reference, java.lang.Object service)
          A service tracked by the ServiceTracker 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.

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

Specified by:
addingService in interface ServiceTrackerCustomizer
Parameters:
reference - The reference to the service being added to the ServiceTracker.
Returns:
The service object to be tracked for the specified referenced service or null if the specified referenced service 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 has been modified.

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

Specified by:
modifiedService in interface ServiceTrackerCustomizer
Parameters:
reference - The reference to the service that has been modified.
service - The service object for the specified referenced 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 has been removed.

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

Specified by:
removedService in interface ServiceTrackerCustomizer
Parameters:
reference - The reference to the service that has been removed.
service - The service object for the specified referenced 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)


Copyright © 2007-2012 FuseSource, Corp.. All Rights Reserved.