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 35551 Details for
Bug 129940
Improve performance of split packages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Better patch
129940_org.eclipse.osgi2.patch (text/plain), 6.01 KB, created by
Thomas Watson
on 2006-03-01 12:54:47 EST
(
hide
)
Description:
Better patch
Filename:
MIME Type:
Creator:
Thomas Watson
Created:
2006-03-01 12:54:47 EST
Size:
6.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.osgi >Index: core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java,v >retrieving revision 1.38 >diff -u -r1.38 PackageAdminImpl.java >--- core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java 17 Jan 2006 21:06:41 -0000 1.38 >+++ core/framework/org/eclipse/osgi/framework/internal/core/PackageAdminImpl.java 1 Mar 2006 17:42:58 -0000 >@@ -15,6 +15,7 @@ > import java.security.AccessController; > import java.security.PrivilegedAction; > import java.util.ArrayList; >+import java.util.HashMap; > import org.eclipse.osgi.framework.adaptor.BundleClassLoader; > import org.eclipse.osgi.framework.adaptor.BundleData; > import org.eclipse.osgi.framework.debug.Debug; >@@ -49,7 +50,7 @@ > public class PackageAdminImpl implements PackageAdmin { > /** framework object */ > protected Framework framework; >- >+ private HashMap multiSourceCache = new HashMap(5); > /** > * Constructor. > * >@@ -188,6 +189,7 @@ > } > } > StateDelta stateDelta = framework.adaptor.getState().resolve(descriptions); >+ clearMultiSourceCache(); > refreshedBundles = processDelta(stateDelta.getChanges(), refreshPackages); > if (refreshPackages) { > AbstractBundle[] allBundles = framework.getAllBundles(); >@@ -586,4 +588,31 @@ > } > FrameworkProperties.setProperty(Constants.OSGI_IMPL_VERSION_KEY, systemBundle.getVersion().toString()); > } >+ >+ MultiSourcePackage createMultiSourcePackage(String id, SingleSourcePackage[] suppliers) { >+ synchronized (multiSourceCache) { >+ MultiSourcePackage[] multiSources = (MultiSourcePackage[]) multiSourceCache.get(id); >+ if (multiSources == null) { >+ multiSources = new MultiSourcePackage[1]; >+ multiSources[0] = new MultiSourcePackage(id, suppliers); >+ multiSourceCache.put(id, multiSources); >+ return multiSources[0]; >+ } >+ for (int i = 0; i < multiSources.length; i++) >+ if (multiSources[i].equals(id, suppliers)) >+ return multiSources[i]; >+ MultiSourcePackage[] temp = multiSources; >+ multiSources = new MultiSourcePackage[temp.length + 1]; >+ System.arraycopy(temp, 0, multiSources, 0, temp.length); >+ multiSources[temp.length] = new MultiSourcePackage(id, suppliers); >+ multiSourceCache.put(id, multiSources); >+ return multiSources[temp.length]; >+ } >+ } >+ >+ private void clearMultiSourceCache() { >+ synchronized (multiSourceCache) { >+ multiSourceCache.clear(); >+ } >+ } > } >Index: core/framework/org/eclipse/osgi/framework/internal/core/MultiSourcePackage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/MultiSourcePackage.java,v >retrieving revision 1.9 >diff -u -r1.9 MultiSourcePackage.java >--- core/framework/org/eclipse/osgi/framework/internal/core/MultiSourcePackage.java 20 Jul 2005 18:50:41 -0000 1.9 >+++ core/framework/org/eclipse/osgi/framework/internal/core/MultiSourcePackage.java 1 Mar 2006 17:42:58 -0000 >@@ -11,11 +11,11 @@ > package org.eclipse.osgi.framework.internal.core; > > import java.net.URL; >-import java.util.Enumeration; >-import java.util.Vector; >+import java.util.*; > > public class MultiSourcePackage extends PackageSource { >- SingleSourcePackage[] suppliers; >+ private SingleSourcePackage[] suppliers; >+ private Hashtable cache = new Hashtable(10); > > MultiSourcePackage(String id, SingleSourcePackage[] suppliers) { > super(id); >@@ -27,11 +27,15 @@ > } > > public Class loadClass(String name) { >- Class result = null; >+ Class result = (Class) cache.get(name); >+ if (result != null) >+ return result; > for (int i = 0; i < suppliers.length; i++) { > result = suppliers[i].loadClass(name); >- if (result != null) >+ if (result != null) { >+ cache.put(name, result); > return result; >+ } > } > return result; > } >@@ -67,4 +71,17 @@ > } > return compoundResults == null ? firstResult : compoundResults.elements(); > } >+ >+ public boolean equals(String name, SingleSourcePackage[] sources) { >+ if (!getId().equals(id)) >+ return false; >+ if (suppliers == sources) >+ return true; // this is really only true if both are null >+ if (suppliers == null || sources == null || suppliers.length != sources.length) >+ return false; >+ for (int i = 0; i < suppliers.length; i++) >+ if (suppliers[i] != sources[i]) >+ return false; // single source packages are shared; so ref check is good enough >+ return true; >+ } > } >Index: core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java,v >retrieving revision 1.73 >diff -u -r1.73 BundleLoader.java >--- core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java 2 Feb 2006 21:07:43 -0000 1.73 >+++ core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java 1 Mar 2006 17:42:58 -0000 >@@ -218,7 +218,7 @@ > return createMultiSource(export.getName(), new PackageSource[] {requiredSource, exportSource}); > } > >- private static PackageSource createMultiSource(String packageName, PackageSource[] sources) { >+ private PackageSource createMultiSource(String packageName, PackageSource[] sources) { > if (sources.length == 1) > return sources[0]; > ArrayList sourceList = new ArrayList(sources.length); >@@ -228,7 +228,7 @@ > if (!sourceList.contains(innerSources[j])) > sourceList.add(innerSources[j]); > } >- return new MultiSourcePackage(packageName, (SingleSourcePackage[]) sourceList.toArray(new SingleSourcePackage[sourceList.size()])); >+ return bundle.framework.packageAdmin.createMultiSourcePackage(packageName, (SingleSourcePackage[]) sourceList.toArray(new SingleSourcePackage[sourceList.size()])); > } > > /*
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 129940
:
35540
| 35551