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<ContentHandler,ServiceReference<ContentHandler>>

public class ContentHandlerProxy
extends ContentHandler
implements ServiceTrackerCustomizer<ContentHandler,ServiceReference<ContentHandler>>

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<ContentHandler> contentHandlerServiceReference
           
protected  ServiceTracker<ContentHandler,ServiceReference<ContentHandler>> contentHandlerServiceTracker
           
protected  String contentType
           
protected  BundleContext context
           
protected  int ranking
           
protected  ContentHandler realHandler
           
 
Constructor Summary
ContentHandlerProxy(String contentType, ServiceReference<ContentHandler> reference, BundleContext context)
           
 
Method Summary
 ServiceReference<ContentHandler> addingService(ServiceReference<ContentHandler> reference)
          A service is being added to the ServiceTracker.
 Object getContent(URLConnection uConn)
           
 void modifiedService(ServiceReference<ContentHandler> reference, ServiceReference<ContentHandler> service)
          A service tracked by the ServiceTracker has been modified.
 void removedService(ServiceReference<ContentHandler> reference, ServiceReference<ContentHandler> 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 ContentHandler realHandler

contentHandlerServiceTracker

protected ServiceTracker<ContentHandler,ServiceReference<ContentHandler>> contentHandlerServiceTracker

context

protected BundleContext context

contentHandlerServiceReference

protected ServiceReference<ContentHandler> contentHandlerServiceReference

contentType

protected String contentType

ranking

protected int ranking
Constructor Detail

ContentHandlerProxy

public ContentHandlerProxy(String contentType,
                           ServiceReference<ContentHandler> reference,
                           BundleContext context)
Method Detail

addingService

public ServiceReference<ContentHandler> addingService(ServiceReference<ContentHandler> 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<ContentHandler,ServiceReference<ContentHandler>>
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<ContentHandler> reference,
                            ServiceReference<ContentHandler> 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<ContentHandler,ServiceReference<ContentHandler>>
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<ContentHandler> reference,
                           ServiceReference<ContentHandler> 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<ContentHandler,ServiceReference<ContentHandler>>
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 Object getContent(URLConnection uConn)
                  throws IOException
Specified by:
getContent in class ContentHandler
Throws:
IOException
See Also:
ContentHandler.getContent(URLConnection)


Copyright © 2007–2014 The Apache Software Foundation. All rights reserved.