Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »

..this page is under construction and will be completed shortly..

Intro

Actions are the lightweight alternative to Pentaho BI Components.  For an understanding of how and why they are different, let's take a step back and examine what a BI Component is and how it is used.  A BI Component is historically a Java class that does some work, yielding some output, when it is provided certain inputs and resources.  The work done as well as the inputs and resources required are entirely up to the component developer.  It's purpose is to perform some work in a sequential success-based workflow (action sequence).  A saavy BI Platform user with a bit of inclination for Java coding can implement his or her own custom component to do just about anything.  However, this is not an easy endevour since developing your own BI Component requires intimate knowledge of internal Pentaho APIs.  When you are done writing your custom component, the code you have written will be tightly coupled to the Pentaho BI Platform, so much so, that it will be difficult to unit test and may be difficult to maintain.

These are some of the problems that the Action API seeks to solve.  As we mentioned earlier, Actions are the lightweight alternative to developing Components.  So, what do we mean by "lightweight"?  Well, we have taken the complex set of APIs required to implement a Component and reduced it to a handful of concise APIs.  Moreover, we allow you to write a Java bean that performs the action you desire, and simply decorate it with the appropriate API for the desired interaction with the platform.  These platform interaction APIs will discussed in more detail later, but they are essentially:

  • IAction - advertises that your bean has something to do and gives the platform's solution engine a method to execute.  This is the API that identifies your bean an Action.
  • IStreamingAction - indicates that your bean accepts output streams managed by action sequence content outputs, such as a ServletResponse output stream.  You would implement this if you intended to write to such an output stream during execution.
  • ILoggingAction - if your bean implements this, it will be provided a logger instance to which it can write errors, warnings, and debug messages.
  • ISessionAwareAction - supplies your bean with an instance of the current Pentaho session
  • IVarArgsAction - Allows an Action to accept inputs from the action sequence that are unspecified by the Action
  • itself
  • IDefinitionAwareAction - Makes an Action privy to certain details about the action definition that is responsible for executing it
  • IPreProcessingAction - Allows an Action to do some preliminary work prior to execution

Actions as Java Beans

Actions, as full-fledged Components, can participate in action sequences and can be provided inputs and resources by the typical means, as defined in xaction solution files.  There is an important distinction in the way that these parameters are obtained in Components versus in Actions.  While developing a Component, you will need to essentially go and mine out the parameters and values you need from within various internal APIs.  Actions are the inverse.  The Action framework will determine what inputs you desire and hand them right to you by way of a setter method (see Java bean specification).

The Action framework expects Action objects to be Java bean compliant with respect to setting inputs, setting resources, and getting outputs.  In other words, if your action needs takes a string input, the action definition in the xaction solution file will specify this string input, and the Action framework will cause that value to be set via a setter method on the Action object.  You do not see parameter Maps and such in the Action API for this reason.  All inputs, output, and resources IO will involve Java bean reflection on your Action object to find the appropriate IO methods.

See the Echo Plugin - a sample plugin for the BI Platform project for examples of how to get data into your IAction and how to expose the output of your IAction so something else can do something with it (i.e. display the results of your IAction, pipe them to another step in an action sequence, or bind them to a session parameter).

Here is a quick reference for how input and output types map from xaction xml files to an Action bean.

Inputs

During an action sequence, the Action framework will attempt to pass all the information you intend for your Action bean.  The action-inputs section of your action definition is the contract which tells the Action framework all the things that your Action bean requires to execute successfully.  In the following table, we've listed the various XML that the Action framework might encounter along with the method that the Action framework will expect to find on your Action bean.  If an appropriate setter method is not found on your Action bean, the framework will report a warning and proceed to the next input.  If an appropriate setter method is found, but the value of the input cannot be converted to the type declared in your setter method, the framework will report an error and fail execution.

xaction input

Java type

expected Action bean method (Java)
(all methods start with 'public void')

<myInput type="string">

java.lang.String

setMyInput(String s) { ...

<myInput type="long">

java.lang.Long

setMyInput(Long n) { ...

<myInputMap type="property-map">

java.util.Map<java.lang.String, java.lang.String>

setMyInputMap(Map<String, String> m) { ...

<myInputListMap type="property-map-list">

java.util.List<java.util.Map<java.lang.String, java.lang.String>>

setMyInputListMap(List<Map<String, String>> l) { ...

<myInputList type="string-list">

java.util.List<java.lang.String>

setMyInputList(List<String> l) { ...

<myInput> (no type specified)

In this case, the Action framework does not know the type and will try to convert the data to the type specified in your Action's setter method.  If the conversion fails, you will see a warning to this effect.

setMyInput(Object o),
or
 setMyInput(SomeOtherType t) //of course this will only work if the data can be cast to a SomeOtherType type

 

 

 

Outputs

xaction output

Java type

expected Action bean method (Java)

<myOutput type="content"/>

java.io.OutputStream

public void setMyOutputStream(OutputStream o)(star)
{ ...

 

 


(star) Note the content type output is treated like an input since the presence of a content type implies that your Action bean intends to write to a pre-existing data stream. This pre-existing stream is retrieved by the Action framework code and passed to your Action bean as a java.io.OuputStream prior to your Action bean executing.

Resources

xaction resource

Java type

expected Action bean method (Java)

<myResource type="resource"/>

java.io.InputStream

setMyResource(InputStream o) { ...

 

 


Resources

Outputs

Action Error Handling

FAQ

How are Actions different than POJO Components? I thought POJO Components already supported the ability to drop in a Java bean and have it work as a "component".

  • No labels