Revision: 4094 http://vexi.svn.sourceforge.net/vexi/?rev=4094&view=rev Author: mkpg2 Date: 2011-03-28 15:45:36 +0000 (Mon, 28 Mar 2011)
Log Message: ----------- Improve. Add option to generate json instead of html to vexi deployment assembler. Modified Paths: -------------- trunk/org.vexi-build.deployment/src/main/java/org/vexi/build/deployment/VexiDeploymentAssembler.java trunk/org.vexi-launcher.testdeploy/meta/product-assembly.xml trunk/org.vexi-launcher.testdeploy/src/main/java/testdeploy/NanoHTTPD.java Modified: trunk/org.vexi-build.deployment/src/main/java/org/vexi/build/deployment/VexiDeploymentAssembler.java =================================================================== --- trunk/org.vexi-build.deployment/src/main/java/org/vexi/build/deployment/VexiDeploymentAssembler.java 2011-03-28 13:56:03 UTC (rev 4093) +++ trunk/org.vexi-build.deployment/src/main/java/org/vexi/build/deployment/VexiDeploymentAssembler.java 2011-03-28 15:45:36 UTC (rev 4094) @@ -1,7 +1,11 @@ package org.vexi.build.deployment; import java.io.File; +import java.util.ArrayList; import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import org.vexi.util.IOUtil; @@ -14,6 +18,7 @@ import ebuild.api.plugin.IPropertyMap; import ebuild.util.CollectionUtil; import ebuild.util.FileUtil; +import ebuild.util.JSONUtil; public class VexiDeploymentAssembler extends AbstractAssembler{ public Collection<File> assemble(IAssemblerArgument arg) throws BuildPluginException { @@ -26,23 +31,36 @@ File output = arg.getOutputDirectory(); File launcher = inputs.expectInput("launcher").expectLoneArtifact(); File core = inputs.expectInput("core").expectLoneArtifact(); - Collection<File> vexis = inputs.expectInput("vexis").getArtifacts(); + Collection<File> vexiFiles = inputs.expectInput("vexis").getArtifacts(); output.mkdirs(); logger.log("launcher:" ); logger.log(" "+ebuild.formatAsDisplayPath(launcher)); + List<String> vexis = new ArrayList(vexiFiles.size()); FileUtil.copyToDir(launcher, output); FileUtil.copyToDir(core, output); FileUtil.copyToDir(launcher, output); - for(File f: vexis) + for(File f: vexiFiles){ FileUtil.copyToDir(f, output); + vexis.add(f.getName()); + } - File index = new File(output, "index.html"); - IOUtil.stringToFile(generateLaunchHtml(props, core, launcher, vexis), index); + String launcherPage = props.getString("launcher-page"); + if(launcherPage!=null){ + File file = new File(output, launcherPage); + IOUtil.stringToFile(generateLaunchHtml(props, core, launcher, vexis), file); + } + + String launcherJson = props.getString("launcher-json"); + if(launcherJson!=null){ + File file = new File(output, launcherJson); + Map m = generateLaunchJson(props, core, launcher, vexis); + JSONUtil.writeObject(file, m); + } return CollectionUtil.singletonList(output); } catch (Exception e) { throw BuildPluginException.wrap(e); @@ -50,7 +68,7 @@ } - public String generateLaunchHtml(IPropertyMap props, File core, File launcher, Collection<File> vexis) throws Exception{ + public String generateLaunchHtml(IPropertyMap props, File core, File launcher, Collection<String> vexis) throws Exception{ String mainClass = props.expectString("applet-class"); String ROOT = props.expectString("root"); @@ -70,9 +88,9 @@ " <param name='option0' value='-t'/>\n"+ " <param name='option1' value='"+props.getString("main-template","main")+"'/>\n"); int i=0; - for(File v: vexis){ + for(String v: vexis){ sb.append( - " <param name='vexi"+(i++)+"' value='"+ROOT+"/"+v.getName()+"'/>\n"); + " <param name='vexi"+(i++)+"' value='"+ROOT+"/"+v+"'/>\n"); } sb.append( " </applet>\n"+ @@ -83,6 +101,17 @@ " </html>"); return sb.toString(); } + + public Map generateLaunchJson(IPropertyMap props, File core, File launcher, Collection<String> vexis) throws Exception{ + Map m = new LinkedHashMap(); + m.put("applet-jar",props.expectString(launcher.getName())); + m.put("applet-class",props.expectString("applet-class")); + m.put("core-signed",core.getName()); + m.put("vexis", vexis); + return m; + } + + // REMARK actually nonsensical - the main class is a standalone jar concept. No such // similar concept for applets ... // Modified: trunk/org.vexi-launcher.testdeploy/meta/product-assembly.xml =================================================================== --- trunk/org.vexi-launcher.testdeploy/meta/product-assembly.xml 2011-03-28 13:56:03 UTC (rev 4093) +++ trunk/org.vexi-launcher.testdeploy/meta/product-assembly.xml 2011-03-28 15:45:36 UTC (rev 4094) @@ -15,6 +15,7 @@ <input name="launcher"> <product source="local" name="launcher.vexi_org" /> <!--conf-mapping="->noshrink"--> </input> + <property key="launcher-page" value="index.html"/> <property key="applet-class" value="org.vexi.launcher.VexiLauncher"/> <property key="title" value="Vexi Demo" /> <property key="root" value="http://localhost:7070/" /> Modified: trunk/org.vexi-launcher.testdeploy/src/main/java/testdeploy/NanoHTTPD.java =================================================================== --- trunk/org.vexi-launcher.testdeploy/src/main/java/testdeploy/NanoHTTPD.java 2011-03-28 13:56:03 UTC (rev 4093) +++ trunk/org.vexi-launcher.testdeploy/src/main/java/testdeploy/NanoHTTPD.java 2011-03-28 15:45:36 UTC (rev 4094) @@ -227,7 +227,10 @@ { - File root = new File("./release/root-working");//args.length>0?new File(args[0]):null; + File root = +// new File("../_ebuild/releases/root-rev_4092"); + new File("./release/root-working"); + //args.length>0?new File(args[0]):null; //NanoHTTPD server = new NanoHTTPD(PORT); NanoHTTPD.start(root); @@ -543,8 +546,12 @@ newUri += "/"; else if ( tok.equals( " " )) newUri += "%20"; - else - newUri += URLEncoder.encode( tok ); + else + try { + newUri += URLEncoder.encode(tok, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new Error(e); + } } return newUri; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn