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

java.lang.Object
  extended by java.net.URLStreamHandler
      extended by org.eclipse.osgi.framework.internal.protocol.URLStreamHandlerProxy
All Implemented Interfaces:
ServiceTrackerCustomizer<URLStreamHandlerService,ServiceReference<URLStreamHandlerService>>
Direct Known Subclasses:
URLStreamHandlerFactoryProxyFor15

public class URLStreamHandlerProxy
extends URLStreamHandler
implements ServiceTrackerCustomizer<URLStreamHandlerService,ServiceReference<URLStreamHandlerService>>

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


Field Summary
protected  BundleContext context
           
protected  String protocol
           
protected  int ranking
           
protected  URLStreamHandlerService realHandlerService
           
protected  URLStreamHandlerSetter urlSetter
           
protected  ServiceTracker<URLStreamHandlerService,ServiceReference<URLStreamHandlerService>> urlStreamHandlerServiceTracker
           
protected  ServiceReference<URLStreamHandlerService> urlStreamServiceReference
           
 
Constructor Summary
URLStreamHandlerProxy(String protocol, ServiceReference<URLStreamHandlerService> reference, BundleContext context)
           
 
Method Summary
 ServiceReference<URLStreamHandlerService> addingService(ServiceReference<URLStreamHandlerService> reference)
          A service is being added to the ServiceTracker.
protected  boolean equals(URL url1, URL url2)
           
protected  int getDefaultPort()
           
protected  InetAddress getHostAddress(URL url)
           
protected  int hashCode(URL url)
           
protected  boolean hostsEqual(URL url1, URL url2)
           
 void modifiedService(ServiceReference<URLStreamHandlerService> reference, ServiceReference<URLStreamHandlerService> service)
          A service tracked by the ServiceTracker has been modified.
protected  URLConnection openConnection(URL url)
           
protected  void parseURL(URL url, String str, int start, int end)
           
 void removedService(ServiceReference<URLStreamHandlerService> reference, ServiceReference<URLStreamHandlerService> service)
          A service tracked by the ServiceTracker has been removed.
protected  boolean sameFile(URL url1, URL url2)
           
 void setURL(URL url, String protocol, String host, int port, String file, String ref)
           
 void setURL(URL u, String protocol, String host, int port, String authority, String userInfo, String file, String query, String ref)
           
protected  String toExternalForm(URL url)
           
 
Methods inherited from class java.net.URLStreamHandler
openConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

realHandlerService

protected URLStreamHandlerService realHandlerService

urlSetter

protected URLStreamHandlerSetter urlSetter

urlStreamHandlerServiceTracker

protected ServiceTracker<URLStreamHandlerService,ServiceReference<URLStreamHandlerService>> urlStreamHandlerServiceTracker

context

protected BundleContext context

urlStreamServiceReference

protected ServiceReference<URLStreamHandlerService> urlStreamServiceReference

protocol

protected String protocol

ranking

protected int ranking
Constructor Detail

URLStreamHandlerProxy

public URLStreamHandlerProxy(String protocol,
                             ServiceReference<URLStreamHandlerService> reference,
                             BundleContext context)
Method Detail

equals

protected boolean equals(URL url1,
                         URL url2)
Overrides:
equals in class URLStreamHandler
See Also:
URLStreamHandler.equals(URL, URL)

getDefaultPort

protected int getDefaultPort()
Overrides:
getDefaultPort in class URLStreamHandler
See Also:
URLStreamHandler.getDefaultPort()

getHostAddress

protected InetAddress getHostAddress(URL url)
Overrides:
getHostAddress in class URLStreamHandler
See Also:
URLStreamHandler.getHostAddress(URL)

hashCode

protected int hashCode(URL url)
Overrides:
hashCode in class URLStreamHandler
See Also:
URLStreamHandler.hashCode(URL)

hostsEqual

protected boolean hostsEqual(URL url1,
                             URL url2)
Overrides:
hostsEqual in class URLStreamHandler
See Also:
URLStreamHandler.hostsEqual(URL, URL)

openConnection

protected URLConnection openConnection(URL url)
                                throws IOException
Specified by:
openConnection in class URLStreamHandler
Throws:
IOException
See Also:
URLStreamHandler.openConnection(URL)

parseURL

protected void parseURL(URL url,
                        String str,
                        int start,
                        int end)
Overrides:
parseURL in class URLStreamHandler
See Also:
URLStreamHandler.parseURL(URL, String, int, int)

sameFile

protected boolean sameFile(URL url1,
                           URL url2)
Overrides:
sameFile in class URLStreamHandler
See Also:
URLStreamHandler.sameFile(URL, URL)

toExternalForm

protected String toExternalForm(URL url)
Overrides:
toExternalForm in class URLStreamHandler
See Also:
URLStreamHandler.toExternalForm(URL)

setURL

public void setURL(URL u,
                   String protocol,
                   String host,
                   int port,
                   String authority,
                   String userInfo,
                   String file,
                   String query,
                   String ref)
Overrides:
setURL in class URLStreamHandler
See Also:
URLStreamHandler.setURL(URL, String, String, int, String, String, String, String, String)

setURL

public void setURL(URL url,
                   String protocol,
                   String host,
                   int port,
                   String file,
                   String ref)
Overrides:
setURL in class URLStreamHandler

addingService

public ServiceReference<URLStreamHandlerService> addingService(ServiceReference<URLStreamHandlerService> 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<URLStreamHandlerService,ServiceReference<URLStreamHandlerService>>
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<URLStreamHandlerService> reference,
                            ServiceReference<URLStreamHandlerService> 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<URLStreamHandlerService,ServiceReference<URLStreamHandlerService>>
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<URLStreamHandlerService> reference,
                           ServiceReference<URLStreamHandlerService> 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<URLStreamHandlerService,ServiceReference<URLStreamHandlerService>>
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)


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