Expand my Community achievements bar.

Join us in celebrating the outstanding achievement of our AEM Community Member of the Year!
SOLVED

what is difference between adaptables and adapters in aem

Avatar

Level 1

what is difference between adaptables and adapters in aem

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Adapters define the behavior and structure that Adaptables are converted to.

 

An Adaptable is an object that can be "adapted" into another type.

  • Purpose: It provides a flexible way to convert an object of one type into another type that may be required in a particular context.

  • Example:

    • Common examples of Adaptables in AEM include:
      • SlingHttpServletRequest
      • Resource
      • Page

 

An Adapter is the target type that an Adaptable can be converted into.

  • Purpose: Adapters are the interfaces or classes into which an Adaptable can be transformed.

  • Example:

    • In AEM, common adapters include:
      • ValueMap
      • ResourceResolver
      • Custom classes implementing specific business logic.

 

 

 


Aanchal Sikka

View solution in original post

3 Replies

Avatar

Level 1

Adaptable is source objects that can be adapted, for example Resource.

Adapter is the Target object produced after adaptation, for example, Page.

 

Call .adaptTo(Class) on an Adaptable, where the result of that method is Adapter.

Avatar

Correct answer by
Community Advisor

Adapters define the behavior and structure that Adaptables are converted to.

 

An Adaptable is an object that can be "adapted" into another type.

  • Purpose: It provides a flexible way to convert an object of one type into another type that may be required in a particular context.

  • Example:

    • Common examples of Adaptables in AEM include:
      • SlingHttpServletRequest
      • Resource
      • Page

 

An Adapter is the target type that an Adaptable can be converted into.

  • Purpose: Adapters are the interfaces or classes into which an Adaptable can be transformed.

  • Example:

    • In AEM, common adapters include:
      • ValueMap
      • ResourceResolver
      • Custom classes implementing specific business logic.

 

 

 


Aanchal Sikka

Avatar

Level 4

In AEM:

  • Adaptables: Objects that can be converted or adapted to another type (e.g., SlingHttpServletRequest, Resource).
  • Adapters: The mechanism or logic that converts an adaptable to a different type (e.g., adapting a Resource to a Sling Model).

Example:

  • Adaptable: SlingHttpServletRequest
  • Adapter: Logic that adapts the request to a model (like a custom Sling Model).

In short: Adaptables are objects that can be adapted; adapters are the logic that performs the adaptation.