public abstract class SlingAdaptable extends java.lang.Object implements Adaptable
SlingAdaptable class is an (abstract) default implementation
of the Adaptable interface. It just uses the default
AdapterManager implemented to adapt itself to the requested type.
Extensions of this class may overwrite the adaptTo(Class) method
using their own knowledge of adapters and should call this base class
implementation to fall back for other types.
| Constructor and Description |
|---|
SlingAdaptable() |
| Modifier and Type | Method and Description |
|---|---|
<AdapterType> |
adaptTo(java.lang.Class<AdapterType> type)
Calls into the registered
AdapterManager to adapt this object to
the desired type. |
static void |
setAdapterManager(AdapterManager adapterMgr)
Sets the global
AdapterManager to be used by this class. |
static void |
unsetAdapterManager(AdapterManager adapterMgr)
Unsets the global
AdapterManager. |
public static void setAdapterManager(AdapterManager adapterMgr)
AdapterManager to be used by this class.
This method is intended to only be called by the AdapterManager
wanting to register itself for use. Currently only a single adapter
manager is supported by this class.
adapterMgr - The AdapterManager to be globally used.public static void unsetAdapterManager(AdapterManager adapterMgr)
AdapterManager.
This method is intended to only be called by the AdapterManager
wanting to unregister itself. Currently only a single adapter manager is
supported by this class.
adapterMgr - The AdapterManager to be unset. If this is not
the same as currently registered this method has no effect.public <AdapterType> AdapterType adaptTo(java.lang.Class<AdapterType> type)
AdapterManager to adapt this object to
the desired type.
This method implements a cache of adapters to improve performance. That is repeated calls to this method with the same class will result in the same object to be returned.
adaptTo in interface AdaptableAdapterType - The generic type to which this resource is adapted
totype - The Class object of the target type, such as
javax.jcr.Node.class or
java.io.File.classnull if the resource cannot
adapt to the requested typeCopyright © 2010 - 2023 Adobe. All Rights Reserved