Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 38861 Details for
Bug 127375
Add update site performance enhancement utility
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
siteOptimizer Application
127375.txt (text/plain), 15.02 KB, created by
Andrew Niefer
on 2006-04-18 18:35:33 EDT
(
hide
)
Description:
siteOptimizer Application
Filename:
MIME Type:
Creator:
Andrew Niefer
Created:
2006-04-18 18:35:33 EDT
Size:
15.02 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.update.core >Index: src/org/eclipse/update/internal/jarprocessor/Main.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/Main.java,v >retrieving revision 1.1 >diff -u -r1.1 Main.java >--- src/org/eclipse/update/internal/jarprocessor/Main.java 12 Apr 2006 16:55:46 -0000 1.1 >+++ src/org/eclipse/update/internal/jarprocessor/Main.java 18 Apr 2006 22:06:58 -0000 >@@ -74,16 +74,17 @@ > options.input = new File(args[i]); > > String problemMessage = null; >+ String inputName = options.input.getName(); > if (options.unpack) { > if (!JarProcessor.canPerformUnpack()) { > problemMessage = "The unpack200 command cannot be found."; //$NON-NLS-1$ >- } else if (options.input.isFile() && !args[i].endsWith(".zip") && !args[i].endsWith(".pack.gz")) { //$NON-NLS-1$ //$NON-NLS-2$ >+ } else if (options.input.isFile() && !inputName.endsWith(".zip") && !inputName.endsWith(".pack.gz")) { //$NON-NLS-1$ //$NON-NLS-2$ > problemMessage = "Input file is not a pack.gz file."; //$NON-NLS-1$ > } else if (options.pack || options.repack || options.signCommand != null) { > problemMessage = "Pack, repack or sign cannot be specified with unpack."; //$NON-NLS-1$ > } > } else { >- if (options.input.isFile() && !args[i].endsWith(".zip") && !args[i].endsWith(".jar")) { //$NON-NLS-1$ //$NON-NLS-2$ >+ if (options.input.isFile() && !inputName.endsWith(".zip") && !inputName.endsWith(".jar")) { //$NON-NLS-1$ //$NON-NLS-2$ > problemMessage = "Input file is not a jar file."; //$NON-NLS-1$ > } else if ((options.pack || options.repack) && !JarProcessor.canPerformPack()) { > problemMessage = "The pack200 command can not be found."; //$NON-NLS-1$ >@@ -99,15 +100,7 @@ > return options; > } > >- /** >- * @param args >- * @throws FileNotFoundException >- */ >- public static void main(String[] args) { >- Options options = processArguments(args); >- if (options == null) >- return; >- >+ public static void runJarProcessor(Options options) { > if (options.input.getName().endsWith(".zip")) { //$NON-NLS-1$ > ZipProcessor processor = new ZipProcessor(); > processor.setWorkingDirectory(options.outputDir); >@@ -147,5 +140,16 @@ > } > } > } >+ >+ /** >+ * @param args >+ * @throws FileNotFoundException >+ */ >+ public static void main(String[] args) { >+ Options options = processArguments(args); >+ if (options == null) >+ return; >+ runJarProcessor(options); >+ } > > } >Index: src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java,v >retrieving revision 1.1 >diff -u -r1.1 SignCommandStep.java >--- src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java 12 Apr 2006 16:55:46 -0000 1.1 >+++ src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java 18 Apr 2006 22:06:58 -0000 >@@ -65,7 +65,7 @@ > private void normalize(File input, File workingDirectory) { > try { > File tempJar = new File(workingDirectory, "temp_" + input.getName()); //$NON-NLS-1$ >- JarFile jar = new JarFile(input); >+ JarFile jar = new JarFile(input, false); > JarOutputStream jarOut = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(tempJar))); > InputStream in = null; > try { >Index: src/org/eclipse/update/internal/core/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/core/messages.properties,v >retrieving revision 1.98 >diff -u -r1.98 messages.properties >--- src/org/eclipse/update/internal/core/messages.properties 17 Mar 2006 06:02:59 -0000 1.98 >+++ src/org/eclipse/update/internal/core/messages.properties 18 Apr 2006 22:06:58 -0000 >@@ -336,7 +336,11 @@ > SiteFilePluginContentConsumer_unableToDelete=Unable to delete {0} > SiteFilePackedPluginContentConsumer_unableToDelete=Unable to delete {0} > >- >+JarProcessor_unpackNotFound = The unpack200 command cannot be found. >+JarProcessor_noPackUnpack = Pack, repack or sign cannot be specified with unpack. >+JarProcessor_packNotFound = The pack200 command cannot be found. >+SiteOptimizer_inputNotSpecified = No input file was specified; >+SiteOptimizer_inputFileNotFound = The input file \"{0}\" was not found. > > HttpResponse_rangeExpected = Server does not support ranges. > HttpResponse_wrongRange = Server returned wrong range. >Index: src/org/eclipse/update/internal/core/FeaturePackagedContentProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/core/FeaturePackagedContentProvider.java,v >retrieving revision 1.49 >diff -u -r1.49 FeaturePackagedContentProvider.java >--- src/org/eclipse/update/internal/core/FeaturePackagedContentProvider.java 12 Apr 2006 16:55:46 -0000 1.49 >+++ src/org/eclipse/update/internal/core/FeaturePackagedContentProvider.java 18 Apr 2006 22:06:58 -0000 >@@ -17,6 +17,7 @@ > import org.eclipse.osgi.util.NLS; > import org.eclipse.update.core.*; > import org.eclipse.update.internal.jarprocessor.JarProcessor; >+import org.eclipse.update.internal.jarprocessor.Utils; > import org.eclipse.update.internal.security.JarVerifier; > import org.eclipse.update.internal.verifier.CertVerifier; > >@@ -41,8 +42,11 @@ > /* > * Constructor > */ >- public FeaturePackagedContentProvider(URL url) { >+ public FeaturePackagedContentProvider(URL url, ISite site) { > super(url); >+ if (site instanceof ExtendedSite) { >+ this.siteModel = (ExtendedSite) site; >+ } > } > > /* >@@ -64,13 +68,6 @@ > return jarVerifier; > } > >- public void setFeature(IFeature feature) { >- super.setFeature(feature); >- ISite featureSite = feature.getSite(); >- if(featureSite instanceof ExtendedSite){ >- siteModel = (ExtendedSite) featureSite; >- } >- } > /* > * @see IFeatureContentProvider#getFeatureManifestReference() > */ >@@ -227,8 +224,14 @@ > JarProcessor processor = JarProcessor.getUnpackProcessor(null); > processor.setWorkingDirectory(tempFile.getParent()); > >- File packedFile = new File(tempFile.toString() + ".pack.gz"); //$NON-NLS-1$ >+ File packedFile = new File(tempFile.toString() + Utils.PACKED_SUFFIX); > tempFile.renameTo(packedFile); >+ >+ if (monitor != null) { >+ monitor.saveState(); >+ monitor.subTask(Messages.JarContentReference_Unpacking + " " + reference.getIdentifier() + Utils.PACKED_SUFFIX); //$NON-NLS-1$ >+ monitor.showCopyDetails(false); >+ } > //unpacking the jar will strip the ".pack.gz" and leave us back with the original filename > processor.processJar(packedFile); > >@@ -237,6 +240,8 @@ > } finally { > LockManager.returnLock(packed); > LockManager.returnLock(key); >+ if(monitor != null) >+ monitor.restoreState(); > } > } > } >Index: src/org/eclipse/update/internal/core/FeaturePackagedFactory.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/core/FeaturePackagedFactory.java,v >retrieving revision 1.28 >diff -u -r1.28 FeaturePackagedFactory.java >--- src/org/eclipse/update/internal/core/FeaturePackagedFactory.java 11 Apr 2006 16:37:57 -0000 1.28 >+++ src/org/eclipse/update/internal/core/FeaturePackagedFactory.java 18 Apr 2006 22:06:58 -0000 >@@ -35,7 +35,7 @@ > > > try { >- IFeatureContentProvider contentProvider = new FeaturePackagedContentProvider(url); >+ IFeatureContentProvider contentProvider = new FeaturePackagedContentProvider(url, site); > ContentReference manifest = contentProvider.getFeatureManifestReference(null/*IProgressMonitor*/); > featureStream = manifest.getInputStream(); > feature = (Feature)parseFeature(featureStream); >Index: src/org/eclipse/update/internal/core/Messages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/core/Messages.java,v >retrieving revision 1.6 >diff -u -r1.6 Messages.java >--- src/org/eclipse/update/internal/core/Messages.java 17 Mar 2006 06:02:59 -0000 1.6 >+++ src/org/eclipse/update/internal/core/Messages.java 18 Apr 2006 22:06:58 -0000 >@@ -335,6 +335,13 @@ > public static String HttpResponse_wrongRange; > public static String DefaultSiteParser_mirrors; > public static String FeatureExecutableContentProvider_UnableToRetriveArchiveContentRef; >+ >+ public static String JarProcessor_unpackNotFound; >+ public static String JarProcessor_noPackUnpack; >+ public static String JarProcessor_packNotFound; >+ >+ public static String SiteOptimizer_inputNotSpecified; >+ public static String SiteOptimizer_inputFileNotFound; > > static { > NLS.initializeMessages(BUNDLE_NAME, Messages.class); >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/plugin.xml,v >retrieving revision 1.55 >diff -u -r1.55 plugin.xml >--- plugin.xml 29 Mar 2006 23:37:07 -0000 1.55 >+++ plugin.xml 18 Apr 2006 22:06:58 -0000 >@@ -72,6 +72,15 @@ > </run> > </application> > </extension> >+ <extension >+ id="siteOptimizer" >+ point="org.eclipse.core.runtime.applications"> >+ <application> >+ <run >+ class="org.eclipse.update.internal.provisional.SiteOptimizerApplication"> >+ </run> >+ </application> >+ </extension> > <extension > id="updateCoreProductProvider" > name="%productProviderName" >Index: src/org/eclipse/update/internal/provisional/SiteOptimizerApplication.java >=================================================================== >RCS file: src/org/eclipse/update/internal/provisional/SiteOptimizerApplication.java >diff -N src/org/eclipse/update/internal/provisional/SiteOptimizerApplication.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/update/internal/provisional/SiteOptimizerApplication.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,138 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.update.internal.provisional; >+ >+import java.io.File; >+import java.util.HashMap; >+import java.util.Map; >+import org.eclipse.core.runtime.IPlatformRunnable; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.update.internal.core.Messages; >+import org.eclipse.update.internal.jarprocessor.JarProcessor; >+import org.eclipse.update.internal.jarprocessor.Main; >+ >+/** >+ * The application class used to perform update site optimizations. >+ * <p> >+ * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to >+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback >+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken >+ * (repeatedly) as the API evolves. >+ * </p> >+ * @since 3.2 >+ */ >+public class SiteOptimizerApplication implements IPlatformRunnable { >+ public final static Integer EXIT_ERROR = new Integer(1); >+ >+ public final static String JAR_PROCESSOR = "-jarProcessor"; //$NON-NLS-1$ >+ public final static String DIGEST_BUILDER = "-digestBuilder"; //$NON-NLS-1$ >+ public final static String INPUT = "input"; //$NON-NLS-1$ >+ public final static String OUTPUT_DIR = "-outputDir"; //$NON-NLS-1$ >+ >+ public final static String JAR_PROCESSOR_PACK = "-pack"; //$NON-NLS-1$ >+ public final static String JAR_PROCESSOR_UNPACK = "-unpack"; //$NON-NLS-1$ >+ public final static String JAR_PROCESSOR_REPACK = "-repack"; //$NON-NLS-1$ >+ public final static String JAR_PROCESSOR_SIGN = "-sign"; //$NON-NLS-1$ >+ >+ >+ /** >+ * Parses the command line in the form: >+ * [-key [value]]* [inputvalue] >+ * If the last argument does not start with a "-" then it is taken as the input value and not the value for a preceding -key >+ * @param args >+ * @return >+ */ >+ private Map parseCmdLine(String [] args) { >+ Map cmds = new HashMap(); >+ for (int i = 0; i < args.length; i++) { >+ if(i == args.length - 1 && !args[i].startsWith("-")) { //$NON-NLS-1$ >+ cmds.put(INPUT, args[i]); >+ } else { >+ String key = args[i]; >+ String val = null; >+ if( i < args.length - 2 && !args[i + 1].startsWith("-")){ //$NON-NLS-1$ >+ val = args[++i]; >+ } >+ cmds.put(key, val); >+ } >+ } >+ return cmds; >+ } >+ >+ private boolean runJarProcessor(Map params) { >+ Main.Options options = new Main.Options(); >+ options.pack = params.containsKey(JAR_PROCESSOR_PACK); >+ options.unpack = params.containsKey(JAR_PROCESSOR_UNPACK); >+ options.repack = params.containsKey(JAR_PROCESSOR_REPACK); >+ options.signCommand = (String) params.get(JAR_PROCESSOR_SIGN); >+ options.outputDir = (String) params.get(OUTPUT_DIR); >+ >+ String problem = null; >+ >+ String input = (String) params.get(INPUT); >+ if(input == null) >+ problem = Messages.SiteOptimizer_inputNotSpecified; >+ else { >+ File inputFile = new File(input); >+ if(inputFile.exists()) >+ options.input = inputFile; >+ else >+ problem = NLS.bind(Messages.SiteOptimizer_inputFileNotFound, new String[] {input}); >+ } >+ >+ if (options.unpack) { >+ if (!JarProcessor.canPerformUnpack()) { >+ problem = Messages.JarProcessor_unpackNotFound; >+ } else if (options.pack || options.repack || options.signCommand != null) { >+ problem = Messages.JarProcessor_noPackUnpack; >+ } >+ } else if ((options.pack || options.repack) && !JarProcessor.canPerformPack()) { >+ problem = Messages.JarProcessor_packNotFound; >+ } >+ >+ if(problem != null) { >+ System.out.println(problem); >+ return false; >+ } >+ >+ Main.runJarProcessor(options); >+ return true; >+ } >+ >+ private boolean runDigestBuilder(Map params) { >+ //TODO >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Object) >+ */ >+ public Object run(Object args) throws Exception { >+ Platform.endSplash(); >+ if (args == null) >+ return EXIT_ERROR; >+ if (args instanceof String[]) { >+ Map params = parseCmdLine((String[]) args); >+ if(params.containsKey(JAR_PROCESSOR)){ >+ if(!runJarProcessor(params)) >+ return EXIT_ERROR; >+ } >+ >+ if(params.containsKey(DIGEST_BUILDER)){ >+ if(!runDigestBuilder(params)) >+ return EXIT_ERROR; >+ } >+ } >+ return IPlatformRunnable.EXIT_OK; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 127375
:
37769
|
37820
|
38035
|
38421
|
38861
|
39181
|
39196