Author: jleroux
Date: Sat Nov 7 15:18:20 2009 New Revision: 833698 URL: http://svn.apache.org/viewvc?rev=833698&view=rev Log: A (slightly modified) patch from Bob Morley "Resolve java warnings exposed in Eclipse : framework - appserver" (https://issues.apache.org/jira/browse/OFBIZ-3101) - OFBIZ-3101 I just prefered to replace the @SuppressWarnings("unchecked") for GenerateContainer.getClasspath() by <?> (generics are not covariant), but it's actually a matter of taste. Modified: ofbiz/trunk/framework/appserver/src/org/ofbiz/appservers/GenerateContainer.java ofbiz/trunk/framework/appserver/src/org/ofbiz/appservers/GenerateGeronimoDeployment.java Modified: ofbiz/trunk/framework/appserver/src/org/ofbiz/appservers/GenerateContainer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/appserver/src/org/ofbiz/appservers/GenerateContainer.java?rev=833698&r1=833697&r2=833698&view=diff ============================================================================== --- ofbiz/trunk/framework/appserver/src/org/ofbiz/appservers/GenerateContainer.java (original) +++ ofbiz/trunk/framework/appserver/src/org/ofbiz/appservers/GenerateContainer.java Sat Nov 7 15:18:20 2009 @@ -47,8 +47,8 @@ import org.ofbiz.base.container.ContainerException; import org.ofbiz.base.start.Classpath; import org.ofbiz.base.util.Debug; -import org.ofbiz.base.util.UtilURL; import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilURL; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.template.FreeMarkerWorker; import org.w3c.dom.Document; @@ -156,7 +156,7 @@ for(int inst = 0; inst <= instancesNumber; inst++) { instanceNumber = (inst == 0 ? "" : inst).toString(); GenerateGeronimoDeployment geronimoDeployment = new GenerateGeronimoDeployment(); - List classpathJars = geronimoDeployment.generate(args[0], geronimoHostHome, instanceNumber); + List<String> classpathJars = geronimoDeployment.generate(args[0], geronimoHostHome, instanceNumber); if (classpathJars == null) { throw new ContainerException("Error in Geronimo deployment, please check the log"); } @@ -391,7 +391,7 @@ private Map<String, Object> buildDataMap() throws ContainerException { Map<String, Object> dataMap = FastMap.newInstance(); - List c[] = getClasspath(); + List<?> c[] = getClasspath(); dataMap.put("targetDirectory", getTargetDirectory()); dataMap.put("pathSeparatorChar", File.pathSeparatorChar); dataMap.put("classpath", System.getProperty("java.class.path")); @@ -403,7 +403,7 @@ return dataMap; } - private List[] getClasspath() { + private List<?>[] getClasspath() { Classpath classPath = new Classpath(System.getProperty("java.class.path")); List<File> elements = classPath.getElements(); List<String> jar = FastList.newInstance(); @@ -420,8 +420,7 @@ } } } - - List[] lists = { jar, dir }; + List<?>[] lists = { jar, dir }; return lists; } @@ -459,6 +458,14 @@ reader = new InputStreamReader(new FileInputStream(templateFile)); } catch (FileNotFoundException e) { throw new ContainerException(e); + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + throw new ContainerException(e); + } + } } // create the target file/directory @@ -468,21 +475,24 @@ Writer writer = null; try { writer = new FileWriter(targetDirectory + templateFile.getName()); + try { + FreeMarkerWorker.renderTemplate(UtilURL.fromFilename(templateFile.getAbsolutePath()).toExternalForm(), dataMap, writer); + } catch (Exception e) { + throw new ContainerException(e); + } } catch (IOException e) { throw new ContainerException(e); - } - try { - FreeMarkerWorker.renderTemplate(UtilURL.fromFilename(templateFile.getAbsolutePath()).toExternalForm(), dataMap, writer); - } catch (Exception e) { - throw new ContainerException(e); + } finally { + try { + if (writer != null) { + writer.flush(); + writer.close(); + } + } catch (IOException e) { + throw new ContainerException(e); + } } - try { - writer.flush(); - writer.close(); - } catch (IOException e) { - throw new ContainerException(e); - } } // This method writes a DOM document to a file Modified: ofbiz/trunk/framework/appserver/src/org/ofbiz/appservers/GenerateGeronimoDeployment.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/appserver/src/org/ofbiz/appservers/GenerateGeronimoDeployment.java?rev=833698&r1=833697&r2=833698&view=diff ============================================================================== --- ofbiz/trunk/framework/appserver/src/org/ofbiz/appservers/GenerateGeronimoDeployment.java (original) +++ ofbiz/trunk/framework/appserver/src/org/ofbiz/appservers/GenerateGeronimoDeployment.java Sat Nov 7 15:18:20 2009 @@ -35,7 +35,6 @@ import java.util.Map; import org.ofbiz.base.component.ComponentConfig; -import org.ofbiz.base.component.ComponentConfig.WebappInfo; import org.ofbiz.base.start.Classpath; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.StringUtil; @@ -110,7 +109,6 @@ } String newCompleteJarName= targetDirectory + newJarName; - File newJarFile = new File(newCompleteJarName); // copy the jar to the target directory try { // Create channel on the source @@ -164,6 +162,14 @@ } catch (FileNotFoundException e) { Debug.logFatal("Unable to create - " + webAppGeronimoWebXmlFileName, module); return; + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + Debug.logError("Trouble closing - " + webAppGeronimoWebXmlFileName, module); + } + } } // write the template to the target directory |
Free forum by Nabble | Edit this page |