Category: Training

Attend Complimentary Crafter CMS Training at Alfresco Summit

Posted by on October 15, 2013

Crafter Software is pleased to offer complimentary Crafter CMS training!

Learn the basics of Crafter CMS for web content and web experience management in a single day class hosted on the day prior to the Alfresco Summit.

You will learn about:

  • Crafter CMS Architecture
  • Content type management and template construction
  • Creating dynamic and targeted experiences

Trainees will be required to bring their own machine (Windows or OSX).
Software, training and lab materials will be provided by the instructor.

Trainee skills should include:

  • Basic understanding of WCM concepts: content types, templates
  • Basic HTML, CSS, JavaScript

Helpful if Trainees have:

  • A background in Alfresco
  • Understanding of basic operating system concepts
  • Ability to code and compile Java (some advanced labs will required coding.)

Request your training today.  Space is limited and registrations will be granted on a first-come, first-serve basis!

Sign up for Barcelona

Sign up for Boston

 

Extending Crafter Engine with Java backed functionality

Posted by on October 06, 2012

Crafter Engine is the high-performance website / web app delivery engine for Crafter Rivet Web Experience Management. Out of the box Crafter Engine ships with support for many of the types of engaging functionality you have come to expect from a WCM/WEM platform.  However, there are times when we want to add additional capabilities to integrate with internal and 3rd party systems to meet specific business objectives.  In this article we’ll demonstrate how you can create Java backed plug-ins for Crafter Engine.

To illustrate the integration process we’ll integrate a simple RSS reader based on the ROME RSS processing library
You can download this example (and others) at the following SVN location: https://svn.rivetlogic.com/repos/crafter-community/ext/engine

To begin let’s start with some background on Crafter Rivet, Crafter Engine and how a plug-in is organized structurally:

Crafter Rivet

Crafter Rivet is web experience management solution based on the Alfresco Content Management platform with a de-coupled architecture.  This means that the authoring environment and the production delivery environment are separate infrastructure integrated by workflow and deployment from authoring to delivery.  Crafter Rivet components power some of the internet’s largest websites.  A decouple architecture makes things easier to support, more flexible and very scalable.

Crafter Engine

Crafter Engine owes its performance characteristics to its simplicity.  Content is stored on disk and is served from memory.  Dynamic support is backed by Apache Solr. At the heart of Crafter Engine is Spring MVC, a simple, high performance application framework based on one of the world’s most popular technologies: Spring framework.

What is a Crafter Engine Plug-in

A Crafter Plug-in is a mechanism for extending the core capabilities of Crafter Engine, the delivery component of Crafter Rivet. Plug-ins allow you to add additional services and make them available to your template / presentation layer.

An example plug-in as we suggested above might be an XML reader which would function as specified below:

  • The plugin would expose a in-process Java based service like Feed RssReaderService.getFeed(String url)
  • Your your presentation templates would then simply call <#assign feedItems = RssReaderService.getFeed(“blogs.rivetlogic.com”) />

Anatomy of a Crafter Engine Plug-in

You will note from the diagram above that plug-ins are simple JAR files that contain both Java code, configuration and an Spring bean factory XML file that loads and registers the services with Crafter Engine.

Loading the plug-in

1. When the container loads the Crafter Engine WAR the shared classes lib folder is included in the class path.

2. When the Crafter Engine WAR starts up it will scan the class path for its own spring files and any available plug-ins. At this time the services described in the Spring bean XML file with in your plug-in will be loaded. Your service interfaces are now available in the presentation layer.

Interacting with your service

A. The user makes a request for a given URL

B. Crafter Engine will load all of the content descriptors from disk for the page and components needed to render the specific URL. Once the descriptors are loaded the templates for the page and components will loaded from disk.

C. The templates may now call your service interfaces to render from and interact with your back-end code. Your Java backed service may then do whatever it was intended to do, returning the results to the template for processing. Once complete, the responses are then returned to the user in the form of a rendered web page.

A simple Example

Now that we have a bit of background, let’s get down to the nuts and bolts of the matter and build, install and configure our RSS reader integration.

The Java Service

/**
 * Reads a RSS or Atom feed from a specified URL and returns a data structure that can be accessed from a template.
 */
public class RssReaderService {

    public SyndFeed getFeed(String url) throws IOException, FeedException {
        SyndFeedInput input = new SyndFeedInput();
        XmlReader reader = new XmlReader(new URL(url));

        try {
            return input.build(reader);
        } finally {
            try {
                reader.close();
            } catch (IOException err) {
                // handle error
            }
        }
    }
}

The Configuration

/crafter/engine/extension/services-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">

    <bean id="rssReaderService" class="org.rivetlogic.crafter.engine.rss.RssReaderService" />
</beans>

Packaging and Install

The compiled class and spring configuration file must be found in the class path.  To facilitate this we build these objects and their dependencies in to a single JAR file.  You can find the build process for these at the SVN location above.  Place the JAR file that is produced by the build process in to your shared class path for example: /TOMCAT-HOME/shared/lib and restart the application.

Now that you have restarted the application your service is available to your presentation layer.  This means that in any template you can now add the following:

<#assign feedItems = RssReaderService.getFeed(“blogs.rivetlogic.com”) />

Using the Plug-in:

Web Ninja: Create a RSS Feed Component for Authors

Create a new content type as a component:

Create a template for the RSS Widget by clicking on the type canvas and editing the template property:

Author: create and configure a RSS Component

Modify the component properties through the content type form:

And insert the widget in to a web page:

Save and close and the configured component is now showing on your web page!