Nuxeo WebEngine: a practical introduction

22
Nuxeo WebEngine Nuxeo WebEngine a practical introduction a practical introduction Bogdan Stefanescu |

description

This tutorial introduces the main concepts behind Nuxeo WebEngine, a new agile Web framework recently introduced by Nuxeo and present interactively how one can quickly develop a simple application.

Transcript of Nuxeo WebEngine: a practical introduction

Page 1: Nuxeo WebEngine: a practical introduction

Nuxeo WebEngineNuxeo WebEnginea practical introductiona practical introduction

Bogdan Stefanescu |

Page 2: Nuxeo WebEngine: a practical introduction

Overview

● What is WebEngine?● Architecture

● JAX-RS● Object Model● Scripting● Templates

Page 3: Nuxeo WebEngine: a practical introduction

Overview

● Examples● Creating a JAX-RS resource● Creating a Web Module● Working with Web Objects● Working with Web Adapters● Managing Links● Internationalization

Page 4: Nuxeo WebEngine: a practical introduction

WebEngine – What Is?

A framework to build RESTful Web Applications on top of the Nuxeo Platform. Goals:● Rapid development of Web Applications: intuitive

and extensible model, scripting, fast startup time, hot reload etc.

● An unique platform to develop all kind of content oriented Web Applications including – Content oriented Web sites.– REST services for Nuxeo Platform.– Rich front ends based on AJAX frameworks like GWT.

● Pleasant coding experience● Light packaging

Page 5: Nuxeo WebEngine: a practical introduction

WebEngine - Features

● Powerful Object Model built on top of JAX-RS.● Full Groovy Scripting support.● Powerful template engine based on Freemarker● Content Management through Nuxeo Platform● Packaged in several flavors:

● Standalone server with GlassFish v3 embedded● Standalone server with Jetty embedded● Tomcat Web Application● Nuxeo EP plug-ins

Page 6: Nuxeo WebEngine: a practical introduction

Architecture - JAX-RS

● WebEngine model is based on JAX-RS standard.

● JAX-RS is a Java API to build RESTful Web Services.

● JAX-RS is exposing Java objects as Web resources. Binging objects to Web resources is done by using Java annotations.

● HTTP requests will be resolved to JAX-RS resources that will be manipulated using common HTTP methods like GET, POST, PUT, DELETE, HEAD.

Page 7: Nuxeo WebEngine: a practical introduction

Architecture – Object Model

● Why an Object Model on top of JAX-RS?● Provides a coherent model to build modular

applications.● An Web Application is deployed as an Web Module.● Web Modules can extend other Web Modules.● Web Modules are bound to a fixed Web path and

provides access to Web Resources defined inside the module or in extended modules.

● Web Resources are extensible and can be shared between modules.

Page 8: Nuxeo WebEngine: a practical introduction

Architecture – Object Model

● Why an Object Model on top of JAX-RS?● Provides a coherent model to expose Java

Objects as Web Resources.● Web Module Entry Point – the root resource that is

the entry point for any request on the module. It is explicitly bound to a Web path using @Path annotation.

● Web Objects – sub-resources that are exposing concrete functionality.

● Web Adapters – sub-resources that enable to easily extends existing Web Objects.

Page 9: Nuxeo WebEngine: a practical introduction

Architecture – Web Modules

● An Web Module is defining:● Web Resources and templates to expose.● Static and i18n resources (CSS, PNG etc)● An Web Path under which the module

resources can be found● A JAX-RS root resource – which will usually

dispatch any request to sub-resources like Web Objects and Web Adapters

● Inherited Web Modules

Page 10: Nuxeo WebEngine: a practical introduction

Architecture – Web Objects

● Web Objects are JAX-RS resources that expose concrete objects to the Web.

● Web Objects have a type and a set of optional facets.

● Web Object types can be derived to create new types that inherit behaviors from the super type.

● Facets describes the Web Object behaviors.● Web Objects may define views using template

files.

Page 11: Nuxeo WebEngine: a practical introduction

Architecture – Web Adapters

● Web Adapters are JAX-RS resources that can be used to expose additional functionalities on existing Web Objects.

● Is a specialized Web Object and have a type and optional facets like any other Web Object.

● Can be restricted to adapt only specific Web Objects by using filters based on target Web Object type and facets.

● Are invoked using a @ prefix● Example: GET /my/doc/@versions

Page 12: Nuxeo WebEngine: a practical introduction

Architecture – Documents

● WebEngine is providing built-in support to expose Nuxeo Documents as Web Objects.

● Document Types are mapped to Web Objects by respecting the document type hierarchy.● Provides a generic Document Object that will catch

any document type which is not explicitly exposed.

● Document types and facets are transparently mapped as Web Object type and facets.

● Several Web Adapters are provided: Versioning Adapter, Lock Adapter, Relations Adapter etc.

Page 13: Nuxeo WebEngine: a practical introduction

Architecture – Scripting

● Built-in Groovy scripting.● Any Web Resource can be defined as a Groovy

object.● Java and Groovy share the same Class Path.

● One can build mixed Web Modules with both Groovy and Java objects.

● A Groovy object may call or extend any Java object and vice-versa.

● Hot reload of Groovy classes in debug mode.

Page 14: Nuxeo WebEngine: a practical introduction

Architecture - Templates

● The template engine is building client responses using template files.

● Based on Freemarker engine.● Custom extensions to add dynamic blocks, Wiki

rendering etc.● Dynamic Blocks are used to create extensible

templates.● Templates that define dynamic blocks may e

extended by other templates that may redefine any block.

Page 15: Nuxeo WebEngine: a practical introduction

Examples – JAX-RS

Page 16: Nuxeo WebEngine: a practical introduction

Examples – Web Module

Page 17: Nuxeo WebEngine: a practical introduction

Examples – Web Object

Page 18: Nuxeo WebEngine: a practical introduction

Examples – Web Adapter

Page 19: Nuxeo WebEngine: a practical introduction

Examples – Templates

Page 20: Nuxeo WebEngine: a practical introduction

Examples – Links

Page 21: Nuxeo WebEngine: a practical introduction

Examples – Internationalization

Page 22: Nuxeo WebEngine: a practical introduction

Thank you!Thank you!