SlideShare une entreprise Scribd logo
1  sur  27
INTEGRATION 
PATTERNS IN AEM 
Yuval Ararat
• Basics 
• Sling 
• Integration 
• Sample 
• Other resources 
• Sling Models
• What do we integrate with? 
– Backend API layer 
• SAP PI, Oracle Fusion or other middleware layer. 
• Bespoke API 
– DB 
– File System 
– Forms Engine
• First questions when arriving to the scene. 
– Is it exposed to WWW? 
– What authentication does the layer require? 
– What can I cache? 
– Protocol and output formats.
• Exposed to WWW? 
– Client side integration 
– Mixed integration 
• Not exposed to the WWW 
– Server Side 
– Tunneled through
• SlingMainServlet 
– Outermost Request Handler 
– Starts Request Processing 
• ResourceResolver 
– Resolves the URL to a Resource 
• ServletResolver 
– Resolve the Resource Type to a Servlet/Script
• Resolve the Resource 
– Source: Request URI 
• Resolve Servlet or Script 
– Source: Resource Type 
• sling:resourceType 
• sling:resourceSuperType 
• Call Servlet Filters 
• Call Servlet or Script 
protocol host path selector extension 
http:// myhost/ tools/spy .print.a4 .html / 
suffix 
a/b ? 
param(s) 
x=12
• ResourceProvider 
• Sling Filter 
• Custom SlingServlet 
• OSGi HTTP Service
• Provides access to resources from different locations 
through a single ResourceResolver 
• Registered to a path in the virtual resource tree 
• The last fallback is always the JCR repository
• PlanetResourceProvider Sample 
• Respond with a relevant planet resource when calling 
“/planets/<planet>” 
https://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/ 
src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/
@Component 
@Service 
@Properties({ 
@Property(name=ResourceProvider.ROOTS, value=PlanetsResourceProvider.ROOT) 
}) 
public class PlanetsResourceProvider implements ResourceProvider { 
private static final Map<String, ValueMap> PLANETS = new HashMap<String, ValueMap>(); 
/** This can be configurable of course */ 
public static final String ROOT = "planets"; 
public static final String ABS_ROOT = "/" + ROOT; 
static { 
definePlanet("Mercury", 57910); 
definePlanet("Venus", 108200); 
definePlanet("Earth", 149600).put("comment", "Resources can have different sets of properties"); 
definePlanet("Mars", 227940); 
definePlanet("Jupiter", 4332); 
definePlanet("Saturn", 10759); 
definePlanet("Uranus", 30685); 
definePlanet("Neptune", 60190); 
// Add the moon to test a two-level hierarchy 
final String moonPath = ABS_ROOT + "/earth/moon"; 
PLANETS.put(moonPath, new PlanetResource.PlanetValueMap("Moon", 384)); 
}
public Resource getResource(ResourceResolver resolver, HttpServletRequest req, String path) { 
// Synthetic resource for our root, so that /planets works 
if((ABS_ROOT).equals(path)) { 
return new SyntheticResource(resolver, path, PlanetResource.RESOURCE_TYPE); 
} 
// Not root, return a Planet if we have one 
final ValueMap data = PLANETS.get(path); 
return data == null ? null : new PlanetResource(resolver, path, data); 
}
public Iterator<Resource> listChildren(Resource parent) { 
if(parent.getPath().startsWith(ABS_ROOT)) { 
// Not the most efficient thing...good enough for this example 
final List<Resource> kids = new ArrayList<Resource>(); 
for(Map.Entry<String, ValueMap> e : PLANETS.entrySet()) { 
if(parent.getPath().equals(parentPath(e.getKey()))) { 
kids.add(new PlanetResource(parent.getResourceResolver(), e.getKey(), e.getValue())); 
} 
} 
return kids.iterator(); 
} else { 
return null; 
} 
}
@Adaptable(adaptableClass=Resource.class, adapters={ 
@Adapter({ValueMap.class}) 
}) 
public class PlanetResource extends AbstractResource implements Resource { 
private final String path; 
private final ResourceMetadata metadata; 
private final ValueMap valueMap; 
private final ResourceResolver resolver; 
public static final String RESOURCE_TYPE = "sling/test-services/planet"; 
PlanetResource(ResourceResolver resolver, String path, ValueMap valueMap) { 
this.path = path; 
this.valueMap = valueMap; 
this.resolver = resolver; 
metadata = new ResourceMetadata(); 
metadata.setResolutionPath(path); 
}
– BundleResourceProvider provides access to files and directories 
contained in an OSGi bundle 
– The BundleResourceProvider is responsible for mapping the 
directory tree into the resource tree 
– It‘s most conveniently configured as instruction in the maven-bundle- 
plugin: 
<configuration> 
<instructions> 
<Sling-Bundle-Resources>/resource/tree;path:=/bundle/tree</Sling-Bundle-Resources> 
</instructions> 
</configuration>
– FsResourceProvider, which is part of org.apache.sling.fsresource, 
maps file system paths as resources. 
– Requires installation. 
– Configuration through fsresource.xml: 
• provider.roots 
• Provider.files 
– http://sling.apache.org/documentation/bundles/accessing-filesystem-resources-extensions- 
fsresource.html
• Sling Models 
– Creating an adaptable class from a POJO by annotations 
• Blueprints 
– Dependency injection framework for OSGi 
– Implementations include SpringDM (Historical) and Neba.io 
• Cognifide Slice framework 
– God’s speed…
• Creat ing an adaptable class from a POJO by annotat ions 
– Resource resource = getResource(); 
– Return resource.adaptTo(YourCustom.class); 
– @Model(adaptables = Resource.class) 
– public class YourCustom { 
– ... 
– } 
• Use Sling Models for Controller or Business Logic that is 
“context-aware” 
• Use Value Map to read resource data 
• http://sling.apache.org/documentation/bundles/models.html
• Use Sling Models for Dependency 
Injection 
– Inject Sling Context Objects via @SlingObject 
– Inject AEM Context Objects via @AemObject 
– Inject Business Classes via @Self 
– Inject Resource Data or Parameters 
• Dependencies can be mocked with tools like 
Mockito@InjectMocks
• Injecting 
@Model(adaptables= Resource.class) public class YourCustom{ 
@Inject // we expected always an email-property 
private String email; 
@Inject @Optional // first name can be empty 
private String firstName; 
// read property “surname” if empty use “empty” 
@Inject @Named(“surname“) @Default(values=“empty“) 
private String lastName; 
}
@Model(adaptables= Resource.class) 
Public class YourCustom{ 
@Inject// OSGiService 
private Externalizer externalizer; 
@PostConstruct 
Protected void init() { 
// gets executed after the class is created 
// set to protected, so it can be unit-tested 
} 
}
@Model(adaptables= Resource.class) 
Public class YourCustom{ 
//option1 
@Self 
private Resource resource; 
//option2 
public YourCustom(Resource resource) { 
// to get access to the adaptor 
this.resource= resource; 
} 
}
• Available for AEM6 
– Can be installed in CQ5.6.1 
– Sling Models Content Packages 
– https://github.com/Adobe-Consulting- 
Services/com.adobe.acs.bundles.sling-models/ 
releases 
• What’s new in Sling Models 1.1 
– http://adapt.to/2014/en/schedule/whats-new-in-sling-models- 
11.html
• Recommended pattern: Controller per concern, 
not per component! 
• Controllers are Sling Models 
• Component/View can re-use multiple controllers
• Sling Models Documentation 
– http://sling.apache.org/documentation/bundles/model 
s.html 
• Sling Models 1.0.x Introduction by Justin Edelson 
– http://slideshare.net/justinedelson/sling-models-overview 
• AEM Object Injector Implementations 
– http://wcm.io/sling/models/ 
– http://adobe-consulting-services.github.io/acs-aem-commons/ 
features/aem-sling-models-injectors.html

Contenu connexe

Tendances

Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
DEEPAK KHETAWAT
 
Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson
AEM HUB
 

Tendances (20)

AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
 
AEM Sightly Template Language
AEM Sightly Template LanguageAEM Sightly Template Language
AEM Sightly Template Language
 
Dynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEMDynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEM
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
 
Sling Models Overview
Sling Models OverviewSling Models Overview
Sling Models Overview
 
Integration Testing in AEM
Integration Testing in AEMIntegration Testing in AEM
Integration Testing in AEM
 
Understanding Sling Models in AEM
Understanding Sling Models in AEMUnderstanding Sling Models in AEM
Understanding Sling Models in AEM
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
 
Heap Dump Analysis - AEM: Real World Issues
Heap Dump Analysis - AEM: Real World IssuesHeap Dump Analysis - AEM: Real World Issues
Heap Dump Analysis - AEM: Real World Issues
 
AEM and Sling
AEM and SlingAEM and Sling
AEM and Sling
 
Sightly - Part 2
Sightly - Part 2Sightly - Part 2
Sightly - Part 2
 
Rest api standards and best practices
Rest api standards and best practicesRest api standards and best practices
Rest api standards and best practices
 
Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson
 
Maven
MavenMaven
Maven
 
The new repository in AEM 6
The new repository in AEM 6The new repository in AEM 6
The new repository in AEM 6
 
Osgi
OsgiOsgi
Osgi
 
Managing an OSGi Framework with Apache Felix Web Console
Managing an OSGi Framework with  Apache Felix Web ConsoleManaging an OSGi Framework with  Apache Felix Web Console
Managing an OSGi Framework with Apache Felix Web Console
 
Web API Basics
Web API BasicsWeb API Basics
Web API Basics
 
vite-en.pdf
vite-en.pdfvite-en.pdf
vite-en.pdf
 
AEM - Client Libraries
AEM - Client LibrariesAEM - Client Libraries
AEM - Client Libraries
 

En vedette

Four approaches to integrate aem with external systems by Jan Kuzniak
Four approaches to integrate aem with external systems by Jan KuzniakFour approaches to integrate aem with external systems by Jan Kuzniak
Four approaches to integrate aem with external systems by Jan Kuzniak
AEM HUB
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEM
connectwebex
 
Microservices Architecture for AEM
Microservices Architecture for AEMMicroservices Architecture for AEM
Microservices Architecture for AEM
Maciej Majchrzak
 
Vimeo Integration with aem
Vimeo Integration with aemVimeo Integration with aem
Vimeo Integration with aem
Manisha Bano
 
Basics of Solr and Solr Integration with AEM6
Basics of Solr and Solr Integration with AEM6Basics of Solr and Solr Integration with AEM6
Basics of Solr and Solr Integration with AEM6
DEEPAK KHETAWAT
 
You wanna crypto in AEM
You wanna crypto in AEMYou wanna crypto in AEM
You wanna crypto in AEM
Damien Antipa
 

En vedette (20)

Four approaches to integrate aem with external systems by Jan Kuzniak
Four approaches to integrate aem with external systems by Jan KuzniakFour approaches to integrate aem with external systems by Jan Kuzniak
Four approaches to integrate aem with external systems by Jan Kuzniak
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEM
 
The six key steps to AEM architecture
The six key steps to AEM architectureThe six key steps to AEM architecture
The six key steps to AEM architecture
 
Microservices Architecture for AEM
Microservices Architecture for AEMMicroservices Architecture for AEM
Microservices Architecture for AEM
 
Vimeo Integration with aem
Vimeo Integration with aemVimeo Integration with aem
Vimeo Integration with aem
 
Apache SOLR in AEM 6
Apache SOLR in AEM 6Apache SOLR in AEM 6
Apache SOLR in AEM 6
 
AEM & eCommerce integration
AEM & eCommerce integrationAEM & eCommerce integration
AEM & eCommerce integration
 
Basics of Solr and Solr Integration with AEM6
Basics of Solr and Solr Integration with AEM6Basics of Solr and Solr Integration with AEM6
Basics of Solr and Solr Integration with AEM6
 
Sling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatSling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak Khetawat
 
Adobe AEM for Business Heads
Adobe AEM for Business HeadsAdobe AEM for Business Heads
Adobe AEM for Business Heads
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEM
 
You wanna crypto in AEM
You wanna crypto in AEMYou wanna crypto in AEM
You wanna crypto in AEM
 
Creating Real-Time Data Mashups with Node.js and Adobe CQ by Josh Miller
Creating Real-Time Data Mashups with Node.js and Adobe CQ by Josh MillerCreating Real-Time Data Mashups with Node.js and Adobe CQ by Josh Miller
Creating Real-Time Data Mashups with Node.js and Adobe CQ by Josh Miller
 
UI Customization in AEM 6.0
UI Customization in AEM 6.0UI Customization in AEM 6.0
UI Customization in AEM 6.0
 
Shooting rabbits with sling
Shooting rabbits with slingShooting rabbits with sling
Shooting rabbits with sling
 
AEM and Sling
AEM and SlingAEM and Sling
AEM and Sling
 
Introducing Mongo DB and setting up Adobe AEM6 with mongo
Introducing Mongo DB and setting up Adobe AEM6 with mongoIntroducing Mongo DB and setting up Adobe AEM6 with mongo
Introducing Mongo DB and setting up Adobe AEM6 with mongo
 
AEM integration with Apache Mahout
AEM integration with Apache MahoutAEM integration with Apache Mahout
AEM integration with Apache Mahout
 
Mail chimp Integration with AEM
Mail chimp Integration with AEMMail chimp Integration with AEM
Mail chimp Integration with AEM
 
AEM WITH MONGODB
AEM WITH MONGODBAEM WITH MONGODB
AEM WITH MONGODB
 

Similaire à Integration patterns in AEM 6

Decoupled Libraries for PHP
Decoupled Libraries for PHPDecoupled Libraries for PHP
Decoupled Libraries for PHP
Paul Jones
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
b_kathir
 

Similaire à Integration patterns in AEM 6 (20)

L04 base patterns
L04 base patternsL04 base patterns
L04 base patterns
 
Decoupled Libraries for PHP
Decoupled Libraries for PHPDecoupled Libraries for PHP
Decoupled Libraries for PHP
 
JAX-RS Creating RESTFul services
JAX-RS Creating RESTFul servicesJAX-RS Creating RESTFul services
JAX-RS Creating RESTFul services
 
RESTful Web services using JAX-RS
RESTful Web services using JAX-RSRESTful Web services using JAX-RS
RESTful Web services using JAX-RS
 
Android Data Persistence
Android Data PersistenceAndroid Data Persistence
Android Data Persistence
 
Java colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rsJava colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rs
 
FFW Gabrovo PMG - PHP OOP Part 3
FFW Gabrovo PMG - PHP OOP Part 3FFW Gabrovo PMG - PHP OOP Part 3
FFW Gabrovo PMG - PHP OOP Part 3
 
RESTful Web Services with Jersey
RESTful Web Services with JerseyRESTful Web Services with Jersey
RESTful Web Services with Jersey
 
Jersey
JerseyJersey
Jersey
 
Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018
 
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RSSpark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RS
 
CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!CDI, Seam & RESTEasy: You haven't seen REST yet!
CDI, Seam & RESTEasy: You haven't seen REST yet!
 
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and OData
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
 
Lab swe-2013intro jax-rs
Lab swe-2013intro jax-rsLab swe-2013intro jax-rs
Lab swe-2013intro jax-rs
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
04 darwino concepts and utility classes
04   darwino concepts and utility classes04   darwino concepts and utility classes
04 darwino concepts and utility classes
 

Dernier

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Dernier (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Integration patterns in AEM 6

  • 1. INTEGRATION PATTERNS IN AEM Yuval Ararat
  • 2. • Basics • Sling • Integration • Sample • Other resources • Sling Models
  • 3. • What do we integrate with? – Backend API layer • SAP PI, Oracle Fusion or other middleware layer. • Bespoke API – DB – File System – Forms Engine
  • 4. • First questions when arriving to the scene. – Is it exposed to WWW? – What authentication does the layer require? – What can I cache? – Protocol and output formats.
  • 5. • Exposed to WWW? – Client side integration – Mixed integration • Not exposed to the WWW – Server Side – Tunneled through
  • 6.
  • 7. • SlingMainServlet – Outermost Request Handler – Starts Request Processing • ResourceResolver – Resolves the URL to a Resource • ServletResolver – Resolve the Resource Type to a Servlet/Script
  • 8. • Resolve the Resource – Source: Request URI • Resolve Servlet or Script – Source: Resource Type • sling:resourceType • sling:resourceSuperType • Call Servlet Filters • Call Servlet or Script protocol host path selector extension http:// myhost/ tools/spy .print.a4 .html / suffix a/b ? param(s) x=12
  • 9. • ResourceProvider • Sling Filter • Custom SlingServlet • OSGi HTTP Service
  • 10.
  • 11. • Provides access to resources from different locations through a single ResourceResolver • Registered to a path in the virtual resource tree • The last fallback is always the JCR repository
  • 12. • PlanetResourceProvider Sample • Respond with a relevant planet resource when calling “/planets/<planet>” https://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/ src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/
  • 13. @Component @Service @Properties({ @Property(name=ResourceProvider.ROOTS, value=PlanetsResourceProvider.ROOT) }) public class PlanetsResourceProvider implements ResourceProvider { private static final Map<String, ValueMap> PLANETS = new HashMap<String, ValueMap>(); /** This can be configurable of course */ public static final String ROOT = "planets"; public static final String ABS_ROOT = "/" + ROOT; static { definePlanet("Mercury", 57910); definePlanet("Venus", 108200); definePlanet("Earth", 149600).put("comment", "Resources can have different sets of properties"); definePlanet("Mars", 227940); definePlanet("Jupiter", 4332); definePlanet("Saturn", 10759); definePlanet("Uranus", 30685); definePlanet("Neptune", 60190); // Add the moon to test a two-level hierarchy final String moonPath = ABS_ROOT + "/earth/moon"; PLANETS.put(moonPath, new PlanetResource.PlanetValueMap("Moon", 384)); }
  • 14. public Resource getResource(ResourceResolver resolver, HttpServletRequest req, String path) { // Synthetic resource for our root, so that /planets works if((ABS_ROOT).equals(path)) { return new SyntheticResource(resolver, path, PlanetResource.RESOURCE_TYPE); } // Not root, return a Planet if we have one final ValueMap data = PLANETS.get(path); return data == null ? null : new PlanetResource(resolver, path, data); }
  • 15. public Iterator<Resource> listChildren(Resource parent) { if(parent.getPath().startsWith(ABS_ROOT)) { // Not the most efficient thing...good enough for this example final List<Resource> kids = new ArrayList<Resource>(); for(Map.Entry<String, ValueMap> e : PLANETS.entrySet()) { if(parent.getPath().equals(parentPath(e.getKey()))) { kids.add(new PlanetResource(parent.getResourceResolver(), e.getKey(), e.getValue())); } } return kids.iterator(); } else { return null; } }
  • 16. @Adaptable(adaptableClass=Resource.class, adapters={ @Adapter({ValueMap.class}) }) public class PlanetResource extends AbstractResource implements Resource { private final String path; private final ResourceMetadata metadata; private final ValueMap valueMap; private final ResourceResolver resolver; public static final String RESOURCE_TYPE = "sling/test-services/planet"; PlanetResource(ResourceResolver resolver, String path, ValueMap valueMap) { this.path = path; this.valueMap = valueMap; this.resolver = resolver; metadata = new ResourceMetadata(); metadata.setResolutionPath(path); }
  • 17. – BundleResourceProvider provides access to files and directories contained in an OSGi bundle – The BundleResourceProvider is responsible for mapping the directory tree into the resource tree – It‘s most conveniently configured as instruction in the maven-bundle- plugin: <configuration> <instructions> <Sling-Bundle-Resources>/resource/tree;path:=/bundle/tree</Sling-Bundle-Resources> </instructions> </configuration>
  • 18. – FsResourceProvider, which is part of org.apache.sling.fsresource, maps file system paths as resources. – Requires installation. – Configuration through fsresource.xml: • provider.roots • Provider.files – http://sling.apache.org/documentation/bundles/accessing-filesystem-resources-extensions- fsresource.html
  • 19. • Sling Models – Creating an adaptable class from a POJO by annotations • Blueprints – Dependency injection framework for OSGi – Implementations include SpringDM (Historical) and Neba.io • Cognifide Slice framework – God’s speed…
  • 20. • Creat ing an adaptable class from a POJO by annotat ions – Resource resource = getResource(); – Return resource.adaptTo(YourCustom.class); – @Model(adaptables = Resource.class) – public class YourCustom { – ... – } • Use Sling Models for Controller or Business Logic that is “context-aware” • Use Value Map to read resource data • http://sling.apache.org/documentation/bundles/models.html
  • 21. • Use Sling Models for Dependency Injection – Inject Sling Context Objects via @SlingObject – Inject AEM Context Objects via @AemObject – Inject Business Classes via @Self – Inject Resource Data or Parameters • Dependencies can be mocked with tools like Mockito@InjectMocks
  • 22. • Injecting @Model(adaptables= Resource.class) public class YourCustom{ @Inject // we expected always an email-property private String email; @Inject @Optional // first name can be empty private String firstName; // read property “surname” if empty use “empty” @Inject @Named(“surname“) @Default(values=“empty“) private String lastName; }
  • 23. @Model(adaptables= Resource.class) Public class YourCustom{ @Inject// OSGiService private Externalizer externalizer; @PostConstruct Protected void init() { // gets executed after the class is created // set to protected, so it can be unit-tested } }
  • 24. @Model(adaptables= Resource.class) Public class YourCustom{ //option1 @Self private Resource resource; //option2 public YourCustom(Resource resource) { // to get access to the adaptor this.resource= resource; } }
  • 25. • Available for AEM6 – Can be installed in CQ5.6.1 – Sling Models Content Packages – https://github.com/Adobe-Consulting- Services/com.adobe.acs.bundles.sling-models/ releases • What’s new in Sling Models 1.1 – http://adapt.to/2014/en/schedule/whats-new-in-sling-models- 11.html
  • 26. • Recommended pattern: Controller per concern, not per component! • Controllers are Sling Models • Component/View can re-use multiple controllers
  • 27. • Sling Models Documentation – http://sling.apache.org/documentation/bundles/model s.html • Sling Models 1.0.x Introduction by Justin Edelson – http://slideshare.net/justinedelson/sling-models-overview • AEM Object Injector Implementations – http://wcm.io/sling/models/ – http://adobe-consulting-services.github.io/acs-aem-commons/ features/aem-sling-models-injectors.html

Notes de l'éditeur

  1. Basic – what is an integration Sling – some sling architecture and request processing Integration – ResourceProvider integration and overview Sample – A code walkthrough of a custom resource provider