[jboss-svn-commits] JBoss Common SVN: r2868 - in common-core/tags: 2.2.7.GA and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jun 11 08:03:52 EDT 2008
Author: dimitris at jboss.org
Date: 2008-06-11 08:03:51 -0400 (Wed, 11 Jun 2008)
New Revision: 2868
Added:
common-core/tags/2.2.7.GA/
common-core/tags/2.2.7.GA/pom.xml
common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java
common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/file/
common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/file/FileURLConnection.java
common-core/tags/2.2.7.GA/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java
Removed:
common-core/tags/2.2.7.GA/pom.xml
common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java
common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/file/
common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/file/FileURLConnection.java
common-core/tags/2.2.7.GA/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java
Log:
[maven-release-plugin] copy for tag 2.2.7.GA
Copied: common-core/tags/2.2.7.GA (from rev 2853, common-core/trunk)
Deleted: common-core/tags/2.2.7.GA/pom.xml
===================================================================
--- common-core/trunk/pom.xml 2008-05-30 18:39:39 UTC (rev 2853)
+++ common-core/tags/2.2.7.GA/pom.xml 2008-06-11 12:03:51 UTC (rev 2868)
@@ -1,92 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-parent</artifactId>
- <version>3</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- <version>2.2.6-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>JBoss Common Classes</name>
- <url>http://www.jboss.org</url>
- <description>JBoss Common Core Utility classes</description>
- <scm>
- <connection>scm:svn:https://svn.jboss.org/repos/common/common-core/tags/2.2.5.GA</connection>
- </scm>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-release-plugin</artifactId>
- <configuration>
- <!-- The tagBase property is needed during the release process so that the maven release plugin
- will create the release tag in the appropriate location. -->
- <tagBase>https://svn.jboss.org/repos/common/common-core/tags</tagBase>
- </configuration>
- </plugin>
- <plugin>
- <groupId>jboss.maven-plugins</groupId>
- <artifactId>jboss-deploy-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- <repositories>
- <repository>
- <id>repository.jboss.org</id>
- <name>JBoss Repository</name>
- <layout>default</layout>
- <url>http://repository.jboss.org/maven2/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- <repository>
- <id>snapshots.jboss.org</id>
- <name>JBoss Snapshot Repository</name>
- <layout>default</layout>
- <url>http://snapshots.jboss.org/maven2/</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <dependencies>
-
- <dependency>
- <groupId>apache-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>2.0.2</version>
- <scope>compile</scope>
- <optional>true</optional> <!-- org.jboss.net.protocol.http.DavURLLister -->
- </dependency>
-
- <dependency>
- <groupId>apache-slide</groupId>
- <artifactId>webdavlib</artifactId>
- <version>2.0</version>
- <scope>compile</scope>
- <optional>true</optional> <!-- org.jboss.net.protocol.http.DavURLLister -->
- </dependency>
-
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- <version>2.0.5.GA</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
-</project>
\ No newline at end of file
Copied: common-core/tags/2.2.7.GA/pom.xml (from rev 2867, common-core/trunk/pom.xml)
===================================================================
--- common-core/tags/2.2.7.GA/pom.xml (rev 0)
+++ common-core/tags/2.2.7.GA/pom.xml 2008-06-11 12:03:51 UTC (rev 2868)
@@ -0,0 +1,92 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>3</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.2.7.GA</version>
+ <packaging>jar</packaging>
+ <name>JBoss Common Classes</name>
+ <url>http://www.jboss.org</url>
+ <description>JBoss Common Core Utility classes</description>
+ <scm>
+ <connection>scm:svn:https://svn.jboss.org/repos/common/common-core/tags/2.2.7.GA</connection>
+ </scm>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <!-- The tagBase property is needed during the release process so that the maven release plugin
+ will create the release tag in the appropriate location. -->
+ <tagBase>https://svn.jboss.org/repos/common/common-core/tags</tagBase>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>jboss.maven-plugins</groupId>
+ <artifactId>jboss-deploy-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <layout>default</layout>
+ <url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <layout>default</layout>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>apache-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>2.0.2</version>
+ <scope>compile</scope>
+ <optional>true</optional> <!-- org.jboss.net.protocol.http.DavURLLister -->
+ </dependency>
+
+ <dependency>
+ <groupId>apache-slide</groupId>
+ <artifactId>webdavlib</artifactId>
+ <version>2.0</version>
+ <scope>compile</scope>
+ <optional>true</optional> <!-- org.jboss.net.protocol.http.DavURLLister -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>2.0.5.GA</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
\ No newline at end of file
Deleted: common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java
===================================================================
--- common-core/trunk/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java 2008-05-30 18:39:39 UTC (rev 2853)
+++ common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java 2008-06-11 12:03:51 UTC (rev 2868)
@@ -1,227 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.net.protocol;
-
-import java.net.URL;
-import java.net.URLStreamHandler;
-import java.util.Collections;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.jboss.logging.Logger;
-
-/**
- * A factory for loading URL protocol handlers. This is based
- * on Sun's URL mechanism, in that <tt>Handler</tt> classes will be
- * searched for in the packages specified by the java.protocol.handler.pkgs
- * property are searched for classes matching the protocol + ".Handler"
- * classname. The default JBoss package "org.jboss.net.protocol" is searched
- * even if not specified in the java.protocol.handler.pkgs property.
- *
- * <p>This factory is installed by the default server implementaion
- * to ensure that protocol handlers not in the system classpath are
- * located. The thread context class is used first followed by the
- * Class.forName method.
- * </p>
- *
- * @version <tt>$Revision$</tt>
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author Scott.Stark at jboss.org
- */
- at SuppressWarnings("unchecked")
-public class URLStreamHandlerFactory
- implements java.net.URLStreamHandlerFactory
-{
- /** Class logger. */
- private static final Logger log = Logger.getLogger(URLStreamHandlerFactory.class);
-
- /** The package prefix where JBoss protocol handlers live. */
- public static final String PACKAGE_PREFIX = "org.jboss.net.protocol";
- /** A map of protocol names to handlers. Since there can only be one
- URLStreamHandlerFactory installed, this is a static map that may be
- cleared.
- */
- private static Map handlerMap = Collections.synchronizedMap(new HashMap());
-
- /** This thread local is used to prevent recursion in the
- * createURLStreamHandler method. Resolving the protocol handler
- * class can end up creating a new URL which can loop back into
- * this factory with a stack like:
- * <pre>
- URLStreamHandlerFactory that use the TCL. See bug#669043
- createURLStreamHandler():146, URLStreamHandlerFactory.java
- getURLStreamHandler():1057, URL.java
- <init>():405, URL.java
- <init>():329, URL.java
- <init>():321, URL.java
- <init>():540, URLClassPath.java
- run():319, URLClassPath.java
- doPrivileged():-1, AccessController.java
- getLoader():308, URLClassPath.java
- getLoader():285, URLClassPath.java
- findResource():136, URLClassPath.java
- run():351, URLClassLoader.java
- doPrivileged():-1, AccessController.java
- findResource():348, URLClassLoader.java
- getResource():780, ClassLoader.java
- getResourceLocally():250, UnifiedClassLoader.java
- getResourceFromClassLoader():333, UnifiedLoaderRepository3.java
- getResource():243, UnifiedLoaderRepository3.java
- getResource():228, UnifiedClassLoader3.java
- </pre>
- So we detect recursion based on the protocol value matches the current
- createURLStreamHandlerProtocol setting.
- */
- private static ThreadLocal createURLStreamHandlerProtocol = new ThreadLocal();
-
- /** The current packages prefixes determined from the java.protocol.handler.pkgs
- property + the org.jboss.net.protocol default package.
- */
- private String[] handlerPkgs = {PACKAGE_PREFIX};
- /** The last java.protocol.handler.pkgs value. Used to determine if the
- java.protocol.handler.pkgs property has changed since handlerPkgs was
- last built.
- */
- private String lastHandlerPkgs = PACKAGE_PREFIX;
-
- /** A list of JBoss specific protocols for preloading. */
- public static final String PROTOCOLS[] = {
- "resource",
- "file"
- };
-
- /**
- * Preload the JBoss specific protocol handlers, so that URL knows about
- * them even if the handler factory is changed.
- */
- @SuppressWarnings("unused")
- public static void preload()
- {
- for (int i = 0; i < PROTOCOLS.length; i ++)
- {
- try
- {
- URL url = new URL(PROTOCOLS[i], "", -1, "");
- log.trace("Loaded protocol: " + PROTOCOLS[i]);
- }
- catch (Exception e)
- {
- log.warn("Failed to load protocol: " + PROTOCOLS[i], e);
- }
- }
- }
-
- /** Clear the current protocol to handler map. The map will be rebuilt
- as protocol handlers are requested.
- */
- public static void clear()
- {
- handlerMap.clear();
- }
-
- /** Search the handlerPkgs for URLStreamHandler classes matching the
- * pkg + protocol + ".Handler" naming convention.
- *
- * @param protocol The protocol to create a stream handler for
- * @return The protocol handler or null if not found
- */
- public URLStreamHandler createURLStreamHandler(final String protocol)
- {
- // Check the handler map
- URLStreamHandler handler = (URLStreamHandler) handlerMap.get(protocol);
- if( handler != null )
- return handler;
-
- // Validate that createURLStreamHandler is not recursing
- String prevProtocol = (String) createURLStreamHandlerProtocol.get();
- if( prevProtocol != null && prevProtocol.equals(protocol) )
- return null;
- createURLStreamHandlerProtocol.set(protocol);
-
- // See if the handler pkgs definition has changed
- checkHandlerPkgs();
-
- // Search the handlerPkgs for a matching protocol handler
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- for(int p = 0; p < handlerPkgs.length; p ++)
- {
- try
- {
- // Form the standard protocol handler class name
- String classname = handlerPkgs[p] + "." + protocol + ".Handler";
- Class<?> type = null;
-
- try
- {
- type = ctxLoader.loadClass(classname);
- }
- catch(ClassNotFoundException e)
- {
- // Try our class loader
- type = Class.forName(classname);
- }
-
- if( type != null )
- {
- handler = (URLStreamHandler) type.newInstance();
- handlerMap.put(protocol, handler);
- log.trace("Found protocol:"+protocol+" handler:"+handler);
- }
- }
- catch (Throwable ignore)
- {
- }
- }
-
- createURLStreamHandlerProtocol.set(null);
- return handler;
- }
-
- /** See if the java.protocol.handler.pkgs system property has changed
- and if it has, parse it to update the handlerPkgs array.
- */
- private synchronized void checkHandlerPkgs()
- {
- String handlerPkgsProp = System.getProperty("java.protocol.handler.pkgs");
- if( handlerPkgsProp != null && handlerPkgsProp.equals(lastHandlerPkgs) == false )
- {
- // Update the handlerPkgs[] from the handlerPkgsProp
- StringTokenizer tokeninzer = new StringTokenizer(handlerPkgsProp, "|");
- ArrayList<String> tmp = new ArrayList<String>();
- while( tokeninzer.hasMoreTokens() )
- {
- String pkg = tokeninzer.nextToken().intern();
- if( tmp.contains(pkg) == false )
- tmp.add(pkg);
- }
- // Include the JBoss default protocol handler pkg
- if( tmp.contains(PACKAGE_PREFIX) == false )
- tmp.add(PACKAGE_PREFIX);
- handlerPkgs = new String[tmp.size()];
- tmp.toArray(handlerPkgs);
- lastHandlerPkgs = handlerPkgsProp;
- }
- }
-
-}
Copied: common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java (from rev 2859, common-core/trunk/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java)
===================================================================
--- common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java (rev 0)
+++ common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java 2008-06-11 12:03:51 UTC (rev 2868)
@@ -0,0 +1,228 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.net.protocol;
+
+import java.net.URL;
+import java.net.URLStreamHandler;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A factory for loading URL protocol handlers. This is based
+ * on Sun's URL mechanism, in that <tt>Handler</tt> classes will be
+ * searched for in the packages specified by the java.protocol.handler.pkgs
+ * property are searched for classes matching the protocol + ".Handler"
+ * classname. The default JBoss package "org.jboss.net.protocol" is searched
+ * even if not specified in the java.protocol.handler.pkgs property.
+ *
+ * <p>This factory is installed by the default server implementaion
+ * to ensure that protocol handlers not in the system classpath are
+ * located. The thread context class is used first followed by the
+ * Class.forName method.
+ * </p>
+ *
+ * @version <tt>$Revision$</tt>
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author Scott.Stark at jboss.org
+ */
+ at SuppressWarnings("unchecked")
+public class URLStreamHandlerFactory implements java.net.URLStreamHandlerFactory
+{
+ /** Class logger. */
+ private static final Logger log = Logger.getLogger(URLStreamHandlerFactory.class);
+
+ /** The package prefix where JBoss protocol handlers live. */
+ public static final String PACKAGE_PREFIX = "org.jboss.net.protocol";
+
+ /** A map of protocol names to handlers. Since there can only be one
+ URLStreamHandlerFactory installed, this is a static map that may be
+ cleared.
+ */
+ private static Map handlerMap = Collections.synchronizedMap(new HashMap());
+
+ /** This thread local is used to prevent recursion in the
+ * createURLStreamHandler method. Resolving the protocol handler
+ * class can end up creating a new URL which can loop back into
+ * this factory with a stack like:
+ * <pre>
+ URLStreamHandlerFactory that use the TCL. See bug#669043
+ createURLStreamHandler():146, URLStreamHandlerFactory.java
+ getURLStreamHandler():1057, URL.java
+ <init>():405, URL.java
+ <init>():329, URL.java
+ <init>():321, URL.java
+ <init>():540, URLClassPath.java
+ run():319, URLClassPath.java
+ doPrivileged():-1, AccessController.java
+ getLoader():308, URLClassPath.java
+ getLoader():285, URLClassPath.java
+ findResource():136, URLClassPath.java
+ run():351, URLClassLoader.java
+ doPrivileged():-1, AccessController.java
+ findResource():348, URLClassLoader.java
+ getResource():780, ClassLoader.java
+ getResourceLocally():250, UnifiedClassLoader.java
+ getResourceFromClassLoader():333, UnifiedLoaderRepository3.java
+ getResource():243, UnifiedLoaderRepository3.java
+ getResource():228, UnifiedClassLoader3.java
+ </pre>
+ So we detect recursion based on the protocol value matches the current
+ createURLStreamHandlerProtocol setting.
+ */
+ private static ThreadLocal createURLStreamHandlerProtocol = new ThreadLocal();
+
+ /** The current packages prefixes determined from the java.protocol.handler.pkgs
+ property + the org.jboss.net.protocol default package.
+ */
+ private String[] handlerPkgs = {PACKAGE_PREFIX};
+
+ /** The last java.protocol.handler.pkgs value. Used to determine if the
+ java.protocol.handler.pkgs property has changed since handlerPkgs was
+ last built.
+ */
+ private String lastHandlerPkgs = PACKAGE_PREFIX;
+
+ /** A list of JBoss specific protocols for preloading. */
+ public static final String PROTOCOLS[] = {
+ "file",
+ "resource"
+ };
+
+ /**
+ * Preload the JBoss specific protocol handlers, so that URL knows about
+ * them even if the handler factory is changed.
+ */
+ @SuppressWarnings("unused")
+ public static void preload()
+ {
+ for (int i = 0; i < PROTOCOLS.length; i ++)
+ {
+ try
+ {
+ URL url = new URL(PROTOCOLS[i], "", -1, "");
+ log.trace("Loaded protocol: " + PROTOCOLS[i]);
+ }
+ catch (Exception e)
+ {
+ log.warn("Failed to load protocol: " + PROTOCOLS[i], e);
+ }
+ }
+ }
+
+ /** Clear the current protocol to handler map. The map will be rebuilt
+ as protocol handlers are requested.
+ */
+ public static void clear()
+ {
+ handlerMap.clear();
+ }
+
+ /** Search the handlerPkgs for URLStreamHandler classes matching the
+ * pkg + protocol + ".Handler" naming convention.
+ *
+ * @param protocol The protocol to create a stream handler for
+ * @return The protocol handler or null if not found
+ */
+ public URLStreamHandler createURLStreamHandler(final String protocol)
+ {
+ // Check the handler map
+ URLStreamHandler handler = (URLStreamHandler) handlerMap.get(protocol);
+ if( handler != null )
+ return handler;
+
+ // Validate that createURLStreamHandler is not recursing
+ String prevProtocol = (String) createURLStreamHandlerProtocol.get();
+ if( prevProtocol != null && prevProtocol.equals(protocol) )
+ return null;
+ createURLStreamHandlerProtocol.set(protocol);
+
+ // See if the handler pkgs definition has changed
+ checkHandlerPkgs();
+
+ // Search the handlerPkgs for a matching protocol handler
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ for(int p = 0; p < handlerPkgs.length; p ++)
+ {
+ try
+ {
+ // Form the standard protocol handler class name
+ String classname = handlerPkgs[p] + "." + protocol + ".Handler";
+ Class<?> type = null;
+
+ try
+ {
+ type = ctxLoader.loadClass(classname);
+ }
+ catch(ClassNotFoundException e)
+ {
+ // Try our class loader
+ type = Class.forName(classname);
+ }
+
+ if( type != null )
+ {
+ handler = (URLStreamHandler) type.newInstance();
+ handlerMap.put(protocol, handler);
+ log.trace("Found protocol:"+protocol+" handler:"+handler);
+ }
+ }
+ catch (Throwable ignore)
+ {
+ }
+ }
+
+ createURLStreamHandlerProtocol.set(null);
+ return handler;
+ }
+
+ /** See if the java.protocol.handler.pkgs system property has changed
+ and if it has, parse it to update the handlerPkgs array.
+ */
+ private synchronized void checkHandlerPkgs()
+ {
+ String handlerPkgsProp = System.getProperty("java.protocol.handler.pkgs");
+ if( handlerPkgsProp != null && handlerPkgsProp.equals(lastHandlerPkgs) == false )
+ {
+ // Update the handlerPkgs[] from the handlerPkgsProp
+ StringTokenizer tokeninzer = new StringTokenizer(handlerPkgsProp, "|");
+ ArrayList<String> tmp = new ArrayList<String>();
+ while( tokeninzer.hasMoreTokens() )
+ {
+ String pkg = tokeninzer.nextToken().intern();
+ if( tmp.contains(pkg) == false )
+ tmp.add(pkg);
+ }
+ // Include the JBoss default protocol handler pkg
+ if( tmp.contains(PACKAGE_PREFIX) == false )
+ tmp.add(PACKAGE_PREFIX);
+ handlerPkgs = new String[tmp.size()];
+ tmp.toArray(handlerPkgs);
+ lastHandlerPkgs = handlerPkgsProp;
+ }
+ }
+
+}
Copied: common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/file (from rev 2859, common-core/trunk/src/main/java/org/jboss/net/protocol/file)
Deleted: common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/file/FileURLConnection.java
===================================================================
--- common-core/trunk/src/main/java/org/jboss/net/protocol/file/FileURLConnection.java 2008-06-10 17:36:21 UTC (rev 2859)
+++ common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/file/FileURLConnection.java 2008-06-11 12:03:51 UTC (rev 2868)
@@ -1,211 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.net.protocol.file;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FilePermission;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLDecoder;
-import java.security.Permission;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-/**
- * Provides local file access via URL semantics, correctly returning
- * the last modified time of the underlying file.
- *
- * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
- * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
- * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $Revision$
- */
-public class FileURLConnection extends URLConnection
-{
- static boolean decodeFilePaths = true;
- static
- {
- String flag = System.getProperty("org.jboss.net.protocol.file.decodeFilePaths");
- if (flag != null)
- decodeFilePaths = Boolean.valueOf(flag).booleanValue();
- }
-
- /** The underlying file */
- protected File file;
-
- public FileURLConnection(final URL url) throws MalformedURLException, IOException
- {
- super(url);
- String path = url.getPath();
- if (decodeFilePaths)
- path = URLDecoder.decode(path, "UTF-8");
-
- // Convert the url '/' to the os file separator
- file = new File(path.replace('/', File.separatorChar).replace('|', ':'));
-
- doOutput = false;
- }
-
- /**
- * Returns the underlying file for this connection.
- * @return the file
- */
- public File getFile()
- {
- return file;
- }
-
- /**
- * Checks if the underlying file for this connection exists.
- *
- * @throws FileNotFoundException
- */
- public void connect() throws IOException
- {
- if (connected)
- return;
-
- if (!file.exists())
- {
- throw new FileNotFoundException(file.getPath());
- }
- connected = true;
- }
-
- public InputStream getInputStream() throws IOException
- {
- if (!connected)
- connect();
-
- if (file.isDirectory())
- {
- String[] files = file.list();
- Arrays.sort(files);
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < files.length; i++)
- {
- sb.append(files[i]).append("\n");
- }
- return new ByteArrayInputStream(sb.toString().getBytes());
- }
- else
- {
- return new FileInputStream(file);
- }
- }
-
- public OutputStream getOutputStream() throws IOException
- {
- if (!connected)
- connect();
-
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- {
- // Check for write access
- FilePermission p = new FilePermission(file.getPath(), "write");
- sm.checkPermission(p);
- }
- return new FileOutputStream(file);
- }
-
- /**
- * Provides support for returning the value for the
- * <tt>last-modified</tt> header.
- */
- public String getHeaderField(final String name)
- {
- String headerField = null;
- if (name.equalsIgnoreCase("last-modified"))
- {
- long lastModified = getLastModified();
- if (lastModified != 0)
- {
- // return the last modified date formatted according to RFC 1123
- Date modifiedDate = new Date(lastModified);
- SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
- sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
- headerField = sdf.format(modifiedDate);
- }
- }
- else if (name.equalsIgnoreCase("content-length"))
- {
- headerField = String.valueOf(file.length());
- }
- else if (name.equalsIgnoreCase("content-type"))
- {
- headerField = getFileNameMap().getContentTypeFor(file.getName());
- if (headerField == null)
- {
- try
- {
- InputStream is = getInputStream();
- BufferedInputStream bis = new BufferedInputStream(is);
- headerField = URLConnection.guessContentTypeFromStream(bis);
- bis.close();
- }
- catch(IOException e)
- {
- // ignore
- }
- }
- }
- else if (name.equalsIgnoreCase("date"))
- {
- headerField = String.valueOf(getLastModified());
- }
- else
- {
- // This always returns null currently
- headerField = super.getHeaderField(name);
- }
- return headerField;
- }
-
- /**
- * Return a permission for reading of the file
- */
- public Permission getPermission() throws IOException
- {
- return new FilePermission(file.getPath(), "read");
- }
-
- /**
- * Returns the last modified time of the underlying file.
- */
- public long getLastModified()
- {
- return file.lastModified();
- }
-}
Copied: common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/file/FileURLConnection.java (from rev 2866, common-core/trunk/src/main/java/org/jboss/net/protocol/file/FileURLConnection.java)
===================================================================
--- common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/file/FileURLConnection.java (rev 0)
+++ common-core/tags/2.2.7.GA/src/main/java/org/jboss/net/protocol/file/FileURLConnection.java 2008-06-11 12:03:51 UTC (rev 2868)
@@ -0,0 +1,226 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.net.protocol.file;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FilePermission;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLDecoder;
+import java.security.Permission;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+/**
+ * Provides local file access via URL semantics, correctly returning
+ * the last modified time of the underlying file.
+ *
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author <a href="mailto:scott.stark at jboss.org">Scott Stark</a>
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @version $Revision$
+ */
+public class FileURLConnection extends URLConnection
+{
+ static boolean decodeFilePaths = true;
+ static
+ {
+ String flag = System.getProperty("org.jboss.net.protocol.file.decodeFilePaths");
+ if (flag != null)
+ {
+ decodeFilePaths = Boolean.valueOf(flag).booleanValue();
+ }
+ }
+
+ /** The underlying file */
+ protected File file;
+
+ public FileURLConnection(final URL url) throws MalformedURLException, IOException
+ {
+ super(url);
+
+ String path = url.getPath();
+ if (decodeFilePaths)
+ {
+ path = URLDecoder.decode(path, "UTF-8");
+ }
+ // Convert the url '/' to the os file separator
+ file = new File(path.replace('/', File.separatorChar).replace('|', ':'));
+
+ super.doOutput = false;
+ }
+
+ /**
+ * Returns the underlying file for this connection.
+ * @return the file
+ */
+ public File getFile()
+ {
+ return file;
+ }
+
+ /**
+ * Checks if the underlying file for this connection exists.
+ *
+ * @throws FileNotFoundException
+ */
+ public void connect() throws IOException
+ {
+ if (connected)
+ return;
+
+ if (!file.exists())
+ {
+ throw new FileNotFoundException(file.getPath());
+ }
+ connected = true;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ connect();
+
+ if (file.isDirectory())
+ {
+ // return a sorted list of the directory contents
+ String[] files = file.list();
+ Arrays.sort(files);
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < files.length; i++)
+ {
+ sb.append(files[i]).append("\n");
+ }
+ return new ByteArrayInputStream(sb.toString().getBytes());
+ }
+ else
+ {
+ return new FileInputStream(file);
+ }
+ }
+
+ // We should probably disallow this?
+ public OutputStream getOutputStream() throws IOException
+ {
+ connect();
+
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ {
+ // Check for write access
+ FilePermission p = new FilePermission(file.getPath(), "write");
+ sm.checkPermission(p);
+ }
+ return new FileOutputStream(file);
+ }
+
+ /**
+ * Provides support for the following headers:
+ *
+ * <tt>last-modified</tt>
+ * <tt>content-length</tt>
+ * <tt>content-type</tt>
+ * <tt>date</tt>
+ */
+ public String getHeaderField(final String name)
+ {
+ String headerField = null;
+ if (name.equalsIgnoreCase("last-modified"))
+ {
+ long lastModified = getLastModified();
+ if (lastModified != 0)
+ {
+ // return the last modified date formatted according to RFC 1123
+ Date modifiedDate = new Date(lastModified);
+ SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
+ sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
+ headerField = sdf.format(modifiedDate);
+ }
+ }
+ else if (name.equalsIgnoreCase("content-length"))
+ {
+ headerField = String.valueOf(file.length());
+ }
+ else if (name.equalsIgnoreCase("content-type"))
+ {
+ if (file.isDirectory())
+ {
+ headerField = "text/plain";
+ }
+ else
+ {
+ headerField = getFileNameMap().getContentTypeFor(file.getName());
+ if (headerField == null)
+ {
+ try
+ {
+ InputStream is = getInputStream();
+ BufferedInputStream bis = new BufferedInputStream(is);
+ headerField = URLConnection.guessContentTypeFromStream(bis);
+ bis.close();
+ }
+ catch(IOException e)
+ {
+ // ignore
+ }
+ }
+ }
+ }
+ else if (name.equalsIgnoreCase("date"))
+ {
+ headerField = String.valueOf(getLastModified());
+ }
+ else
+ {
+ // This always returns null currently
+ headerField = super.getHeaderField(name);
+ }
+ return headerField;
+ }
+
+ /**
+ * Return a permission for reading of the file
+ */
+ public Permission getPermission() throws IOException
+ {
+ return new FilePermission(file.getPath(), "read");
+ }
+
+ /**
+ * Returns the last modified time of the underlying file.
+ */
+ public long getLastModified()
+ {
+ return file.lastModified();
+ }
+}
Deleted: common-core/tags/2.2.7.GA/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java
===================================================================
--- common-core/trunk/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java 2008-05-30 18:39:39 UTC (rev 2853)
+++ common-core/tags/2.2.7.GA/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java 2008-06-11 12:03:51 UTC (rev 2868)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.util.test.protocol;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.URL;
-import java.net.URLConnection;
-
-import junit.framework.TestCase;
-
-/**
- * Tests of the expected jdk file: url connection protocol handler behaviors.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class FileURLConnectionTestCase extends TestCase
-{
- public void testLastModified()
- throws Exception
- {
- File tmp = File.createTempFile("testLastModified", "test");
- tmp.deleteOnExit();
- long lastModified = tmp.lastModified();
- System.out.println(tmp.getAbsolutePath()+", lastModified:"+lastModified);
- URL tmpURL = tmp.toURL();
- URLConnection tmpConn = tmpURL.openConnection();
- assertEquals(lastModified, tmpConn.getLastModified());
- long lastModifiedHdr = tmpConn.getHeaderFieldDate("Last-Modified", 0);
- System.out.println("Last-Modified: "+lastModifiedHdr);
- assertEquals(lastModified, lastModifiedHdr);
- }
-
- public void testLength()
- throws Exception
- {
- File tmp = File.createTempFile("testLastModified", "test");
- tmp.deleteOnExit();
- FileOutputStream fos = new FileOutputStream(tmp);
- fos.write("testLength".getBytes());
- fos.close();
-
- URL tmpURL = tmp.toURL();
- URLConnection tmpConn = tmpURL.openConnection();
- int length = tmpConn.getContentLength();
- System.out.println(tmp.getAbsolutePath()+", length:"+length);
- assertEquals(tmp.length(), length);
- int lengthHdr = tmpConn.getHeaderFieldInt("Content-Length", 0);
- assertEquals(length, lengthHdr);
- }
-}
Copied: common-core/tags/2.2.7.GA/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java (from rev 2866, common-core/trunk/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java)
===================================================================
--- common-core/tags/2.2.7.GA/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java (rev 0)
+++ common-core/tags/2.2.7.GA/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java 2008-06-11 12:03:51 UTC (rev 2868)
@@ -0,0 +1,185 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.util.test.protocol;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
+
+import junit.framework.TestCase;
+
+import org.jboss.net.protocol.file.FileURLConnection;
+import org.jboss.util.file.Files;
+
+/**
+ * Tests of the expected jdk file: url connection protocol handler behaviors.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author Dimitris.Andreadis at jboss.org
+ * @version $Revision:$
+ */
+public class FileURLConnectionTestCase extends TestCase
+{
+ public void testLastModified() throws Exception
+ {
+ File tmp = File.createTempFile("testLastModified", "");
+ tmp.deleteOnExit();
+ long lastModified = tmp.lastModified();
+ System.out.println("Created file: " + tmp.getAbsolutePath() + ", lastModified:" + lastModified);
+
+ URL tmpURL = tmp.toURL();
+ // Test JDK's provided FileURLConnection
+ checkLastModified(tmpURL.openConnection(), lastModified);
+ // Test JBoss's FileURLConnection
+ checkLastModified(new FileURLConnection(tmpURL), lastModified);
+ }
+
+ public void testContentLength() throws Exception
+ {
+ File tmp = File.createTempFile("testContentLength", "");
+ tmp.deleteOnExit();
+ FileOutputStream fos = new FileOutputStream(tmp);
+ fos.write("testLength".getBytes());
+ fos.close();
+ long expectedLength = tmp.length();
+
+ URL tmpURL = tmp.toURL();
+ checkContentLength(tmpURL.openConnection(), expectedLength);
+ checkContentLength(new FileURLConnection(tmpURL), expectedLength);
+ }
+
+ public void testContentType() throws Exception
+ {
+ File tmp = File.createTempFile("testContentType", ".txt");
+ tmp.deleteOnExit();
+
+ FileOutputStream fos = new FileOutputStream(tmp);
+ fos.write("A text file".getBytes());
+ fos.close();
+ String expectedContentType = "text/plain";
+
+ URL tmpURL = tmp.toURL();
+ checkContentType(tmpURL.openConnection(), expectedContentType);
+
+ checkContentType(new FileURLConnection(tmpURL), expectedContentType);
+
+ File dir = tmp.getParentFile();
+ URL dirURL = dir.toURL();
+ checkContentType(dirURL.openConnection(), expectedContentType);
+
+ checkContentType(new FileURLConnection(dirURL), expectedContentType);
+ }
+
+ public void testDirectoryListing() throws Exception
+ {
+ // create a test directory structure
+ // TMPDIR/testDirectoryList39558
+ // TMPDIR/testDirectoryList39558/test.txt
+ // TMPDIR/testDirectoryList39558/test.dir
+ File rootDir = File.createTempFile("testDirectoryList", "");
+ try
+ {
+ rootDir.delete();
+ rootDir.mkdir();
+ System.out.println(rootDir);
+ File tmpFile = new File(rootDir, "test.txt");
+ tmpFile.createNewFile();
+ System.out.println(tmpFile);
+ FileOutputStream fos = new FileOutputStream(tmpFile);
+ fos.write("this is a test file".getBytes());
+ fos.close();
+ File tmpDir = new File(rootDir, "test.dir");
+ tmpDir.mkdir();
+ System.out.println(tmpDir);
+
+ String[] expectedList = { "test.dir", "test.txt", null };
+ URL rootURL = rootDir.toURL();
+
+ // Check JDK FileURLConnection impl
+ checkDirectoryListing(rootURL.openConnection(), expectedList);
+
+ // Test JBoss FileURLConnection impl
+ checkDirectoryListing(new FileURLConnection(rootURL), expectedList);
+ }
+ finally
+ {
+ // cleanup
+ Files.delete(rootDir);
+ }
+ }
+
+ private void checkLastModified(URLConnection conn, long expectedLastModified)
+ {
+ System.out.println("Got URLConnection of type: " + conn.getClass().getName());
+ assertEquals(expectedLastModified, conn.getLastModified());
+
+ long lastModifiedHdr = conn.getHeaderFieldDate("last-modified", 0);
+ System.out.println(conn.getURL() + ", last-modified header: "+lastModifiedHdr);
+ // the last-modified header is expected to strip the milliseconds to
+ // comply with the (dd MMM yyyy HH:mm:ss) format, so the following assertions
+ // is invalid on windows that provide millisecond accuracy to File.lastModified()
+ // see, http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4504473
+ // assertEquals(expectedLastModified, lastModifiedHdr);
+ }
+
+ private void checkContentLength(URLConnection conn, long expectedLength)
+ {
+ System.out.println("Got URLConnection of type: " + conn.getClass().getName());
+ int length = conn.getContentLength();
+ System.out.println(conn.getURL() + ", content-length:" + length);
+ assertEquals(expectedLength, length);
+ int lengthHdr = conn.getHeaderFieldInt("content-length", 0);
+ assertEquals(expectedLength, lengthHdr);
+ }
+
+ private void checkContentType(URLConnection conn, String expectedType)
+ {
+ System.out.println("Got URLConnection of type: " + conn.getClass().getName());
+ String type = conn.getContentType();
+ System.out.println(conn.getURL() + ", content-type: " + type);
+ assertEquals(type, expectedType);
+ }
+
+ private void checkDirectoryListing(URLConnection conn, String[] expectedFiles) throws IOException
+ {
+ System.out.println("Got URLConnection of type: " + conn.getClass().getName());
+ BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+ try
+ {
+ // verify the sorted directory list
+ for (int i = 0; i < expectedFiles.length; i++)
+ {
+ String msg = "directory entry #" + i;
+ System.out.println(msg + " : " + expectedFiles[i]);
+ assertEquals(msg, expectedFiles[i], in.readLine());
+ }
+ }
+ finally
+ {
+ in.close();
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list