crx best practices

19
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Condential. 2011-Mar-30 CRX and Sling Best Practices for Web Apps Tools, Resources & Scripts Wednesday, 30 March 2011

Upload: lisui0807

Post on 16-Apr-2017

2.218 views

Category:

Education


0 download

TRANSCRIPT

Page 1: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential. 2011-Mar-30

CRX and Sling Best Practices for Web AppsTools, Resources & Scripts

Wednesday, 30 March 2011

Page 2: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Outline

CRX OverviewResource AddressingComponents / ModularizationComponent InheritanceSide track: GFX RenderingUsing File Vault Command Line ToolUpdating ContentQ&A

2

Wednesday, 30 March 2011

Page 3: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

CRX Terminology

3

§ CRX Platform § CRX JCR Repository§ CRX Quickstart§ CRX Welcome Screen§ CRX Admin Console (legacy)§ CRX Explorer§ CRX Package Manager & Package Share§ OSGi Console (Apache Felix)§ CQSE Admin (Communique Servlet Engine)§ CRXDE Lite (vs CRXDE Eclipse)

Wednesday, 30 March 2011

Page 4: CRX Best practices

Application Runtime

JCR Repository

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

CRX Open Core Architecture

4

Web Framework: Apache Sling Web/Eclipse IDE

OSGi Runtime: Apache Felix Vault & SVN Tools

JCR: Apache Jackrabbit

Search: Lucene

Content Extraction:POI, Tika, PDFBox

Search Extensions

GFX Rendering

TAR-basedNode-store

CIFS/SMB Access

Virtual Repository

Shared-nothingCluster

CRX Platform

Repository Admin

Wednesday, 30 March 2011

Page 5: CRX Best practices

Application Runtime

JCR Repository

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

CRX Open Core Architecture

4

Web Framework: Apache Sling Web/Eclipse IDE

OSGi Runtime: Apache Felix Vault & SVN Tools

JCR: Apache Jackrabbit

Search: Lucene

Content Extraction:POI, Tika, PDFBox

Search Extensions

GFX Rendering

TAR-basedNode-store

CIFS/SMB Access

Virtual Repository

Shared-nothingCluster

CRX Platform...CRX is the commercial version of

Jackrabbit + Sling

Repository Admin

Wednesday, 30 March 2011

Page 6: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Coding - Let’s Begin

§ Reuse old OOP example: Shapes§ Content goes here: /content§ Scripts go here: /apps/shapes/components

5

Wednesday, 30 March 2011

Page 7: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Resource Addressing

6

Old School Static HTML§ h"p://xyz.com/products/12345.html

#e Script Hype (jsp, .net, cgi-bin, ...)§ h"p://xyz.com/products.jsp?id=12345§ Script centric

RESTful / Sling§ h"p://xyz.com/products/12345.html§ Resource centric

Wednesday, 30 March 2011

Page 8: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Resources & Resource Types

§ Resource hierarchy§ Each resource has a type§ Scripts (and Servlets) are resources, too§ URLs are mapped to resources

7

Wednesday, 30 March 2011

Page 9: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

URL Decomposition

8

path

GET /content/shape.head.html/markup?simple=true HTTP/1.1

selector

extension

suffix

query parameters

1. Content resolution: “/content/shape”2. Resource type: “sling:resourceType = /apps/shapes/shape” 3. Script resolution look in /apps/shapes/shape:

1. “head.html.jsp” or “head.jsp”2. “html.jsp” or “shape.jsp”3. “GET.jsp”

for more info google: “sling script resolution”

Wednesday, 30 March 2011

Page 10: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Coding - Modularize

§ Identify semantical / reusable blocks§ use the <sling:include/> tag

9

Wednesday, 30 March 2011

Page 11: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Script Resource Inheritance

§ sling:resourceSuperType§ Script resolution traverses the inheritance chain§ Components = Script resources§ CQ Components = Script resources++§ Fallback: DefaultGetServlet / SlingPostServlet

10

Wednesday, 30 March 2011

Page 12: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Coding - Create sub types

§ Create new types for rectangle and triangle shapes§ Only “implement” scripts that differ

11

Wednesday, 30 March 2011

Page 13: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Script Like Java Servlets (Java Scriptlets?)

§ Normal Java classes extend H"pServlet§ Naming follows normal script resolution rules

e.g: “text.java”, “png.java”, etc.§ Compiled on demand§ Example: GFX Rendering

12

Wednesday, 30 March 2011

Page 14: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Coding - Let’s add Images

Graphic Rendering§ day-commons-gfx bundle (CQ, but not in CRX 2.2, yet)§ Simple tools to generate png, jpeg and gif images§ Multiple layers with alpha blending support§ Text rendering with in-repository font support

13

Wednesday, 30 March 2011

Page 15: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Coding - Let’s use a real IDE

Using the File Vault command line tool§ Source control like synchronization with JCR repository

§ check-out !les

§ view changes / differences

§ check-in !les

§ Same format as CRX Content Packages§ Setup your IDE to use offline content + libs

§ Code completion and be"er syntax highlighting

§ Hybrid variant allows tight integration with SCM and automated build systems.

14

Wednesday, 30 March 2011

Page 16: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Updating Content

Sling Post Servlet§ POST requests to the resources§ AJAX friendly responses§ Mapping for CREATE / DELETE / MOVE operations§ h"p://sling.apache.org/site/manipulating-content-the-

slingpostservlet-servletspost.html

15

Wednesday, 30 March 2011

Page 17: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

More Information

Official Sites§ h"p://sling.apache.org/§ h"p://felix.apache.org/§ h"p://dev.day.com/docs/en/crx/current.html§ h"p://jackrabbit.apache.org/

CRX / Jackrabbit Source Code§ h"p://svn.day.com/repos/crx/branches/2.2/§ h"p://svn.apache.org/repos/asf/jackrabbit/branches/2.2/

16

Wednesday, 30 March 2011

Page 18: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

More Information

Visit this sessions wiki page§ h"ps://zerowing.corp.adobe.com/display/~tripod/

CRXBestPractices

§ Slides and recording available§ Feedback welcome!§ Vote for future topics

17

Wednesday, 30 March 2011

Page 19: CRX Best practices

© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential. 18

!ank you.

Wednesday, 30 March 2011