General Overview

Table of Contents

4.1. Introduction
4.1.1. Architecture Goals
4.1.2. Main concepts and design
4.2. Nuxeo 5 Architecture Overview
4.3. Nuxeo Runtime: the Nuxeo EP component model
4.3.1. The motivations for the runtime layer
4.3.2. Extensible component model
4.3.3. Flexible deployment system
4.4. Nuxeo EP layered architecture
4.4.1. Layers in Nuxeo EP
4.4.2. API and Packaging impacts
4.5. Core Layer overview
4.5.1. Features of Nuxeo Core
4.5.2. Nuxeo Core main modules
4.5.3. Schemas and document types
4.5.4. The life cycle associated with documents
4.5.5. Security model
4.5.6. Core events system
4.5.7. Query system
4.5.8. Versioning system
4.5.9. Repository and SPI Model
4.5.10. DocumentModel
4.5.11. Proxies
4.5.12. Core API
4.6. Service Layer overview
4.6.1. Role of services in Nuxeo EP architecture
4.6.2. Services implementation patterns
4.6.3. Platform API
4.6.4. Adapters
4.6.5. Some examples of Nuxeo EP services
4.7. Web presentation layer overview
4.7.1. Technology choices
4.7.2. Componentized web application

4.1. Introduction

4.1.1. Architecture Goals

When we started building Nuxeo EP, we defined several goals to achieve. Because these goals have a structural impact on Nuxeo EP platform it is important to understand them: it helps understanding the logic behind the platform.

4.1.1.1. Flexible deployment on multiple targets

An ECM platform like Nuxeo EP can be used in a lot of different cases.

The deployment of Nuxeo EP must be adapted to all these different cases:

  • Standard ECM web application

    This is the most standard use case. The web browser is used to navigate in content repositories.

    • All services are deployed on an Application server

    • In order to be easily hostable, the platform needs to be compatible with several application servers

  • Complex edition or rich media manipulation

    In this case having a rich client that seamlessly communicates with other desktop applications and offers a rich GUI is more comfortable than a simple web browser.

    • Interface is deployed on a rich client on the user desktop

    • Services and storage are handled on the server

  • Offline usage

    In some cases, it is useful to be able to manipulate and contribute content without needing a network connection.

    • GUI and some services (like a local repository) need to be deployed on the client side

    • Server hosts the collaborative services (like the workflow) and the central repository

  • Distributed architecture

    In order to be able to address the needs of large decentralized organizations, Nuxeo EP must provide a way to be deployed on several servers on several locations

    • Scale out on several servers

    • Dedicate servers to some specific services

    • Have one unique Web application accessing several decentralized repositories

  • Use Nuxeo EP components from another application

    When building a business application, it can be useful to integrate services from Nuxeo EP in order to address all content oriented needs of the application.

    • Provide web service API to access generic ECM services (including repository)

    • Provide EJB3 remoting API to access generic ECM services (including repository)

    • Provide POJO API to generic ECM services

There are certainly a lot of other use cases, but mainly the constraints are:

  • Be able to choose the deployment platform: POJO vs Java EE

    As first deployment targets we choose

    • Eclipse RCP: a rich client solution that uses a POJO (OSGi) component model

    • JBoss Application Server: a Java EE 5 compliant application server

  • Be able to choose the deployment location of each component: client side vs server side

    The idea is to be able to deploy a component on the server side or on the client side without having to change its code or its packaging

4.1.1.2. Leverage CPS experience

Before building Nuxeo EP we worked during several years on the Zope platform with the CPS solution. CPS was deployed for a lot different use cases and we learned a lot of good practices and design patterns. Although Nuxeo EP is a full rewrite of our ECM platform, we wanted to keep as many of the good CPS concepts as possible.

  • Concept of schemas and documents

    Inside CPS most of the data manipulated was represented by a document object with a structure based on schemas.

    This concept is very interesting:

    • Schemas enforce structure constraints and data integrity but also permit some flexibility.

      When defining a schema you can specify what fields are compulsory, their data types etc, but you can also define some flexible parts of the schema.

    • Share API and UI components for Documents, Users, Records ...

      Because the Document/Schema model is very flexible it can be used to manipulate different types of data: like Users, Records and standards documents.

      From the developer's perspective this permits using the same API and be able to reuse some UI components

      From the users' perspective it gives the application some consistency: because the same features and GUI can be used for all the data they manipulate.

  • Actions and Views

    Because CPS was very pluggable, it was possible to easily define different views for each document type and also to let additional components contribute new actions or views on existing documents.

    Nuxeo EP has a similar concept of views and actions, even if technically speaking the technologies are different.

  • Lazy fetching and caching

    Because ECM applications make a very intensive use of the repository and often need to fetch a lot of different documents to construct each page, the way the document retrieval is handled if very important to have a scalable application.

    With CPS we worked a lot on caching and lazy fetching.

    With Nuxeo EP we incorporated this requirement from the beginning:

    • Distributed caching

    • Lazy fetching on schemas and fields

4.1.1.3. Extensible platform based on components

CPS was constructed as a set of pluggable components relying on a common platform. This modularity has been maintained in the new platform. Deploying a new feature or component on the new platform is as simple as it was on the old one.

This requirement has a huge impact on the platform because the Java packaging model and the Java EE constraints are not directly compatible with it.

Adding a new component should be as simple as dropping a file or an archive in some directory without having to rebuild nor repackage the application.

This is important from the administrator point of view: be able to easily deploy new features.

This is also very important from the support point of view: to be able to deploy customized components without taking the risk of forking the platform, and maintaining the possibility to upgrade the standard components.

4.1.1.4. Easily accessible development framework

The CPS framework was powerful but we know it was very complex to use. Not only because of the unusual CMF/Zope/Python programming model, but also because there was a lot of different concepts and you had to understand them all to be able to leverage the platform when building a new application on top of it.

Nuxeo EP aims at simplifying the task of the developer

  • Clearly separate each layer

    The idea is to clearly separate presentation, processing and storage so that developers can concentrate on their task.

  • Offer plugin API and SPI

    Nuxeo EP is constructed as a set of plugins so you can modify the behavior of the application by just contributing a new plugin. This is simpler because for common tasks we will offer a simple plugin API and the developer just has to implement the given interface without having to understand each part of the platform.

  • Rely on JAVA standards

    We try to follow as much as possible all the Java standards when they are applicable. This will allow experienced Java developers to quickly contribute to the Nuxeo EP platform.

4.1.1.5. Leverage Java open source community

We know what it's like to have to build and maintain an entire framework starting from the application server. With the switch to the Java technology, we will use as many existing open source components as possible and focus on integrating them seamlessly into the ECM platform. Nuxeo EP is a complete integrated solution for building an ECM application, but Nuxeo won't write all infrastructure components. This approach will also make the platform more standards compliant.

Thus developers can optimize their Java/JEE and open source experience to use Nuxeo EP.

4.1.1.6. Make the platform ready for SI integration

Because ECM applications often need to be deeply integrated into the existing SI, Nuxeo EP will be easily integrable

  • API for each reusable service or component

    Depending on the components, this API could be POJO, EJB3, or WebService, and in most cases it will be available in the three formats.

  • Pluggable hooks into Nuxeo EP

    This mainly means synchronous or asynchronous events listener that are a great place to handle communication and synchronization between applications.

4.1.1.7. Future-proof design

The Nuxeo EP platform was rewritten from the ground up with the switch to Java. But we don't plan to do this kind of work every couple of years, it won't be efficient neither for us, nor for the users of the platform. For that reason, we choose innovative Java technologies like OSGi, EJB3, JSF, Seam ....

4.1.2. Main concepts and design

All the design goals explained just before have a huge impact on the Nuxeo EP architecture. Before going into more details, here are the main concepts of Nuxeo EP architecture.

4.1.2.1. Layered architecture

Nuxeo EP is built of several layers, following at least the 3 tiers standard architecture

  • Presentation layer

    Handles GUI interactions (in HTML, SWT ...)

  • Service layer

    Service stack that offers all generic ECM services like workflow, relations, annotations, record management...

  • Storage layer

    Handles all storage-oriented services like document storage, versioning, life cycle ....

Depending on the components, their complexity and the needed pluggability, there can be more than 3 layers.

This layering of all the components brings Nuxeo EP the following advantages

  • The ability to choose the deployment target for each part of a component

    By separating clearly the different parts of a feature, you can choose what part to deploy on the client and what part to deploy on a server.

  • Clear API separation

    Each layer will provide its own API stack

  • Components are easier to reuse

    Because the service and storage layers are not bound to a GUI, they are more generic and then more reusable

Thanks to this separation in component families you can easily extract from Nuxeo EP the components you need for your application.

If you need to include Document storage facilities into your application you can just use Nuxeo EP Core: It will offer you all the needed features to store, version and retrieve documents (or any structured but flexible dataset). If you also need process management and workflow you can also use Nuxeo EP Workflow service. And finally, if you want to have a Web application to browse and manage your data, you can reuse the Nuxeo EP Web layer.

4.1.2.2. Deployment services

The targeted platform does not provide the same mechanism to handle all the deployment tasks:

  • Packaging (Java EE vs OSGi)

  • Dependency management

  • Extension management

Because of these differences, Nuxeo EP provides a unified deployment service that hides the specificity of the target platform. This is also a way to add a pluggable component deployment system to some platforms that don't handle this (like Java EE).

This is one of the motivating factors for the Nuxeo Runtime that will be briefly introduced later in this document.

4.1.2.3. Extensible component model

In Nuxeo EP, an ECM application is seen as an assembly of components.

This assembly will include:

  • Existing generic Nuxeo EP Components

  • Extensions or configurations contributing to generic Nuxeo EP components

  • Specific components and configuration

Inside Nuxeo EP each feature is implemented by one or several reusable components and services. A feature may be implemented completely at storage level, or may require a dedicated service and a dedicated GUI.

Nuxeo EP Web application is a default distribution of a set of ECM components. This can be used "as is" or can be the base for making a business ECM application.

  • If you need to remove a feature

    Just remove the component or deploy a configuration for disabling it.

  • If you need to change the default behavior of one component

    You can deploy a new configuration for the component .

    • Declare a new Schema or define a document type

    • Configure the versioning policy

    • Deploy new workflow

    • ...

    This configuration may use an extension point to contribute to the new behavior (see Section 4.3.2, “Extensible component model”, Section 4.3.2.2, “Extension points” and the chapter on extension points in the Learning Nuxeo EP5 Guide. ) .

    • Contribute a new security policy

    • Contribute a new event handler

    • Deploy a new View on a document

    • ...

  • If you need to add a completely new feature you can make your own component.

    First check that there is no generic Nuxeo EP component available that could help you in your task (all components are not deployed in the default webapp).

4.1.2.4. Use of innovative Java EE technology

Here is a quick list of the Java technology we use inside Nuxeo EP platform:

  • Java 5

  • Java EE 5: JSF and EJB3

  • OSGi component model

  • A lot a innovative open source projects

    • JBoss Seam, Trinidad and Ajax4JSF on the web layer

    • jBPM for the default workflow engine implementation

    • Lucene for the default search engine implementation

    • Jackrabbit JSR-170 repository for the default storage back end implementation

    • JenaRDF for the relation framework

    • ...

4.2. Nuxeo 5 Architecture Overview

The figure below shows a high level overview of the Nuxeo 5 Architecture that will be discussed in the sections below. The sections that follow will discuss:

  1. The Nuxeo Runtime (Section 4.3, “Nuxeo Runtime: the Nuxeo EP component model”)

  2. The Nuxeo Core Layer (Section 4.5, “Core Layer overview”)

  3. The Nuxeo Service/Platform Layer (Section 4.6, “Service Layer overview”)

  4. The Web Presentation Layer ( Section 4.7, “Web presentation layer overview”) - shown in the figure as either a web interface or rich client interface implementation

4.3. Nuxeo Runtime: the Nuxeo EP component model

4.3.1. The motivations for the runtime layer

Building the Nuxeo Runtime was one of the first tasks we started. This is one of the main infrastructure components of the Nuxeo EP architecture.

This section will give you a quick overview of the Nuxeo Runtime. A more detailed technical presentation can be found in Section 28.1, “Overview” of this book.

4.3.1.1. Host platform transparency

Because most Nuxeo EP components are shared by Nuxeo RCP (OSGI/RCP) and Nuxeo EP (Java EE), an abstraction layer is required so the components can transparently use the components services independently from the underlying infrastructure.

Nuxeo Runtime provides an abstraction layer on top of the target host platform. Depending on the target host platform, this Runtime layer may be very thin.

Nuxeo Runtime already supports Equinox (Eclipse RCP OSGi layer) and JBoss 4.x (JMX). The port of Nuxeo Runtime to other Java EE application servers is in progress, we already have a part of Nuxeo EP components that can be deployed on top of SUN Glassfish application server. Technically speaking, the port of Nuxeo Runtime could be done on any JEE5 compliant platform and will be almost straightforward for any platform that supports natively the OSGi component model.

4.3.1.2. Overcome Java EE model limitations

Java EE is a great standard, but it was not designed for a component based framework: it is not modular at all.

  • Java EE deployment model limitations

    • Most Java EE deployment descriptors are monolithic

      For example, the web.xml descriptor is a unique XML file. If you want to deploy an additional component that needs to declare a new Java module you are stuck. You have to make one version of the web.xml for your custom configuration. For the Nuxeo EP platform, this constraint is not possible:

      • Components don't know each other

        Because there are a lot of optional components, we can't have a fixed configuration that fits all.

      • We can make a version of the web.xml for each possible distribution

        There are too many optional components to build one static web.xml for each possible combination.

      This problem with the web.xml is of course also true for a lot of standard descriptors (application.xml, faces-config.xml, persistence.xml, ejb-jar.xml ....)

    • One archive for one web application

      We have here the exact same problem as with the web.xml. additional components can contribute new web pages, new web components ... We can have a monolithic web archive.

    • No dependency declaration

      Inside Java EE there is no standard way to declare the dependency between components.

      Because Nuxeo EP is extensible and has a plugin model, we need that feature. A contribution is dependent on the component it contributes to:

      • Contribution is only activated if/when the target component is activated

      • The contribution must be deployed after the target component as it may override some configuration

  • Java EE component model limitations

    • Unable to deploy a new component without rebuilding the whole package

      If you take a .ear archive and want to add a new component, you have to rebuild a new ear.

    • No support for versioned components

Nuxeo Runtime provides an extensible component model that supports all these features. It also handles the deployment of these components on the target host platform.

4.3.2. Extensible component model

Nuxeo Runtime provides the component model for the platform.

This component model is heavily based on OSGi and provides the following features:

  • Platform diagnostic component model

    Can be deployed on POJO and Java EE platforms

  • Supports dependencies management

    Components explicitly declare their requirements and are deployed and activated by respecting the inferred dependency chain.

  • Includes a plugin model

    To let you easily configure and contribute to deployed components

  • A POJO test environment

    Nuxeo Runtime components can be unit tested using JUnit without the need of a specific container.

4.3.2.1. The OSGi component model

OSGi (Open Services Gateway initiative) is a great standard for components based Java architecture.

OSGi provides out of the box the following features:

  • Dependencies declaration and management

    A component gets activated only when the needed requirements are fulfilled

  • Modular deployment system

    • Manage bundles

    • Manage fragments (sub parts of a master bundle)

    • an OSGi bundle can define one or several services

  • A system to identify and lookup a component

For Nuxeo EP, the OSGi standard provides a lot of the needed features. This is the reason why Nuxeo Runtime is based on OSGi. In fact Nuxeo Runtime component model is a subset of the OSGi specification.

To ensure platform transparency, Nuxeo Runtime provides adapters for each target platform to help it support OSGi components.

  • This adapter layer is very thin on Equinox (Eclipse RCP) since the underlying platform is already OSGi compliant.

  • This adapter may be more complex for platforms that are not aware of OSGi (JBoss 4.x or Glassfish)

    In this case, the runtime adapter will handle all OSGi logic and deploy the components as native platform components. For example, on JBoss 4.x, Runtime components are deployed as JMX MBeans.

4.3.2.2. Extension points

OSGi does not define a plugin model, but the Eclipse implementation (Equinox) does provide an extension point system.

Because we found many benefits in the Eclipse Extension Point system, Nuxeo Runtime also includes an Extension Point system. In other words, the underlying mechanism which allows extension points to be implemented in Nuxeo EP, has been built into the Nuxeo EP runtime and core.

An extension point is a way to declare that your component can be customized from the outside:

  • Contribute configuration

    Activate or deactivate a component. Define resources for a given service.

  • Contribute code and behavior

    Extension points also give you the possibility to register plugins

Basically every Nuxeo Component can:

  • declare its dependencies

    The component will also be activated after all needed components have been activated

  • declare exposed extension points

    Each component can define extension points that other components can use to contribute configuration or code.

  • declare contribution to other components

Extension points and contributions to extension points are defined using a XML descriptor that has to be referenced in the MANIFEST.MF. For a more detailed understanding of extension points in Nuxeo EP, we recommend reading the Learning Nuxeo EP5 guide.

Some examples of extension point usage

Inside Nuxeo 5, extension points are used each time a behavior or a component needs to be configurable or pluggable.

Here are some examples of extension points used inside the Nuxeo 5 platform.

  • Schemas and document types

    Inside Nuxeo 5 a document structure is defined by a set of XSD schemas. Schemas and Document Types are defined using an extension point.

  • Storage repository

    Nuxeo core stores documents according to their type but independently of the low level storage back-end. The default back-end is Jackrabbit JCR implementation. Nuxeo Core exposes an extension point to define the storage back-end. We are working on another repository implementation that will be purely SQL based.

  • Security Management

    Nuxeo include a security manager that checks access rights on each single operation. The extension point system allow to have different implementation of the security manager depending on the project requirements:

    • Enforce data integrity: store security descriptors directly inside the document

    • Performance: store security descriptors in an externalized index

    • Corporate security policy: implement a specific security manager that will enforce business rules

  • Event handlers

    Nuxeo platform lets you define custom Event handler for a very large variety of events related to content or processes. The event handler extension mechanism gives a powerful way to add new behavior to an existing application

    • You can modify the behavior of the application without changing its code

    • The development model is easy because you have a very simple Interface to implement and you can use Nuxeo Core API to manipulate the data

    • Event handlers can be synchronous or asynchronous

    Nuxeo 5 itself uses the Event Handler system for a lot of generic and configurable services

    • Automatic versioning: create a new version when a document is modified according to business rules

    • Meta-data automatic update: update contributor lists, last modification date ...

    • Meta-data extraction / synchronization: extract Meta-Data from MS-Office file, Picture ....

Nuxeo 5 Platform development model

Nuxeo 5 development model is heavily based on the usage of extension points. When a project requires specific features we try as much of possible to include it as an extension of the existing framework rather than writing separated specific component. This means make existing services more generic and more configurable and implement the project specific needs as a configuration or a plugin of a generic component using Extension Points.

4.3.3. Flexible deployment system

Nuxeo Runtime also provides deployment services to manage how components are deployed and contribute to each other

  • Dependencies management

    The dependencies are declared in the MANIFEST.MF and can also be defined in XML descriptors that hold contributions.

    The Nuxeo Runtime orders the component deployment in order to be sure the dependencies are respected. Components that have unresolved dependencies are simply not deployed

  • Extension point contributions

    XML descriptors are referenced in the MANIFEST.MF. These descriptors make contributions to existing extension points or declare new extension points.

  • Each component has its own deployment-fragment

    The deployment fragment defines

    • Contribution to configuration files

      For example contribute a navigation rule to faces-config.xml or a module declaration to web.xml.

      Nuxeo Runtime lets you declare template files (like web.xml, persistence.xml) and lets other components contribute to these files.

    • Installation instructions

      Some resources contributions (like i18n files or web pages) need more complex installation instructions because they need archives and file manipulations. Nuxeo Runtime provide basic commands to define how your components should be deployed

Here is a simple example of a deployment-fragment.

<fragment>
  <extension target="application#MODULE">
    <module> <ejb>${bundle.fileName}</ejb> </module>
  </extension>
  <extension target="faces-config#VALIDATOR">
    <validator>
      <validator-id>dueDateValidator</validator-id>
      <validator-class>org.nuxeo.ecm.platform.workflow.web.ui.jsf.DueDateValidator</validator-class>
    </validator>
  </extension>
  <install>
    <!-- unzip the war template -->
    <unzip from="${bundle.fileName}" to="/">
      <include>nuxeo.war/**</include>
    </unzip>
    <!-- create a temp dir -->
    <!-- be sure no directory with that name exists -->
    <delete path="nxworkflow-client.tmp" />
    <mkdir path="nxworkflow-client.tmp" />
    <unzip from="${bundle.fileName}" to="nxworkflow-client.tmp">
      <include>OSGI-INF/l10n/**</include>
    </unzip>
    <append from="nxworkflow-client.tmp/OSGI-INF/l10n/messages.properties"
               to="nuxeo.war/WEB-INF/classes/messages.properties" addNewLine="true" />
    <append from="nxworkflow-client.tmp/OSGI-INF/l10n/messages_en.properties"
               to="nuxeo.war/WEB-INF/classes/messages_en.properties" addNewLine="true" />
    <append from="nxworkflow-client.tmp/OSGI-INF/l10n/messages_fr.properties"
               to="nuxeo.war/WEB-INF/classes/messages_fr.properties" addNewLine="true" />
    <append from="nxworkflow-client.tmp/OSGI-INF/l10n/messages_de.properties"
               to="nuxeo.war/WEB-INF/classes/messages_de.properties" addNewLine="true" />
    <append from="nxworkflow-client.tmp/OSGI-INF/l10n/messages_it.properties"
               to="nuxeo.war/WEB-INF/classes/messages_it.properties" addNewLine="true" />
    <delete path="nxworkflow-client.tmp" />
  </install>
</fragment> 

4.4. Nuxeo EP layered architecture

4.4.1. Layers in Nuxeo EP

Nuxeo EP components are separated in 3 main layers: Core / Service / UI

From the logical point of view each layer is a group of components that provide the same nature of service:

  • Storage oriented services: Nuxeo Core

    Nuxeo core provides all the storage services for managing documents

    • Repository service

    • Versioning service

    • Security service

    • Lifecycle service

    • Records storage (directories)

    • ...

  • Content and process oriented services: Nuxeo Platform

    Nuxeo provides a stack of generic services that handle documents and provide content and process management features. Depending on the project requirement only a part of the existing services can be deployed.

    Typical Nuxeo EP platform services are:

    • Workflow management service

    • Relation management service

    • Archive management service

    • Notification service

    • ...

  • Presentation service: UI Layer

    The UI layer is responsible for providing presentation services like

    • Displaying a view of a document

    • Displaying available actions according to context

    • Managing page flow on a process driven operation

    These services can be very generic (like the action manager) but can also be directly tied to a type of client (like the View generation can be bound to JSF/facelets for the web implementation)

The layer organization can also be seen as a deployment strategy

Thanks to the Nuxeo Runtime remoting features it is very easy to split the components on several JVMs. But splitting some services can have a very bad effect on the global system performance.

Because of this, all the storage oriented services are inside the core. All components that have extensive usage of the repository and need multiple synchronous interaction with it are located in the core. This is especially true for all synchronous event handlers.

The services layer can itself be split in multiple deployment units on multiple JVMs.

On the UI side all the services are logically deployed inside the same JVM. At least each JVM must have the minimum set of services to handle user interaction for the given application.

The components are also grouped by layers according to their dependencies.

Core Modules can depend on Core Internal API.

Generic ECM services can depend on Core external API and can depend on external optional library (like jBPM, Jena, OpenOffice.org ...).

UI services can rely on a client side API (like Servlet API) and share a common state associated to the user session.

Layers are also organized according to deployment target.

The Core layer is a POJO Layer with an optional EJB facade. The core can be embedded in a client application.

The services are mostly implemented as POJO services so that they can be used as an embedded library. But some of them can depend on typical Application Server infrastructure (like JMS or EJB).

Inside the UI Layer most services are dedicated to a target platform: web (JSF/Seam), Eclipse RCP or other.

Because the layer organization has several constraints, the implementation of a unique feature is spread across several layers.

Typically a lot of these "transverse services" are split into several sub-components in each layer in order to comply with deployment constraints and also to provide better reusability. For example, the Audit service is made of 3 main parts which are split across 3 layers:

  • Core Event <=> JMS bridge (Core Layer)

    Forwards core events to JMS Bridge according to configuration.

  • JMS Listener and JPA Logger (Service Layer)

    Message driven bean that writes logs in DB via JPA.

  • Audit View (UI Layer)

    Generates HTML fragment that displays all events that occurred on a document.

4.4.2. API and Packaging impacts

The layer organization can also be seen in the API.

4.4.2.1. Core API

Most of the components forming the core are exposed via the DocumentManager / CoreSession interface. The interfaces and dependencies needed to access the Core services are packaged in an API package: even if there are several Core components, you have only one dependency and API package.

The idea is that for accessing the core, you will only need to use the DocumentManager to manipulate DocumentModels (the document object artifact). Some core services can be directly accessed via the DocumentModel (like the life cycle or security data).

4.4.2.2. Service Stack API

Each service exposes its own API and then has its own API package. Service related data (like process data, relation data) are not directly hosted by the DocumentModel object but can be associated to it via adapters and facets.

4.4.2.3. UI API

The web layer can be very specific to the target application. Nuxeo EP provides a default web application and a set of base classes, utility classes and pluggable services to handle web navigation inside the content repository.

4.4.2.4. Packaging

Most features are made of several Java projects and generate several Maven 2 artifacts.

Nuxeo packaging and deployment system (Nuxeo Runtime, Platform API, Maven ...) leverage this separation to help you distributing the needed deployment unit according to your target physical platform.

4.5. Core Layer overview

4.5.1. Features of Nuxeo Core

Nuxeo core provides all the storage services for managing documents.

  • Schema service

    Lets you register XSD schemas and document types based on schemas.

  • Repository service

    Lets you define one or more repository for storing your documents.

  • Versioning service

    Lets you configure how to store versions.

  • Security service

    Manages data level security checks

  • Lifecycle service

    Manages life cycle state of each document

4.5.2. Nuxeo Core main modules

4.5.2.1. Nuxeo Repository Service

The repository service lets you define new document repositories. Defining separate repositories for your documents is pretty much like defining separate Databases for your records.

Because Nuxeo Core defines an SPI on repository, you can configure how you want the repository to be implemented. For now, the default implementation uses JSR-170 (Java Content Repository) reference implementation: Apache Jack Rabbit. In the future, we may provide other implementations of the Repository SPI (like native SQL DB or Object Oriented DB).

Even if for now there is only one Repository implementation available, using JCR implementation, you can configure how your data will be persisted: filesystem, xml or SQL Database. Please see "How to"s about repository configuration (Chapter 43, RDBMS Storage and Database Configuration).

When defining a new repository, you can configure:

  • The name.

  • The configuration file

    For JCR, it lets you define persistence manager.

  • The security manager

    Defines how security descriptors are stored in the repository (for now: org.nuxeo.ecm.core.repository.jcr.JCRSecurityManager)

  • The repository factory

    Defines how the repository is created (for now: org.nuxeo.ecm.core.repository.jcr.JCRRepositoryFactory)

4.5.3. Schemas and document types

The repository enforces data integrity and consistency based on Document types definition.

Each document type is defined by:

  • A name.

  • An optional super document type (inheritance)

  • A list of XSD schemas

    Defines storage structure

  • A list of facets

    Simple markers used to define document behavior.

Here is a simple DocumentType declaration:

<extension target="org.nuxeo.ecm.core.schema.TypeService"
    point="doctype">
    <documentation>The core document types</documentation>
    <doctype name="Folder" extends="Document">
      <schema name="common" />
      <schema name="dublincore" />
      <facet name="Folderish" />
    </doctype>
    </extension>

For further explanation on Schemas and Document types, please see Chapter 5, Schemas and Documents.

4.5.4. The life cycle associated with documents

Inside the Nuxeo repository each document may be associated with a life-cycle. The life-cycle defines the states a document may have and the possible transitions between these states. Here we are not talking about workflow or process, rather we are just defining the possible states of a document inside the system.

The Nuxeo Core contains a LifeCycleManager service that exposes several extension points:

  • one for contribution to the Life-Cycle management engine

    (the default one is called JCRLifeCycleManager and stores life-cycle related information directly inside the JSR 170 repository)

  • one for contributing life-cycle definition

    This includes states and transitions. On 5.2, since 5.2.0, it is possible to define additional initial states to the default state, by adding a keyword to the state definition, for instance: <state name="approved" description="Content has been validated" initial="true">. The desired initial state can be passed in the document model context data used for creation: document.putContextData("initialLifecycleState", "approved").

  • one for binding life-cycle to document-types

    Here is an example

    <lifecycle name="default" lifecyclemanager="jcrlifecyclemanager"
      initial="project">
    
      <transitions>
        <transition name="approve" destinationState="approved">
          <description>Approve the content</description>
        </transition>
        <transition name="obsolete" destinationState="obsolete">
          <description>Content becomes obsolete</description>
        </transition>
        <transition name="delete" destinationState="deleted">
          <description>Move document to trash (temporary delete)</description>
        </transition>
        <transition name="undelete" destinationState="project">
          <description>Recover the document from trash</description>
        </transition>
        <transition name="backToProject" destinationState="project">
          <description>Recover the document from trash</description>
        </transition>
      </transitions>
    
      <states>
        <state name="project" description="Default state">
          <transitions>
            <transition>approve</transition>
            <transition>obsolete</transition>
            <transition>delete</transition>
          </transitions>
        </state>
        <state name="approved" description="Content has been validated">
          <transitions>
            <transition>delete</transition>
            <transition>backToProject</transition>
          </transitions>
        </state>
        <state name="obsolete" description="Content is obsolete">
          <transitions>
            <transition>delete</transition>
            <transition>backToProject</transition>
          </transitions>
        </state>
        <state name="deleted" description="Document is deleted">
          <transitions>
            <transition>undelete</transition>
          </transitions>
        </state>
      </states>
    
    </lifecycle>
    

Life-Cycle service is detailed later in this document (Section 29.4.5, “Life Cycle” and Section 29.5.2, “LifeCycle Managers”).

4.5.5. Security model

Note: You may also want to read the chapter on "Access Control and Security" in the Learning Nuxeo EP5 Guide.

Inside the Nuxeo Repository security is always checked when accessing a document.

The Nuxeo security model includes :

  • Permissions

    (Read, Write, AddChildren, ...).

    Permissions management is hierarchical (there are groups of permissions)

  • ACE: Access Control Entry

    An ACE grants or denies a permission to a user or a group of users.

  • ACL: Access Control List

    An ACL is a list of ACEs.

  • ACP: Access Control Policy

    An ACP is a stack of ACLs. We use ACP because security can be bound to multiples rules: there can be a static ACL, an ACL that is driven by the workflow, and another one that is driven by business rules.

    Separating ACLs allows us to easily reset the ACP when a process or a rules does not apply any more.

Inside the repository each single document can have an ACP. By default security descriptors are inherited from their parent, but inheritance can be blocked when needed.

The security engine also lets you contribute custom policy services so that security management can include business rules.

The security model and policy service are described in detail later in this document.

4.5.6. Core events system

When an event occurs inside the repository (document creation, document modification, etc...), an event is sent to the event service that dispatches the notification to its listeners. Listeners can perform any number of actions when receiving an event, which may include modifying the document on the fly.

As an example, part of the dublincore management logic is implemented as a CoreEvent listener: whenever a document is created or modified, the "creation date", "modification date", "author" and "contributors" fields are automatically updated by a CoreEvent Listener.

The Core Events system is explained in more detail later in this document (see Chapter 31, Nuxeo Event Service and Chapter 9, Event Listeners and Scheduling) and in the Learning Nuxeo EP5 guide.

4.5.7. Query system

The Repository supports a Query API to extract Documents using SQL like queries.

NXQL (the associated Query Language) is presented later in this document (see Example 11.2, “Sample NXQL queries”).

4.5.8. Versioning system

The documents in the repository can be versioned.

Nuxeo Core provides:

  • A pluggable version storage manager

    This lets you define how versions are stored and what operations can be done on versions

  • A pluggable versioning policy

    This lets you define rules and logic that drive when new versions must be created and how version numbers are incremented.

The versioning system is explained in details later in this document (see Chapter 16, Document Versioning).

4.5.9. Repository and SPI Model

Nuxeo Core exposes a repository API on top of Jackrabbit JSR170 repository.

Nuxeo repository is implemented using an SPI and extension point model: this basically means that a non JCR based repository plugin can be contributed. In fact, we have already started a native SQL repository implementation (that is not yet finished because we have no direct requirement for such a repository).

Nuxeo core can server several repository: it provides a extension point to declare an additional repository: this means a single web application can use several document repositories.

4.5.10. DocumentModel

Inside Nuxeo EP and especially inside the Core API the main data object is a Document.

Inside Nuxeo Core API, the object artifact used to represent a Document is called a DocumentModel.

The DocumentModel artifact encapsulates several useful features:

  • Data Access over the network

    the DocumentModel encapsulates all access to a Document's internal fields, and the DocumentModel can be sent over the network

  • DocumentModel supports lazy loading

    When fetched from the Core, a DocumentModel does not carry all document related information. Some data (called prefetch data) are always present, other data will be loaded (locally or remotely) from the core when needed.

    This feature is very important to reduce network and disk I/O when manipulating a Document that contains a lot of big blob files (like video, music, images ...) .

  • DocumentModel uses Core Streaming Service

    For files above 1 MB the DocumentModel uses the Core Streaming service.

  • DocumentModel carries the security descriptors

    ACE/ACL/ACP are embedded inside the DocumentModel

  • DocumentModels support an adapter service

    In addition to the data oriented interface, a DocumentModel can be associated with one or more Adapters that will expose a business oriented interface.

  • DocumentModels embed lifecycle service access

  • DocumentModels can have facets

    Facets are used to declare a behavior (Versionnable, HiddenInNavigation, Commentable...)

A DocumentModel can be located inside the repository using a DocumentRef. DocumentRef can be an IdRef (UUID in the case of the JCR Repository Implementation) or PathRef (absolute path).

DocumentModels also hold information about the Type of the Document and a set of flags to define some useful characteristics of the Document:

  • isFolder

    Defines if the targeted document is a container

  • isVersion

    Defines if the targeted document is an historic version

  • isProxy

    Defines if the targeted document is a Proxy (see below)

4.5.11. Proxies

A Proxy is a DocumentModel that points to a another one: very much like a symbolic link between 2 files.

Proxies are used when the same document must be accessible from several locations (paths) in the repository. This is typically the case when doing publishing: the same document can be visible in several sections (note: 'section' here has a special meaning as defined in the Nuxeo User Guide). In order to avoid duplicating the data, we use proxies that point to same document.

A proxy can point to a checked out document (not yet associated to a version label) or to a versioned version (typical use-case of publishing).

The proxy does not store document data: all data access are forwarded to the source document. But the Proxy does holds:

  • its own security descriptors

  • its own DocumentRef

4.5.12. Core API

TO DO

4.6. Service Layer overview

4.6.1. Role of services in Nuxeo EP architecture

The service layer is an ECM services stack on top of the Nuxeo Repository. In a sense, the Repository itself is very much like any service of this layer, it just plays a central role.

This service layer is used for :

  • adding new generic ECM services (Workflow, Relations, Audit ...)

  • adding connectors to existing external services

  • adding dedicated project-specific components when the requirements can not be integrated into a generic component

This service layer provides the API used by client applications (Webapp or RCP based applications) to do their work.

This means that in this layer, services don't care about UI, navigation or pageflows: they simply explore an API to achieve document oriented tasks.

4.6.2. Services implementation patterns

Nuxeo platform provides a lot of different services, but they all fellow the same implementation pattern. This basically means that once you understand how works one service, you almost know how they all work.

As with everything in the Nuxeo Platform the services use the Nuxeo Runtime component model.

A generic service will be composed of the following packages :

  • An API package (usually called nuxeo-platform-XXX-api)

    Contains all interfaces and remotable objects.

    This package is required to be able to call the service from the same JVM or from a remote JVM.

    You can view these in your Nuxeo server installation directory if you are curious (/nuxeo/server/default/deploy/nuxeo.ear/system/ - assuming you have your server installed in /nuxeo).

  • A POJO Runtime component (usually called nuxeo-platform-XXX-core)

    The Runtime component will implement the service business logic (ie: implement the API) and also expose Extensions Points.

    All the extensibility and pluggability is handled at runtime component level. This for example means that the API can be partially implemented via plugins.

  • A EJB3 Facade (usually called nuxeo-platform-XXX-facade)

    The facade exposes the same API as the POJO component.

    The target of this facade is to:

    • provide EJB3 remoting access to the API

    • integrate the service into JEE managed environment (JTA and JAAS)

    • leverage some additional features of the application server like JMS and Message Driven Bean

    • provide state management via Stateful Session Beans when needed

Typically, the POJO module will be a Nuxeo Runtime Component that inherits from DefaultComponent, provides extension points and implements a Service Interface.

public class RelationService extends DefaultComponent 
      implements RelationManager { ...}

The deployment descriptor associated with the component will register the component, declare it as service provider and it may also declare extension points

<?xml version="1.0"?>
<component name="org.nuxeo.ecm.platform.relations.services.RelationService">
  <implementation class="org.nuxeo.ecm.platform.relations.services.RelationService" />
  <service>
    <provide interface="org.nuxeo.ecm.platform.relations.api.RelationManager" />
  </service>
  <!-- declare here extension points -->
</component>      

The facade will declare an EJB that implements the same service interface. In simple cases, the implementation simply delegates calls to the POJO component.

The facade package will also contain a contribution to the Runtime Service management to declare the service implementation.

<?xml version="1.0" encoding="UTF-8"?>
<component name="org.nuxeo.ecm.platform.relation.service.binding.contrib">
  <extension target="org.nuxeo.runtime.api.ServiceManagement" point="services">
      <documentation> Define the Relation bean as a platform service. </documentation>
      <service class="org.nuxeo.ecm.platform.relations.api.RelationManager" group="platform/relations">
        <locator>%RelationManagerBean</locator>
      </service>
    </extension>
</component>

Thanks to this declaration the POJO and the EJB Facade can now be used for providing the same interface based on a configuration of the framework and not on the client code.

This configuration is used when deploying Nuxeo components on several servers: platform configuration provides a way to define service groups and to bind them together on physical servers.

4.6.3. Platform API

Each service provides its own API composed of a main interface and of the other interfaces and types that can be accessed.

The API package is unique for a given service, and access to a remote EJB3 based service is the same as accessing the POJO service.

From the client point of view, accessing a service is very simple and independent from service location and implementation: this means a manual JNDI call is not required. Everything that is needed is encapsulated in the Framework.getService runtime API.

RelationManager rm = Framework.getService(RelationManager.class);

The framework.getService will return the interface of the required service:

  • This can be the POJO service (ie: Runtime Component based Service)

  • This can be the local interface of the EJB3 service (using call by ref in JBoss)

  • This can be the remote interface of the EJB3 service (using full network marshalling)

The choice of the implementation to return is left to the Nuxeo Runtime that will take the decision based on the platform configuration.

The client can explicitly ask for the POJO service via the Framework.getLocalService() API: this is typically used in the EJB Facade to delegate calls to the POJO implementation.

4.6.4. Adapters

DocumentModel adapters are a way to adapt the DocumentModel interface (that is purely data oriented) to a more business logic oriented interface.

In the pure Service logic, adding a comment to a document would look like this:

CommentManager cm = Framework.getService(CommentManager.class);
cm.createComment(doc,"my comment");
List<DocumentModel> comments = cm.getComments(doc);

DocumentModel adapters give the possibility to have a more object oriented API:

CommentableDoc cDoc = doc.getAdapter(CommentableDoc);
cDoc.addComment("my comment");
List<DocumentModel> comments = cDoc.getComments();

The difference may seem small, but DocumentModel adapter can be very handy

  • to have cleaner and clearer code

  • to handle caching at the DocumentModel level

  • to implement behavior and logic associating a Document with a Service

DocumenModelAdapters are declared using an extension point that defines the interface provided by the adapter and the factory class. DocumentModelAdapters can be associated to a Facet of the DocumentModel.

4.6.5. Some examples of Nuxeo EP services

TO DO

4.7. Web presentation layer overview

4.7.1. Technology choices

4.7.1.1. Requirements

The requirements for the Nuxeo Web Framework are :

  • A Powerful templating system that supports composition

  • A modern MVC model that provides Widgets, Validators and Controllers

  • A standard framework

  • A set of Widget libraries that allow reusing existing components

  • Support for AJAX integration

4.7.1.2. The JSF/Facelets/Seam choice

Nuxeo Web Layer uses JSF (SUN RI 1.2) and Facelets as presentation layer: JSF is standard and very pluggable, Facelets is much more flexible and adapted to JSF than JSP.

NXThemes provides a flexible Theme and composition engine based on JSF and Facelets.

In the 5.1 version of the platform, Nuxeo Web Layer uses Apache Tomahawk and trinidad as a components library and AJAX4JSF for Ajax integration. In the 5.2 version we will move to Rich Faces.

Nuxeo Web Layer also uses Seam Web Framework to handle all the ActionListeners.

Using Seam provides :

  • Simplification and help with JSF usage

  • A context management framework

  • Dependency injection

  • Remoting to access ActionsListeners from JavaScript

  • A built-in event system

4.7.2. Componentized web application

4.7.2.1. Requirements

Nuxeo Web Layer comes on top of a set of pluggable services.

Because this stack of services is very modular, the web layer must also be modular.

This basically means that depending on the set of deployed services and on the configuration, the web framework must provide a way

  • to add, remove or customize views

    for example, if you don't need relations, you may want to remove the relations tab that is available on document by default

  • to add or remove an action button or link

    the typical use case is removing actions that are bound to non-deployed services or to add new actions that are specific to your project

  • to override an action listener

    you may want to change how some actions are handled by just overriding Nuxeo defaults

  • to add or customize forms

    Adding fields or customizing forms used to display documents is very useful

In order to fullfill these requirements, the key points of Nuxeo Web Frame fulfill:

  • Context management to let components share some state

  • Event system and dependency injection to let loosely coupled components collaborate

  • A deployment system to let several components make one unique WebApp

  • A set of pluggable services to configure the web application

4.7.2.2. Context management

Inside the web framework, each component will need to know at least

  • the current navigation context

    This includes current document, current container, current Workspace, current Domain.

    This information is necessary because most of the services will display a view on the current document, and can fetch some configuration from the content hierarchy.

  • the current user

    This includes not only identity and roles, but also its preferences and the set of documents they choose to work on

In some cases, this context information may be huge, and it's time consuming to recompute all this information for each request.

Inside Nuxeo Web Framework, Seam context management is used to store this data. Depending on the lifecycle of the data, Session, Conversation or Event context are used.

4.7.2.3. Loosely coupled component

At some point the components of the web framework need to interact with each other. But because components can be present or not depending on the deployment scenario, they can't call each other directly.

For that matter, the Nuxeo Web Framework uses a lot of Seam features:

  • Seam's context is used to share some state between the components

  • Seam's event system is used to let components notify each other

  • Seam's dependency injection and Factory system is used to let components pull some data from each other without having to know each other

In order to facilitate Nuxeo Services integration into the web framework, we use the Seam Unwrap pattern to wrap a Nuxeo Service into Seam Components that can be injected and manipulated as a standard Seam component.

4.7.2.4. Deployment

The Web Layer is composed of several components.

The main components are webapp-core (default webapp base) and ui-web (web framework). On top of these base components, dedicated web components are deployed for each specific service.

For example, the workflow-service has its own web components package, so do relation-service, audit-service, comment-service and so on.

Each package contains a set of views, actions, and ActionsListeners that are dedicated to one service and integrate this service into the base webapp.

Because JEE standards require the webapp to be monolithic (ie. it cannot be split up), we use the Nuxeo Runtime deployment service to assemble the target webapp at deployment time.

This deployment framework let you: override resources, contribute XML descriptors like web.xml from several components and manage deployment order.

4.7.2.5. Key web framework services

TO DO