[jboss-cvs] JBossAS SVN: r103717 - projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/deployable.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 8 15:55:42 EDT 2010
Author: ALRubinger
Date: 2010-04-08 15:55:42 -0400 (Thu, 08 Apr 2010)
New Revision: 103717
Modified:
projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/deployable/DeployableArchive.java
Log:
[EMB-80] Export ZIP to file and remove boilerplate
Modified: projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/deployable/DeployableArchive.java
===================================================================
--- projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/deployable/DeployableArchive.java 2010-04-08 19:45:11 UTC (rev 103716)
+++ projects/embedded/trunk/core/src/main/java/org/jboss/embedded/core/deployable/DeployableArchive.java 2010-04-08 19:55:42 UTC (rev 103717)
@@ -17,15 +17,9 @@
package org.jboss.embedded.core.deployable;
import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.logging.Level;
import java.util.logging.Logger;
import org.jboss.embedded.api.Deployable;
@@ -107,58 +101,12 @@
// Make the new temp file
final String name = archive.getName();
- final InputStream in = archive.as(ZipExporter.class).exportZip();
final File tmpFile = new File(tmpDir, name);
tmpFile.deleteOnExit();
// Write the ZIP to the temp file
- final OutputStream out;
- try
- {
- out = new FileOutputStream(tmpFile);
- }
- catch (final FileNotFoundException fnfe)
- {
- throw new RuntimeException("Created temp file could not be found: " + tmpFile);
- }
- final int len = 1024;
- final byte[] buffer = new byte[len];
- int read = 0;
- try
- {
+ archive.as(ZipExporter.class).exportZip(tmpFile, true);
- while (((read = in.read(buffer)) != -1))
- {
- out.write(buffer, 0, read);
- }
- }
- catch (final IOException ioe)
- {
- throw new RuntimeException("Error in obtainting bytes from " + archive, ioe);
- }
- finally
- {
- try
- {
- in.close();
- }
- catch (final IOException ignore)
- {
- }
- try
- {
- out.close();
- }
- catch (final IOException ignore)
- {
-
- }
- }
- if (log.isLoggable(Level.FINE))
- {
- log.fine("Using temporary file to back deployable: " + tmpFile.getAbsolutePath());
- }
-
// Create a Deployable from the File
final Deployable deployableFile = new DeployableFile(tmpFile);
More information about the jboss-cvs-commits
mailing list