User: tobyallsopp
Date: 01/05/04 23:38:28
Modified: src/main/org/jboss/resource Tag: Branch_2_2 RARDeployer.java
Log:
Fixed the RAR redployment bug (#415516) thanks to a patch from Claudio Vesco.
Revision Changes Path
No revision
No revision
1.1.1.1.2.1 +22 -9 jbosscx/src/main/org/jboss/resource/RARDeployer.java
Index: RARDeployer.java
===================================================================
RCS file: /cvsroot/jboss/jbosscx/src/main/org/jboss/resource/RARDeployer.java,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.2.1
diff -u -r1.1.1.1 -r1.1.1.1.2.1
--- RARDeployer.java 2001/02/06 06:54:40 1.1.1.1
+++ RARDeployer.java 2001/05/05 06:38:28 1.1.1.1.2.1
@@ -47,7 +47,7 @@
* <code>ConnectionFactoryLoader</code> service.
*
* @author Toby Allsopp ([EMAIL PROTECTED])
- * @version $Revision: 1.1.1.1 $
+ * @version $Revision: 1.1.1.1.2.1 $
*
* @see org.jboss.resource.ConnectionFactoryLoader
*/
@@ -128,7 +128,8 @@
// included JARs for classloading (I don't think URLClassLoader
// deals with JARs within JARs).
- File unpackedDir = new File(rarTmpDir, generateUniqueDirName(url));
+ String unpackedDirName = generateUniqueDirName(url);
+ File unpackedDir = new File(rarTmpDir, unpackedDirName);
if (unpackedDir.exists())
{
throw new DeploymentException("The application at URL '" + url + "' " +
@@ -150,8 +151,21 @@
}
else
{
- // this is a .rar file somewhere
- inflateJar(url, unpackedDir);
+ // this is a .rar file somewhere so we copy it to the temp
+ // dir because otherwise we run into problems when we try to
+ // open it again later
+ File copyFile = new File(rarTmpDir, "copy" + unpackedDirName);
+ InputStream input = url.openStream();
+ try
+ {
+ OutputStream output = new FileOutputStream(copyFile);
+ try
+ {
+ copy(input, output);
+ } finally { output.close(); }
+ } finally { input.close(); }
+ // then we can inflate the copy without fear of retribution
+ inflateJar(copyFile.toURL(), unpackedDir);
}
// Right, now we can forget about URLs and just use the file
@@ -202,15 +216,14 @@
}
};
Collection jarFiles = recursiveFind(unpackedDir, filter);
+ log.debug("Adding the following URLs to classpath:");
for (Iterator i = jarFiles.iterator(); i.hasNext(); )
{
File file = (File) i.next();
- jars.add(file.toURL());
+ URL jarUrl = file.toURL();
+ jars.add(jarUrl);
+ log.debug(jarUrl.toString());
}
-
- log.debug("Adding the following URLs to classpath:");
- for (Iterator i = jars.iterator(); i.hasNext(); )
- log.debug(((URL) i.next()).toString());
// Ok, now we have the URLs of the JARs contained in the RAR we
// can create a classloader that loads classes from them
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development