tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1295357 [1/2] - in /openejb/trunk/openejb: arquillian-tomee/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/ container/openejb-core/src/main/java/org/apache/openejb/assembler/ container/openejb-core/src/main/java...
Date Thu, 01 Mar 2012 00:43:39 GMT
Author: dblevins
Date: Thu Mar  1 00:43:35 2012
New Revision: 1295357

URL: http://svn.apache.org/viewvc?rev=1295357&view=rev
Log:
OPENEJB-1788: Consolidate IO code
Overall reduction in duplicate code covered by the IO util and Zips

Added:
    openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java   (contents, props changed)
      - copied, changed from r1295185, openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Files.java
    openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/Zips.java
      - copied, changed from r1295185, openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Zips.java
Removed:
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Files.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/JarUtils.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Zips.java
Modified:
    openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/MavenCache.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/CmpJarBuilder.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/Deploy.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/EnvEntriesPropertiesDeployer.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ServiceUtils.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/JaxbOpenejb.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/PropertiesAdapter.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimplePassivater.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/ProviderWrapper.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceBootstrap.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/InstantdbDataSourcePlugin.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/JarExtractor.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Log4jLogStreamFactory.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/UrlCache.java
    openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java
    openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/rules/ValidationKeysAuditorTest.java
    openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/util/Archives.java
    openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/FileUtils.java
    openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java
    openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java
    openejb/trunk/openejb/itests/failover/src/main/java/org/apache/openejb/server/control/StandaloneServer.java
    openejb/trunk/openejb/itests/failover/src/test/java/org/apache/openejb/itest/failover/FailoverTest.java
    openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java
    openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java
    openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/Stop.java
    openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/osgi/ServiceManagerExtender.java
    openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatLoader.java
    openejb/trunk/openejb/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java
    openejb/trunk/openejb/tomee/tomee-common/src/main/java/org/apache/tomee/common/TomcatVersion.java
    openejb/trunk/openejb/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java
    openejb/trunk/openejb/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installers.java
    openejb/trunk/openejb/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Container.java
    openejb/trunk/openejb/tomee/tomee-loader/src/main/java/org/apache/tomee/loader/TomcatHook.java
    openejb/trunk/openejb/utils/openejb-provisionning/src/main/java/org/apache/openejb/resolver/Resolver.java
    openejb/trunk/openejb/utils/openejb-provisionning/src/main/java/org/apache/openejb/resolver/maven/AetherBasedResolver.java
    openejb/trunk/openejb/utils/webdeployer/src/main/java/org/apache/tomee/catalina/deployer/WebappDeployer.java

Modified: openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/MavenCache.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/MavenCache.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/MavenCache.java (original)
+++ openejb/trunk/openejb/arquillian-tomee/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/MavenCache.java Thu Mar  1 00:43:35 2012
@@ -16,7 +16,7 @@
  */
 package org.apache.openejb.arquillian.common;
 
-import org.apache.openejb.loader.ProvisioningUtil;
+import org.apache.openejb.loader.*;
 import org.apache.openejb.resolver.Resolver;
 
 import java.io.File;

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/DeployerEjb.java Thu Mar  1 00:43:35 2012
@@ -38,9 +38,8 @@ import javax.ejb.Remote;
 import javax.ejb.Stateless;
 import javax.ejb.TransactionManagement;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.math.BigInteger;
 import java.security.SecureRandom;
 import java.util.Collection;
@@ -216,8 +215,8 @@ public class DeployerEjb implements Depl
         // dump it
         try {
             final AdditionalDeployments additionalDeployments;
-            if (config.exists()) {
-                final FileInputStream fis = new FileInputStream(config);
+            if (config.exists() && config.length() > 0) {
+                final InputStream fis = IO.read(config);
                 try {
                     additionalDeployments = JaxbOpenejb.unmarshal(AdditionalDeployments.class, fis);
                 } finally {
@@ -242,7 +241,7 @@ public class DeployerEjb implements Depl
                     }
                 }
             }
-            JaxbOpenejb.marshal(AdditionalDeployments.class, additionalDeployments, new FileOutputStream(config));
+            JaxbOpenejb.marshal(AdditionalDeployments.class, additionalDeployments, IO.write(config));
         } catch (Exception e) {
             LOGGER.error("can't save the added app, will not be present next time you'll start", e);
         }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/CmpJarBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/CmpJarBuilder.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/CmpJarBuilder.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/CmpJarBuilder.java Thu Mar  1 00:43:35 2012
@@ -17,7 +17,6 @@
 package org.apache.openejb.assembler.classic;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Set;
 import java.util.StringTokenizer;
@@ -30,6 +29,7 @@ import org.apache.openejb.core.cmp.cmp2.
 import org.apache.openejb.core.cmp.cmp2.Cmp1Generator;
 import org.apache.openejb.core.cmp.CmpUtil;
 import org.apache.openejb.ClassLoaderUtil;
+import org.apache.openejb.loader.IO;
 import org.apache.openejb.util.UrlCache;
 
 /**
@@ -249,7 +249,7 @@ public class CmpJarBuilder {
         }
 
         jarFile.deleteOnExit();
-        JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(jarFile));
+        JarOutputStream jarOutputStream = new JarOutputStream(IO.write(jarFile));
         return jarOutputStream;
     }
 

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java Thu Mar  1 00:43:35 2012
@@ -81,6 +81,7 @@ import javax.ejb.embeddable.EJBContainer
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -453,9 +454,9 @@ public class ConfigurationFactory implem
             additionalDeploymentFile = null;
         }
         if (additionalDeploymentFile.exists()) {
-            FileInputStream fis = null;
+            InputStream fis = null;
             try {
-                fis = new FileInputStream(additionalDeploymentFile);
+                fis = IO.read(additionalDeploymentFile);
                 final AdditionalDeployments additionalDeployments = JaxbOpenejb.unmarshal(AdditionalDeployments.class, fis);
                 deployments.addAll(additionalDeployments.getDeployments());
             } catch (Exception e) {

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/Deploy.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/Deploy.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/Deploy.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/Deploy.java Thu Mar  1 00:43:35 2012
@@ -37,6 +37,7 @@ import org.apache.openejb.assembler.clas
 import org.apache.openejb.assembler.classic.PersistenceUnitInfo;
 import org.apache.openejb.assembler.classic.WebAppInfo;
 import org.apache.openejb.cli.SystemExitException;
+import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.util.JarExtractor;
 import org.apache.openejb.util.Messages;
@@ -45,16 +46,11 @@ import org.apache.openejb.util.OpenEjbVe
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.util.List;
 import java.util.Properties;
 import java.util.jar.JarFile;
 
-import static org.apache.openejb.loader.IO.close;
 import static org.apache.openejb.util.JarExtractor.delete;
 
 /**
@@ -300,23 +296,10 @@ public class Deploy {
     }
 
     private static void copyFile(File file, File destFile) throws DeploymentTerminatedException {
-        InputStream in = null;
-        OutputStream out = null;
         try {
-            in = new FileInputStream(file);
-            out = new FileOutputStream(destFile);
-
-            byte[] buffer = new byte[BUF_SIZE];
-            int count = 0;
-            do {
-                out.write(buffer, 0, count);
-                count = in.read(buffer, 0, buffer.length);
-            } while (count != -1);
+            IO.copy(file, destFile);
         } catch (Exception e) {
             throw new DeploymentTerminatedException(messages.format("cmd.deploy.cantCopy", file.getAbsolutePath(), destFile.getAbsolutePath()));
-        } finally {
-            close(in);
-            close(out);
         }
     }
 

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java Thu Mar  1 00:43:35 2012
@@ -124,7 +124,7 @@ public class DeploymentLoader implements
                         !jarFile.getName().endsWith(".rar")) {
                     try {
                         tmpFile = File.createTempFile("AppModule-", "", UrlCache.cacheDir);
-                        JarExtractor.copy(URLs.toFile(baseUrl), tmpFile);
+                        JarExtractor.copyRecursively(URLs.toFile(baseUrl), tmpFile);
                         tempURL = tmpFile.toURI().toURL();
 
                         doNotUseClassLoader = ClassLoaderUtil.createClassLoader(tmpFile.getCanonicalPath(), new URL[]{baseUrl}, getOpenEJBClassLoader(baseUrl));

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/EnvEntriesPropertiesDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/EnvEntriesPropertiesDeployer.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/EnvEntriesPropertiesDeployer.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/EnvEntriesPropertiesDeployer.java Thu Mar  1 00:43:35 2012
@@ -125,10 +125,7 @@ public class EnvEntriesPropertiesDeploye
         }
         if (propsUrl == null) return Collections.emptyMap();
         try {
-
-            InputStream in = IO.read(propsUrl);
-            Properties envEntriesProps = new Properties();
-            envEntriesProps.load(in);
+            Properties envEntriesProps = IO.readProperties(propsUrl);
 
             return new HashMap(envEntriesProps);
         } catch (IOException e) {

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/OutputGeneratedDescriptors.java Thu Mar  1 00:43:35 2012
@@ -27,6 +27,7 @@ import org.apache.openejb.jee.oejb2.Gero
 import org.apache.openejb.jee.oejb2.JaxbOpenejbJar2;
 import org.apache.openejb.jee.oejb3.JaxbOpenejbJar3;
 import org.apache.openejb.jee.oejb3.OpenejbJar;
+import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.Options;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.util.LogCategory;
@@ -35,10 +36,9 @@ import org.apache.openejb.util.Logger;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
-import java.io.BufferedOutputStream;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.util.Random;
 
 public class OutputGeneratedDescriptors implements DynamicDeployer {
@@ -89,16 +89,15 @@ public class OutputGeneratedDescriptors 
 	    	Connector connector = connectorModule.getConnector();
 	
 	        File tempFile = tempFile("ra-", connectorModule.getModuleId() + ".xml");
-	        FileOutputStream fout = new FileOutputStream(tempFile);
-	        BufferedOutputStream out = new BufferedOutputStream(fout);
-	
+
+            final OutputStream out = IO.write(tempFile);
 	        try {
 		    	JAXBContext ctx = JAXBContextFactory.newInstance(Connector.class);
 		    	Marshaller marshaller = ctx.createMarshaller();
 		    	marshaller.marshal(connector, out);
 	        } catch (JAXBException e) {
 	        } finally {
-	        	out.close();
+	        	IO.close(out);
 	        }
     	} catch (IOException e) {
     	}
@@ -120,15 +119,13 @@ public class OutputGeneratedDescriptors 
 
 	private void writeGenratedCmpMappings(AppModule appModule) {
         try {
-            File tempFile = tempFile("openejb-cmp-generated-orm-", ".xml");
-            FileOutputStream fout = new FileOutputStream(tempFile);
-            BufferedOutputStream out = new BufferedOutputStream(fout);
-
+            final File tempFile = tempFile("openejb-cmp-generated-orm-", ".xml");
+            final OutputStream out = IO.write(tempFile);
             try {
                 JpaJaxbUtil.marshal(EntityMappings.class, appModule.getCmpMappings(), out);
             } catch (JAXBException e) {
             } finally{
-                out.close();
+                IO.close(out);
             }
         } catch (IOException e) {
         }
@@ -136,16 +133,16 @@ public class OutputGeneratedDescriptors 
 
     private void writeOpenejbJar(EjbModule ejbModule) {
         try {
-            OpenejbJar openejbJar = ejbModule.getOpenejbJar();
-            File tempFile = tempFile("openejb-jar-", ejbModule.getModuleId() + ".xml");
-            FileOutputStream fout = new FileOutputStream(tempFile);
-            BufferedOutputStream out = new BufferedOutputStream(fout);
+            final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
+            final File tempFile = tempFile("openejb-jar-", ejbModule.getModuleId() + ".xml");
+
+            final OutputStream out = IO.write(tempFile);
             try {
                 JaxbOpenejbJar3.marshal(OpenejbJar.class, openejbJar, out);
                 logger.info("Dumping Generated openejb-jar.xml to: " + tempFile.getAbsolutePath());
             } catch (JAXBException e) {
             } finally {
-                out.close();
+                IO.close(out);
             }
         } catch (Exception e) {
         }
@@ -153,19 +150,19 @@ public class OutputGeneratedDescriptors 
 
     private void writeGeronimoOpenejb(EjbModule ejbModule) {
         try {
-            GeronimoEjbJarType geronimoEjbJarType = (GeronimoEjbJarType) ejbModule.getAltDDs().get("geronimo-openejb.xml");
+            final GeronimoEjbJarType geronimoEjbJarType = (GeronimoEjbJarType) ejbModule.getAltDDs().get("geronimo-openejb.xml");
 
             if (geronimoEjbJarType == null) return;
 
-            File tempFile = tempFile("geronimo-openejb-", ejbModule.getModuleId() + ".xml");
-            FileOutputStream fout = new FileOutputStream(tempFile);
-            BufferedOutputStream out = new BufferedOutputStream(fout);
+            final File tempFile = tempFile("geronimo-openejb-", ejbModule.getModuleId() + ".xml");
+
+            final OutputStream out = IO.write(tempFile);
             try {
                 JaxbOpenejbJar2.marshal(GeronimoEjbJarType.class, geronimoEjbJarType, out);
                 logger.info("Dumping Generated geronimo-openejb.xml to: " + tempFile.getAbsolutePath());
             } catch (JAXBException e) {
             } finally {
-                out.close();
+                IO.close(out);
             }
         } catch (Exception e) {
         }
@@ -173,16 +170,16 @@ public class OutputGeneratedDescriptors 
 
     private void writeEjbJar(EjbModule ejbModule) {
         try {
-            EjbJar ejbJar = ejbModule.getEjbJar();
-            File tempFile = tempFile("ejb-jar-", ejbModule.getModuleId() + ".xml");
-            FileOutputStream fout = new FileOutputStream(tempFile);
-            BufferedOutputStream out = new BufferedOutputStream(fout);
+            final EjbJar ejbJar = ejbModule.getEjbJar();
+            final File tempFile = tempFile("ejb-jar-", ejbModule.getModuleId() + ".xml");
+
+            final OutputStream out = IO.write(tempFile);
             try {
                 JaxbJavaee.marshal(EjbJar.class, ejbJar, out);
                 logger.info("Dumping Generated ejb-jar.xml to: " + tempFile.getAbsolutePath());
             } catch (JAXBException e) {
             } finally {
-                out.close();
+                IO.close(out);
             }
         } catch (Exception e) {
         }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java Thu Mar  1 00:43:35 2012
@@ -63,7 +63,6 @@ import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 import java.io.ByteArrayInputStream;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -305,14 +304,7 @@ public class ReadDescriptors implements 
                     try {
                         File tempFile = File.createTempFile("openejb-jar-", ".xml");
                         try {
-                            FileOutputStream out = new FileOutputStream(tempFile);
-                            InputStream in = source.get();
-                            int b = in.read();
-                            while (b != -1){
-                                out.write(b);
-                                b = in.read();
-                            }
-                            out.close();
+                            IO.copy(source.get(), tempFile);
                         } catch (IOException e) {
                         }
                         filePath = tempFile.getAbsolutePath();

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ServiceUtils.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ServiceUtils.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ServiceUtils.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ServiceUtils.java Thu Mar  1 00:43:35 2012
@@ -256,22 +256,14 @@ public class ServiceUtils {
     }
 
     public static Properties loadProperties(String propertiesFile, Properties defaults) throws OpenEJBException {
-        InputStream in = null;
         try {
-            File pfile = new File(propertiesFile);
-            in = new FileInputStream(pfile);
-
-            try {
-                /*
-                This may not work as expected.  The desired effect is that
-                the load method will read in the properties and overwrite
-                the values of any properties that may have previously been
-                defined.
-                */
-                defaults.load(in);
-            } catch (IOException ex) {
-                throw new OpenEJBException(messages.format("conf.0012", ex.getLocalizedMessage()), ex);
-            }
+            /*
+            The desired effect is that
+            the load method will read in the properties and overwrite
+            the values of any properties that may have previously been
+            defined.
+            */
+            IO.readProperties(new File(propertiesFile), defaults);
 
             return defaults;
         } catch (FileNotFoundException ex) {
@@ -280,8 +272,6 @@ public class ServiceUtils {
             throw new OpenEJBException(messages.format("conf.0007", propertiesFile, ex.getLocalizedMessage()), ex);
         } catch (SecurityException ex) {
             throw new OpenEJBException(messages.format("conf.0005", propertiesFile, ex.getLocalizedMessage()), ex);
-        } finally {
-            IO.close(in);
         }
     }
 

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java Thu Mar  1 00:43:35 2012
@@ -26,6 +26,7 @@ import org.apache.openejb.assembler.clas
 import org.apache.openejb.assembler.classic.EjbJarInfo;
 import org.apache.openejb.assembler.classic.InfoObject;
 import org.apache.openejb.assembler.classic.WebAppInfo;
+import org.apache.openejb.loader.IO;
 
 import javax.enterprise.deploy.model.DeployableObject;
 import javax.enterprise.deploy.shared.ActionType;
@@ -282,15 +283,10 @@ public class VmDeploymentManager impleme
         // load properties
         Properties properties = new Properties();
         if (planFile != null) {
-            InputStream in = null;
             try {
-                in = new FileInputStream(planFile);
-                properties.load(in);
+                IO.readProperties(planFile, properties);
             } catch (IOException ignored) {
-            } finally {
-                close(in);
             }
-
         }
 
         ProgressObject progressObject = deploy(targetList, properties);

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/JaxbOpenejb.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/JaxbOpenejb.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/JaxbOpenejb.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/JaxbOpenejb.java Thu Mar  1 00:43:35 2012
@@ -43,8 +43,6 @@ import javax.xml.parsers.SAXParserFactor
 import javax.xml.transform.sax.SAXSource;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -224,7 +222,7 @@ public abstract class JaxbOpenejb {
                 URL url = new URL(configFile);
                 in = IO.read(url);
             } else {
-                in = new FileInputStream(configFile);
+                in = IO.read(new File(configFile));
             }
             Openejb openejb = (Openejb) unmarshal(SystemInstance.get().getOptions().get("openejb.configuration.class", Openejb.class), in);
             return openejb;
@@ -241,7 +239,7 @@ public abstract class JaxbOpenejb {
         OutputStream out = null;
         try {
             File file = new File(configFile);
-            out = new FileOutputStream(file);
+            out = IO.write(file);
             marshal(Openejb.class, openejb, out);
         } catch (IOException e) {
             throw new OpenEJBException(ConfigUtils.messages.format("conf.1040", configFile, e.getLocalizedMessage()), e);

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/PropertiesAdapter.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/PropertiesAdapter.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/PropertiesAdapter.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/sys/PropertiesAdapter.java Thu Mar  1 00:43:35 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.openejb.config.sys;
 
+import org.apache.openejb.loader.IO;
 import org.apache.openejb.util.SuperProperties;
 
 import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -28,10 +29,7 @@ import java.util.Properties;
  */
 public class PropertiesAdapter extends XmlAdapter<String, Properties> {
     public Properties unmarshal(String s) throws Exception {
-        Properties properties = new SuperProperties();
-        ByteArrayInputStream in = new ByteArrayInputStream(s.getBytes());
-        properties.load(in);
-        return properties;
+        return IO.readProperties(IO.read(s), new SuperProperties());
     }
 
     public String marshal(Properties properties) throws Exception {

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java Thu Mar  1 00:43:35 2012
@@ -256,7 +256,7 @@ public class IvmContext implements Conte
                 InputStream in = null;
                 try {
                     File propertiesFile = new File(new File(javahome, "lib"), "jndi.properties");
-                    in = new FileInputStream(propertiesFile);
+                    in = IO.read(propertiesFile);
                     urlPackagePrefixes = getUrlPackagePrefixes(in);
                 } catch (FileNotFoundException ignored) {
                 } finally {
@@ -270,10 +270,8 @@ public class IvmContext implements Conte
 
     private static String getUrlPackagePrefixes(InputStream in) {
         try {
-            Properties properties = new Properties();
-            properties.load(in);
-            String urlPackagePrefixes = properties.getProperty(Context.URL_PKG_PREFIXES);
-            return urlPackagePrefixes;
+            final Properties properties = IO.readProperties(in, new Properties());
+            return properties.getProperty(Context.URL_PKG_PREFIXES);
         } catch (IOException e) {
             return null;
         }
@@ -578,48 +576,4 @@ public class IvmContext implements Conte
         throw new NotSerializableException("IntraVM java.naming.Context objects can not be passed as arguments");
     }
 
-    /* for testing only*/
-    public static void main(String str []) throws Exception {
-        String str1 = "root/comp/env/rate/work/doc/lot/pop";
-        String str2 = "root/comp/env/rate/work/doc/lot/price";
-        String str3 = "root/comp/env/rate/work/doc/lot";
-        String str4 = "root/comp/env/rate/work/doc/lot/break/story";
-
-        IvmContext context = new IvmContext();
-        context.bind(str1, new Integer(1));
-        context.bind(str2, new Integer(2));
-        context.bind(str4, new Integer(3));
-/*
-        Object obj = context.lookup(str1);
-        obj = context.lookup(str2);
-        obj = context.lookup(str1);
-        obj = context.lookup(str3);
-        obj = obj;
-
-        NamingEnumeration ne = context.list(str3);
-        while(ne.hasMore()){
-            NameClassPair ncp = (NameClassPair)ne.nextElement();
-            System.out.println(ncp.getName()+" "+ncp.getClassName());
-        }
-        */
-
-        Context subcntx = (Context) context.lookup(str3);
-        org.apache.openejb.core.ivm.IntraVmCopyMonitor x = null;
-        java.io.FileOutputStream fos = new java.io.FileOutputStream("x.ser");
-        java.io.ObjectOutputStream oos = new java.io.ObjectOutputStream(fos);
-        org.apache.openejb.core.ivm.IntraVmCopyMonitor.prePassivationOperation();
-        oos.writeObject(subcntx);
-        org.apache.openejb.core.ivm.IntraVmCopyMonitor.postPassivationOperation();
-        oos.flush();
-        oos.close();
-        java.io.FileInputStream fis = new java.io.FileInputStream("x.ser");
-        java.io.ObjectInputStream ois = new java.io.ObjectInputStream(fis);
-        Object newObj = ois.readObject();
-        ois.close();
-    }
-
-    //
-    // Helper methods for debugging
-    //
-
 }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimplePassivater.java Thu Mar  1 00:43:35 2012
@@ -17,8 +17,6 @@
 package org.apache.openejb.core.managed;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.Map;
@@ -26,6 +24,7 @@ import java.util.Properties;
 
 import org.apache.openejb.SystemException;
 import org.apache.openejb.core.EnvProps;
+import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
@@ -65,7 +64,7 @@ public class SimplePassivater implements
             File sessionFile = new File(sessionDirectory, filename);
 
             logger.info("Passivating to file " + sessionFile);
-            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(sessionFile));
+            ObjectOutputStream oos = new ObjectOutputStream(IO.write(sessionFile));
 
             oos.writeObject(state);// passivate just the bean instance
             oos.close();
@@ -94,7 +93,7 @@ public class SimplePassivater implements
             if (sessionFile.exists()) {
                 logger.info("Activating from file " + sessionFile);
 
-                ObjectInputStream ois = new ObjectInputStream(new FileInputStream(sessionFile));
+                ObjectInputStream ois = new ObjectInputStream(IO.read(sessionFile));
                 Object state = ois.readObject();
                 ois.close();
                 sessionFile.delete();

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimplePassivater.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimplePassivater.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimplePassivater.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimplePassivater.java Thu Mar  1 00:43:35 2012
@@ -17,20 +17,15 @@
 package org.apache.openejb.core.stateful;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.io.InputStream;
-import java.io.BufferedInputStream;
-import java.io.OutputStream;
-import java.io.BufferedOutputStream;
 import java.util.Map;
 import java.util.Properties;
 
 import org.apache.openejb.SystemException;
 import org.apache.openejb.core.EnvProps;
 import org.apache.openejb.core.ivm.EjbObjectInputStream;
+import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
@@ -70,13 +65,15 @@ public class SimplePassivater implements
             File sessionFile = new File(sessionDirectory, filename);
 
             logger.info("Passivating to file " + sessionFile);
-            OutputStream out = new FileOutputStream(sessionFile);
-            out = new BufferedOutputStream(out);
-            ObjectOutputStream oos = new ObjectOutputStream(out);
-
-            oos.writeObject(state);// passivate just the bean instance
-            oos.close();
-            sessionFile.deleteOnExit();
+
+            final ObjectOutputStream oos = new ObjectOutputStream(IO.write(sessionFile));
+            try {
+                oos.writeObject(state);// passivate just the bean instance
+            } finally {
+                sessionFile.deleteOnExit();
+                IO.close(oos);
+            }
+
         } catch (java.io.NotSerializableException nse) {
             logger.error("Passivation failed ", nse);
             throw (SystemException) new SystemException("The type " + nse.getMessage() + " is not serializable as mandated by the EJB specification.").initCause(nse);
@@ -101,13 +98,13 @@ public class SimplePassivater implements
             if (sessionFile.exists()) {
                 logger.info("Activating from file " + sessionFile);
 
-                InputStream in = new FileInputStream(sessionFile);
-                in = new BufferedInputStream(in);
-                ObjectInputStream ois = new EjbObjectInputStream(in);
-                Object state = ois.readObject();
-                ois.close();
-                sessionFile.delete();
-                return state;
+                final ObjectInputStream ois = new EjbObjectInputStream(IO.read(sessionFile));
+                try {
+                    return ois.readObject();
+                } finally {
+                    IO.close(ois);
+                    sessionFile.delete();
+                }
             } else {
                 logger.info("Activation failed: file not found " + sessionFile);
                 return null;

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/ProviderWrapper.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/ProviderWrapper.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/ProviderWrapper.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/ProviderWrapper.java Thu Mar  1 00:43:35 2012
@@ -39,10 +39,7 @@ import javax.xml.ws.spi.ServiceDelegate;
 import javax.xml.ws.wsaddressing.W3CEndpointReference;
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.lang.reflect.InvocationTargetException;
@@ -383,11 +380,8 @@ public class ProviderWrapper extends Pro
         String javaHome = System.getProperty("java.home");
         File jaxrpcPropertiesFile = new File(new File(javaHome, "lib"), "jaxrpc.properties");
         if (jaxrpcPropertiesFile.exists()) {
-            InputStream in = null;
             try {
-                in = new FileInputStream(jaxrpcPropertiesFile);
-                Properties properties = new Properties();
-                properties.load(in);
+                final Properties properties = IO.readProperties(jaxrpcPropertiesFile);
 
                 providerClass = properties.getProperty(JAXWSPROVIDER_PROPERTY);
                 provider = createProviderInstance(providerClass, classLoader);
@@ -395,8 +389,6 @@ public class ProviderWrapper extends Pro
                     return provider;
                 }
             } catch(Exception ignored) {
-            } finally {
-                IO.close(in);
             }
         }
 
@@ -442,7 +434,7 @@ public class ProviderWrapper extends Pro
             try {
                 File tempFile = File.createTempFile("openejb-jaxws-provider", "tmp");
                 tempFile.deleteOnExit();
-                OutputStream out = new FileOutputStream(tempFile);
+                OutputStream out = IO.write(tempFile);
                 out.write(ProviderWrapper.class.getName().getBytes());
                 out.close();
                 PROVIDER_URL = tempFile.toURI().toURL();

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceBootstrap.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceBootstrap.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceBootstrap.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/persistence/PersistenceBootstrap.java Thu Mar  1 00:43:35 2012
@@ -195,12 +195,7 @@ public class PersistenceBootstrap {
             URL resource = classLoader.getResource("PersistenceBootstrap.properties");
             if (resource != null) {
                 debug("found PersistenceBootstrap.properties file");
-                InputStream in = IO.read(resource);
-                try {
-                    properties.load(in);
-                } finally {
-                    if (in != null) in.close();
-                }
+                IO.readProperties(resource, properties);
             }
         } catch (Throwable e) {
             debug("can't read PersistenceBootstrap.properties file", e);

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/DataSourceFactory.java Thu Mar  1 00:43:35 2012
@@ -22,6 +22,7 @@ import org.apache.commons.dbcp.managed.D
 import org.apache.commons.dbcp.managed.LocalXAConnectionFactory;
 import org.apache.commons.dbcp.managed.TransactionRegistry;
 import org.apache.commons.dbcp.managed.XAConnectionFactory;
+import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.resource.XAResourceWrapper;
 import org.apache.xbean.recipe.ObjectRecipe;
@@ -72,9 +73,7 @@ public class DataSourceFactory {
     }
 
     private static Map<?, ?> asProperties(String definition) throws IOException {
-        final ByteArrayInputStream in = new ByteArrayInputStream(definition.getBytes());
-        final Properties properties = new Properties();
-        properties.load(in);
+        final Properties properties = IO.readProperties(IO.read(definition), new Properties());
         trimNotSupportedDataSourceProperties(properties);
         return properties;
     }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/InstantdbDataSourcePlugin.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/InstantdbDataSourcePlugin.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/InstantdbDataSourcePlugin.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/InstantdbDataSourcePlugin.java Thu Mar  1 00:43:35 2012
@@ -17,11 +17,11 @@
 package org.apache.openejb.resource.jdbc;
 
 import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.xbean.finder.ResourceFinder;
 
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 
 public class InstantdbDataSourcePlugin implements DataSourcePlugin {
@@ -53,21 +53,13 @@ public class InstantdbDataSourcePlugin i
             return;
         }
 
-        FileOutputStream out = null;
         try {
             ResourceFinder finder = new ResourceFinder("");
             String defaultProperties = finder.findString("default.instantdb.properties");
-            out = new FileOutputStream(file);
-            out.write(defaultProperties.getBytes());
-            out.flush();
+            IO.copy(defaultProperties.getBytes(), file);
         } catch (IOException e) {
             // TODO; Handle this
             e.printStackTrace();
-        } finally {
-            try {
-                out.close();
-            } catch (IOException e) {
-            }
         }
     }
 

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/JarExtractor.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/JarExtractor.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/JarExtractor.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/JarExtractor.java Thu Mar  1 00:43:35 2012
@@ -16,7 +16,9 @@
  */
 package org.apache.openejb.util;
 
+import org.apache.openejb.loader.Files;
 import org.apache.openejb.loader.IO;
+import org.apache.openejb.loader.Zips;
 
 import java.io.BufferedOutputStream;
 import java.io.File;
@@ -25,9 +27,6 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.channels.FileChannel;
-import java.util.Enumeration;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
 
 /**
  * @version $Rev$ $Date$
@@ -67,56 +66,15 @@ public class JarExtractor {
 
         logger.info("Extracting jar: " + file.getAbsolutePath());
 
-        // Create the new document base directory
-        destinationDir.mkdirs();
+        Files.mkdirs(destinationDir);
 
-        // Extract the JAR into the new directory
-        JarFile jarFile = null;
-        InputStream input = null;
         try {
-            jarFile = new JarFile(file);
-            Enumeration jarEntries = jarFile.entries();
-            while (jarEntries.hasMoreElements()) {
-                JarEntry jarEntry = (JarEntry) jarEntries.nextElement();
-                String name = jarEntry.getName();
-                int last = name.lastIndexOf('/');
-                if (last >= 0) {
-                    File parent = new File(destinationDir,
-                            name.substring(0, last));
-                    parent.mkdirs();
-                }
-                if (name.endsWith("/")) {
-                    continue;
-                }
-                input = jarFile.getInputStream(jarEntry);
-
-                File extractedFile = extract(input, destinationDir, name);
-                long lastModified = jarEntry.getTime();
-                if ((lastModified != -1) && (lastModified != 0) && (extractedFile != null)) {
-                    extractedFile.setLastModified(lastModified);
-                }
-
-                input.close();
-                input = null;
-            }
+            Zips.unzip(file, destinationDir);
         } catch (IOException e) {
             // If something went wrong, delete extracted dir to keep things
             // clean
             deleteDir(destinationDir);
             throw e;
-        } finally {
-            if (input != null) {
-                try {
-                    input.close();
-                } catch (Throwable t) {
-                }
-            }
-            if (jarFile != null) {
-                try {
-                    jarFile.close();
-                } catch (Throwable t) {
-                }
-            }
         }
 
         // Return the absolute path to our new document base directory
@@ -130,11 +88,12 @@ public class JarExtractor {
      * @param src  File object representing the source
      * @param dest File object representing the destination
      */
-    public static boolean copy(File src, File dest) {
+    public static boolean copyRecursively(File src, File dest) {
 
         boolean result = true;
 
         String files[];
+
         if (src.isDirectory()) {
             files = src.list();
             result = dest.mkdir();
@@ -142,15 +101,20 @@ public class JarExtractor {
             files = new String[1];
             files[0] = "";
         }
+
         if (files == null) {
             files = new String[0];
         }
         for (int i = 0; (i < files.length) && result; i++) {
-            File fileSrc = new File(src, files[i]);
-            File fileDest = new File(dest, files[i]);
+            final File fileSrc = new File(src, files[i]);
+            final File fileDest = new File(dest, files[i]);
+
             if (fileSrc.isDirectory()) {
-                result = copy(fileSrc, fileDest);
+
+                result = copyRecursively(fileSrc, fileDest);
+
             } else {
+
                 FileChannel ic = null;
                 FileChannel oc = null;
                 try {

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Log4jLogStreamFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Log4jLogStreamFactory.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Log4jLogStreamFactory.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Log4jLogStreamFactory.java Thu Mar  1 00:43:35 2012
@@ -23,12 +23,9 @@ import org.apache.openejb.loader.FileUti
 import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.SystemInstance;
 
-import java.io.BufferedInputStream;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
@@ -78,13 +75,10 @@ public class Log4jLogStreamFactory imple
 
             if (loggingPropertiesFile.exists()) {
                 // load logging.properties file
-                final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(loggingPropertiesFile));
-                final Properties props = new Properties();
-                props.load(bis);
-                applyOverrides(props);
-                preprocessProperties(props);
-                PropertyConfigurator.configure(props);
-                IO.close(bis);
+                final Properties properties = IO.readProperties(loggingPropertiesFile);
+                applyOverrides(properties);
+                preprocessProperties(properties);
+                PropertyConfigurator.configure(properties);
             } else {
                 // install our logging.properties file into the conf dir
                 installLoggingPropertiesFile(loggingPropertiesFile);
@@ -177,20 +171,10 @@ public class Log4jLogStreamFactory imple
 
     private static Properties asProperies(final URL resource) {
         final Properties properties = new Properties();
-        InputStream in = null;
         try {
-            in = IO.read(resource);
-            properties.load(in);
+            IO.readProperties(resource, properties);
         } catch (Throwable e) {
             //Ignore
-        } finally {
-            if (null != in) {
-                try {
-                    in.close();
-                } catch (Throwable e) {
-                    //Ignore
-                }
-            }
         }
         return properties;
     }
@@ -205,38 +189,18 @@ public class Log4jLogStreamFactory imple
             return;
         }
 
-        InputStream in = null;
-        FileOutputStream out = null;
+        final Properties props = IO.readProperties(resource);
 
-        try {
-            in = IO.read(resource);
-            final Properties props = new Properties();
-            props.load(in);
+        preprocessProperties(props);
 
-            preprocessProperties(props);
-
-            out = new FileOutputStream(loggingPropertiesFile);
+        final OutputStream out = IO.write(loggingPropertiesFile);
+        try {
             props.store(out, "OpenEJB Default Log4j Configuration");
-
-            PropertyConfigurator.configure(props);
         } finally {
-
-            if (null != in) {
-                try {
-                    in.close();
-                } catch (Throwable e) {
-                    //Ignore
-                }
-            }
-
-            if (null != out) {
-                try {
-                    out.close();
-                } catch (Throwable e) {
-                    //Ignore
-                }
-            }
+            IO.close(out);
         }
 
+        PropertyConfigurator.configure(props);
+
     }
 }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java Thu Mar  1 00:43:35 2012
@@ -314,16 +314,7 @@ public class Logger {
 
             final File file = new File(conf, "logging.properties");
 
-            final Properties properties = new Properties();
-
-            final InputStream read = IO.read(file);
-
-            try {
-                properties.load(read);
-            } finally {
-                read.close();
-            }
-            return properties;
+            return IO.readProperties(file);
         } catch (IOException e) {
             return new Properties();
         }

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/UrlCache.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/UrlCache.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/UrlCache.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/UrlCache.java Thu Mar  1 00:43:35 2012
@@ -17,12 +17,13 @@
 package org.apache.openejb.util;
 
 import org.apache.openejb.loader.FileUtils;
+import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.SystemInstance;
 
 import java.io.Closeable;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Arrays;
@@ -225,7 +226,7 @@ public class UrlCache {
         try {
             cacheFile = File.createTempFile(prefix, suffix, cacheDir);
             cacheFile.deleteOnExit();
-            success = JarExtractor.copy(sourceFile, cacheFile);
+            success = JarExtractor.copyRecursively(sourceFile, cacheFile);
         } catch (IOException e) {
             success = false;
         }
@@ -292,9 +293,9 @@ public class UrlCache {
             File manifestFile = new File(location, "META-INF/MANIFEST.MF");
 
             if (manifestFile.isFile() && manifestFile.canRead()) {
-                FileInputStream in = null;
+                InputStream in = null;
                 try {
-                    in = new FileInputStream(manifestFile);
+                    in = IO.read(manifestFile);
                     Manifest manifest = new Manifest(in);
                     return manifest;
                 } finally {

Modified: openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java Thu Mar  1 00:43:35 2012
@@ -20,12 +20,14 @@ import static org.apache.openejb.util.UR
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 import junit.framework.TestResult;
+import org.apache.openejb.loader.IO;
 import org.apache.xbean.asm.ClassReader;
 import org.apache.xbean.asm.ClassWriter;
 
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -108,12 +110,12 @@ public class DependenceValidationTest ex
 
     private static void file(File file, DependencyVisitor dependencyVisitor) {
         try {
-            FileInputStream in = new FileInputStream(file);
+            final InputStream in = IO.read(file);
             try {
                 ClassReader classReader = new ClassReader(in);
                 classReader.accept(dependencyVisitor, ClassWriter.COMPUTE_MAXS);
             } finally {
-                in.close();
+                IO.close(in);
             }
         } catch (IOException e) {
             e.printStackTrace();

Modified: openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/rules/ValidationKeysAuditorTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/rules/ValidationKeysAuditorTest.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/rules/ValidationKeysAuditorTest.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/rules/ValidationKeysAuditorTest.java Thu Mar  1 00:43:35 2012
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URL;
 import java.util.HashSet;
 import java.util.ResourceBundle;
@@ -33,6 +34,7 @@ import java.util.Map.Entry;
 
 import org.apache.openejb.config.rules.KeysAnnotationVisitor.ClassInfo;
 import org.apache.openejb.config.rules.KeysAnnotationVisitor.MethodInfo;
+import org.apache.openejb.loader.IO;
 import org.apache.xbean.asm.ClassReader;
 import org.apache.xbean.asm.ClassWriter;
 import org.codehaus.swizzle.confluence.Confluence;
@@ -330,12 +332,12 @@ public class ValidationKeysAuditorTest {
 
     private static void file(File file, KeysAnnotationVisitor visitor) {
         try {
-            FileInputStream in = new FileInputStream(file);
+            InputStream in = IO.read(file);
             try {
                 ClassReader classReader = new ClassReader(in);
                 classReader.accept(visitor, ClassWriter.COMPUTE_MAXS);
             } finally {
-                in.close();
+                IO.close(in);
             }
         } catch (IOException e) {
             e.printStackTrace();

Modified: openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/util/Archives.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/util/Archives.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/util/Archives.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/util/Archives.java Thu Mar  1 00:43:35 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.openejb.util;
 
+import org.apache.openejb.loader.IO;
+
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
 import java.io.File;
@@ -61,16 +63,7 @@ public class Archives {
             URL resource = loader.getResource(name);
             assertNotNull(resource);
 
-            InputStream in = new BufferedInputStream(resource.openStream());
-            BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
-
-            int i = -1;
-            while ((i = in.read()) != -1) {
-                out.write(i);
-            }
-
-            out.close();
-            in.close();
+            IO.copy(IO.read(resource), file);
         }
 
         for (Map.Entry<String, String> entry : entries.entrySet()) {
@@ -83,11 +76,7 @@ public class Archives {
 
             if (!d.exists()) assertTrue(d.getAbsolutePath(), d.mkdirs());
 
-            BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
-
-            out.write(entry.getValue().getBytes());
-
-            out.close();
+            IO.copy(entry.getValue().getBytes(), file);
         }
 
         return classpath;

Modified: openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/FileUtils.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/FileUtils.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/FileUtils.java (original)
+++ openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/FileUtils.java Thu Mar  1 00:43:35 2012
@@ -17,12 +17,8 @@
 package org.apache.openejb.loader;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.util.Hashtable;
 
 public class FileUtils {
@@ -140,29 +136,4 @@ public class FileUtils {
         return createTempDirectory(prefix);
     }
 
-    public static void copyFile(File destination, File source) throws java.io.IOException {
-        copyFile(destination, source, false);
-    }
-
-    public static void copy(OutputStream out, InputStream source) throws java.io.IOException {
-        try {
-            int len;
-            byte[] buffer = new byte[4096];
-            while ((len = source.read(buffer)) != -1) {
-                out.write(buffer, 0, len);
-            }
-        } finally {
-            source.close();
-            out.close();
-        }
-    }
-
-    public static void copyFile(File destination, File source, boolean deleteSourceFile) throws java.io.IOException {
-        copy(new FileOutputStream(destination), new FileInputStream(source));
-
-        if (deleteSourceFile) {
-            source.delete();
-        }
-    }
-
 }

Copied: openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java (from r1295185, openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Files.java)
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java?p2=openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java&p1=openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Files.java&r1=1295185&r2=1295357&rev=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Files.java (original)
+++ openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java Thu Mar  1 00:43:35 2012
@@ -14,12 +14,13 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.openejb.util;
+package org.apache.openejb.loader;
 
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.regex.Pattern;
 
@@ -132,7 +133,7 @@ public class Files {
 
         if (!file.exists()) {
 
-            if (file.mkdirs()) throw new RuntimeException("Cannot mkdirs: " + file.getAbsolutePath());
+            if (!file.mkdirs()) throw new RuntimeException("Cannot mkdirs: " + file.getAbsolutePath());
 
             return file;
         }
@@ -178,7 +179,19 @@ public class Files {
     public static File select(File dir, String pattern) {
         final List<File> matches = collect(dir, pattern);
         if (matches.size() == 0) throw new IllegalStateException(String.format("Missing '%s'", pattern));
-        if (matches.size() > 1) throw new IllegalStateException(String.format("Too many found '%s': %s", Join.join(", ", new Join.FileCallback(), matches)));
+        if (matches.size() > 1) throw new IllegalStateException(String.format("Too many found '%s': %s", pattern, join(", ", matches)));
         return matches.get(0);
     }
+
+    private static String join(String delimiter, Collection<File> collection) {
+        if (collection.size() == 0) {
+            return "";
+        }
+        StringBuilder sb = new StringBuilder();
+        for (File obj : collection) {
+            sb.append(obj.getName()).append(delimiter);
+        }
+        return sb.substring(0, sb.length() - delimiter.length());
+    }
+
 }

Propchange: openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java (original)
+++ openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/IO.java Thu Mar  1 00:43:35 2012
@@ -78,33 +78,35 @@ public class IO {
     }
 
     public static Properties readProperties(URL resource) throws IOException {
-        Properties properties = new Properties();
-        InputStream in = null;
-        try {
-            in = resource.openStream();
-            in = new BufferedInputStream(in);
-            properties.load(in);
-        } finally{
-            try {
-                if (in != null) in.close();
-            } catch (IOException e) {
-            }
-        }
-        return properties;
+        return readProperties(resource, new Properties());
+    }
+
+    public static Properties readProperties(URL resource, Properties properties) throws IOException {
+        return readProperties(read(resource), properties);
     }
 
     public static Properties readProperties(final File resource) throws IOException {
-        Properties properties = new Properties();
-        InputStream in = null;
+        return readProperties(resource, new Properties());
+    }
+
+    public static Properties readProperties(File resource, Properties properties) throws IOException {
+        return readProperties(read(resource), properties);
+    }
+
+    /**
+     * Reads and closes the input stream
+     * @param in
+     * @param properties
+     * @return
+     * @throws IOException
+     */
+    public static Properties readProperties(InputStream in, Properties properties) throws IOException {
+        if (in == null) throw new NullPointerException("InputStream is null");
+        if (properties == null) throw new NullPointerException("Properties is null");
         try {
-            in = new BufferedInputStream(new FileInputStream(resource));
             properties.load(in);
         } finally{
-            try {
-                if (in != null) in.close();
-            } catch (IOException ignored) {
-                // no-op
-            }
+            close(in);
         }
         return properties;
     }
@@ -193,6 +195,15 @@ public class IO {
         }
     }
 
+    public static void copy(byte[] from, File to) throws IOException {
+        final OutputStream write = write(to);
+        try {
+            write.write(from);
+        } finally {
+            close(write);
+        }
+    }
+
     public static void copy(InputStream from, File to, boolean append) throws IOException {
         final OutputStream write = write(to, append);
         try {

Modified: openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java (original)
+++ openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java Thu Mar  1 00:43:35 2012
@@ -18,7 +18,6 @@ package org.apache.openejb.loader;
 
 import java.io.BufferedInputStream;
 import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.Proxy;
@@ -51,7 +50,11 @@ public class ProvisioningUtil {
             return null;
         }
 
-        FileUtils.copy(new FileOutputStream(destination), is);
+        try {
+            IO.copy(is, destination);
+        } finally {
+            IO.close(is);
+        }
         return destination.getAbsolutePath();
     }
 

Copied: openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/Zips.java (from r1295185, openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Zips.java)
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/Zips.java?p2=openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/Zips.java&p1=openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Zips.java&r1=1295185&r2=1295357&rev=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/Zips.java (original)
+++ openejb/trunk/openejb/container/openejb-loader/src/main/java/org/apache/openejb/loader/Zips.java Thu Mar  1 00:43:35 2012
@@ -14,11 +14,10 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.openejb.util;
-
-import org.apache.openejb.loader.IO;
+package org.apache.openejb.loader;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
@@ -26,11 +25,11 @@ import java.util.zip.ZipInputStream;
  * @version $Rev$ $Date$
  */
 public class Zips {
-    public static void unzip(File zipFile, File destination) {
+    public static void unzip(File zipFile, File destination) throws IOException {
         unzip(zipFile, destination, false);
     }
 
-    public static void unzip(File zipFile, File destination, boolean noparent) {
+    public static void unzip(File zipFile, File destination, boolean noparent) throws IOException {
 
         Files.dir(destination);
         Files.writable(destination);
@@ -66,8 +65,8 @@ public class Zips {
 
             in.close();
 
-        } catch (Exception e) {
-            throw new IllegalStateException("Unable to unzip " + zipFile.getAbsolutePath(), e);
+        } catch (IOException e) {
+            throw new IOException("Unable to unzip " + zipFile.getAbsolutePath(), e);
         }
     }
 }

Modified: openejb/trunk/openejb/itests/failover/src/main/java/org/apache/openejb/server/control/StandaloneServer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/failover/src/main/java/org/apache/openejb/server/control/StandaloneServer.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/failover/src/main/java/org/apache/openejb/server/control/StandaloneServer.java (original)
+++ openejb/trunk/openejb/itests/failover/src/main/java/org/apache/openejb/server/control/StandaloneServer.java Thu Mar  1 00:43:35 2012
@@ -17,7 +17,7 @@
 package org.apache.openejb.server.control;
 
 import org.apache.openejb.client.Options;
-import org.apache.openejb.util.Files;
+import org.apache.openejb.loader.Files;
 import org.apache.openejb.util.Join;
 import org.apache.openejb.util.OutputScanner;
 import org.apache.openejb.util.Pipe;
@@ -33,11 +33,11 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
-import static org.apache.openejb.util.Files.dir;
-import static org.apache.openejb.util.Files.exists;
-import static org.apache.openejb.util.Files.file;
-import static org.apache.openejb.util.Files.readable;
-import static org.apache.openejb.util.Files.select;
+import static org.apache.openejb.loader.Files.dir;
+import static org.apache.openejb.loader.Files.exists;
+import static org.apache.openejb.loader.Files.file;
+import static org.apache.openejb.loader.Files.readable;
+import static org.apache.openejb.loader.Files.select;
 
 /**
  * @version $Rev$ $Date$

Modified: openejb/trunk/openejb/itests/failover/src/test/java/org/apache/openejb/itest/failover/FailoverTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/itests/failover/src/test/java/org/apache/openejb/itest/failover/FailoverTest.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/itests/failover/src/test/java/org/apache/openejb/itest/failover/FailoverTest.java (original)
+++ openejb/trunk/openejb/itests/failover/src/test/java/org/apache/openejb/itest/failover/FailoverTest.java Thu Mar  1 00:43:35 2012
@@ -18,13 +18,12 @@ package org.apache.openejb.itest.failove
 
 import org.apache.openejb.client.RemoteInitialContextFactory;
 import org.apache.openejb.itest.failover.ejb.Calculator;
+import org.apache.openejb.loader.Files;
 import org.apache.openejb.loader.IO;
+import org.apache.openejb.loader.Zips;
 import org.apache.openejb.server.control.StandaloneServer;
-import org.apache.openejb.util.Files;
 import org.apache.openejb.util.Join;
-import org.apache.openejb.util.Zips;
 import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import javax.ejb.EJBException;
@@ -32,9 +31,15 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import java.io.File;
 import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.NetworkInterface;
 import java.net.ServerSocket;
+import java.net.SocketAddress;
+import java.nio.channels.ServerSocketChannel;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Enumeration;
 import java.util.List;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
@@ -42,10 +47,36 @@ import java.util.concurrent.TimeUnit;
 public class FailoverTest {
 
     @Test
-    public void testNothing() {
+    public void testNothing() throws Exception {
+        ServerSocketChannel serverChannel = ServerSocketChannel.open();
+        ServerSocket serverSocket = serverChannel.socket();
+        InetSocketAddress address = new InetSocketAddress("0.0.0.0", 33333);
+        serverSocket.bind(address);
+
+        final SocketAddress localSocketAddress = serverSocket.getLocalSocketAddress();
+        System.out.println("localSocketAddress = " + localSocketAddress);
+        System.out.println(serverSocket.getInetAddress());
+        final InetAddress[] locahosts = InetAddress.getAllByName("localhost");
+        for (InetAddress locahost : locahosts) {
+            System.out.println(locahost);
+        }
+        final Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
+        while (interfaces.hasMoreElements()) {
+            NetworkInterface in = interfaces.nextElement();
+            if (in.isLoopback()) continue;
+            if (in.isVirtual()) continue;
+            if (in.isPointToPoint()) continue;
+            if (!in.isUp()) continue;
+            System.out.println(in);
+            final Enumeration<InetAddress> addresses = in.getInetAddresses();
+            while (addresses.hasMoreElements()) {
+                InetAddress inetAddress = addresses.nextElement();
+                System.out.println(inetAddress);
+            }
+        }
     }
 
-    @Test @Ignore
+    @Test
     public void testFailover() throws Exception {
 
         final File zip = new File("/Users/dblevins/.m2/repository/org/apache/openejb/openejb-standalone/4.0.0-beta-3-SNAPSHOT/openejb-standalone-4.0.0-beta-3-SNAPSHOT.zip");

Modified: openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java (original)
+++ openejb/trunk/openejb/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MultipointServer.java Thu Mar  1 00:43:35 2012
@@ -99,13 +99,17 @@ public class MultipointServer {
         serverChannel.configureBlocking(false);
 
         this.port = serverSocket.getLocalPort();
-        me = URI.create("conn://" + this.host + ":" + this.port);
+        if (name != null) {
+            me = URI.create("conn://" + this.host + ":" + this.port + "/" + name);
+        } else {
+            me = URI.create("conn://" + this.host + ":" + this.port);
+        }
 
         selector = Selector.open();
 
         serverChannel.register(selector, SelectionKey.OP_ACCEPT);
 
-        println("Listening");
+        println("Broadcasting ");
     }
 
     public int getPort() {

Modified: openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java (original)
+++ openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServiceManager.java Thu Mar  1 00:43:35 2012
@@ -170,12 +170,7 @@ public abstract class ServiceManager {
         if (conf.exists()) {
             File serviceConfig = new File(conf, serviceName + ".properties");
             if (serviceConfig.exists()) {
-                FileInputStream in = new FileInputStream(serviceConfig);
-                try {
-                    serviceProperties.load(in);
-                } finally {
-                    in.close();
-                }
+                IO.readProperties(serviceConfig, serviceProperties);
             } else {
 
                 if (EnvProps.extractConfigurationFiles()){

Modified: openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/Stop.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/Stop.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/Stop.java (original)
+++ openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/admin/Stop.java Thu Mar  1 00:43:35 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.openejb.server.admin;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.ConnectException;
@@ -24,6 +25,7 @@ import java.net.URL;
 import java.util.Properties;
 
 import org.apache.openejb.client.RequestType;
+import org.apache.openejb.loader.IO;
 
 
 public class Stop {
@@ -84,8 +86,7 @@ public class Stop {
     private static void printHelp() {
         String header = "OpenEJB Remote Server ";
         try {
-            Properties versionInfo = new Properties();
-            versionInfo.load(new URL("resource:/openejb-version.properties").openConnection().getInputStream());
+            Properties versionInfo = loadVersionProperties();
             header += versionInfo.get("version");
         } catch (java.io.IOException e) {
         }
@@ -107,8 +108,7 @@ public class Stop {
     private static void printExamples() {
         String header = "OpenEJB Remote Server ";
         try {
-            Properties versionInfo = new Properties();
-            versionInfo.load(new URL("resource:/openejb-version.properties").openConnection().getInputStream());
+            Properties versionInfo = loadVersionProperties();
             header += versionInfo.get("version");
         } catch (java.io.IOException e) {
         }
@@ -126,4 +126,8 @@ public class Stop {
         } catch (java.io.IOException e) {
         }
     }
+
+    private static Properties loadVersionProperties() throws IOException {
+        return IO.readProperties(new URL("resource:/openejb-version.properties"));
+    }
 }

Modified: openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/osgi/ServiceManagerExtender.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/osgi/ServiceManagerExtender.java?rev=1295357&r1=1295356&r2=1295357&view=diff
==============================================================================
--- openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/osgi/ServiceManagerExtender.java (original)
+++ openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/osgi/ServiceManagerExtender.java Thu Mar  1 00:43:35 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.openejb.server.osgi;
 
+import org.apache.openejb.loader.IO;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.server.DiscoveryRegistry;
 import org.apache.openejb.server.ServerService;
@@ -247,46 +248,11 @@ public class ServiceManagerExtender exte
         }
 
         private Properties loadProperties(URL resource) throws IOException {
-            InputStream in = resource.openStream();
-
-            BufferedInputStream reader = null;
-            try {
-                reader = new BufferedInputStream(in);
-                Properties properties = new Properties();
-                properties.load(reader);
-
-                return properties;
-            } finally {
-                try {
-                    in.close();
-                    reader.close();
-                } catch (Exception e) {
-                }
-            }
+            return IO.readProperties(resource);
         }
         
         private String readContents(URL resource) throws IOException {
-            InputStream in = resource.openStream();
-            BufferedInputStream reader = null;
-            StringBuffer sb = new StringBuffer();
-
-            try {
-                reader = new BufferedInputStream(in);
-
-                int b = reader.read();
-                while (b != -1) {
-                    sb.append((char) b);
-                    b = reader.read();
-                }
-
-                return sb.toString().trim();
-            } finally {
-                try {
-                    in.close();
-                    reader.close();
-                } catch (Exception e) {
-                }
-            }
+            return IO.slurp(resource);
         }
 
     }



Mime
View raw message