From: <fu...@us...> - 2007-03-01 19:56:11
|
Revision: 370 http://svn.sourceforge.net/cishell/?rev=370&view=rev Author: fugu13 Date: 2007-03-01 11:56:09 -0800 (Thu, 01 Mar 2007) Log Message: ----------- Fix to static executable algorithm factory. It now does exact matching with proper precedence order. Modified Paths: -------------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-03-01 17:39:55 UTC (rev 369) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-03-01 19:56:09 UTC (rev 370) @@ -22,7 +22,9 @@ import java.nio.channels.ReadableByteChannel; import java.util.Dictionary; import java.util.Enumeration; +import java.util.HashSet; import java.util.Properties; +import java.util.Set; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; @@ -64,7 +66,13 @@ } private class StaticExecutableAlgorithm implements Algorithm { - Data[] data; + private static final String ALGORITHM = "ALGORITHM/"; + private static final String ALGORITHM_MACOSX_PPC = ALGORITHM + "macosx.ppc/"; + private static final String MACOSX = "macosx"; + private static final String ALGORITHM_WIN32 = ALGORITHM + "/win32/"; + private static final String WIN32 = "win32"; + private static final String ALGORITHM_DEFAULT = ALGORITHM + "/default/"; + Data[] data; Dictionary parameters; CIShellContext context; @@ -97,6 +105,16 @@ private void copyFiles(File dir) throws IOException { Enumeration e = bContext.getBundle().getEntryPaths("/"+algName); + Set entries = new HashSet(); + + while(e != null && e.hasMoreElements()) { + String entryPath = (String) e.nextElement(); + System.err.println(entryPath); + if(entryPath.endsWith("/")) { + entries.add(entryPath); + } + } + dir = new File(dir.getPath() + File.separator + algName); dir.mkdirs(); @@ -104,24 +122,48 @@ String arch = bContext.getProperty("osgi.arch"); boolean foundExecutable = false; - while (e != null && e.hasMoreElements()) { - String path = (String)e.nextElement(); + String path = null; + + //take the default, if there + if(entries.contains(ALGORITHM_DEFAULT)) { + path = ALGORITHM_DEFAULT; + } + + //but override with platform idiosyncracies + if(os.equals(WIN32) && entries.contains(ALGORITHM_WIN32)) { + path = ALGORITHM_WIN32; + } else if(os.equals(MACOSX) && entries.contains(ALGORITHM_MACOSX_PPC)) { + path = ALGORITHM_MACOSX_PPC; + } + + String platform_path = ALGORITHM + os + "." + arch + "/"; + //and always override anything with an exact match + if(entries.contains(platform_path)) { + path = platform_path; + } + + + + /*while (e != null && e.hasMoreElements()) { + String path = (String)entryPath; if (path.endsWith("/")) { if (path.endsWith("default/")) { copyDir(dir, path); } else if (path.endsWith(os+"."+arch+"/") || - path.endsWith("win32/") && os.equals("win32")) { + (path.endsWith("win32/") && os.equals("win32")) || (path.endsWith("macosx.ppc/") && os.equals("macosx") && arch.equals("x86"))) { copyDir(dir, path); foundExecutable = true; } } else { //copyFile(dir, path); } - } + }*/ - if (!foundExecutable) { + if (path == null) { throw new RuntimeException("Unable to find compatible executable"); + } else { + copyDir(dir, path); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fu...@us...> - 2007-03-01 20:14:54
|
Revision: 371 http://svn.sourceforge.net/cishell/?rev=371&view=rev Author: fugu13 Date: 2007-03-01 12:14:17 -0800 (Thu, 01 Mar 2007) Log Message: ----------- Fix to deal with arbitrary algorithm locations. Modified Paths: -------------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-03-01 19:56:09 UTC (rev 370) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-03-01 20:14:17 UTC (rev 371) @@ -66,12 +66,12 @@ } private class StaticExecutableAlgorithm implements Algorithm { - private static final String ALGORITHM = "ALGORITHM/"; - private static final String ALGORITHM_MACOSX_PPC = ALGORITHM + "macosx.ppc/"; - private static final String MACOSX = "macosx"; - private static final String ALGORITHM_WIN32 = ALGORITHM + "/win32/"; - private static final String WIN32 = "win32"; - private static final String ALGORITHM_DEFAULT = ALGORITHM + "/default/"; + private String ALGORITHM; + private String ALGORITHM_MACOSX_PPC; + private String MACOSX; + private String ALGORITHM_WIN32; + private String WIN32; + private String ALGORITHM_DEFAULT; Data[] data; Dictionary parameters; CIShellContext context; @@ -80,6 +80,14 @@ this.data = data; this.parameters = parameters; this.context = context; + + ALGORITHM = algName + "/"; + ALGORITHM_MACOSX_PPC = ALGORITHM + "macosx.ppc/"; + MACOSX = "macosx"; + ALGORITHM_WIN32 = ALGORITHM + "/win32/"; + WIN32 = "win32"; + ALGORITHM_DEFAULT = ALGORITHM + "/default/"; + } public Data[] execute() { @@ -142,24 +150,6 @@ path = platform_path; } - - - /*while (e != null && e.hasMoreElements()) { - String path = (String)entryPath; - - if (path.endsWith("/")) { - if (path.endsWith("default/")) { - copyDir(dir, path); - } else if (path.endsWith(os+"."+arch+"/") || - (path.endsWith("win32/") && os.equals("win32")) || (path.endsWith("macosx.ppc/") && os.equals("macosx") && arch.equals("x86"))) { - copyDir(dir, path); - foundExecutable = true; - } - } else { - //copyFile(dir, path); - } - }*/ - if (path == null) { throw new RuntimeException("Unable to find compatible executable"); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fu...@us...> - 2007-03-01 20:26:15
|
Revision: 372 http://svn.sourceforge.net/cishell/?rev=372&view=rev Author: fugu13 Date: 2007-03-01 12:26:13 -0800 (Thu, 01 Mar 2007) Log Message: ----------- Now always copies over 'default' (really platform-indepedent) code every time. Like the last fix, not relevant for any (I think) algorithms we currently include, but possibly necessary later. Modified Paths: -------------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-03-01 20:14:17 UTC (rev 371) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-03-01 20:26:13 UTC (rev 372) @@ -134,7 +134,8 @@ //take the default, if there if(entries.contains(ALGORITHM_DEFAULT)) { - path = ALGORITHM_DEFAULT; + String default_path = ALGORITHM_DEFAULT; + copyDir(dir, default_path); } //but override with platform idiosyncracies This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hu...@us...> - 2007-03-02 16:06:51
|
Revision: 373 http://svn.sourceforge.net/cishell/?rev=373&view=rev Author: huangb Date: 2007-03-02 08:06:38 -0800 (Fri, 02 Mar 2007) Log Message: ----------- Have double file separators in ALGORITHM_WIN32 and ALGORITHM_DEFAULT. Remove one, now the staticexcutable algorithms can run on windows Modified Paths: -------------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-03-01 20:26:13 UTC (rev 372) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-03-02 16:06:38 UTC (rev 373) @@ -84,9 +84,9 @@ ALGORITHM = algName + "/"; ALGORITHM_MACOSX_PPC = ALGORITHM + "macosx.ppc/"; MACOSX = "macosx"; - ALGORITHM_WIN32 = ALGORITHM + "/win32/"; + ALGORITHM_WIN32 = ALGORITHM + "win32/"; WIN32 = "win32"; - ALGORITHM_DEFAULT = ALGORITHM + "/default/"; + ALGORITHM_DEFAULT = ALGORITHM + "default/"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bh...@us...> - 2007-03-02 20:22:19
|
Revision: 374 http://svn.sourceforge.net/cishell/?rev=374&view=rev Author: bh2 Date: 2007-03-02 12:22:16 -0800 (Fri, 02 Mar 2007) Log Message: ----------- Got rid of spurious println and an unused variable Modified Paths: -------------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-03-02 16:06:38 UTC (rev 373) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-03-02 20:22:16 UTC (rev 374) @@ -117,7 +117,7 @@ while(e != null && e.hasMoreElements()) { String entryPath = (String) e.nextElement(); - System.err.println(entryPath); + if(entryPath.endsWith("/")) { entries.add(entryPath); } @@ -128,7 +128,6 @@ String os = bContext.getProperty("osgi.os"); String arch = bContext.getProperty("osgi.arch"); - boolean foundExecutable = false; String path = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fu...@us...> - 2007-12-03 22:23:23
|
Revision: 550 http://cishell.svn.sourceforge.net/cishell/?rev=550&view=rev Author: fugu13 Date: 2007-12-03 14:23:19 -0800 (Mon, 03 Dec 2007) Log Message: ----------- Fix bug that occurs when copying multiple directories. Neighboring directories had been copied as nesting directories, because the variable holding the directory to copy to was overwritten each time a subdirectory to copy was encountered. Modified Paths: -------------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-11-14 17:23:59 UTC (rev 549) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-12-03 22:23:19 UTC (rev 550) @@ -168,9 +168,9 @@ if (path.endsWith("/")) { String dirName = getName(path); - dir = new File(dir.getPath() + File.separator + dirName); - dir.mkdirs(); - copyDir(dir, path); + File subDirectory = new File(dir.getPath() + File.separator + dirName); + subDirectory.mkdirs(); + copyDir(subDirectory, path); } else { copyFile(dir, path); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Bruce H. <bh...@bh...> - 2007-12-04 14:17:20
|
You should also update org.cishell.templates.standalone.executable w/ the change. These need to be kept in sync (at some point we need to make it so we only have one version of this). Bruce On Dec 3, 2007 5:23 PM, <fu...@us...> wrote: > Revision: 550 > http://cishell.svn.sourceforge.net/cishell/?rev=550&view=rev > Author: fugu13 > Date: 2007-12-03 14:23:19 -0800 (Mon, 03 Dec 2007) > > Log Message: > ----------- > Fix bug that occurs when copying multiple directories. Neighboring > directories had been copied as nesting directories, because the variable > holding the directory to copy to was overwritten each time a subdirectory to > copy was encountered. > > Modified Paths: > -------------- > > trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java > > Modified: > trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java > =================================================================== > --- > trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java > 2007-11-14 17:23:59 UTC (rev 549) > +++ > trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java > 2007-12-03 22:23:19 UTC (rev 550) > @@ -168,9 +168,9 @@ > if (path.endsWith("/")) { > String dirName = getName(path); > > - dir = new File(dir.getPath() + File.separator + > dirName); > - dir.mkdirs(); > - copyDir(dir, path); > + File subDirectory = new File(dir.getPath() + > File.separator + dirName); > + subDirectory.mkdirs(); > + copyDir(subDirectory, path); > } else { > copyFile(dir, path); > } > > > This was sent by the SourceForge.net collaborative development platform, > the world's largest Open Source development site. > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: The Future of Linux Business White Paper > from Novell. From the desktop to the data center, Linux is going > mainstream. Let it simplify your IT future. > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 > _______________________________________________ > Cishell-svn mailing list > Cis...@li... > https://lists.sourceforge.net/lists/listinfo/cishell-svn > -- Bruce Herr Senior Software Developer Cyberinfrastructure for Network Science Center School of Library and Information Science Indiana University 10th Street & Jordan Avenue Phone: (812) 856-7034 Fax: -6166 Main Library 022 E-mail: bh...@bh... Bloomington, IN 47405, USA |
From: Bruce H. <bh...@bh...> - 2007-12-04 14:18:53
|
oh wait, never mind. Bruce On Dec 4, 2007 9:17 AM, Bruce Herr <bh...@bh...> wrote: > You should also update org.cishell.templates.standalone.executable w/ the > change. These need to be kept in sync (at some point we need to make it so > we only have one version of this). > > Bruce > > > On Dec 3, 2007 5:23 PM, <fu...@us...> wrote: > > > Revision: 550 > > http://cishell.svn.sourceforge.net/cishell/?rev=550&view=rev > > Author: fugu13 > > Date: 2007-12-03 14:23:19 -0800 (Mon, 03 Dec 2007) > > > > Log Message: > > ----------- > > Fix bug that occurs when copying multiple directories. Neighboring > > directories had been copied as nesting directories, because the variable > > holding the directory to copy to was overwritten each time a subdirectory to > > copy was encountered. > > > > Modified Paths: > > -------------- > > > > trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java > > > > Modified: > > trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java > > > > =================================================================== > > --- > > trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java > > 2007-11-14 17:23:59 UTC (rev 549) > > +++ > > trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java > > 2007-12-03 22:23:19 UTC (rev 550) > > @@ -168,9 +168,9 @@ > > if (path.endsWith ("/")) { > > String dirName = getName(path); > > > > - dir = new File(dir.getPath() + File.separator + > > dirName); > > - dir.mkdirs(); > > - copyDir(dir, path); > > + File subDirectory = new File(dir.getPath() + > > File.separator + dirName); > > + subDirectory.mkdirs(); > > + copyDir(subDirectory, path); > > } else { > > copyFile(dir, path); > > } > > > > > > This was sent by the SourceForge.net collaborative development platform, > > the world's largest Open Source development site. > > > > ------------------------------------------------------------------------- > > > > SF.Net email is sponsored by: The Future of Linux Business White Paper > > from Novell. From the desktop to the data center, Linux is going > > mainstream. Let it simplify your IT future. > > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 > > _______________________________________________ > > Cishell-svn mailing list > > Cis...@li... > > https://lists.sourceforge.net/lists/listinfo/cishell-svn > > > > > > -- > Bruce Herr > > Senior Software Developer > Cyberinfrastructure for Network Science Center > School of Library and Information Science > Indiana University > > 10th Street & Jordan Avenue Phone: (812) 856-7034 Fax: -6166 > Main Library 022 E-mail: bh...@bh... > Bloomington, IN 47405, USA -- Bruce Herr Senior Software Developer Cyberinfrastructure for Network Science Center School of Library and Information Science Indiana University 10th Street & Jordan Avenue Phone: (812) 856-7034 Fax: -6166 Main Library 022 E-mail: bh...@bh... Bloomington, IN 47405, USA |
From: <hu...@us...> - 2007-12-06 20:07:59
|
Revision: 552 http://cishell.svn.sourceforge.net/cishell/?rev=552&view=rev Author: huangb Date: 2007-12-06 12:07:54 -0800 (Thu, 06 Dec 2007) Log Message: ----------- replace File.separator with "/" Modified Paths: -------------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-12-04 18:25:29 UTC (rev 551) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2007-12-06 20:07:54 UTC (rev 552) @@ -32,6 +32,7 @@ import org.cishell.framework.data.Data; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; +import org.osgi.service.log.LogService; import org.osgi.service.metatype.MetaTypeProvider; import org.osgi.service.metatype.MetaTypeService; @@ -75,11 +76,13 @@ Data[] data; Dictionary parameters; CIShellContext context; + LogService logger; public StaticExecutableAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { this.data = data; this.parameters = parameters; this.context = context; + logger = (LogService)context.getService(LogService.class.getName()); ALGORITHM = algName + "/"; ALGORITHM_MACOSX_PPC = ALGORITHM + "macosx.ppc/"; @@ -117,7 +120,7 @@ while(e != null && e.hasMoreElements()) { String entryPath = (String) e.nextElement(); - + //logger.log(LogService.LOG_DEBUG, "entry: " + entryPath + "\n\n"); if(entryPath.endsWith("/")) { entries.add(entryPath); } @@ -134,7 +137,9 @@ //take the default, if there if(entries.contains(ALGORITHM_DEFAULT)) { String default_path = ALGORITHM_DEFAULT; - copyDir(dir, default_path); + //logger.log(LogService.LOG_DEBUG, "base path: "+default_path+ + // "\n\t"+dir.getAbsolutePath() + "\n\n"); + copyDir(dir, default_path, 0); } //but override with platform idiosyncracies @@ -153,14 +158,16 @@ if (path == null) { throw new RuntimeException("Unable to find compatible executable"); } else { - copyDir(dir, path); + //logger.log(LogService.LOG_DEBUG, "base path: "+path+ + // "\n\t"+dir.getAbsolutePath() + "\n\n"); + copyDir(dir, path, 0); } } - private void copyDir(File dir, String dirPath) throws IOException { + private void copyDir(File dir, String dirPath, int depth) throws IOException { Enumeration e = bContext.getBundle().getEntryPaths(dirPath); - dirPath = dirPath.replace('/', File.separatorChar); + //dirPath = dirPath.replace('/', File.separatorChar); while (e != null && e.hasMoreElements()) { String path = (String)e.nextElement(); @@ -170,7 +177,9 @@ File subDirectory = new File(dir.getPath() + File.separator + dirName); subDirectory.mkdirs(); - copyDir(subDirectory, path); + //logger.log(LogService.LOG_DEBUG, "path: " + depth + " "+path+ + // "\n\t"+subDirectory.getAbsolutePath() + "\n\n"); + copyDir(subDirectory, path, depth + 1); } else { copyFile(dir, path); } @@ -180,7 +189,7 @@ private void copyFile(File dir, String path) throws IOException { URL entry = bContext.getBundle().getEntry(path); - path = path.replace('/', File.separatorChar); + //path = path.replace('/', File.separatorChar); String file = getName(path); FileOutputStream outStream = new FileOutputStream(dir.getPath() + File.separator + file); @@ -193,11 +202,11 @@ } private String getName(String path) { - if (path.lastIndexOf(File.separator) == path.length()-1) { + if (path.lastIndexOf('/') == path.length()-1) { path = path.substring(0, path.length()-1); } - path = path.substring(path.lastIndexOf(File.separatorChar)+1, + path = path.substring(path.lastIndexOf('/')+1, path.length()); return path; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bh...@us...> - 2008-01-24 18:35:22
|
Revision: 604 http://cishell.svn.sourceforge.net/cishell/?rev=604&view=rev Author: bh2 Date: 2008-01-24 10:35:08 -0800 (Thu, 24 Jan 2008) Log Message: ----------- Added fallback code such that on a 64-bit linux machine, a 32-bit linux static executable will be called if there is no 64-bit linux static executable. Modified Paths: -------------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2008-01-23 20:54:25 UTC (rev 603) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2008-01-24 18:35:08 UTC (rev 604) @@ -79,6 +79,8 @@ private String MACOSX; private String ALGORITHM_WIN32; private String WIN32; + private String ALGORITHM_LINUX_X86; + private String LINUX; private String ALGORITHM_DEFAULT; Data[] data; Dictionary parameters; @@ -96,8 +98,9 @@ MACOSX = "macosx"; ALGORITHM_WIN32 = ALGORITHM + "win32/"; WIN32 = "win32"; + ALGORITHM_LINUX_X86 = ALGORITHM + "linux.x86/"; + LINUX = "linux"; ALGORITHM_DEFAULT = ALGORITHM + "default/"; - } public Data[] execute() { @@ -154,6 +157,8 @@ path = ALGORITHM_WIN32; } else if(os.equals(MACOSX) && entries.contains(ALGORITHM_MACOSX_PPC)) { path = ALGORITHM_MACOSX_PPC; + } else if(os.equals(LINUX) && entries.contains(ALGORITHM_LINUX_X86)) { + path = ALGORITHM_LINUX_X86; } String platform_path = ALGORITHM + os + "." + arch + "/"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-07-08 18:51:35
|
Revision: 785 http://cishell.svn.sourceforge.net/cishell/?rev=785&view=rev Author: mwlinnem Date: 2008-07-08 11:50:58 -0700 (Tue, 08 Jul 2008) Log Message: ----------- A little refactoring. Modified Paths: -------------- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java Modified: trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java =================================================================== --- trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2008-07-08 18:00:25 UTC (rev 784) +++ trunk/templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/StaticExecutableAlgorithmFactory.java 2008-07-08 18:50:58 UTC (rev 785) @@ -13,29 +13,14 @@ * ***************************************************************************/ package org.cishell.templates.staticexecutable; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.URL; -import java.nio.channels.Channels; -import java.nio.channels.FileChannel; -import java.nio.channels.ReadableByteChannel; import java.util.Dictionary; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; -import org.cishell.framework.algorithm.AlgorithmExecutionException; import org.cishell.framework.algorithm.AlgorithmFactory; -import org.cishell.framework.algorithm.ProgressMonitor; -import org.cishell.framework.algorithm.ProgressTrackable; import org.cishell.framework.data.Data; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; -import org.osgi.service.log.LogService; import org.osgi.service.metatype.MetaTypeProvider; import org.osgi.service.metatype.MetaTypeService; @@ -47,6 +32,7 @@ public StaticExecutableAlgorithmFactory() {} + //pretty sure this isn't used by anything, but I fear deleting it. public StaticExecutableAlgorithmFactory(String algName, BundleContext bContext) { this.algName = algName; this.bContext = bContext; @@ -69,183 +55,10 @@ } public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { - return new StaticExecutableAlgorithm(data, parameters, context); + return new StaticExecutableAlgorithm(data, parameters, context, this.bContext, this.algName); } public MetaTypeProvider createParameters(Data[] data) { return provider; } - - private class StaticExecutableAlgorithm implements Algorithm, ProgressTrackable { - private String ALGORITHM; - private String ALGORITHM_MACOSX_PPC; - private String MACOSX; - private String ALGORITHM_WIN32; - private String WIN32; - private String ALGORITHM_LINUX_X86; - private String LINUX; - private String ALGORITHM_DEFAULT; - Data[] data; - Dictionary parameters; - CIShellContext context; - LogService logger; - - private ProgressMonitor monitor; - - public StaticExecutableAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) - { - this.data = data; - this.parameters = parameters; - this.context = context; - logger = (LogService)context.getService(LogService.class.getName()); - - ALGORITHM = algName + "/"; - ALGORITHM_MACOSX_PPC = ALGORITHM + "macosx.ppc/"; - MACOSX = "macosx"; - ALGORITHM_WIN32 = ALGORITHM + "win32/"; - WIN32 = "win32"; - ALGORITHM_LINUX_X86 = ALGORITHM + "linux.x86/"; - LINUX = "linux"; - ALGORITHM_DEFAULT = ALGORITHM + "default/"; - } - - public Data[] execute() throws AlgorithmExecutionException { - try { - Properties serviceProps = getProperties("/"+algName+"/service.properties"); - Properties configProps = getProperties("/"+algName+"/config.properties"); - - serviceProps.putAll(configProps); - serviceProps.put("Algorithm-Directory", algName); - - StaticExecutableRunner runner = - new StaticExecutableRunner(bContext, context, serviceProps, parameters, data, monitor); - - copyFiles(runner.getTempDirectory()); - - return runner.execute(); - } catch (IOException e) { - throw new AlgorithmExecutionException(e.getMessage(), e); - } - } - - private void copyFiles(File dir) throws IOException, AlgorithmExecutionException { - Enumeration e = bContext.getBundle().getEntryPaths("/"+algName); - - Set entries = new HashSet(); - - while(e != null && e.hasMoreElements()) { - String entryPath = (String) e.nextElement(); - //logger.log(LogService.LOG_DEBUG, "entry: " + entryPath + "\n\n"); - if(entryPath.endsWith("/")) { - entries.add(entryPath); - } - } - - dir = new File(dir.getPath() + File.separator + algName); - dir.mkdirs(); - - String os = bContext.getProperty("osgi.os"); - String arch = bContext.getProperty("osgi.arch"); - - String path = null; - - //take the default, if there - if(entries.contains(ALGORITHM_DEFAULT)) { - String default_path = ALGORITHM_DEFAULT; - //logger.log(LogService.LOG_DEBUG, "base path: "+default_path+ - // "\n\t"+dir.getAbsolutePath() + "\n\n"); - copyDir(dir, default_path, 0); - } - - //but override with platform idiosyncracies - if(os.equals(WIN32) && entries.contains(ALGORITHM_WIN32)) { - path = ALGORITHM_WIN32; - } else if(os.equals(MACOSX) && entries.contains(ALGORITHM_MACOSX_PPC)) { - path = ALGORITHM_MACOSX_PPC; - } else if(os.equals(LINUX) && entries.contains(ALGORITHM_LINUX_X86)) { - path = ALGORITHM_LINUX_X86; - } - - String platform_path = ALGORITHM + os + "." + arch + "/"; - //and always override anything with an exact match - if(entries.contains(platform_path)) { - path = platform_path; - } - - if (path == null) { - throw new AlgorithmExecutionException("Unable to find compatible executable"); - } else { - //logger.log(LogService.LOG_DEBUG, "base path: "+path+ - // "\n\t"+dir.getAbsolutePath() + "\n\n"); - copyDir(dir, path, 0); - } - } - - private void copyDir(File dir, String dirPath, int depth) throws IOException { - Enumeration e = bContext.getBundle().getEntryPaths(dirPath); - - //dirPath = dirPath.replace('/', File.separatorChar); - - while (e != null && e.hasMoreElements()) { - String path = (String)e.nextElement(); - - if (path.endsWith("/")) { - String dirName = getName(path); - - File subDirectory = new File(dir.getPath() + File.separator + dirName); - subDirectory.mkdirs(); - //logger.log(LogService.LOG_DEBUG, "path: " + depth + " "+path+ - // "\n\t"+subDirectory.getAbsolutePath() + "\n\n"); - copyDir(subDirectory, path, depth + 1); - } else { - copyFile(dir, path); - } - } - } - - private void copyFile(File dir, String path) throws IOException { - URL entry = bContext.getBundle().getEntry(path); - - //path = path.replace('/', File.separatorChar); - String file = getName(path); - FileOutputStream outStream = new FileOutputStream(dir.getPath() + File.separator + file); - - ReadableByteChannel in = Channels.newChannel(entry.openStream()); - FileChannel out = outStream.getChannel(); - out.transferFrom(in, 0, Integer.MAX_VALUE); - - in.close(); - out.close(); - } - - private String getName(String path) { - if (path.lastIndexOf('/') == path.length()-1) { - path = path.substring(0, path.length()-1); - } - - path = path.substring(path.lastIndexOf('/')+1, - path.length()); - - return path; - } - - private Properties getProperties(String entry) throws IOException { - URL url = bContext.getBundle().getEntry(entry); - Properties props = null; - - if (url != null) { - props = new Properties(); - props.load(url.openStream()); - } - return props; - } - - public ProgressMonitor getProgressMonitor() { - return this.monitor; - } - - public void setProgressMonitor(ProgressMonitor monitor) { - this.monitor = monitor; - } - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |