Programming Aspire is mostly about these three fundamental Java classes:
Once you know the objects above, you can start creating your own Groovy scripts. Groovy scripts are written directly into your application.xml file , using the aspire-groovy component, like this:
<component name="MyComponent" subType="default" factoryName="aspire-groovy"> <script> <![CDATA[ println "Hello World, my document looks like this:"; println doc.toXmlString(true); ]]> </script> </component>
Inside Groovy scripts, you can use the "component" variable to call any method of ComponentImpl, the "job" variable to access the current job object, and the "doc" variable (as in the example above) to access the current AspireObject.
Go to Groovy Scripting to learn more about the Groovy scripting component.
When programming new Aspire components in Java, we recommend using Eclipse and Maven. Specifically:
The version of Java you should use depends on the Aspire version you are targeting to:
Search Technologies uses subversion internally for source code control, but it's not required to program Aspire.
See Environment Setup for step-by-step details on setting up your environment.
Aspire development goes smoother if you have a Maven repository handy.
Components you develop can be deployed to your Maven repository. Once deployed, they can be used in any Aspire application simply by referring to them using their maven coordinates. This allows you to deploy and combine components from multiple sources into a single, unified content processing application.
Even better, updates to components deployed as -SNAPSHOT versions to Maven can be dynamically updated inside of an Aspire deployment, without having to restart the servers, thanks to OSGi.
So, we recommend installing a Maven repository to serve as central storage for all components that you create. Artifactory (http://www.jfrog.com/home/v_artifactory_opensource_overview) is a perfectly functional, open source repository for holding your completed components, if you don't already have a repository of your own.
Aspire is made up of a few basic Java interfaces: Component, Stage, ComponentManager (a group of components), Pipeline Manager (processes jobs through pipelines), and the Aspire Application itself.
These Java interfaces are arranged into a hierarchy like this:
You will only ever need to concern yourself with "Stage" and "Component". All of the other interfaces are fully implemented by the Aspire framework.
Each of these interfaces has an associated "Impl" class. For example, StageImpl, ComponentImpl, etc.
Most new components are pipeline stages, and all of these have the same basic structure:
public class MyComponent extends StageImpl { public void initialize(Element config) throws AspireException { . . . } public void process(Job j) throws AspireException { . . . } public void close() throws AspireException { . . . } }
Those are the only methods that you will ever need to implement.
initialize(Element config)
process(Job j)
close()
Creating new components is made much easier with a Maven archetype. This archetype will create a complete, working Java Maven project for a brand-new pipeline stage, complete with unit tests!
The stage archetype will prompt you to enter some data so it can create the stage properly. Specifically, you will be asked for:
See Creating a New Pipeline Stage for a detailed, step-by-step description for using the Stage archetype to create a new Aspire pipeline stage.