1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
|
#! /bin/sh -e
##
## DP: Debian specific patch, converted from eclipse-fileinitializer.patch
[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
if [ $# -ne 1 ]; then
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
fi
case "$1" in
-patch)
patch $patch_opts -p0 < $0;;
-unpatch)
patch $patch_opts -p0 -R < $0;;
*)
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1;;
esac
exit 0
@DPATCH@
--- source-tree/plugins/org.eclipse.core.runtime/plugin.xml.orig 2006-01-11 19:16:49.000000000 +0000
+++ source-tree/plugins/org.eclipse.core.runtime/plugin.xml 2006-01-11 19:19:20.000000000 +0000
@@ -6,4 +6,16 @@
<extension-point id="adapters" name="%adaptersName" schema="schema/adapters.exsd"/>
<extension-point id="preferences" name="%preferencesName" schema="schema/preferences.exsd"/>
<extension-point id="contentTypes" name="%contentTypesName" schema="schema/contentTypes.exsd"/>
+ <extension-point id="initializers" name="%initializersName" schema="schema/initializers.exsd"/>
+
+ <extension id="initializer" name="%initializerApp" point="org.eclipse.core.runtime.applications">
+ <application>
+ <run class="org.eclipse.core.internal.runtime.Initializer"/>
+ </application>
+ </extension>
+ <extension id="fileInitializer" point="org.eclipse.core.runtime.initializers">
+ <initializer>
+ <initialize class="org.eclipse.core.internal.runtime.FileInitializer"/>
+ </initializer>
+ </extension>
</plugin>
--- source-tree/plugins/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Messages.java.orig 2006-01-11 19:20:41.000000000 +0000
+++ source-tree/plugins/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Messages.java 2006-01-11 19:22:12.000000000 +0000
@@ -39,6 +39,14 @@
public static String meta_unableToReadAuthorization;
public static String meta_unableToWriteAuthorization;
+ // initializer
+ public static String initializer_error;
+
+ // file initializer
+ public static String fileInitializer_fileNotFound;
+ public static String fileInitializer_IOError;
+ public static String fileInitializer_missingFileName;
+
// parsing/resolve
public static String plugin_deactivatedLoad;
--- source-tree/plugins/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java.orig 2006-01-11 19:28:23.000000000 +0000
+++ source-tree/plugins/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java 2006-01-11 19:30:05.000000000 +0000
@@ -86,6 +86,15 @@
*/
public static final String PT_PRODUCT = "products"; //$NON-NLS-1$
+ /**
+ * The simple identifier constant (value "<code>initializers</code>") of
+ * the extension point of the Core Runtime plug-in where plug-ins declare
+ * their the existence of initialization code.
+ *
+ * @since 3.2
+ */
+ public static final String PT_INITIALIZERS = "initializers"; //$NON-NLS-1$
+
/**
* The simple identifier constant (value "<code>initializers</code>") of
* the extension point of the Core Runtime plug-in where plug-ins declare
Index: source-tree/plugins/org.eclipse.core.runtime/schema/initializers.exsd
===================================================================
RCS file: schema/initializers.exsd
diff -N schema/initializers.exsd
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ source-tree/plugins/org.eclipse.core.runtime/schema/initializers.exsd 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,138 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.core.runtime">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.core.runtime" id="initializers" name="Plug-in Initializers"/>
+ </appInfo>
+ <documentation>
+ Platform runtime supports plug-ins which would like to
+be initialized. That is, plug-ins that needs to be initialized when
+the initialization application is being run should provide an extension
+to this extension-point.
+The initializers are run when the org.eclipse.core.runtime.initializer application
+is being run. The initializers are run in any order.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="initializer"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="initializer">
+ <complexType>
+ <sequence>
+ <element ref="initialize"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="initialize">
+ <complexType>
+ <sequence>
+ <element ref="initialize"/>
+ </sequence>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.core.runtime.IPlatformRunnable"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 3.1
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ Following is an example of initializer declaration:
+<p>
+<pre>
+ <extension id="myInitializer" point="org.eclipse.core.runtime.initializers">
+ <initializer>
+ <initialize class="myInitializer.Doit"/>
+ </initializer>
+ </extension>
+</pre>
+</p>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The value of the class attribute must represent an
+implementor of
+<samp>org.eclipse.core.runtime.IPlatformRunnable</samp>.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2005 IBM Corporation and others.<br>
+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
+<a
+href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ </documentation>
+ </annotation>
+
+</schema>
Index: source-tree/plugins/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/FileInitializer.java
===================================================================
RCS file: src/org/eclipse/core/internal/runtime/FileInitializer.java
diff -N src/org/eclipse/core/internal/runtime/FileInitializer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ source-tree/plugins/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/FileInitializer.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,153 @@
+package org.eclipse.core.internal.runtime;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.LinkedList;
+
+import org.eclipse.core.runtime.IPlatformRunnable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+import org.osgi.framework.Bundle;
+
+/**
+ * <p>
+ * This application extracts files to their "localURL". The file patterns that you
+ * want to extract should be specified in a file with one pattern per line. This
+ * application should be run through the generic initializer mechanism and not
+ * run directly.
+ * </p>
+ *
+ * <p>
+ * To run this application, do something like:
+ * </p>
+ *
+ * <p>
+ * <code>
+ * java -cp startup.jar org.eclipse.core.launcher.Main -application org.eclipse.core.runtime.initializer -fileInitializer <fileWithFilePatternsToExtract>
+ * </code>
+ * </p>
+ *
+ * <p>
+ * <ul>
+ * <li>
+ * Note: Only the files that are extracted will be printed to the console. If you
+ * want to debug things, use the -consolelog option in
+ * org.eclipse.core.launcher.Main
+ * </li>
+ * </ul>
+ * </p>
+ *
+ * @see Initializer
+ * @see Platform#asLocalURL(URL)
+ * @since 3.1
+ */
+public class FileInitializer implements IPlatformRunnable {
+
+ private final String SWT_BUNDLE_NAME = "org.eclipse.swt"; //$NON-NLS-1$
+
+ public Object run(Object args) throws Exception {
+ ArrayList fileNamePatterns = getFileNamePatterns((String[]) args);
+
+ // don't do anything if the arrayList is empty
+ if (fileNamePatterns == null || fileNamePatterns.size() < 1) {
+ return IPlatformRunnable.EXIT_OK;
+ }
+
+ Bundle[] installedBundles = InternalPlatform.getDefault().getBundleContext().getBundles();
+ LinkedList extractedFiles = new LinkedList();
+
+ for (int i = 0; i < installedBundles.length; i++) {
+ for (int j = 0; j < fileNamePatterns.size(); j++) {
+
+ Enumeration e = installedBundles[i].findEntries("/", (String) fileNamePatterns.get(j), true); //$NON-NLS-1$
+ String bundleName = installedBundles[i].getSymbolicName();
+
+ while(e != null && e.hasMoreElements()) {
+ URL fileURL = (URL) e.nextElement();
+ String filePath = fileURL.getPath();
+
+
+ if (bundleName.startsWith(SWT_BUNDLE_NAME)) {
+ // special case for swt
+ if (!bundleName.equals(SWT_BUNDLE_NAME + '.' + Platform.getWS() + '.' + Platform.getOS() + '.' + Platform.getOSArch()))
+ continue;
+ } else {
+ // everything but swt plugins
+ String[] path = filePath.split(File.separator);
+ // check to see if the file is should be extracted to the current os/arch
+ if (path.length == 4 && path[0].equals("os") && !(path[1].equals(Platform.getOS()) && path[2].equals(Platform.getOSArch()))) { //$NON-NLS-1$
+ continue;
+ }
+ // check to see if the file is should be extracted to the current ws
+ if (path.length == 3 && path[0].equals("ws") && !path[1].equals(Platform.getWS())) { //$NON-NLS-1$
+ continue;
+ }
+ }
+
+ // the call to Platform.asLocalURL(URL) does the actual extraction
+ String localURL = Platform.asLocalURL(fileURL).getPath();
+
+ // only print the path if it hasn't been printed yet
+ int index = Collections.binarySearch(extractedFiles, localURL);
+ if (index < 0) {
+ extractedFiles.add(-(index + 1), localURL);
+ System.out.println("FileInitializer: " + localURL); //$NON-NLS-1$
+ }
+ }
+ } // end for
+ } // end for
+
+ return IPlatformRunnable.EXIT_OK;
+ }
+
+ private final String ARG_FILE = "-fileInitializer"; //$NON-NLS-1$
+
+ private ArrayList getFileNamePatterns(String[] argsArray) {
+
+ for (int i = 0; i < argsArray.length; i++) {
+ if (argsArray[i].equalsIgnoreCase(ARG_FILE)) {
+
+ // the "file patterns" file was not specified
+ if (argsArray.length < i + 2) {
+ String msg = NLS.bind(Messages.fileInitializer_missingFileName, this.getClass().getName());
+ IStatus status = new Status(IStatus.ERROR, Platform.PI_RUNTIME, Platform.PLUGIN_ERROR, msg, null);
+ InternalPlatform.getDefault().log(status);
+ return null;
+ }
+
+ ArrayList fileList = new ArrayList();
+ try {
+ BufferedReader in = new BufferedReader(new FileReader(argsArray[i + 1]));
+ String line;
+ while ((line = in.readLine()) != null) {
+ fileList.add(line);
+ }
+ in.close();
+ } catch (FileNotFoundException e) {
+ String msg = NLS.bind(Messages.fileInitializer_fileNotFound, this.getClass().getName(), argsArray[i + 1]);
+ IStatus status = new Status(IStatus.ERROR, Platform.PI_RUNTIME, Platform.PLUGIN_ERROR, msg, null);
+ InternalPlatform.getDefault().log(status);
+ return null;
+ } catch (IOException e) {
+ String msg = NLS.bind(Messages.fileInitializer_IOError, this.getClass().getName(), argsArray[i + 1]);
+ IStatus status = new Status(IStatus.ERROR, Platform.PI_RUNTIME, Platform.PLUGIN_ERROR, msg, e);
+ InternalPlatform.getDefault().log(status);
+ return null;
+ }
+ return fileList;
+ }
+ }
+
+ // ARG_FILE wasn't found
+ return null;
+ }
+}
Index: source-tree/plugins/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Initializer.java
===================================================================
RCS file: src/org/eclipse/core/internal/runtime/Initializer.java
diff -N src/org/eclipse/core/internal/runtime/Initializer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ source-tree/plugins/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/Initializer.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,49 @@
+/*******************************************************************************
+* Copyright (c) 2005 Red Hat Incoporated 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 implementation
+*******************************************************************************/
+package org.eclipse.core.internal.runtime;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPlatformRunnable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+
+public class Initializer implements IPlatformRunnable {
+
+ public Object run(Object args) throws Exception {
+ IExtensionPoint xpt = Platform.getExtensionRegistry().getExtensionPoint(Platform.PI_RUNTIME, Platform.PT_INITIALIZERS);
+ if (xpt == null)
+ return IPlatformRunnable.EXIT_OK;
+
+ IExtension[] exts = xpt.getExtensions();
+ for (int i = 0; i < exts.length; i++) {
+ IConfigurationElement[] configs = exts[i].getConfigurationElements();
+ IPlatformRunnable initializer = null;
+ if (configs.length != 0) {
+ try {
+ initializer = (IPlatformRunnable) configs[0].createExecutableExtension("initialize"); //$NON-NLS-1$
+ initializer.run(args);
+ } catch(CoreException e) {
+ String msg = NLS.bind(Messages.initializer_error, exts[i].getExtensionPointUniqueIdentifier());
+ IStatus status = new Status(IStatus.ERROR, Platform.PI_RUNTIME, Platform.PLUGIN_ERROR, msg, e);
+ InternalPlatform.getDefault().log(status);
+ return null;
+ }
+ }
+ }
+ return IPlatformRunnable.EXIT_OK;
+ }
+
+}
|