org.gloin.resource.protocol.jrap
Class JrapURLConnection

java.lang.Object
  |
  +--java.net.URLConnection
        |
        +--org.gloin.resource.protocol.jrap.JrapURLConnection

public class JrapURLConnection
extends java.net.URLConnection

Implementation of URLConnection which looks up and uses a Jini service in order to fullfil requests to load bytes for a given "jrap" url. The discovered service, which fulfills requests to load bytes from JRAP urls, will implement the interface, net.gloin.resource.ResourceAccess. The reconnect method of this class performs the steps needed to lookup the ResourceAccess service. The getInputStream method actually delegates to ResourceAccess.getResourceAsStream(String resourceName). The byte[] result of calling this remote method is in turn used by callers (e.g. URLClassLoader) in order to load resource and/or classes for Jini applications.


Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
 
Constructor Summary
JrapURLConnection(java.net.URL u)
          Construct a JrapURLConnection to load resources from the given url.
 
Method Summary
 void connect()
          Discover a resource service and open a connection to it.
 boolean equals(java.lang.Object other)
           
 java.lang.String getHeaderField(int n)
           
 java.lang.String getHeaderField(java.lang.String name)
           
 java.lang.String getHeaderFieldKey(int n)
           
 java.io.InputStream getInputStream()
          Delegates to discovered up ResourceAccess objects in order to fulfill a request to load the bytes referenced by a jrap url.
 java.io.OutputStream getOutputStream()
          Get the output stream.
 java.security.Permission getPermission()
          Permission to connect to a JRAP url implies the ability to connect to arbitrary hosts and ports (at least it does for now).
 int hashCode()
           
 void setRequestHeader(java.lang.String name, java.lang.String value)
           
 
Methods inherited from class java.net.URLConnection
getAllowUserInteraction, getContent, getContent, getContentEncoding, getContentLength, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderFieldDate, getHeaderFieldInt, getIfModifiedSince, getLastModified, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setRequestProperty, setUseCaches, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JrapURLConnection

public JrapURLConnection(java.net.URL u)
                  throws java.net.MalformedURLException
Construct a JrapURLConnection to load resources from the given url. Creates a new JrapURLParser from the supplied url.
Parameters:
url - the url from which this connection will load resources.
Method Detail

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

connect

public void connect()
             throws java.io.IOException
Discover a resource service and open a connection to it.
Overrides:
connect in class java.net.URLConnection

setRequestHeader

public void setRequestHeader(java.lang.String name,
                             java.lang.String value)

getHeaderFieldKey

public java.lang.String getHeaderFieldKey(int n)
Overrides:
getHeaderFieldKey in class java.net.URLConnection

getHeaderField

public java.lang.String getHeaderField(int n)
Overrides:
getHeaderField in class java.net.URLConnection

getHeaderField

public java.lang.String getHeaderField(java.lang.String name)
Overrides:
getHeaderField in class java.net.URLConnection

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Get the output stream. Used for form POSTs. REMIND: currently this is not fully implemented.
Overrides:
getOutputStream in class java.net.URLConnection

getPermission

public java.security.Permission getPermission()
                                       throws java.io.IOException
Permission to connect to a JRAP url implies the ability to connect to arbitrary hosts and ports (at least it does for now). REMIND: obviously have to work out the security ramifications of JRAP urls better in the near future. Seems like a dynamic security policy is needed to handle permissions needed to access arbitrary resource services.
Overrides:
getPermission in class java.net.URLConnection

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Delegates to discovered up ResourceAccess objects in order to fulfill a request to load the bytes referenced by a jrap url. If this connection has not already looked up a ResourceAccess object, this method reconnects in order to obtain an appropriate service object.
Overrides:
getInputStream in class java.net.URLConnection
Returns:
input stream object created as a result of calling ResourceAccess.getResourceAsStream on download ResourceAccess objects.