Nuxeo Enterprise Platform 5.4

org.nuxeo.runtime.services.adapter
Class AdaptableObject

java.lang.Object
  extended by org.nuxeo.runtime.services.adapter.AdaptableObject
All Implemented Interfaces:
Adaptable

public abstract class AdaptableObject
extends java.lang.Object
implements Adaptable

An abstract superclass implementing the Adaptable interface. getAdapter invocations are directed to the platform's adapter manager.

Note: In situations where it would be awkward to subclass this class, the same affect can be achieved simply by implementing the IAdaptable interface and explicitly forwarding the getAdapter request to the platform's adapter manager. The method would look like:

     public Object getAdapter(Class adapter) {
         return NXRuntime.getAdapterManager().getAdapter(this, adapter);
     }
 

This class can be used without OSGi running.

Clients may subclass.

See Also:
Adaptable

Constructor Summary
AdaptableObject()
           
 
Method Summary
<T> T
getAdapter(java.lang.Class<T> adapter)
          Returns an object which is an instance of the given class associated with this object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdaptableObject

public AdaptableObject()
Method Detail

getAdapter

public <T> T getAdapter(java.lang.Class<T> adapter)
Returns an object which is an instance of the given class associated with this object. Returns null if no such object can be found.

This implementation of the method declared by IAdaptable passes the request along to the platform's adapter manager; roughly Platform.getAdapterManager().getAdapter(this, adapter). Subclasses may override this method (however, if they do so, they should invoke the method on their superclass to ensure that the Platform's adapter manager is consulted).

Specified by:
getAdapter in interface Adaptable
Parameters:
adapter - the class to adapt to
Returns:
the adapted object or null
See Also:
Adaptable.getAdapter(Class)

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.