Class URLHandlersStreamHandlerProxy
- All Implemented Interfaces:
InvocationHandler
,URLStreamHandlerSetter
This class implements a stream handler proxy. When the stream handler proxy instance is created, it is associated with a particular protocol and will answer all future requests for handling of that stream type. It does not directly handle the stream handler requests, but delegates the requests to an underlying stream handler service.
The proxy instance for a particular protocol is used for all framework instances that may contain their own stream handler services. When performing a stream handler operation, the proxy retrieves the handler service from the framework instance associated with the current call stack and delegates the call to the handler service.
The proxy will create simple stream handler service trackers for each framework instance. The trackers will listen to service events in its respective framework instance to maintain a reference to the "best" stream handler service at any given time.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Method
private static final Method
private static final Method
private static final Method
private static final Method
private final SecureAction
private final URLStreamHandler
private final URL
private static final ThreadLocal
private final String
private final Object
private static final Method
private static final Method
private static final Method
private static final Class[]
private static final Method
private static final Class[]
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
URLHandlersStreamHandlerProxy
(Object service, SecureAction action) URLHandlersStreamHandlerProxy
(String protocol, SecureAction action, URLStreamHandler builtIn, URL builtInURL) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
protected int
protected InetAddress
getHostAddress
(URL url) private Object
Private method to retrieve the stream handler service from the framework instance associated with the current call stack.protected int
protected boolean
hostsEqual
(URL url1, URL url2) protected URLConnection
openConnection
(URL url) protected URLConnection
openConnection
(URL url, Proxy proxy) protected void
protected boolean
void
void
setURL
(URL url, String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref) protected String
toExternalForm
(URL url) private String
toExternalForm
(URL url, Object svc)
-
Field Details
-
URL_PROXY_CLASS
-
STRING_TYPES
-
EQUALS
-
GET_DEFAULT_PORT
-
GET_HOST_ADDRESS
-
HASH_CODE
-
HOSTS_EQUAL
-
OPEN_CONNECTION
-
OPEN_CONNECTION_PROXY
-
SAME_FILE
-
TO_EXTERNAL_FORM
-
m_service
-
m_action
-
m_builtIn
-
m_builtInURL
-
m_protocol
-
m_loopCheck
-
-
Constructor Details
-
URLHandlersStreamHandlerProxy
public URLHandlersStreamHandlerProxy(String protocol, SecureAction action, URLStreamHandler builtIn, URL builtInURL) -
URLHandlersStreamHandlerProxy
-
-
Method Details
-
equals
- Overrides:
equals
in classURLStreamHandler
-
getDefaultPort
protected int getDefaultPort()- Overrides:
getDefaultPort
in classURLStreamHandler
-
getHostAddress
- Overrides:
getHostAddress
in classURLStreamHandler
-
hashCode
- Overrides:
hashCode
in classURLStreamHandler
-
hostsEqual
- Overrides:
hostsEqual
in classURLStreamHandler
-
openConnection
- Specified by:
openConnection
in classURLStreamHandler
- Throws:
IOException
-
openConnection
- Overrides:
openConnection
in classURLStreamHandler
- Throws:
IOException
-
parseURL
- Overrides:
parseURL
in classURLStreamHandler
-
sameFile
- Overrides:
sameFile
in classURLStreamHandler
-
setURL
public void setURL(URL url, String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref) - Specified by:
setURL
in interfaceURLStreamHandlerSetter
- Overrides:
setURL
in classURLStreamHandler
- See Also:
-
setURL
- Specified by:
setURL
in interfaceURLStreamHandlerSetter
- Overrides:
setURL
in classURLStreamHandler
- See Also:
-
toExternalForm
- Overrides:
toExternalForm
in classURLStreamHandler
-
toExternalForm
-
getStreamHandlerService
Private method to retrieve the stream handler service from the framework instance associated with the current call stack. A simple service tracker is created and cached for the associated framework instance when this method is called.
- Returns:
- the stream handler service from the framework instance associated with the current call stack or null is no service is available.
-
invoke
- Specified by:
invoke
in interfaceInvocationHandler
- Throws:
Throwable
-