APACHE SLING & FRIENDS TECH MEETUP BERLIN, 26-28 SEPTEMBER 2012. APACHE SLING & SCALA Jochen Fliedner



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

CQCON 2013: five Sling features you should know

NextRow - AEM Training Program Course Catalog

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

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

RESTful web applications with Apache Sling

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

Meister Going Beyond Maven

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

Developing modular Java applications

OSGi Remote Management

Java Application Developer Certificate Program Competencies

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

<Insert Picture Here> GlassFish v3 - A Taste of a Next Generation Application Server

How to extend Puppet using Ruby

Learning GlassFish for Tomcat Users

Communiqué 4. Standardized Global Content Management. Designed for World s Leading Enterprises. Industry Leading Products & Platform

How To Develop An Open Play Context Framework For Android (For Android)

Kohsuke Kawaguchi Sun Microsystems, Inc. hk2.dev.java.net, glassfish.dev.java.net. Session ID

Web Development with the Eclipse Platform

YouTrack MPS case study

Drupal CMS for marketing sites

JobScheduler and Script Languages

TYLER JUNIOR COLLEGE School of Continuing Studies 1530 SSW Loop 323 Tyler, TX

Sightly Component Development

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

BEST WEB PROGRAMMING LANGUAGES TO LEARN ON YOUR OWN TIME

AEM Developer Tools for Eclipse

Chapter 3.2 C++, Java, and Scripting Languages. The major programming languages used in game development.

Integrating your Maven Build and Tomcat Deployment

Enterprise Service Bus

This course provides students with the knowledge and skills to develop ASP.NET MVC 4 web applications.

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

SCA & SDO Implementations Open Source and Vendor Products

Rapid Application Development. and Application Generation Tools. Walter Knesel

Jonathan Worthington Scarborough Linux User Group

Continuous Delivery of Apache Sling Applications

The Decaffeinated Robot

How to start with 3DHOP

WELCOME TO Open Source Enterprise Architecture

<Insert Picture Here> Java, the language for the future

Running and Testing Java EE Applications in Embedded Mode with JupEEter Framework

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

Developing Eclipse Plug-ins* Learning Objectives. Any Eclipse product is composed of plug-ins

Coherence Managed Servers

Liferay Portal 6.2. Key Features List

CommentTemplate: A Lightweight Code Generator for Java built with Eclipse Modeling Technology

Extending XSLT with Java and C#

Acrolinx IQ. Acrolinx IQ Plug-in for Adobe CQ Rich Text Editor Installation Guide Version: 2.9

Glassfish, JAVA EE, Servlets, JSP, EJB

Windows Azure Data Services (basics) 55093A; 3 Days

Build management & Continuous integration. with Maven & Hudson

Version Control Your Jenkins Jobs with Jenkins Job Builder

PHP vs. Java. In this paper, I am not discussing following two issues since each is currently hotly debated in various communities:

CrownPeak Java Web Hosting. Version 0.20

Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages. Corky Cartwright Swarat Chaudhuri November 30, 20111

WIRIS quizzes web services Getting started with PHP and Java

1 Building, Deploying and Testing DPES application

MENDIX FOR MOBILE APP DEVELOPMENT WHITE PAPER

Preface. Motivation for this Book

LAB 2 SPARK / D-STREAM PROGRAMMING SCIENTIFIC APPLICATIONS FOR IOT WORKSHOP

Rapid Game Development Using Cocos2D-JS

First Steps User s Guide

Software project management. and. Maven

DocBook Framework (DBF)

Programming Hadoop 5-day, instructor-led BD-106. MapReduce Overview. Hadoop Overview

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

The future of middleware: enterprise application integration and Fuse

The Hotspot Java Virtual Machine: Memory and Architecture

WEB APPLICATION DEVELOPMENT. UNIT I J2EE Platform 9

Beyond The Web Drupal Meets The Desktop (And Mobile) Justin Miller Code Sorcery Workshop, LLC

Apache Karaf in real life ApacheCon NA 2014

Introduction to Oracle Mobile Application Framework Raghu Srinivasan, Director Development Mobile and Cloud Development Tools Oracle

SPRING INTERVIEW QUESTIONS

Developing a Web Server Platform with SAPI Support for AJAX RPC using JSON

Habanero Extreme Scale Software Research Project

Esigate Module Documentation

What is the NXTware Evolution Server Peter Marquez, Product Marketing ecube Systems

Viewpoint. Choosing the right automation tool and framework is critical to project success. - Harsh Bajaj, Technical Test Lead ECSIVS, Infosys

Programming IoT Gateways With macchina.io

GETTING STARTED WITH ANDROID DEVELOPMENT FOR EMBEDDED SYSTEMS

Cross-domain Identity Management System for Cloud Environment

JBoss Portlet Container. User Guide. Release 2.0

Azure Day Application Development

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

CompuScholar, Inc. Alignment to Utah's Computer Programming II Standards

L01: Using the WebSphere Application Server Liberty Profile for lightweight, rapid development. Lab Exercise

Managing Complexity in Mobile Application Deployment Using the OSGi Service Platform

Glassbox: Open Source and Automated Application Troubleshooting. Ron Bodkin Glassbox Project Leader

Aspect-Oriented Web Development in PHP

Transcription:

APACHE SLING & FRIENDS TECH MEETUP BERLIN, 26-28 SEPTEMBER 2012 APACHE SLING & SCALA Jochen Fliedner

About the speaker Jochen Fliedner Senior Developer pro!vision GmbH Wilmersdorfer Str. 50-51 10627 Berlin http://www.pro-vision.de Spezialized on Adobe CQ and it s technology stack since 2003 2

Using VM languages in Sling/CQ5 Want to use Scala, Groovy for CMS implementations templating. For that differentiate between Scripting textual resource (content) Components precompiled type (bytecode in OSGi bundle) 3

Using scripts/scripting languages in Java We have all heard heated arguments between developers who use scripting languages and developers who use Java. One of the reasons for the war between these two factions is that the process of integrating the two was so difficult that developers on both sides were almost forced to choose one or the other. http://www.drdobbs.com/jvm/jsr-223-scripting-for-the-javaplatform/215801163 What to do? Call scripts from Java. And the solution for that: Scripting for the Java Platform JSR 223 4

Scripting part: JSR 223: Scripting for the Java Platform Script engine? set of interfaces describing methods to execute scripts providing context to script: set and get data service provider mechanism: register engine (factory) javax.script.scriptenginemanager: retrieve engine instance supply script string provide javax.script.bindings (or simply put key-value pairs) evaluation retrieve result by any obj reference held (Bindings ) 5

Scripting part: Script engines implementations Where to find (usually)? Comes with Java 6 SE platform Set of interfaces, helpers, manager class: Package javax.script Included: Javascript (Rhino) engine implementation Included on OS X: Applescript engine implementation 6

Scripting part: Meet JSR 223 in Sling sling.api <- sling.scripting.api/sling.scripting.core DefaultSlingScript (sling.scripting API) manager class used to select script engine (you already use) JSP (+ Taglib) Python, Ruby (as VM languages) XProc ( xml pipeline processor ) Freemarker, Velocity (template languages) Scala (but using guggla now) 7

Scripting part: script resolution Examples - typically with CQ5: /apps/my_template_set/components/my_component/html.scala /apps/my_template_set/components/pages/home/sitemap.xml.scala Script is a textual resource Can be edited with CRX Resides in OSGi bundle as its initial content Script resolution is applied Engine selected by file extension 8

Scripting part: Bindings What s in for the script? Bindings supplied by Sling generally: org.apache.sling.api.scripting.slingbindings "out", "request", "response", "resource", "sling", "log", "reader" JCR specific: org.apache.sling.jcr.resource.internal.scripting.jcrobjects BindingsValuesProvider "currentnode", "currentsession" 9

Component part: OSGi Precompiled types in bundle javax.servlet.servlet interface OSGi component, using Service Component Runtime Needs to be declared to the framework as service and component: OSGI-INF/serviceComponents.xml (referenced in manifest file) Optionally references to other services have to be declared and supported in the code 10

Component part: SCR Tooling Easing by scr annotations and maven-scr-plugin mvn build process with plugin: Identifies types After compile look up target bytecode for these classes Scan classes for annotations Generate service component xml Enhance bytecode: bindrefxy / unbindrefxy @SlingServlet (service component plus sling metadata) scrplugin 1.8.0 (FELIX-3550) 11

Excursion/Example: CQ5 Groovy Console (internals) Sling-Application implemented in Groovy org.codehaus.groovy:groovy-all-2.0.1 Nicely done and example in many ways: Probably first 3rd-party open sourced stand-alone app for Sling/CQ Serverside logic done in Groovy (scripting AND component) Use of Groovy DSL features (demonstrated later) Nice and lightweight webfrontend (Bootstrap framework, ACE editor) And: Build process and tooling (!) 12

Scala: guggla generic Scala script engine by Adobe s Michael Dürig fka org.apache.sling.scripting.scala.script (sling contrib) disconnected from Sling, generic for Java runtime or OSGi: The scripting engine supports running in an OSGi container or as part of a stand alone application. It has optional support for compiling from/to a JCR repository. more unit tests 13

Scala: guggla a Scala script? Scala code snippet to be interpreted But there is no concept of script in Scala As there is no ScriptRunner or ScriptShell class Decision: script will be code in constructor of a simple object With that script (String) a greater Scala snippet is synthesized (script-args-runner, #preprocess) #compile on classpath invoked by reflection 14

Scala Templating demonstration Targeting Scala leverage in a sample that is an actual Template set (not a standalone Sling app) Using guggla for scripts Reintegration into Sling as of org.apache.sling.scripting.scala.config: JCR classpath used for compiled scripts Own Context type overriding the ScalaInterpreter impl, for own Context type Also use Scala components, declarations by current scrplugin Build and deployment by maven build process Make available for download, anyone could reproduce and test 15

Example component //geometrixx/de.gsitemap.xml create google sitemap xml Scala idioms used: a) enriching a type by implicits - here: Page (cq wcm) b) flatten and map methods on Scala collection (Iterable, Array) c) Scala XML literal integrating String values 16

Example script resourcetype geometrixx/components/title Exchanged for a Scala script impl. -> modification to geometrixx templating Scala idioms used: a) implicitly enriching javax.jcr.node b) using Scala XML literal integrating String values (see type conversion in synthetic code) 17

Example: some drawbacks maven-scr-plugin supports service component xml generation only with a tweak Bytecode manipulation - (un)boundxy - will probably not work with Scala Idiomatic Scala may be a little expensive (heavy on heap, gc) Possible synchronization problems with ScalaCompiler (M. Dürig) 18

Summing up Can use Java VM languages in Sling For components and more or less for scripting Start to use usage only for certain parts of the project? Can build up knowledge for any future project Scala as a language really is groundbreaking - but better start with basic Scala skillset, read a book Groovy is for pragmatists (lightweight, easier to learn - sucessively) 19

Summing up Recent developments Scr generator reimplemention, plugin improvements Guggla generic Scala script engine Scala CQ5 integration and example code available soon Check out and try, please contribute and criticize Check out and see internals https://github.com/citytechinc/cq5-groovy-console 20

Thanks to Michael Dürig, Bertrand Delacrétaz (sling contrib, guggla) Carsten Ziegeler (Felix SCR, generator, annotations, tooling ) Prior connected adaptto() talks: R. Bartl and P. Mannel (Sling introduction, mentioning scripts and components) Todd Haser (Groovy console introduction) And last but not least 21

APACHE SLING & FRIENDS TECH MEETUP BERLIN, 26-28 SEPTEMBER 2012 Thank you for your attention! Any questions?