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 89246 Details for
Bug 82973
IAdapterManager and bundle activation
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]
Patch for new IAdapterManager.loadAdapter(Object, Class) API
bug82973_adapterManager.diff.txt (text/plain), 5.45 KB, created by
Martin Oberhuber
on 2008-02-08 08:52:02 EST
(
hide
)
Description:
Patch for new IAdapterManager.loadAdapter(Object, Class) API
Filename:
MIME Type:
Creator:
Martin Oberhuber
Created:
2008-02-08 08:52:02 EST
Size:
5.45 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.common >Index: src/org/eclipse/core/internal/runtime/AdapterManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/AdapterManager.java,v >retrieving revision 1.5 >diff -u -r1.5 AdapterManager.java >--- src/org/eclipse/core/internal/runtime/AdapterManager.java 7 Sep 2007 16:13:29 -0000 1.5 >+++ src/org/eclipse/core/internal/runtime/AdapterManager.java 8 Feb 2008 13:35:44 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 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 >@@ -7,13 +7,13 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >- * David Green - fix factories with non-standard class loading (bug 200068) >+ * David Green - fix factories with non-standard class loading (bug 200068) >+ * Martin Oberhuber (Wind River ) - [82973] add loadAdapter(Object,Class) API > *******************************************************************************/ > package org.eclipse.core.internal.runtime; > > import java.util.*; >-import org.eclipse.core.runtime.IAdapterFactory; >-import org.eclipse.core.runtime.IAdapterManager; >+import org.eclipse.core.runtime.*; > > /** > * This class is the standard implementation of <code>IAdapterManager</code>. It provides >@@ -344,6 +344,27 @@ > } > > /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.IAdapterManager#loadAdapter(java.lang.Object, java.lang.Class) >+ */ >+ public Object loadAdapter(Object adaptable, Class adapterType) { >+ if (adaptable instanceof IAdaptable) { >+ //ask the adaptable first >+ IAdaptable a = (IAdaptable) adaptable; >+ Object adapter = a.getAdapter(adapterType); >+ if (adapter == null) { >+ Object factoryResult = loadAdapter(adaptable, adapterType.getName()); >+ //ask the adaptable again, after loading adapter factory >+ adapter = a.getAdapter(adapterType); >+ if (adapter == null) { >+ adapter = factoryResult; >+ } >+ } >+ return adapter; >+ } >+ return loadAdapter(adaptable, adapterType.getName()); >+ } >+ >+ /* (non-Javadoc) > * @see org.eclipse.core.runtime.IAdapterManager#loadAdapter(java.lang.Object, java.lang.String) > */ > public Object loadAdapter(Object adaptable, String adapterTypeName) { >Index: src/org/eclipse/core/runtime/IAdapterManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterManager.java,v >retrieving revision 1.7 >diff -u -r1.7 IAdapterManager.java >--- src/org/eclipse/core/runtime/IAdapterManager.java 5 Sep 2006 13:43:43 -0000 1.7 >+++ src/org/eclipse/core/runtime/IAdapterManager.java 8 Feb 2008 13:35:44 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 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 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Martin Oberhuber (Wind River ) - [82973] add loadAdapter(Object,Class) API > *******************************************************************************/ > package org.eclipse.core.runtime; > >@@ -198,6 +199,34 @@ > public int queryAdapter(Object adaptable, String adapterTypeName); > > /** >+ * Returns an object which is an instance of the given class associated >+ * with the given object. Returns <code>null</code> if no such object can >+ * be found. >+ * <p> >+ * Note that unlike the <code>getAdapter</code> methods, this method >+ * will cause the plug-in that contributes the adapter factory to be loaded >+ * if necessary. As such, this method should be used judiciously, in order >+ * to avoid unnecessary plug-in activations. Most clients should avoid >+ * activation by using <code>getAdapter</code> instead. >+ * <p> >+ * Unlike {link #loadAdapter(Object, String)}, this method first >+ * queries the adaptable object for an adapter, in case it is an >+ * instance of {link {@link IAdaptable}. Only if that query fails, >+ * the adapter manager mechnism is used to potentially load an adapter >+ * factory. Once the adapter factory is loaded, the object in question >+ * is again first queried before querying the adapter factory. >+ * >+ * @param adaptable the adaptable object being queried (usually an instance >+ * of <code>IAdaptable</code>) >+ * @param adapterType the type of adapter to look up >+ * @return an object castable to the given adapter type, or <code>null</code> >+ * if the given adaptable object does not have an available adapter of the >+ * given type >+ * @since 3.4 >+ */ >+ public Object loadAdapter(Object adaptable, Class adapterType); >+ >+ /** > * Returns an object that is an instance of the given class name associated > * with the given object. Returns <code>null</code> if no such object can > * be found.
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 82973
: 89246