Shooting rabbits with sling

Slides:



Advertisements
Similar presentations
E-Commerce CMM503 – Lecture 8 Stuart Watt Room C2.
Advertisements

CTS2 DEVELOPMENT FRAMEWORK CTS2 Overview. Schedule What is it? Why a framework? What does this do for me? Plugins Implementations available now CTS2 Compliance.
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
1 Actuate Corporation © 2010 THE BIRT COMPANY THE BIRT COMPANY THE BIRT COMPANY THE BIRT COMPANY THE BIRT COMPANY THE BIRT COMPANY THE BIRT COMPANY THE.
Java Server Pages (JSP)
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
SE 370: Programming Web Services Week 4: SOAP & NetBeans Copyright © Steven W. Johnson February 1, 2013.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Ruby on Rails Model of MVC. Model-View-Controller Paradigm A way of organizing a software system Benefits: Isolation of business logic from the user interface.
Introduction to Backend James Kahng. Install Node.js.
Servlets and a little bit of Web Services Russell Beale.
Fast Track to ColdFusion 9. Getting Started with ColdFusion Understanding Dynamic Web Pages ColdFusion Benchmark Introducing the ColdFusion Language Introducing.
Drupal Create a website/web app quickly with this Content Management System Jiaying Xu Spring 2011 COMS E6125 Web-enHanced Information.
Creating a SharePoint App with Microsoft Access Services
Web Programming Language Dr. Ken Cosh Week 1 (Introduction)
Understanding and Managing WebSphere V5
Lecture 2 - Struts ENTERPRISE JAVA. 2 Contents  Servlet Deployment  Servlet Filters  Model View Controllers  Struts  Dependency Injection.
OMap By: Haitham Khateeb Yamama Dagash Under Suppervision of: Benny Daon.
Content Management with Apache Jackrabbit Jukka Zitting Day Software (862)
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
SAKAI 3 MICHAEL KORCUSKA March 2009 Why Sakai 3?  Changing expectations  Google docs/apps, Social Networking, Web 2.0  Success of project sites =
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
About Dynamic Sites (Front End / Back End Implementations) by Janssen & Associates Affordable Website Solutions for Individuals and Small Businesses.
Dynamic Data Exchanges with the Java Flow Processor Presenter: Scott Bowers Date: April 25, 2007.
School of Computing and Information Systems CS 371 Web Application Programming PHP - Basics Serving up web pages.
11/16/2012ISC329 Isabelle Bichindaritz1 Web Database Application Development.
Java support for WWW Babak Esfandiari (sources: Qusay Mahmoud, Roger Impey, textbook)
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
1 Accelerated Web Development Course JavaScript and Client side programming Day 2 Rich Roth On The Net
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Overview of IU Digital Collections Search Hui Zhang Jon Dunn Indiana University Digital Library Program IU Digital Library Brown Bag October 19, 2011.
Putting it all together Dynamic Data Base Access Norman White Stern School of Business.
Nadir Saghar, Tony Pan, Ashish Sharma REST for Data Services.
A NoSQL Database - Hive Dania Abed Rabbou.
Chapter 6 Server-side Programming: Java Servlets
What’s new in Kentico CMS 5.0 Michal Neuwirth Product Manager Kentico Software.
DemocracyApps, Inc. Community Budget Explorer A Technical Overview.
Content Storage with Apache Jackrabbit , Jukka Zitting.
AEM & TDD It’s so boring… AUGUST 6, 2015
Rails & Ajax Module 5. Introduction to Rails Overview of Rails Rails is Ruby based “A development framework for Web-based applications” Rails uses the.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
1 Java Servlets l Servlets : programs that run within the context of a server, analogous to applets that run within the context of a browser. l Used to.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
1 Brian Remmington Alfresco Product Architect. 2 A demonstration The Web Quick Start model Overview of the features in the repository tier Overview of.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Session #2482 Implementing WebDAV Using J2EE TM and Open Source Technologies Juergen Pill Team Leader Software AG Remy Maucherat Software Engineer Sun.
Apache Solr Dima Ionut Daniel. Contents What is Apache Solr? Architecture Features Core Solr Concepts Configuration Conclusions Bibliography.
© 2010 IBM Corporation RESTFul Service Modelling in Rational Software Architect April, 2011.
Apache Cocoon – XML Publishing Framework 데이터베이스 연구실 박사 1 학기 이 세영.
BOF-1147, JavaTM Technology and WebDAV: Standardizing Content Management Java and WebDAV Juergen Pill Team Leader Software AG Remy Maucherat Software Engineer.
Web Technology Solutions
Web Programming Language
Ask the Experts – Building Login-Based Sites in AEM
Getting Started with Alfresco Development
Web Development Web Servers.
Node.js Express Web Applications
JSP (Java Server Page) JSP is server side technology which is used to create dynamic web pages just like Servlet technology. This is mainly used for implementing.
Getting started with Alfresco Development
PHP / MySQL Introduction
Testing REST IPA using POSTMAN
How the VIAF Magic Happens
EPIC INFOTECH CONSULTING GROUP
Introduction to Apache
Web Application Development Using PHP
Presentation transcript:

Shooting rabbits with sling Introduction to Apache Jackrabbit & Apache Sling

JCR Content Repository API for Java JSR-170 & JSR-283 Object database javax.jcr Object database Hierarchical data model Apache Jackrabbit – reference implementation

Mantra: everything is content Content is content Blogs, articles, posts, etc. Structured data List of addresses in e-mail database Unstructured data Word document ACLs Code

Content hierarchy JCR has tree-like data model Repository consists of items Item can be node or property Node children are properties or other nodes Properties are leaves

Node Nodes form content hierarchy Nodes are named Each node has primary type specifying it’s structure (allowed and required children and properties) Something like class Eg. myapp:Contact requires properties myapp:givenName and myapp:familyName Nodes can also have mixin types Something like interface Eg. mix:versionable, mix:lockable or myapp:Emailable Popular types: nt:base, nt:unstructured, nt:folder

Property Property contains data Types: Can be multivalued string, binary, long, double, date, boolean, name, path, reference Can be multivalued Show examples here: CRXDE and Eclipse “Helloworld”

Searching Node names and properties are indexed Jackrabbit uses Apache Lucene Supported query languages: XPath JCR-SQL JCR-SQL2 (recommended)

SQL2 Main purpose: find node by property contents SELECT * FROM [cq:PageContent] AS s WHERE ISDESCENDANTNODE([/content]) AND s.[jcr:title] = ’Moja strona’ Main purpose: find node by property contents Avoid queries with parent path (as it’s not indexed) It’s better to create a mixin or marker property We don’t JOIN SQL and XPath are isomorphic

Versioning Any subtree can be versioned Add mixin mix:versionable node.checkin() Creates new version Makes the node read-only node.checkout() Allows to modify the node Usage examples: Page versions at many levels Eclipse example Versioning

Observation Event listener We can filter events with: Usage examples: Event type Path Node types An explicit list of nodes Usage examples: Automatic workflows Generating thumbnails “Last modified” date Indexing in internal and external search engine

Other features Locking Access control Users & groups Groups can be members of other groups Privileges on nodes to read, write, etc.

JCR – advantages and problems Site structure is easy to reflect Flexible Hierarchical structure Disadvantages Storing large amount of structured data is neither easy nor efficient Don’t load CSV file with 1 000 000 rows Data has to be denormalized (as there is no JOINs) Clustering is tricky Master-slave works OK Waiting for Jackrabbit 3.0 – codename Oak Transactions…

HTTP access to JCR repository Apache Sling HTTP access to JCR repository

Apache Sling Web framework RESTful access to JCR nodes Powered by OSGi Support multiple scripting languages (JSP, Groovy, …) Open source, developed by Adobe within Apache foundation

REST # Create / Update $ curl -u admin:admin –d name=“Java User Group” –d city=Poznan \ localhost:8080/content/hello # Read $ curl localhost:8080/content/hello.tidy.json # Delete $ curl -X DELETE -u admin:admin \ localhost:8080/content/hello

Resource URL Resource path: /content/hello http://localhost:8080/content/hello.xml http://localhost:8080/content/hello.json http://localhost:8080/content/hello.html There are simple built-in renderers Each can be overridden

sling:resourceType In order to create custom rendition we need to set sling:resourceType property It’s a JCR path to some renderer Renderer can be JSP, Java Servlet, Scala, Python, Groovy, Ruby or ESP (internal Sling language, kind of backend JS) Content-centric: you don’t invoke script directly

Sample HTML renderer <html> <head><title>ESP example</title> </head> <body> <h1> Hello <%= currentNode.getProperty('name') %> </h1> <h2> <%= currentNode.getProperty('city') %> </h2> </body> </html> jug/hellocomponent

How does it work? /apps/jug/hellocomponent GET /content/home.html Get node path from URL Get extension Get HTTP method GET /content/home.html Find sling:resourceType Choose appropriate script (POST.jsp, json.jsp, etc.) /apps/jug/hellocomponent Render node using found renderer and appropriate script Hello JUG!

URL decomposition /content/corporate/jobs/developer.print.a4.html/mysuffix Resource path Selectors Extension Suffix

Resource path /content/corporate/jobs/developer.print.a4.html/mysuffix Substring before the first dot Path to the resource in JCR This part of the URL defines data. Rest defines way of the presentation.

Extension /content/corporate/jobs/developer.print.a4.html/mysuffix Defines content format Most common: html, json, xml But may be png

Selectors /content/corporate/jobs/developer.print.a4.html/mysuffix Specifies additional variants of the given content type Optional Multiple selectors are allowed

Suffix /content/corporate/jobs/developer.print.a4.html/mysuffix Additional information passed to the rendering script Similar to GET ?name=value parameter, but can be cached

Script resolution GET /content/corporate/jobs/developer.print.a4.html/mysuffix /content/corporate/jobs/developer/sling:resourceType = cognifide/hr/jobs /apps/cognifide/hr/jobs: jobs.print.a4.GET.html.esp jobs.print.a4.html.esp jobs.print.a4.esp jobs.print.GET.html.esp jobs.print.html.esp jobs.print.esp jobs.GET.html.esp jobs.html.esp jobs.GET.esp jobs.esp

Composed resources Page Left column Main <html> title Left column Main <html> <head><title><%= currentNode.getProperty(’title') %></title></head> <body> <div class=“left_column”> <sling:include path=“left” resourceType=“foundation/parsys”/> </div> <div class=“main”> <sling:include path=“main” resourceType=“foundation/parsys”/> <div> </body> </html>

Paragraph system Left column Article list Twitter widget Contact info <c:forEach var=“par” items=“${resource.children}”> <sling:include path=“${par.path}” resourceType=“${par[‘sling:resourceType’]}”/> </c:forEach>

Resource Resolver In JCR we had Node In Sling we have Resource Virtual tree of resources, reflecting the JCR ResourceResolver – transforms nodes to resources It’s possible to create own ResourceResolvers and reflect other data sources Filesystem, MongoDB, PostgreSQL Many ResourceResolvers may work together Like mount in UNIX

Resolver usage Resource res = resourceResolver.getResource(“/content/hello”); ModifiableValueMap map = res.adaptTo(ModifiableValueMap.class); String name = map.get(“name”, String.class); map.put(“name”, name.toUpperCase()); resourceResolver.commit(); Node node = res.adaptTo(javax.jcr.Node); Session = resourceResolver.adaptTo(javax.jcr.Session);

Why do we use resolver? API is friendlier than JCR Sling provides us resources and resolver in many places Servlets Scripts

Servlets Like ordinary servlets but… Can be assigned to: Paths Selectors Extensions Resource types (so can act as rendering script) doGet(), doPost() methods are invoked with SlingHttpServletRequest and …Response Additional methods for getting requested resource, resolver, decompose URL, etc.

Sample Sling servlet @Component @Service @SlingServlet(resourceTypes = ”jug/hellocomponent”) public class AuthCheckerServlet extends SlingSafeMethodsServlet { @Reference private ResourceResolverFactory resolverFactory; public void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) { response.getWriter().println(“Hello world”); }

Sling – pros and cons Similar to JCR Pros Cons Natural reflection of site and filesystem structure Document repositories, Digital Asset Management OSGi stack Javascript has easy access to repository Cons Security issues internal resources available as xml and json, handling user generated content Lack of free tools, eg. repo explorer Show CQ as demo – what page?

Q&A