Category: Crafter Rivet

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!

Personalizing and Targeting Web Content for Customer Experience Management

Posted by on August 28, 2012

Content targeting is all about getting the right content to the right user at the right time. While targeting used to be something large companies with big budgets did to make incremental improvements on transactions, it’s becoming increasingly important that organizations of all sizes start looking at content targeting.

Mobile devices have drastically changed the internet landscape, and the change they’re bringing is moving very fast as mobile use of the internet is expected to take over desktop use by 2014. And it’s not just about people visiting your sites on a different form factor, but also how they use your sites. People are online more often than ever before, but in shorter bursts for specific, immediate needs in the context of their daily activity. In order to hold the attention of this new type of Web consumer, we must speak directly to them with content that is relevant to who they are, where they are, and what they need or are doing.

So how do you tailor your website to deliver targeted content to specific audiences? Traditional approaches to handle audience specific content on websites include creating mixed audience pages with content that speaks to more than one audience on a given page, or creating stove-pipe websites where sections are dedicated to each audience, or a mixture of the two. These approaches make it difficult for users to get to the content they want and need efficiently, especially in a mobile context.

In our most recent webinar, we discussed in detail what content targeting is and how our Crafter Rivet WEM solution enables delivery of real-time, dynamic and personalized content based on visitor profiles, behavioral patterns, social graphs, and more.

To learn more, a recording of the webinar is available on our website, and the slides are available here.

Crafter Rivet & Alfresco How-To Demos

Posted by on August 02, 2012

We all know the importance of creating engaging and content-rich websites to keep up with the demands of the modern day user. New websites often need to be created quickly to satisfy a variety of business needs – new product launches, events, marketing campaigns, and more. The process should be hassle free, intuitive and user-friendly for content authors and publishers.

This is why we developed Crafter Rivet, our award-winning Web experience management application built on Alfresco 4. It provides business users with a powerful toolset for easily building rich websites.

In two recent webinars, we demonstrated some of the robust features of Crafter Rivet by showing users how to build a website from scratch with Crafter Rivet and Alfresco and how to migrate your existing website to Alfresco 4, both in just 30 minutes.

If you’re interested in seeing these demos, recordings of both webinars are available on our website, http://rivetlogic.com/resources/webcasts.