Changes to Components Required for 0.5

Jump to: navigation, search

For Information on Aspire 3.1 Click Here

Aspire / Version 0.5 Release Notes / Changes to Components Required for 0.5

List of changes required for refactoring components for Aspire 0.5.

Unit tests

Details below of common updates required for unit tests.

  • Any unit tests that used ComponentManagerImpl must now use ComponentManager.
  • If you need to get a component by name, you would have previously got the component manger from the component test bench and then got the component from there. Now you must use ComponentTestBench.getComponent(String name)

Also, as ComponentManagerImpl has moved to the Application, you may need to add a test dependency to the application in the pom.

If you see an exception containing:

 Caused by: Unable to locate class name "com.searchtechnologies.aspire.application.ComponentManagerImpl". Check the spelling carefully in your ComponentFactory.xml file for the @implementation attribute.
     at com.searchtechnologies.aspire.framework.ComponentSubType.setImplementation(
     ... 45 more

add this to the pom:


CTB Application Port

The default application port has changed to 60606 for unit testing. Your unit tests will need to connect to this port rather than 50505

Inconsistent Test Failures

New static variables used in the Aspire Application can give inconsistent results when running tests. Sometimes the tests will pass individually and fail when run with other tests. Other times, tests will pass in eclipse, but fail when run via Maven.

This seems to be related to whether or not you are running the Application test bench or Component test bench.


 // Ensure a clean startup for the test

to the test start up to reset the statics

AspireDocument has been replaced by AspireObject

See AspireObject for more details.

  • The static element names (eg AspireDocument.FETCH_URL) have been moved in the framework in the class Standards.Basic in the package com.searchtechnologies.framework.
  • Document variables have been moved on to the Job (see above).
  • Deprecated methods have been removed
    • getObject(String name)
    • putObject(String name, Object obj)
    • getObjectMap()
    • getObjectMapForUse()
  • Other methods moved in to the class Standards.Basic in the package com.searchtechnologies.framework and parameterised.
    • getContentBytes() --> getContentBytes(Job)
    • setContentBytes(byte[] content) --> setContentBytes(Job, byte[] content)
    • getContentStream() --> getContentStream(Job)
    • setContentStream(InputStream contentStream) --> setContentStream(Job, InputStream contentStream)
    • getContentAsStream(Component cmpnt) --> getContentAsStream(Job, Component cmpnt)
    • getUrl() --> getUrl(AspireObject)

When creating a "Document" to process (either in a feeder or for a subjob) use:

   AspireObject doc = new AspireObject(Standards.Basic.DOCUMENT_ROOT);

The add content as before (AspireObject methods are similar to AXML)

   doc.add(Standards.Basic.FETCH_URL_TAG, urlS);
   if(feederLabel != null)
     doc.add(Standards.Basic.FEEDER_LABEL_TAG, feederLabel);

And finally create the Job:

   Job j = JobFactory.newInstance(doc);

Job & JobFactory

"Job" is now an Interface

"Job" is now an interface. This will improve stability of Aspire across multiple versions, will allow more flexibility in implementing Jobs, including, possibly, multiple implementations in the future.

This means that "new Job()" is no longer available:

 Job j = new Job();    // Only available in 0.4 and earlier

Jobs must now be constructed using JobFactory:

 Job j = JobFactory.newInstance();  // 0.5 and later

The other common constructor includes:

 Job j = JobFactory.newInstance(AspireObject data);

JobFactory is resolved by:

 import com.searchtechnologies.aspire.framework.JobFactory;

Getting and Setting Objects

Setting and getting job objects has changed. The methods have been renamed and the arguments/returns are now AspireObject rather than Object. If you need to pass any other type of Object, wrap it in an AspireObject (ie set it as content to the AspireObject) with the name of Standards.Basic.OBJECT_WRAPPER.

 void Job.setObject(Object) -> void set(AspireObject)
 Object Job.getObject() -> AspireObject Job.get()

Job ID's are Now Automatically Created

All jobs are now stamped automatically with a "universal job ID" which is used to track the job throughout Aspire.

This universal ID will make the job uniquely identifiable across multiple Aspire nodes in a cluster for distributed processing.

Therefore, "jobId" now no longer (and should no longer be used, unless you are an expert user) when creating a job.

Document Variables are now Job Variables

The "doc" object used to have setVariable() and getVariable() methods.

These variables have been moved up to the "job". So:

CHANGE: doc.getVariable() --> job.getVariable()

CHANGE: doc.putVariable() --> job.putVariable()

For users of 0.3 and before

The early methods for variables on documents were done with getObject() and setObject(). These were deprecated in 0.4 in favor of getVariable() and setVariable()

CHANGE: doc.getObject() --> job.getVariable()

CHANGE: doc.putObject() --> job.putVariable()

Job properties

Job properties have been merged with job variables

CHANGE: job.getProperty(); --> job.getVariable()

CHANGE: job.setProperty(); --> job.putVariable()

CHANGE: job.removeProperty(); --> job.setVariable("<name>", null)

Returning status

AXML has been moved in to the framework and is no longer the return from Component.getStatus() or Component.addDerivedStatus

You may continue to use AXML to build status information, but you should note the following:

  • The return is an element. You may use AXML.getMark() or AXML.getMyElement() as the return.
  • The returned element should be the element to which any nested content should be added.
  • A new AXML constructor allows you to contruct from an element, but set the object to the root of the element, push to the element and mark the element. This is particularly useful with addDerivedStatus().

Example of getStatus() is shown below

 public Element getStatus() throws AspireException {
   AXML xml = new AXML(addDerivedStatus("TestComponent", super.getStatus()), AXML.ROOT_PUSH_MARK);
   xml.add("aTest","attribute test");
   xml.add("statusTest","Test component status");
   return xml.getMark();

This example calls super.getStatus, putting it in and AspireObject, pointing to the root of the DOM, but with the element pushed so you can add directly to the child and marked so you can return the appropriate Element to add further content.


"BranchHandler" is now an interface in services (the BranchHandler implementation has been moved from the framework to the Aspire Application). This will provide more stability in changes to the Branch Handler, which is taking on an increasingly important role inside the framework.

A new BranchHandlerFactory is now available to create branch handlers.


 import com.searchtechnologies.aspire.framework.BranchHandler;  << CHANGE "framework" to "services"
                                                                << ADD Import for "framework.BranchHandlerFactory"
 bh = BranchHandler.getInstance(config, this);                  << CHANGE TO BranchHandlerFactory.newInstance()


 import com.searchtechnologies.aspire.framework.BranchHandlerFactory;
 bh = BranchHandlerFactory.newInstance(config, this);


initializeForSubType() has been removed from the component, resite any code to initialize() or to default in the variable initialization. Note, if the @Override tag was not in the code, you may not see an error, so please search for the method, to make sure it's gone

Remove the <config> tag from the ComponentFactory.xml to avoid confusion.


The metadata mapper initializeForSubType() has been removed. New methods are available for defaulting mappings. See Metadata Mapper for details