CQCON 2013: five Sling features you should know



Similar documents
Apache Sling A REST-based Web Application Framework Carsten Ziegeler cziegeler@apache.org ApacheCon NA 2014

Server-side OSGi with Apache Sling. Felix Meschberger Day Management AG 124

APACHE SLING & FRIENDS TECH MEETUP BERLIN, SEPTEMBER APACHE SLING & SCALA Jochen Fliedner

Liferay Enterprise ecommerce. Adding ecommerce functionality to Liferay Reading Time: 10 minutes

How To Write A Web Framework In Java

NextRow - AEM Training Program Course Catalog

Structured Content: the Key to Agile. Web Experience Management. Introduction

Effective Web Application Development with Apache Sling. Robert Munteanu ), Adobe Systems Romania

Enterprise Application Development In Java with AJAX and ORM

Java EE Introduction, Content. Component Architecture: Why and How Java EE: Enterprise Java

Servlet 3.0. Alexis Moussine-Pouchkine. mercredi 13 avril 2011

Java Servlet 3.0. Rajiv Mordani Spec Lead

RESTful web applications with Apache Sling

Complete Java Web Development

Customer Bank Account Management System Technical Specification Document

GlassFish v3. Building an ex tensible modular Java EE application server. Jerome Dochez and Ludovic Champenois Sun Microsystems, Inc.

ESB pilot project at the FMI

Lessons learned from a large scale OSGi web app. Jago de Vreede Paul Bakker

Building Applications with Protégé: An Overview. Protégé Conference July 23, 2006

Nicholas S. Williams. wrox. A Wiley Brand

Best Practices for Programming Eclipse and OSGi

HPC Portal Development Platform with E-Business and HPC Portlets

Creating new university management software by methodologies of Service Oriented Architecture (SOA)

How To Implement Lightweight ESOA with Java

Choosing a Content Management System (CMS)

Web Frameworks and WebWork

Building a Modular Server Platform with OSGi. Dileepa Jayakody Software Engineer SSWSO2 Inc.

Java EE 6 development with Eclipse, Netbeans, IntelliJ and GlassFish. Ludovic Champenois Oracle Corporation

The end. Carl Nettelblad

Japan Communication India Skill Development Center

Java EE 7: Back-End Server Application Development

Course Name: Course in JSP Course Code: P5

Java 7 Recipes. Freddy Guime. vk» (,\['«** g!p#« Carl Dea. Josh Juneau. John O'Conner

OUR COURSES 19 November All prices are per person in Swedish Krona. Solid Beans AB Kungsgatan Göteborg Sweden

FUSE-ESB4 An open-source OSGi based platform for EAI and SOA

Official Android Coding Style Conventions

Software Development Kit

SwiftScale: Technical Approach Document

Accessing Data with ADOBE FLEX 4.6

YouTrack MPS case study

Eclipse 4 RCP application Development COURSE OUTLINE

Install guide for Websphere 7.0

An introduction to creating JSF applications in Rational Application Developer Version 8.0

Creating a REST API for Cloud services using Apache Felix and Sling Carsten Ziegeler and David Bosschaert

Development. with NetBeans 5.0. A Quick Start in Basic Web and Struts Applications. Geertjan Wielenga

JBoss Portlet Container. User Guide. Release 2.0

JAVA ENTERPRISE IN A NUTSHELL. Jim Farley and William Crawford. O'REILLY 4 Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo.

A Comparison of Open Source Application Development Frameworks for the Enterprise

Portal Factory CMIS Connector Module documentation

Case Studies of Running the Platform. NetBeans UML Servlet JSP GlassFish EJB

Expert Spring MVC and Web Flow

Ligero Content Delivery Server. Documentum Content Integration with

Drupal CMS for marketing sites

Framework Adoption for Java Enterprise Application Development

Architecture Guide Jahia EE v6.1

Sightly Component Development

Why IBM WebSphere Application Server V8.0?

WebSphere Training Outline

Reusing Existing * Java EE Applications from Oracle SOA Suite

Easy configuration of NETCONF devices

Spring Security SAML module

Model-View-Controller. and. Struts 2

Alkacon Software GmbH

Spoilt for Choice Which Integration Framework to choose? Mule ESB. Integration. Kai Wähner

Converting Java EE Applications into OSGi Applications

SSC - Web development Model-View-Controller for Java web application development

CERTIFIED MULESOFT DEVELOPER EXAM. Preparation Guide

Japan Communication India Skill Development Center

Esigate Module Documentation

SAP Web Application Server 6.30: Learning Map for Development Consultants

This presentation will provide a brief introduction to Rational Application Developer V7.5.

The Oracle Fusion Development Platform

Developer s Guide. How to Develop a Communiqué Digital Asset Management Solution

JBoss JEE5 with EJB3.0 on NonStop. JAVA SIG, San Jose

Apache Ki (formerly JSecurity) DevNexus

What means extensibility?

Operations and Monitoring with Spring

MarkLogic Server. Reference Application Architecture Guide. MarkLogic 8 February, Copyright 2015 MarkLogic Corporation. All rights reserved.

Oracle Application Development Framework Overview

Web Frameworks. web development done right. Course of Web Technologies A.A. 2010/2011 Valerio Maggio, PhD Student Prof.

METADATA-DRIVEN QLIKVIEW APPLICATIONS AND POWERFUL DATA INTEGRATION WITH QLIKVIEW EXPRESSOR

GLOBAL CONSULTING SERVICES TOOLS FOR WEBMETHODS Software AG. All rights reserved. For internal use only

MASTERTAG DEVELOPER GUIDE

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

HPC PORTAL DEVELOPMENT PLATFORM

User Application: Design Guide

Beginning POJOs. From Novice to Professional. Brian Sam-Bodden

Lecture 4 Cross-Platform Development. <lecturer, date>

Learning GlassFish for Tomcat Users

Building and Using Web Services With JDeveloper 11g

Web Services Development for IBM WebSphere Application Server V7.0. Version: Demo. Page <<1/10>>

Building Web Services with Apache Axis2

OpenShift is FanPaaStic For Java EE. By Shekhar Gulati Promo Code JUDCON.IN

Web Container Components Servlet JSP Tag Libraries

Transcription:

CQCON 2013: five Sling features you should know Olaf Otto 19.06.2013

1: Write custom tag libraries Use current XSD Fully qualified identifier <taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"> <taglib> <uri>http://www.corp.com/taglibs/mytaglib/1.0</uri>... </taglib> Multiple TLDs allowed META-INF/<name>.tld computing.co.uk Version your API! Taglibs are not exactly the latest trend, but they get the job done properly reusable, testable implementations for viewrelated tasks such as rich text transformation, i18n, date formatting etc. Unic - Seite 2

1.1 Talking of versioned taglibs: <sling:include /> <sling:forward /> <sling:defineobjects /> <sling:call /> <sling:eval /> http://sling.apache.org/taglibs/sling/1.0 http://sling.apache.org/taglibs/sling/1.2 Current ${sling:adaptto(from, to) ${sling:findresources(resolver, query, language) ${sling:getrelativeresource(resource, path) ${sling:getresource(resolver, path) ${sling:listchildren(resource) Coming http://sling.apache.org/taglibs/sling/1.3 <sling:getproperty /> <sling:getresource /> Unic - Seite 3

2: Enriching the view @Service @Component(immediate = true) public class Provider implements BindingsValuesProvider { @Override public void addbindings(bindings bindings) { Map<String,?> ${bindings.key anything View (JSP) computing.co.uk The BindingsValuesProvider allows you to inject anything into any view and thus aides in decoupling view and backend layer. Unic - Seite 4

2.1 By the way: Semantic Annotations @SlingServlet(paths = "/bin/myservlet") public class MyServlet extends SlingSafeMethodsServlet { @Override public void doget( ) { @SlingFilter public class MyFilter implements Filter { @Override public void dofilter( ) { Use typesafe Java 5 annotations (not the JAVADoc ones). SlingFilter and SlingServlet are part of felix-scrannotations and supported by the maven-scr-plugin. Unic - Seite 5

Click ++complexity to edit Master title style Sling has a simple generic resource model (Resource, ValueMap), which may not suffice when resources require complex operations on their data Unic - Seite 6

3: When Resource is not enough Page cq:page These are independent aspects of the cq:page resource type taken from an actual project. Each aspect requires an implementation. CUG protection Sitemap entry Link Properties Persistence Unic - Seite 7

3.1.adaptTo(TheRescue) Please do not implement such aspects in static util functions. This is a terrible anti-pattern. No more util-class projects, please. {data, Operations : Model.adaptTo(X) Best pratice for Sling: write a POJO for an aspect and.adaptto it..adaptto s most valueable application is adaptation to type safe representations of aspects of resources Unic - Seite 8

3.2:.adaptTo & OSGi best practices.adapto is a perfect match for OSGi best practices. Refer to http://www.ibm.com/developerworks/websphere/techjournal/1007_charters/1007_charter s.html#sec5 Feature.adaptTo computing.co.uk Implementation dadcando.com API Provides API implementation + AdapterFactory Contains adapter interface Clean separation Unic - Seite 9

3.3: Boilerplate, anyone? = from @Component @Service @Properties({ = to @Property(name = "adaptables", value = "org.apache.sling.api.resource.resource"), @Property(name = "adapters", value = "fully.qualified.type.name") ) public class MyFactory implements AdapterFactory Stringly { typed public <T> T getadapter(object from, Class<T> totype) { If () else if () Such boilerplate may well be the reason developers avoid adapter factories Unic - Seite 10

3.4: Choices! Improve declaration Luckily, boilerplate can be circumvented by either simplifying declaration or programmatically publishing a generic adapter factory onespoonatatime.com Note: AdapterFactories are excellent extension points for Spring integration. When obtaining the Adapter from the Spring bean factory, you can transparently adapt to a Spring bean at any time from anywhere in you application. Generic Adapterfactory Unic - Seite 11

3.5 Custom SCR annotation for adapter factories Typesafe! The simple most approach is to exchange the boilerplate SCR metadata with a semantic annotation @Adapts(from = Resource.class, to = Name.class) public class MyFactory implements AdapterFactory { public <T> T getadapter(object from, Class<T> totype) { How? SCR plugin / task + AnnotationProcessor Refer to: http://felix.apache.org/documentation/subprojects/apache-felixmaven-scr-plugin/extending-scr-annotations.html Unic - Seite 12

4: Decorating resources @Service @Component(immediate = true) public class Decorator implements ResourceDecorator { @Override public Resource decorate(resource resource) { Note: This is one of the most powerful extension points allowing manipulating any resource even script and servlets Manipulation of any Resource (everything is a resource!). Transparent (.adaptto, Views) Sample application: Resources with a specific property (e.g. inherit=true) are wrapped with a resource that provides an InhertianceVauleMap. This way, you can enable transparent inheritance for any resource at any time without changing a single line of code. Source from CQCON, see: http://www.cqcon.eu/2013/en/speakers/olaf-otto.html Unic - Seite 13

5: Providing custom resources JCR ResourceProvider /custom /content /site /custom/<child> Refer to http://sling.apache.org/documentation/the-slingengine/resources.html, «Providing Resources» Unic - Seite 14

5.1: The pros an cons Bad fit for thirdparty integration (tight coupling!). Better: soaml ESB RESTful support e.g. ServiceMix System Client Advertise Use Enterprise serv ice bus System Client JSONP for crossdomain integration System Client Good fit for local integration (DBs, Filesystem ). Upcoming Sling version features provider for MongoDB. Unic - Seite 15

Some more things to take a look at: CRUD support with PersistableValueMap Deployment of custom node types in bundles (CND) Static resource support: Serve static resource from bundles Unic - Seite 16

Unic AG Belpstrasse 48 3007 Bern Tel +41 31 560 12 12 Fax +41 31 560 12 13 info@unic.com www.unic.com Unic - Seite 17