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 2878 Details for
Bug 24414
[runtime] Plug-in registry performance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch for core.runtime
org.eclipse.core.runtime-24414-diff.txt (text/plain), 36.17 KB, created by
Rafael Chaves
on 2003-01-02 12:24:05 EST
(
hide
)
Description:
patch for core.runtime
Filename:
MIME Type:
Creator:
Rafael Chaves
Created:
2003-01-02 12:24:05 EST
Size:
36.17 KB
patch
obsolete
>Index: .classpath >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.runtime/.classpath,v >retrieving revision 1.6 >diff -u -r1.6 .classpath >--- .classpath 28 Mar 2002 20:07:09 -0000 1.6 >+++ .classpath 2 Jan 2003 17:16:04 -0000 >@@ -2,7 +2,7 @@ > <classpath> > <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/> > <classpathentry kind="src" path="/org.eclipse.core.boot"/> >- <classpathentry kind="src" path="src"/> > <classpathentry kind="src" path="/org.apache.xerces"/> >+ <classpathentry kind="src" path="src"/> > <classpathentry kind="output" path="bin"/> > </classpath> >Index: build.xml >=================================================================== >RCS file: build.xml >diff -N build.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ build.xml 2 Jan 2003 17:16:04 -0000 >@@ -0,0 +1,121 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<project name="org.eclipse.core.runtime" default="build.jars" basedir="."> >+ >+ <property name="bootclasspath" value=""/> >+ <property name="ws" value="win32"/> >+ <property name="os" value="win32"/> >+ <property name="arch" value="x86"/> >+ >+ <target name="init" depends="properties"> >+ <property name="plugin" value="org.eclipse.core.runtime"/> >+ <property name="version.suffix" value="_2.1.0"/> >+ <property name="full.name" value="${plugin}${version.suffix}"/> >+ <property name="temp.folder" value="${basedir}/temp.folder"/> >+ <property name="plugin.destination" value="${basedir}"/> >+ <property name="build.result.folder" value="${basedir}"/> >+ </target> >+ >+ <target name="properties" if="eclipse.running"> >+ <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> >+ </target> >+ >+ <target name="build.update.jar" depends="init"> >+ <delete dir="${temp.folder}"/> >+ <mkdir dir="${temp.folder}"/> >+ <antcall target="build.jars"/> >+ <antcall target="gather.bin.parts"> >+ <param name="destination.temp.folder" value="${temp.folder}/"/> >+ </antcall> >+ <zip zipfile="${plugin.destination}/${full.name}.jar" basedir="${temp.folder}/${full.name}" filesonly="false"/> >+ <delete dir="${temp.folder}"/> >+ </target> >+ >+ <target name="gather.bin.parts" depends="init" if="destination.temp.folder"> >+ <mkdir dir="${destination.temp.folder}/${full.name}"/> >+ <copy file="${build.result.folder}/runtime.jar" todir="${destination.temp.folder}/${full.name}"/> >+ <copy todir="${destination.temp.folder}/${full.name}"> >+ <fileset dir="${basedir}" includes=".options,plugin.xml,*.jar,plugin.properties,about.html"/> >+ </copy> >+ </target> >+ >+ <target name="runtime.jar" depends="init" unless="runtime.jar"> >+ <property name="destdir" value="${temp.folder}/runtime.jar.bin"/> >+ <delete dir="${temp.folder}/runtime.jar.bin"/> >+ <mkdir dir="${temp.folder}/runtime.jar.bin"/> >+ <!-- compile the source code --> >+ <javac destdir="${temp.folder}/runtime.jar.bin" failonerror="false" verbose="true" debug="on" includeAntRuntime="no" bootclasspath="${bootclasspath}" classpath="runtime.jar;bin;../../../../../I20021216/eclipse/plugins/org.apache.xerces_4.0.7/xmlParserAPIs.jar;../../../../../I20021216/eclipse/plugins/org.apache.xerces_4.0.7/bin;../../../../../I20021216/eclipse/plugins/org.apache.xerces_4.0.7/xercesImpl.jar;../org.eclipse.core.boot/boot.jar;../org.eclipse.core.boot/bin"> >+ <src path="src/"/> >+ </javac> >+ <!-- copy necessary resources --> >+ <copy todir="${temp.folder}/runtime.jar.bin"> >+ <fileset dir="src/" excludes="**/*.java"/> >+ </copy> >+ <mkdir dir="${build.result.folder}"/> >+ <jar jarfile="${build.result.folder}/runtime.jar" basedir="${temp.folder}/runtime.jar.bin"/> >+ <delete dir="${temp.folder}/runtime.jar.bin"/> >+ </target> >+ >+ <target name="runtimesrc.zip" depends="init" unless="runtimesrc.zip"> >+ <mkdir dir="${build.result.folder}"/> >+ <zip zipfile="${build.result.folder}/runtimesrc.zip" filesonly="false"> >+ <fileset dir="src/" includes="**/*.java"/> >+ </zip> >+ </target> >+ >+ <target name="build.jars" depends="init"> >+ <available property="runtime.jar" file="${build.result.folder}/runtime.jar"/> >+ <antcall target="runtime.jar"/> >+ </target> >+ >+ <target name="build.sources" depends="init"> >+ <available property="runtimesrc.zip" file="${build.result.folder}/runtimesrc.zip"/> >+ <antcall target="runtimesrc.zip"/> >+ </target> >+ >+ <target name="build.zips" depends="init"> >+ </target> >+ >+ <target name="gather.sources" depends="init" if="destination.temp.folder"> >+ <mkdir dir="${destination.temp.folder}/${full.name}"/> >+ <copy file="${build.result.folder}/runtimesrc.zip" todir="${destination.temp.folder}/${full.name}"/> >+ <copy todir="${destination.temp.folder}/${full.name}"> >+ <fileset dir="${basedir}" includes="about.html"/> >+ </copy> >+ </target> >+ >+ <target name="gather.logs" depends="init" if="destination.temp.folder"> >+ <mkdir dir="${destination.temp.folder}/${full.name}"/> >+ <copy file="${temp.folder}/runtime.jar.bin.log" todir="${destination.temp.folder}/${full.name}"/> >+ </target> >+ >+ <target name="clean" depends="init"> >+ <delete file="${build.result.folder}/runtime.jar"/> >+ <delete file="${build.result.folder}/runtimesrc.zip"/> >+ <delete file="${plugin.destination}/${full.name}.jar"/> >+ <delete file="${plugin.destination}/${full.name}.zip"/> >+ <delete dir="${temp.folder}"/> >+ </target> >+ >+ <target name="refresh" depends="init" if="eclipse.running"> >+ <eclipse.refreshLocal resource="${plugin}" depth="infinite"/> >+ </target> >+ >+ <target name="zip.plugin" depends="init"> >+ <delete dir="${temp.folder}"/> >+ <mkdir dir="${temp.folder}"/> >+ <antcall target="build.jars"/> >+ <antcall target="build.sources"/> >+ <antcall target="gather.bin.parts"> >+ <param name="destination.temp.folder" value="${temp.folder}/"/> >+ </antcall> >+ <antcall target="gather.sources"> >+ <param name="destination.temp.folder" value="${temp.folder}/"/> >+ </antcall> >+ <delete> >+ <fileset dir="${temp.folder}" includes="**/*.bin.log"/> >+ </delete> >+ <zip zipfile="${plugin.destination}/${full.name}.zip" basedir="${temp.folder}" filesonly="true"/> >+ <delete dir="${temp.folder}"/> >+ </target> >+ >+</project> >Index: runtime.jar >=================================================================== >RCS file: runtime.jar >diff -N runtime.jar >Binary files /dev/null and runtime.jar differ >Index: src/org/eclipse/core/internal/plugins/ExtensionModelLoader.java >=================================================================== >RCS file: src/org/eclipse/core/internal/plugins/ExtensionModelLoader.java >diff -N src/org/eclipse/core/internal/plugins/ExtensionModelLoader.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/plugins/ExtensionModelLoader.java 2 Jan 2003 17:16:04 -0000 >@@ -0,0 +1,115 @@ >+/********************************************************************* >+ * Copyright (c) 2003 IBM Corporation and others. All rights reserved. >+ * This program and the accompanying materials are made available under >+ * the terms of the Common Public License v1.0 which accompanies this >+ * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial implementation >+ *********************************************************************/ >+package org.eclipse.core.internal.plugins; >+ >+import java.io.*; >+import java.util.*; >+ >+import org.eclipse.core.internal.plugins.RegistryCacheReader.InvalidRegistryCacheException; >+import org.eclipse.core.runtime.model.*; >+ >+/** >+ * Implements the plug-in model object lazy loading mechanism for extensions. >+ */ >+public class ExtensionModelLoader implements IPluginModelLoader { >+ >+ /** >+ * A map containing all extension model objects being currently managed by >+ * this loader. >+ */ >+ private Map managedExtensions; >+ >+ /** The location of the registry cache file. */ >+ private File cacheLocation; >+ >+ /** >+ * The plug-in model object factory to be used when loading the >+ * configuration elements of an extension. >+ */ >+ private Factory factory; >+ >+ private boolean debug; >+ >+ /** >+ * A cross-reference list is mantained in order to avoid redundant >+ * copies of objects that are multiply referred in the plug-in registry >+ * graph. This cross reference list is shared by the registry readers. >+ */ >+ private List crossReferences; >+ >+ private RegistryCacheReader reader; >+ >+ public ExtensionModelLoader(Factory factory, File location, List crossReferences, boolean debug) { >+ this.cacheLocation = location; >+ this.factory = factory; >+ this.debug = debug; >+ this.managedExtensions = new HashMap(); >+ this.crossReferences = crossReferences; >+ } >+ /** >+ * Ensures the sub-elements of the provided extension model object are >+ * properly loaded. >+ * >+ * @see org.eclipse.core.runtime.model.IPluginModelLoader#ensureLoaded >+ */ >+ public void ensureLoaded(ILazilyLoadable modelObject) { >+ Integer offset = (Integer) managedExtensions.remove(modelObject); >+ // if the object was not in the map, its loading is not managed by this loader >+ if (offset == null) { >+ modelObject.setLoader(null); >+ return; >+ } >+ ExtensionModel extensionModel = (ExtensionModel) modelObject; >+ // tries to effectively load the extension's sub-elements >+ loadExtension(extensionModel, offset.intValue()); >+ } >+ /** >+ * Register the extension model as a partially loaded object. >+ * >+ * @param extension a partially loaded extension model object >+ * @param offset the position in the registry cache file from where to read >+ * the remaining state >+ */ >+ void manageExtension(ExtensionModel extension, int offset) { >+ managedExtensions.put(extension, new Integer(offset)); >+ extension.setLoader(this); >+ } >+ /** >+ * Loads the extension model's sub-elements. >+ */ >+ private void loadExtension(ExtensionModel extensionModel, int offset) { >+ DataInputStream input = null; >+ try { >+ input = new DataInputStream(new FileInputStream(cacheLocation)); >+ input.skipBytes(offset); >+ ConfigurationElementModel[] subElements = getReader().readSubElements(input, extensionModel, debug); >+ extensionModel.setSubElements(subElements); >+ extensionModel.setLoader(null); >+ // to force the just loaded sub-elements to be read-only as their parent >+ if (extensionModel.isReadOnly()) >+ extensionModel.markReadOnly(); >+ } catch (IOException e) { >+ //TODO: maybe we should log this exception >+ } catch (InvalidRegistryCacheException e) { >+ // it has already been checked by RegistryCacheLazyReader - shouldn't happen >+ } finally { >+ try { >+ if (input != null) >+ input.close(); >+ } catch (IOException ioe) { >+ } >+ } >+ } >+ private RegistryCacheReader getReader() { >+ if (this.reader == null) >+ this.reader = new RegistryCacheReader(this.factory, crossReferences); >+ return reader; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/core/internal/plugins/RegistryCacheLazyReader.java >=================================================================== >RCS file: src/org/eclipse/core/internal/plugins/RegistryCacheLazyReader.java >diff -N src/org/eclipse/core/internal/plugins/RegistryCacheLazyReader.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/internal/plugins/RegistryCacheLazyReader.java 2 Jan 2003 17:16:04 -0000 >@@ -0,0 +1,119 @@ >+/********************************************************************** >+ * Copyright (c) 2003 IBM Corporation and others. All rights reserved. >+ * This program and the accompanying materials are made available under >+ * the terms of the Common Public License v1.0 which accompanies this >+ * distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.core.internal.plugins; >+ >+import java.io.*; >+ >+import org.eclipse.core.runtime.model.*; >+ >+public class RegistryCacheLazyReader extends RegistryCacheReader { >+ private ExtensionModelLoader modelLoader; >+ >+ public RegistryCacheLazyReader(Factory factory, File cacheFileLocation, boolean debugEnabled) { >+ super(factory); >+ this.modelLoader = new ExtensionModelLoader(factory, cacheFileLocation, objectTable, debugEnabled); >+ } >+ public void checkConfigurationElement(DataInput in, boolean debugFlag) throws InvalidRegistryCacheException, IOException { >+ // add a place holder to keep higher indexes valid >+ addToObjectTable(new Object()); >+ if (in.readByte() != CONFIGURATION_ELEMENT_LABEL) >+ throw new InvalidRegistryCacheException(); >+ byte inByte = 0; >+ boolean done = false; >+ while (!done) { >+ try { >+ inByte = in.readByte(); >+ } catch (EOFException eofe) { >+ done = true; >+ break; >+ } >+ switch (inByte) { >+ case READONLY_LABEL : >+ in.readBoolean(); >+ break; >+ case START_LINE : >+ in.readInt(); >+ break; >+ case NAME_LABEL : >+ in.readUTF(); >+ break; >+ case VALUE_LABEL : >+ in.readUTF(); >+ break; >+ case PROPERTIES_LENGTH_LABEL : >+ int propertiesLength = in.readInt(); >+ for (int i = 0; i < propertiesLength && !done; i++) >+ checkConfigurationProperty(in, debugFlag); >+ break; >+ case SUBELEMENTS_LENGTH_LABEL : >+ int subElementsLength = in.readInt(); >+ for (int i = 0; i < subElementsLength && !done; i++) >+ checkConfigurationElement(in, debugFlag); >+ break; >+ case CONFIGURATION_ELEMENT_PARENT_LABEL : >+ in.readInt(); >+ break; >+ case CONFIGURATION_ELEMENT_END_LABEL : >+ done = true; >+ break; >+ default : >+ throw new InvalidRegistryCacheException(); >+ } >+ } >+ } >+ public void checkConfigurationProperty(DataInput in, boolean debugFlag) throws InvalidRegistryCacheException, IOException { >+ byte inByte = 0; >+ boolean done = false; >+ while (!done) { >+ try { >+ inByte = in.readByte(); >+ } catch (EOFException eofe) { >+ done = true; >+ break; >+ } >+ switch (inByte) { >+ case CONFIGURATION_PROPERTY_LABEL : >+ break; >+ case READONLY_LABEL : >+ in.readBoolean(); >+ break; >+ case START_LINE : >+ in.readInt(); >+ break; >+ case NAME_LABEL : >+ in.readUTF(); >+ break; >+ case VALUE_LABEL : >+ in.readUTF(); >+ break; >+ case CONFIGURATION_PROPERTY_END_LABEL : >+ done = true; >+ break; >+ default : >+ throw new InvalidRegistryCacheException(); >+ } >+ } >+ } >+ public ConfigurationElementModel[] readSubElements(DataInput in, ExtensionModel parent, boolean debugFlag) throws IOException, InvalidRegistryCacheException { >+ int offset = in.readInt(); >+ >+ modelLoader.manageExtension(parent, offset); >+ >+ byte nextLabel = in.readByte(); >+ if (nextLabel != SUBELEMENTS_LENGTH_LABEL) >+ throw new InvalidRegistryCacheException(); >+ int subElementsLength = in.readInt(); >+ for (int i = 0; i < subElementsLength; i++) { >+ checkConfigurationElement(in, debugFlag); >+ } >+ return null; >+ } >+} >Index: src/org/eclipse/core/internal/plugins/RegistryCacheReader.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.runtime/src/org/eclipse/core/internal/plugins/RegistryCacheReader.java,v >retrieving revision 1.37 >diff -u -r1.37 RegistryCacheReader.java >--- src/org/eclipse/core/internal/plugins/RegistryCacheReader.java 10 Dec 2002 04:04:13 -0000 1.37 >+++ src/org/eclipse/core/internal/plugins/RegistryCacheReader.java 2 Jan 2003 17:16:04 -0000 >@@ -1,4 +1,4 @@ >-/********************************************************************** >+ /********************************************************************** > * Copyright (c) 2000,2002 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Common Public License v1.0 >@@ -14,6 +14,8 @@ > import java.io.*; > import java.net.URL; > import java.util.ArrayList; >+import java.util.List; >+ > import org.eclipse.core.boot.BootLoader; > import org.eclipse.core.internal.runtime.InternalPlatform; > import org.eclipse.core.internal.runtime.Policy; >@@ -27,11 +29,11 @@ > // like a plugin descriptor, extension, extension point, etc. The integer > // index value will be used in the cache to allow cross-references in the > // cached registry. >- ArrayList objectTable = null; >+ protected List objectTable = null; > > public MultiStatus cacheReadProblems = null; > >- public static final byte REGISTRY_CACHE_VERSION = 10; >+ public static final byte REGISTRY_CACHE_VERSION = 11; > > public static final byte NONLABEL = 0; > >@@ -102,9 +104,10 @@ > public static final byte TYPE_LABEL = 54; > public static final byte VALUE_LABEL = 43; > public static final byte VERSION_LABEL = 44; >+ public static final byte SUBELEMENTS_LABEL = 62; > > // So it's easier to add a new label ... >- public static final byte LARGEST_LABEL = 61; >+ public static final byte LARGEST_LABEL = 62; > > // String constants for those byte values in the cache that > // do not translate directly to strings found in manifest xml >@@ -139,20 +142,20 @@ > private static final String REQUIRES_INDEX = "<index of prerequisite>"; //$NON-NLS-1$ > private static final String UNKNOWN = "<unknown label>"; //$NON-NLS-1$ > >-public RegistryCacheReader(Factory factory) { >+public RegistryCacheReader(Factory factory, List crossReferenceList) { > super(); > cacheFactory = factory; >- objectTable = null; >+ this.objectTable = crossReferenceList; > } >-private int addToObjectTable(Object object) { >- if (objectTable == null) { >- objectTable = new ArrayList(); >- } >+public RegistryCacheReader(Factory factory) { >+ this(factory, new ArrayList()); >+} >+protected int addToObjectTable(Object object) { > objectTable.add(object); > // return the index of the object just added (i.e. size - 1) > return (objectTable.size() - 1); > } >-private void debug(String msg) { >+protected void debug(String msg) { > System.out.println("RegistryCacheReader: " + msg); //$NON-NLS-1$ > } > public static String decipherLabel(byte labelValue) { >@@ -342,7 +345,7 @@ > retValue += "\""; //$NON-NLS-1$ > return retValue; > } >-public boolean interpretHeaderInformation(DataInputStream in) { >+public boolean interpretHeaderInformation(DataInput in) { > try { > if (in.readInt() != REGISTRY_CACHE_VERSION) > return false; >@@ -368,11 +371,9 @@ > return false; > } > } >-public ConfigurationElementModel readConfigurationElement(DataInputStream in, boolean debugFlag) { >+public ConfigurationElementModel readConfigurationElement(DataInput in, Object parent, boolean debugFlag) { > ConfigurationElementModel configurationElement = cacheFactory.createConfigurationElement(); >- // Use this flag to determine if the read-only flag should be set. You >- // can't set it now or you won't be able to add anything more to this >- // configuration element. >+ configurationElement.setParent(parent); > addToObjectTable(configurationElement); > try { > byte inByte = 0; >@@ -427,7 +428,7 @@ > byte subInByte = in.readByte(); > switch (subInByte) { > case CONFIGURATION_ELEMENT_LABEL : >- subElements[i] = readConfigurationElement(in, debugFlag); >+ subElements[i] = readConfigurationElement(in, configurationElement, debugFlag); > if (subElements[i] == null) { > if (debugFlag) { > String name = configurationElement.getName(); >@@ -440,8 +441,8 @@ > } > break; > case CONFIGURATION_ELEMENT_INDEX_LABEL : >- subElements[i] = (ConfigurationElementModel) objectTable.get(in.readInt()); >- break; >+ //TODO: remove this sanity check once it proves to never happen >+ throw new IllegalStateException("Found cross-reference to configuration element"); //$NON-NLS-1$ > default: > // We found something we weren't expecting > if (debugFlag) { >@@ -460,8 +461,8 @@ > subElements = null; > break; > case CONFIGURATION_ELEMENT_PARENT_LABEL : >- // We know the parent already exists, just grab it. >- configurationElement.setParent(objectTable.get(in.readInt())); >+ //TODO: get rid of cross-references to parents (they are now explicitly passed to children) >+ in.readInt(); > break; > case CONFIGURATION_ELEMENT_END_LABEL : > done = true; >@@ -485,11 +486,8 @@ > } > return configurationElement; > } >-public ConfigurationPropertyModel readConfigurationProperty(DataInputStream in, boolean debugFlag) { >+public ConfigurationPropertyModel readConfigurationProperty(DataInput in, boolean debugFlag) { > ConfigurationPropertyModel configurationProperty = cacheFactory.createConfigurationProperty(); >- // Use this flag to determine if the read-only flag should be set. You >- // can't set it now or you won't be able to add anything more to this >- // configuration property. > try { > byte inByte = 0; > boolean done = false; >@@ -537,12 +535,9 @@ > } > return configurationProperty; > } >-public ExtensionModel readExtension(DataInputStream in, boolean debugFlag) { >+public ExtensionModel readExtension(DataInput in, boolean debugFlag) throws InvalidRegistryCacheException { > ExtensionModel extension = cacheFactory.createExtension(); > addToObjectTable(extension); >- // Use this flag to determine if the read-only flag should be set. You >- // can't set it now or you won't be able to add anything more to this >- // extension. > try { > byte inByte = 0; > boolean done = false; >@@ -569,46 +564,9 @@ > case EXTENSION_EXT_POINT_NAME_LABEL : > extension.setExtensionPoint(in.readUTF()); > break; >- case SUBELEMENTS_LENGTH_LABEL : >- int subElementsLength = in.readInt(); >- ConfigurationElementModel[] subElements = new ConfigurationElementModel[subElementsLength]; >- for (int i = 0; i < subElementsLength && !done; i++) { >- // Do we have a configuration element or an index into >- // objectTable? >- byte subInByte = in.readByte(); >- switch (subInByte) { >- case CONFIGURATION_ELEMENT_LABEL : >- subElements[i] = readConfigurationElement(in, debugFlag); >- if (subElements[i] == null) { >- if (debugFlag) { >- String name = extension.getName(); >- if (name == null) >- name = new String("<unknown name>"); //$NON-NLS-1$ >- debug ("Unable to read subelement #" + i + " for extension " + name); //$NON-NLS-1$ //$NON-NLS-2$ >- } >- extension = null; >- done = true; >- } >- break; >- case CONFIGURATION_ELEMENT_INDEX_LABEL : >- subElements[i] = (ConfigurationElementModel) objectTable.get(in.readInt()); >- break; >- default: >- // We got something unexpected >- if (debugFlag) { >- String name = extension.getName(); >- if (name == null) >- name = new String("<unknown name>"); //$NON-NLS-1$ >- debug ("Unexpected byte code " + decipherLabel(subInByte) + " reading subelements for extension " + name); //$NON-NLS-1$ //$NON-NLS-2$ >- } >- extension = null; >- done = true; >- break; >- } >- } >- if (extension != null) >- extension.setSubElements(subElements); >- subElements = null; >+ case SUBELEMENTS_LABEL : >+ ConfigurationElementModel[] subElements = readSubElements(in, extension, debugFlag); >+ extension.setSubElements(subElements); > break; > case EXTENSION_PARENT_LABEL : > // Either there is a plugin or there is an index into the >@@ -686,7 +644,8 @@ > } > return extension; > } >-public ExtensionPointModel readExtensionPoint(DataInputStream in, boolean debugFlag) { >+ >+public ExtensionPointModel readExtensionPoint(DataInput in, boolean debugFlag) throws InvalidRegistryCacheException { > ExtensionPointModel extPoint = cacheFactory.createExtensionPoint(); > addToObjectTable(extPoint); > >@@ -788,7 +747,7 @@ > } > return extPoint; > } >-public LibraryModel readLibrary(DataInputStream in, boolean debugFlag) { >+public LibraryModel readLibrary(DataInput in, boolean debugFlag) { > LibraryModel library = cacheFactory.createLibrary(); > addToObjectTable(library); > // Use this flag to determine if the read-only flag should be set. You >@@ -885,7 +844,7 @@ > } > return library; > } >-public PluginDescriptorModel readPluginDescriptor(DataInputStream in, boolean debugFlag) { >+public PluginDescriptorModel readPluginDescriptor(DataInput in, boolean debugFlag) throws InvalidRegistryCacheException { > PluginDescriptorModel plugin = cacheFactory.createPluginDescriptor(); > addToObjectTable(plugin); > // Use this flag to determine if the read-only flag should be set. You >@@ -1178,7 +1137,7 @@ > } > return plugin; > } >-public PluginFragmentModel readPluginFragment(DataInputStream in, boolean debugFlag) { >+public PluginFragmentModel readPluginFragment(DataInput in, boolean debugFlag) throws InvalidRegistryCacheException { > PluginFragmentModel fragment = cacheFactory.createPluginFragment(); > addToObjectTable(fragment); > // Use this flag to determine if the read-only flag should be set. You >@@ -1429,7 +1388,7 @@ > } > return fragment; > } >-public PluginPrerequisiteModel readPluginPrerequisite(DataInputStream in, boolean debugFlag) { >+public PluginPrerequisiteModel readPluginPrerequisite(DataInput in, boolean debugFlag) { > PluginPrerequisiteModel requires = cacheFactory.createPluginPrerequisite(); > addToObjectTable(requires); > // Use this flag to determine if the read-only flag should be set. You >@@ -1496,7 +1455,7 @@ > } > return requires; > } >-public PluginRegistryModel readPluginRegistry(DataInputStream in, URL[] pluginPath, boolean debugFlag) { >+public PluginRegistryModel readPluginRegistry(DataInput in, URL[] pluginPath, boolean debugFlag) { > if (cacheReadProblems == null) { > cacheReadProblems = new MultiStatus(Platform.PI_RUNTIME, Platform.PARSE_PROBLEM, Policy.bind("meta.registryCacheReadProblems"), null); //$NON-NLS-1$ > } >@@ -1583,6 +1542,9 @@ > break; > } > } >+ } catch (InvalidRegistryCacheException irce) { >+ cacheReadProblems.add(new Status(IStatus.WARNING, Platform.PI_RUNTIME, Platform.PARSE_PROBLEM, Policy.bind ("meta.registryCacheReadProblems", decipherLabel(REGISTRY_LABEL)), irce)); //$NON-NLS-1$ >+ return null; > } catch (IOException ioe) { > cacheReadProblems.add(new Status(IStatus.WARNING, Platform.PI_RUNTIME, Platform.PARSE_PROBLEM, Policy.bind ("meta.regCacheIOException", decipherLabel(REGISTRY_LABEL)), ioe)); //$NON-NLS-1$ > return null; >@@ -1614,5 +1576,40 @@ > // XXX: attempt to read URL and see if we got html dir page > } > return list == null ? new String[0] : list; >+} >+/** >+ * Loads the configuration elements for an extension. >+ */ >+ConfigurationElementModel[] readSubElements(DataInput in, ExtensionModel parent, boolean debugFlag) throws IOException, InvalidRegistryCacheException { >+ >+ // the first field is extension sub-elements data offset >+ in.readInt(); >+ >+ byte nextLabel = in.readByte(); >+ if (nextLabel != SUBELEMENTS_LENGTH_LABEL) >+ throw new InvalidRegistryCacheException(); >+ int subElementsLength = in.readInt(); >+ ConfigurationElementModel[] subElements = new ConfigurationElementModel[subElementsLength]; >+ for (int i = 0; i < subElementsLength; i++) { >+ nextLabel = in.readByte(); >+ if (nextLabel != CONFIGURATION_ELEMENT_LABEL) >+ throw new InvalidRegistryCacheException(); >+ subElements[i] = readConfigurationElement(in, parent, debugFlag); >+ if (subElements[i] == null) { >+ String message = null; >+ if (debugFlag) >+ message = "Unable to read subelement #" + i + " for extension " + parent.getName(); //$NON-NLS-1$ //$NON-NLS-2$ >+ throw new InvalidRegistryCacheException(message); >+ } >+ } >+ return subElements; >+} >+public class InvalidRegistryCacheException extends Exception { >+ public InvalidRegistryCacheException() { >+ super(); >+ } >+ public InvalidRegistryCacheException(String string) { >+ super(string); >+ } > } > } >Index: src/org/eclipse/core/internal/plugins/RegistryCacheWriter.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.runtime/src/org/eclipse/core/internal/plugins/RegistryCacheWriter.java,v >retrieving revision 1.28 >diff -u -r1.28 RegistryCacheWriter.java >--- src/org/eclipse/core/internal/plugins/RegistryCacheWriter.java 10 Dec 2002 04:04:13 -0000 1.28 >+++ src/org/eclipse/core/internal/plugins/RegistryCacheWriter.java 2 Jan 2003 17:16:04 -0000 >@@ -209,6 +209,9 @@ > > ConfigurationElementModel[] subElements = extension.getSubElements(); > if (subElements != null) { >+ writeLabel(RegistryCacheReader.SUBELEMENTS_LABEL, out); >+ // write the offset for sub-elements data >+ out.writeInt(out.size()); > writeLabel(RegistryCacheReader.SUBELEMENTS_LENGTH_LABEL, out); > out.writeInt(subElements.length); > for (int i = 0; i < subElements.length; i++) { >Index: src/org/eclipse/core/internal/runtime/InternalPlatform.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java,v >retrieving revision 1.60 >diff -u -r1.60 InternalPlatform.java >--- src/org/eclipse/core/internal/runtime/InternalPlatform.java 16 Dec 2002 02:30:39 -0000 1.60 >+++ src/org/eclipse/core/internal/runtime/InternalPlatform.java 2 Jan 2003 17:16:04 -0000 >@@ -664,8 +664,8 @@ > try { > input = new DataInputStream(new BufferedInputStream(new FileInputStream(path.toFile()))); > try { >- long start = System.currentTimeMillis(); >- RegistryCacheReader cacheReader = new RegistryCacheReader(factory); >+ long start = System.currentTimeMillis(); >+ RegistryCacheReader cacheReader = new RegistryCacheLazyReader(factory, cacheFile, debugEnabled); > registry = (PluginRegistry)cacheReader.readPluginRegistry(input, augmentedPluginPath, DEBUG && DEBUG_PLUGINS); > if (DEBUG) > System.out.println("Read registry cache: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ >Index: src/org/eclipse/core/runtime/model/ExtensionModel.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.runtime/src/org/eclipse/core/runtime/model/ExtensionModel.java,v >retrieving revision 1.5 >diff -u -r1.5 ExtensionModel.java >--- src/org/eclipse/core/runtime/model/ExtensionModel.java 17 May 2002 20:51:58 -0000 1.5 >+++ src/org/eclipse/core/runtime/model/ExtensionModel.java 2 Jan 2003 17:16:04 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2000, 2002 IBM Corporation and others. >+ * Copyright (c) 2000, 2003 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Common Public License v0.5 > * which accompanies this distribution, and is available at >@@ -12,12 +12,20 @@ > > /** > * An object which represents the user-defined extension in a >- * plug-in manifest. >+ * plug-in manifest. >+ * <p> >+ * Since 2.1, extension models support lazy initialization of their sub- >+ * elements by collaborating with a plug-in model loader. >+ * </p> > * <p> > * This class may be instantiated, or further subclassed. > * </p> >+ * >+ * @see IPluginModelLoader >+ * @see ILazilyLoadable > */ >-public class ExtensionModel extends PluginModelObject { >+ >+public class ExtensionModel extends PluginModelObject implements ILazilyLoadable { > > // DTD properties (included in plug-in manifest) > private String extensionPoint = null; >@@ -26,6 +34,8 @@ > > // transient properties (not included in plug-in manifest) > private PluginModel plugin = null; // declaring plugin >+ private IPluginModelLoader loader; >+ > /** > * Creates a new extension model in which all fields > * are <code>null</code>. >@@ -78,6 +88,8 @@ > * or <code>null</code> > */ > public ConfigurationElementModel[] getSubElements() { >+ if (loader != null) >+ loader.ensureLoaded(this); > return elements; > } > /** >@@ -148,7 +160,15 @@ > * May be <code>null</code>. > */ > public void setSubElements(ConfigurationElementModel[] value) { >- assertIsWriteable(); >+ // ignore read-only constraints if it has not been fully loaded yet >+ if (loader == null) >+ assertIsWriteable(); > elements = value; >+} >+/** >+ * @see ILazilyLoadable#setLoader(IPluginModelLoader) >+ */ >+public void setLoader(IPluginModelLoader loader) { >+ this.loader = loader; > } > } >Index: src/org/eclipse/core/runtime/model/ILazilyLoadable.java >=================================================================== >RCS file: src/org/eclipse/core/runtime/model/ILazilyLoadable.java >diff -N src/org/eclipse/core/runtime/model/ILazilyLoadable.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/runtime/model/ILazilyLoadable.java 2 Jan 2003 17:16:04 -0000 >@@ -0,0 +1,38 @@ >+/********************************************************************** >+ * Copyright (c) 2003 IBM Corporation and others. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Common Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.core.runtime.model; >+ >+/** >+ * A lazily loadable plug-in model object has its non-essential state loaded >+ * only when needed (if needed). >+ * >+ * This interface is intended to be implemented only by sub-classes of >+ * <code>PluginModelObject</code>. >+ * >+ * @see IPluginModelLoader >+ * >+ * @since 2.1 >+ */ >+public interface ILazilyLoadable { >+ /** >+ * Sets this lazily loadable plug-in model object's loader. >+ * <p> >+ * This method will be called tipically twice: first, after the object has >+ * been created and partially loaded, with a reference to an existing >+ * loader, and later again, having <code>null</code> as argument, to >+ * indicate the object has been fully loaded. >+ * </p> >+ * >+ * @param newLoader a reference to a plug-in model object loader, or >+ * <code>null</code>, indicating there is no loader associated to this >+ * object any more >+ */ >+ public void setLoader(IPluginModelLoader newLoader); >+} >Index: src/org/eclipse/core/runtime/model/IPluginModelLoader.java >=================================================================== >RCS file: src/org/eclipse/core/runtime/model/IPluginModelLoader.java >diff -N src/org/eclipse/core/runtime/model/IPluginModelLoader.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/runtime/model/IPluginModelLoader.java 2 Jan 2003 17:16:04 -0000 >@@ -0,0 +1,42 @@ >+/********************************************************************** >+ * Copyright (c) 2003 IBM Corporation and others. All rights reserved. This >+ * program and the accompanying materials are made available under the terms of >+ * the Common Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.core.runtime.model; >+/** >+ * A plug-in model loader implementation provides a lazy-loading mechanism for >+ * plug-in model objects. >+ * >+ * @since 2.1 >+ */ >+public interface IPluginModelLoader { >+ /** >+ * Ensures the provided model object is fully loaded. >+ * <p> >+ * In the case the model object has been successfully loaded, clears the >+ * reference to this loader by calling <code>setLoader(null)</code> on the >+ * model object. >+ * </p> >+ * <p> A lazily loadable plug-in model object that has an associated loader >+ * must be properly instrumented to call >+ * <code>IPluginModelLoader#ensureLoaded(this)</code> on its loader in >+ * order to ensure its lazily loadable state is available before trying to >+ * read it. >+ * </p> >+ * <p> >+ * This interface may be implemented by providers of plug-in registry >+ * loading mechanisms. >+ * </p> >+ * >+ * @see ILazilyLoadable >+ * >+ * @param modelObject the model object to be fully loaded >+ */ >+ public void ensureLoaded(ILazilyLoadable modelObject); >+}
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 24414
:
2462
|
2878
|
2879
|
2880
|
2927