|
|||||||||
| Home >> All >> org >> eclipse >> core >> internal >> [ runtime overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.core.internal.runtime
Class AdapterManager

java.lang.Objectorg.eclipse.core.internal.runtime.AdapterManager
- All Implemented Interfaces:
- java.util.EventListener, org.eclipse.core.runtime.IAdapterManager, org.eclipse.core.runtime.IRegistryChangeListener
- public final class AdapterManager
- extends java.lang.Object
- implements org.eclipse.core.runtime.IAdapterManager, org.eclipse.core.runtime.IRegistryChangeListener
- extends java.lang.Object
This class is the standard implementation of IAdapterManager. It provides
fast lookup of property values with the following semantics:
- At most one factory will be invoked per property lookup
- If multiple installed factories provide the same adapter, only the first found in the search order will be invoked.
- The search order from a class with the definition
class X extends Y implements A, B
is as follows:- the target's class: X
- X's superclasses in order to
Object- a breadth-first traversal of the target class's interfaces in the order returned by
getInterfaces(in the example, A and its superinterfaces then B and its superinterfaces)
| Field Summary | |
protected java.util.HashMap |
factories
Map of factories, keyed by String, fully qualified class name of
the adaptable class that the factory provides adapters for. |
protected java.util.HashMap |
lookup
Cache of adapters for a given adaptable class. |
| Constructor Summary | |
AdapterManager()
Constructs a new adapter manager. |
|
| Method Summary | |
private void |
addFactoriesFor(java.lang.String typeName,
java.util.Map table)
Given a type name, add all of the factories that respond to those types into the given table. |
private java.lang.Class |
classForName(org.eclipse.core.runtime.IAdapterFactory factory,
java.lang.String typeName)
Returns the class with the given fully qualified name, or null if that class does not exist or belongs to a plug-in that has not yet been loaded. |
private java.util.Map |
computeClassOrder(java.lang.Class adaptable)
Builds and returns a table of adapters for the given adaptable type. |
private void |
computeInterfaceOrder(java.lang.Class[] interfaces,
java.util.Map table,
java.util.Set seen)
|
void |
flushLookup()
Flushes the cache of adapter search paths. |
java.lang.Object |
getAdapter(java.lang.Object adaptable,
java.lang.Class adapterType)
Returns an object which is an instance of the given class associated with the given object. |
java.lang.Object |
getAdapter(java.lang.Object adaptable,
java.lang.String adapterType)
Returns an object which is an instance of the given class name associated with the given object. |
private java.lang.Object |
getAdapter(java.lang.Object adaptable,
java.lang.String adapterType,
boolean force)
Returns an adapter of the given type for the provided adapter. |
private org.eclipse.core.runtime.IAdapterFactory |
getFactory(java.lang.Class adaptable,
java.lang.String adapterName)
Gets the adapter factory installed for objects of class extensibleClass
which defines adapters of type adapter. |
boolean |
hasAdapter(java.lang.Object adaptable,
java.lang.String adapterTypeName)
Returns whether there is an adapter factory registered that may be able to convert adaptable to an object of type adapterTypeName. |
java.lang.Object |
loadAdapter(java.lang.Object adaptable,
java.lang.String adapterTypeName)
Returns an object that is an instance of the given class name associated with the given object. |
void |
registerAdapters(org.eclipse.core.runtime.IAdapterFactory factory,
java.lang.Class adaptable)
Registers the given adapter factory as extending objects of the given type. |
private void |
registerExtension(org.eclipse.core.runtime.IExtension extension)
|
private void |
registerFactory(org.eclipse.core.runtime.IAdapterFactory factory,
java.lang.String adaptableType)
|
private void |
registerFactoryProxies()
Loads adapters registered with the adapters extension point from the plug-in registry. |
void |
registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent event)
Notifies this listener that some registry changes are happening, or have already happened. |
void |
unregisterAdapters(org.eclipse.core.runtime.IAdapterFactory factory)
Removes the given adapter factory completely from the list of registered factories. |
void |
unregisterAdapters(org.eclipse.core.runtime.IAdapterFactory factory,
java.lang.Class adaptable)
Removes the given adapter factory from the list of factories registered as extending the given class. |
void |
unregisterAllAdapters()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
factories
protected final java.util.HashMap factories
- Map of factories, keyed by
String, fully qualified class name of the adaptable class that the factory provides adapters for. Value is aListofIAdapterFactory.
lookup
protected java.util.HashMap lookup
- Cache of adapters for a given adaptable class. Maps String -> Map
(adaptable class name -> (adapter class name -> factory instance))
| Constructor Detail |
AdapterManager
public AdapterManager()
- Constructs a new adapter manager.
| Method Detail |
addFactoriesFor
private void addFactoriesFor(java.lang.String typeName, java.util.Map table)
- Given a type name, add all of the factories that respond to those types into
the given table. Each entry will be keyed by the adapter class name (supplied in
IAdapterFactory.getAdapterList).
classForName
private java.lang.Class classForName(org.eclipse.core.runtime.IAdapterFactory factory, java.lang.String typeName)
- Returns the class with the given fully qualified name, or null
if that class does not exist or belongs to a plug-in that has not
yet been loaded.
computeClassOrder
private java.util.Map computeClassOrder(java.lang.Class adaptable)
- Builds and returns a table of adapters for the given adaptable type.
The table is keyed by adapter class name. The
value is the sole factory that defines that adapter. Note that
if multiple adapters technically define the same property, only the
first found in the search order is considered.
Note that it is important to maintain a consistent class and interface
lookup order. See the class comment for more details.
computeInterfaceOrder
private void computeInterfaceOrder(java.lang.Class[] interfaces, java.util.Map table, java.util.Set seen)
flushLookup
public void flushLookup()
- Flushes the cache of adapter search paths. This is generally required whenever an
adapter is added or removed.
It is likely easier to just toss the whole cache rather than trying to be smart and remove only those entries affected.
getAdapter
public java.lang.Object getAdapter(java.lang.Object adaptable, java.lang.Class adapterType)
- Description copied from interface:
org.eclipse.core.runtime.IAdapterManager - Returns an object which is an instance of the given class associated
with the given object. Returns
nullif no such object can be found.Note that this method will never cause plug-ins to be loaded. If the only suitable factory is not yet loaded, this method will return
null.- Specified by:
getAdapterin interfaceorg.eclipse.core.runtime.IAdapterManager
getAdapter
public java.lang.Object getAdapter(java.lang.Object adaptable, java.lang.String adapterType)
- Description copied from interface:
org.eclipse.core.runtime.IAdapterManager - Returns an object which is an instance of the given class name associated
with the given object. Returns
nullif no such object can be found.Note that this method will never cause plug-ins to be loaded. If the only suitable factory is not yet loaded, this method will return
null. If activation of the plug-in providing the factory is required, use theloadAdaptermethod instead.- Specified by:
getAdapterin interfaceorg.eclipse.core.runtime.IAdapterManager
getAdapter
private java.lang.Object getAdapter(java.lang.Object adaptable, java.lang.String adapterType, boolean force)
- Returns an adapter of the given type for the provided adapter.
getFactory
private org.eclipse.core.runtime.IAdapterFactory getFactory(java.lang.Class adaptable, java.lang.String adapterName)
- Gets the adapter factory installed for objects of class
extensibleClasswhich defines adapters of typeadapter. If no such factories exists, returns null.
hasAdapter
public boolean hasAdapter(java.lang.Object adaptable, java.lang.String adapterTypeName)
- Description copied from interface:
org.eclipse.core.runtime.IAdapterManager - Returns whether there is an adapter factory registered that may be able
to convert
adaptableto an object of typeadapterTypeName.Note that a return value of
truedoes not guarantee that a subsequent call togetAdapterwith the same arguments will return a non-null result. If the factory's plug-in has not yet been loaded, or if the factory itself returnsnull, thengetAdapterwill still returnnull.- Specified by:
hasAdapterin interfaceorg.eclipse.core.runtime.IAdapterManager
loadAdapter
public java.lang.Object loadAdapter(java.lang.Object adaptable, java.lang.String adapterTypeName)
- Description copied from interface:
org.eclipse.core.runtime.IAdapterManager - Returns an object that is an instance of the given class name associated
with the given object. Returns
nullif no such object can be found.Note that unlike the
getAdaptermethods, 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 usinggetAdapterinstead.- Specified by:
loadAdapterin interfaceorg.eclipse.core.runtime.IAdapterManager
registerAdapters
public void registerAdapters(org.eclipse.core.runtime.IAdapterFactory factory, java.lang.Class adaptable)
- Description copied from interface:
org.eclipse.core.runtime.IAdapterManager - Registers the given adapter factory as extending objects of the given
type.
If the type being extended is a class, the given factory's adapters are available on instances of that class and any of its subclasses. If it is an interface, the adapters are available to all classes that directly or indirectly implement that interface.
- Specified by:
registerAdaptersin interfaceorg.eclipse.core.runtime.IAdapterManager
registerExtension
private void registerExtension(org.eclipse.core.runtime.IExtension extension)
registerFactory
private void registerFactory(org.eclipse.core.runtime.IAdapterFactory factory, java.lang.String adaptableType)
registerFactoryProxies
private void registerFactoryProxies()
- Loads adapters registered with the adapters extension point from
the plug-in registry. Note that the actual factory implementations
are loaded lazily as they are needed.
registryChanged
public void registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent event)
- Description copied from interface:
org.eclipse.core.runtime.IRegistryChangeListener - Notifies this listener that some registry changes are happening, or have
already happened.
The supplied event gives details. This event object (and the deltas in it) is valid only for the duration of the invocation of this method.
Note: This method is called by the platform; it is not intended to be called directly by clients.
- Specified by:
registryChangedin interfaceorg.eclipse.core.runtime.IRegistryChangeListener
unregisterAdapters
public void unregisterAdapters(org.eclipse.core.runtime.IAdapterFactory factory)
- Description copied from interface:
org.eclipse.core.runtime.IAdapterManager - Removes the given adapter factory completely from the list of registered
factories. Equivalent to calling
unregisterAdapters(IAdapterFactory,Class)on all classes against which it had been explicitly registered. Does nothing if the given factory is not currently registered.- Specified by:
unregisterAdaptersin interfaceorg.eclipse.core.runtime.IAdapterManager
unregisterAdapters
public void unregisterAdapters(org.eclipse.core.runtime.IAdapterFactory factory, java.lang.Class adaptable)
- Description copied from interface:
org.eclipse.core.runtime.IAdapterManager - Removes the given adapter factory from the list of factories registered
as extending the given class. Does nothing if the given factory and type
combination is not registered.
- Specified by:
unregisterAdaptersin interfaceorg.eclipse.core.runtime.IAdapterManager
unregisterAllAdapters
public void unregisterAllAdapters()
|
|||||||||
| Home >> All >> org >> eclipse >> core >> internal >> [ runtime overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.eclipse.core.internal.runtime.AdapterManager