[jboss-svn-commits] JBoss Common SVN: r2856 - in common-core/tags: 2.2.6.GA and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Jun 8 12:06:01 EDT 2008
Author: dimitris at jboss.org
Date: 2008-06-08 12:06:01 -0400 (Sun, 08 Jun 2008)
New Revision: 2856
Added:
common-core/tags/2.2.6.GA/
common-core/tags/2.2.6.GA/pom.xml
common-core/tags/2.2.6.GA/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java
common-core/tags/2.2.6.GA/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java
Removed:
common-core/tags/2.2.6.GA/pom.xml
common-core/tags/2.2.6.GA/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java
common-core/tags/2.2.6.GA/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java
Log:
[maven-release-plugin] copy for tag 2.2.6.GA
Copied: common-core/tags/2.2.6.GA (from rev 2853, common-core/trunk)
Deleted: common-core/tags/2.2.6.GA/pom.xml
===================================================================
--- common-core/trunk/pom.xml 2008-05-30 18:39:39 UTC (rev 2853)
+++ common-core/tags/2.2.6.GA/pom.xml 2008-06-08 16:06:01 UTC (rev 2856)
@@ -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.6.GA/pom.xml (from rev 2855, common-core/trunk/pom.xml)
===================================================================
--- common-core/tags/2.2.6.GA/pom.xml (rev 0)
+++ common-core/tags/2.2.6.GA/pom.xml 2008-06-08 16:06:01 UTC (rev 2856)
@@ -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.6.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.6.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.6.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.6.GA/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java 2008-06-08 16:06:01 UTC (rev 2856)
@@ -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.6.GA/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java (from rev 2854, common-core/trunk/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java)
===================================================================
--- common-core/tags/2.2.6.GA/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java (rev 0)
+++ common-core/tags/2.2.6.GA/src/main/java/org/jboss/net/protocol/URLStreamHandlerFactory.java 2008-06-08 16:06:01 UTC (rev 2856)
@@ -0,0 +1,227 @@
+/*
+ * 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[] = {
+ "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;
+ }
+ }
+
+}
Deleted: common-core/tags/2.2.6.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.6.GA/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java 2008-06-08 16:06:01 UTC (rev 2856)
@@ -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.6.GA/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java (from rev 2854, common-core/trunk/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java)
===================================================================
--- common-core/tags/2.2.6.GA/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java (rev 0)
+++ common-core/tags/2.2.6.GA/src/test/java/org/jboss/test/util/test/protocol/FileURLConnectionTestCase.java 2008-06-08 16:06:01 UTC (rev 2856)
@@ -0,0 +1,77 @@
+/*
+ * 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
+ * @author Dimitris.Andreadis 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.print(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);
+ System.out.println("Got URLConnection of type: " + tmpConn.getClass().getName());
+ // 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(lastModified, lastModifiedHdr);
+ }
+
+ public void testLength()
+ throws Exception
+ {
+ File tmp = File.createTempFile("testLength", "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);
+ }
+}
More information about the jboss-svn-commits
mailing list