org.xwiki.classloader.internal.protocol.jar
Class JarURLConnection

java.lang.Object
  extended by java.net.URLConnection
      extended by org.xwiki.classloader.internal.protocol.jar.JarURLConnection
All Implemented Interfaces:
JarURLConnection

public class JarURLConnection
extends java.net.URLConnection
implements JarURLConnection

URL Connection that knows how to get a JAR file with any custom protocol specified (in the form jar:<custom protocol>://<path to jar file>!<path inside jar file>. Note that we don't extend the JDK's JarURLConnection since it doesn't know how to use a custom URL Stream Handler Factory to handle custom protocols.

Since:
2.0.1
Version:
$Id$

Nested Class Summary
static interface JarURLConnection.JarOpener
          Abstraction of JAR opener which allows to implement various caching policies.
 
Field Summary
 
Fields inherited from class java.net.URLConnection
allowUserInteraction, doInput, doOutput, ifModifiedSince, url, useCaches
 
Constructor Summary
JarURLConnection(java.net.URL url, JarURLConnection.JarOpener opener, java.net.URLStreamHandlerFactory handlerFactory)
           
 
Method Summary
 void connect()
           
 java.util.jar.Attributes getAttributes()
          Return the Attributes object for this connection if the URL for it points to a JAR file entry, null otherwise.
 java.security.cert.Certificate[] getCertificates()
          Return the Certificate object for this connection if the URL for it points to a JAR file entry, null otherwise.
 java.lang.String getEntryName()
          Return the entry name for this connection.
 java.io.InputStream getInputStream()
           
 java.util.jar.JarEntry getJarEntry()
           
 java.util.jar.JarFile getJarFile()
           
 java.net.URL getJarFileURL()
          Returns the URL for the Jar file for this connection.
 java.util.jar.Attributes getMainAttributes()
          Returns the main Attributes for the JAR file for this connection.
 java.util.jar.Manifest getManifest()
          Returns the Manifest for this connection, or null if none.
 java.security.Permission getPermission()
           
 
Methods inherited from class java.net.URLConnection
addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFields, getIfModifiedSince, getLastModified, getOutputStream, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JarURLConnection

public JarURLConnection(java.net.URL url,
                        JarURLConnection.JarOpener opener,
                        java.net.URLStreamHandlerFactory handlerFactory)
                 throws java.io.IOException
Throws:
java.io.IOException
Method Detail

connect

public void connect()
             throws java.io.IOException
Specified by:
connect in class java.net.URLConnection
Throws:
java.io.IOException

getJarFile

public java.util.jar.JarFile getJarFile()
                                 throws java.io.IOException
Specified by:
getJarFile in interface JarURLConnection
Throws:
java.io.IOException

getJarEntry

public java.util.jar.JarEntry getJarEntry()
                                   throws java.io.IOException
Throws:
java.io.IOException

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Overrides:
getInputStream in class java.net.URLConnection
Throws:
java.io.IOException

getPermission

public java.security.Permission getPermission()
                                       throws java.io.IOException
Overrides:
getPermission in class java.net.URLConnection
Throws:
java.io.IOException

getJarFileURL

public java.net.URL getJarFileURL()
Returns the URL for the Jar file for this connection.

Returns:
the URL for the Jar file for this connection.

getEntryName

public java.lang.String getEntryName()
Return the entry name for this connection. This method returns null if the JAR file URL corresponding to this connection points to a JAR file and not a JAR file entry.

Returns:
the entry name for this connection, if any.

getManifest

public java.util.jar.Manifest getManifest()
                                   throws java.io.IOException
Returns the Manifest for this connection, or null if none.

Returns:
the manifest object corresponding to the JAR file object for this connection.
Throws:
java.io.IOException - if getting the JAR file for this connection causes an IOException to be trown.
See Also:
getJarFile()

getAttributes

public java.util.jar.Attributes getAttributes()
                                       throws java.io.IOException
Return the Attributes object for this connection if the URL for it points to a JAR file entry, null otherwise.

Returns:
the Attributes object for this connection if the URL for it points to a JAR file entry, null otherwise.
Throws:
java.io.IOException - if getting the JAR entry causes an IOException to be thrown.
See Also:
getJarEntry()

getMainAttributes

public java.util.jar.Attributes getMainAttributes()
                                           throws java.io.IOException
Returns the main Attributes for the JAR file for this connection.

Returns:
the main Attributes for the JAR file for this connection.
Throws:
java.io.IOException - if getting the manifest causes an IOException to be thrown.
See Also:
getJarFile(), getManifest()

getCertificates

public java.security.cert.Certificate[] getCertificates()
                                                 throws java.io.IOException
Return the Certificate object for this connection if the URL for it points to a JAR file entry, null otherwise. This method can only be called once the connection has been completely verified by reading from the input stream until the end of the stream has been reached. Otherwise, this method will return null

Returns:
the Certificate object for this connection if the URL for it points to a JAR file entry, null otherwise.
Throws:
java.io.IOException - if getting the JAR entry causes an IOException to be thrown.
See Also:
getJarEntry()


Copyright © 2004-2011 XWiki. All Rights Reserved.