public class

WebComponentTask

extends AbstractAppTask
java.lang.Object
   ↳ com.microstrategy.web.tasks.AbstractBaseTask
     ↳ com.microstrategy.web.app.tasks.AbstractAppTask
       ↳ com.microstrategy.web.app.tasks.WebComponentTask
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

This class implements the Task interface using a WebComponent to handle data collection. The definition of the task is provided through a single XML file.

Summary

Constants
String FP_NAME_CONTENT_TYPE The name of the formal parameter that defines the desired content type.
[Expand]
Inherited Constants
From class com.microstrategy.web.tasks.AbstractBaseTask
Fields
protected String initializationErrorMessage If an error occurred at initialization time, then this field contains the message.
[Expand]
Inherited Fields
From class com.microstrategy.web.tasks.AbstractBaseTask
Public Constructors
WebComponentTask()
No args constructor for a WebComponentTask.
Public Methods
void destroy()
Destroy any data structures created by the 'init' method.
void init(ContainerServices containerSvcs)
Handles the initialization of the task.
TaskRequestContext newRequestContext()
Returns a BeanTaskRequestContext object to use for the duration of this request.
void processRequest(TaskRequestContext context, TaskOutput taskOutput)
Process the incoming request.
void setTaskID(String taskID)
Sets the Task ID.
Protected Methods
TransformInstance addTransform(BeanTaskRequestContext btrContext)
Adds the specified Transform to the WebBean.
void collectData(BeanTaskRequestContext btrContext)
This method calls the 'collectData' method on the WebBean instance.
WebComponent createUntypedWebComponent(BeanTaskRequestContext btrContext)
This method creates an instance of an "untyped" Web Component.
WebComponent createWebBean(BeanTaskRequestContext btrContext)
This method creates the WebComponent or WebBean from the specified bean type.
boolean generatesContent(BeanTaskRequestContext btrContext)
This method determines whether the Task is going to generate any content.
BeanInfo getBeanInfo()
Returns the BeanInfo object associated with this BeanTask.
String getStyleName(BeanTaskRequestContext btrContext)
void handleEvent(BeanTaskRequestContext btrContext)
This method instructs the WebBean to handle the event.
boolean isSuccessfullyInitialized()
Returns whether the BeanTask was successfully initialized or not.
void overrideActualParameters(BeanTaskRequestContext btrContext, TransformInstance instance)
Overrides any actual parameters specified in the Bean Task XML.
void prepareArgumentRequestKeys(RequestKeys requestKeys)
This method prepares the RequestKeys by adding the necessary "event argument" parameters.
void prepareArgumentRequestKeys(RequestKeys requestKeys, EventInfo[] events)
void prepareBean(BeanTaskRequestContext btrContext)
This method prepares the WebBean for execution.
void prepareEventOrderRequestKeys(RequestKeys requestKeys)
The method sets the request keys necessary for multiple events.
void prepareEventOrderRequestKeys(RequestKeys requestKeys, EventInfo[] events)
void prepareEventRequestKeys(RequestKeys requestKeys)
This method prepares the RequestKeys by adding the necessary keys for events.
void prepareEventRequestKeys(RequestKeys requestKeys, EventInfo[] events)
void prepareParameterRequestKeys(RequestKeys requestKeys)
This method prepares the RequestKeys by adding any default values for parameters.
void prepareRequestKeys(BeanTaskRequestContext btrContext)
Prepares the RequestKeys for handling the event.
void registerParameterMetadata(TaskParameterMetadata parameterMetadata)
Registers a specific Task parameter metadata.
void registerTaskMetadata(TaskMetadata sourceMetadata)
This method is used to register the task metadata.
boolean requiresIServerSession()
Returns whether this Task requires an Intelligence Server session.
void restoreBeanState(BeanTaskRequestContext btrContext)
Restores the state of a previously serialized WebBean.
void serializeResult(BeanTaskRequestContext btrContext, TaskOutput taskOutput)
This method attempts to serialize the results to the supplied TaskOutput object.
void setBeanContext(BeanTaskRequestContext btrContext)
Set the BeanContext associated with the Bean.
void setBeanInfo(BeanInfo beanInfo)
Sets the BeanInfo object associated with this BeanTask.
void setBeanName(BeanTaskRequestContext btrContext)
Sets the Bean's name.
void setBeanProperties(BeanTaskRequestContext btrContext)
Set any properties on the Bean.
void setBeanSession(BeanTaskRequestContext btrContext)
Set the WebIServerSession object to use with the WebBean.
void setSuccessfullyInitialized(boolean successfullyInitialized)
Sets whether the BeanTask was successfully initialized or not.
void transformBean(BeanTaskRequestContext btrContext, TaskOutput taskOutput)
This method wraps a call to transform().
[Expand]
Inherited Methods
From class com.microstrategy.web.app.tasks.AbstractAppTask
From class com.microstrategy.web.tasks.AbstractBaseTask
From class java.lang.Object
From interface com.microstrategy.web.tasks.Task

Constants

public static final String FP_NAME_CONTENT_TYPE

The name of the formal parameter that defines the desired content type. If found, the Task infrastructure will assign the value of the Task Content Type parameter to it. This allows transforms to be written that generate Block trees and the Task caller can decide how they are rendered.

Constant Value: "contentType"

Fields

protected String initializationErrorMessage

If an error occurred at initialization time, then this field contains the message.

Public Constructors

public WebComponentTask ()

No args constructor for a WebComponentTask.

Public Methods

public void destroy ()

Destroy any data structures created by the 'init' method.

public void init (ContainerServices containerSvcs)

Handles the initialization of the task. This involves parsing the XML file and retrieving all of the contents. This method calls registerTaskMetadata(TaskMetadata).

Parameters
containerSvcs The ContainerServices object that can be used to find more initialization parameters.

public TaskRequestContext newRequestContext ()

Returns a BeanTaskRequestContext object to use for the duration of this request.

Returns

public void processRequest (TaskRequestContext context, TaskOutput taskOutput)

Process the incoming request. This method proceeds through the following sequence:

  1. Check for all required parameters. (calls checkForRequiredParameters(RequestKeys))
  2. Prepare the RequestKeys for use. (calls prepareRequestKeys(BeanTaskRequestContext))
  3. Prepare the WebBean for use. (calls prepareBean(BeanTaskRequestContext))
  4. Handle the event. (calls handleEvent(BeanTaskRequestContext))
  5. Collect data for the request. (calls collectData(BeanTaskRequestContext))
  6. Serialize the results into the supplied TaskOutput. (calls serializeResult(BeanTaskRequestContext, TaskOutput))

Parameters
context The TaskRequestContext object that contains information specific to this request.
taskOutput The TaskOutput object to serialize the results into.
Throws
TaskException If anything fails in the process of servicing the request.
TaskConfigurationException If the task is not properly configured.

public void setTaskID (String taskID)

Sets the Task ID.

Parameters
taskID The Task ID.

Protected Methods

protected TransformInstance addTransform (BeanTaskRequestContext btrContext)

Adds the specified Transform to the WebBean. This method is called by serializeResult(BeanTaskRequestContext, TaskOutput) and performs the following actions:

  1. Retrieves the name of the style to use.
  2. Adds the Transform by looking up the style.

Parameters
btrContext The BeanTaskRequestContext to use.
Returns
Throws
TaskConfigurationException If the static style name does not exist in the StyleCatalog.
TaskRequestMalformedException If the dynamic style name does not exist in the Style Catalog.

protected void collectData (BeanTaskRequestContext btrContext)

This method calls the 'collectData' method on the WebBean instance. This method is called by processRequest(TaskRequestContext, TaskOutput).

Parameters
btrContext The BeanTaskRequestContext object.
Throws
TaskException If there is a failure while trying to collect data for the Web Bean.

protected WebComponent createUntypedWebComponent (BeanTaskRequestContext btrContext)

This method creates an instance of an "untyped" Web Component. This component implements the Transformable interface and can be used with any Transform. It provides no specialized data access methods.

Parameters
btrContext The BeanTaskRequestContext object.
Returns
  • An instance of a WebComponent to use when no bean type has been specified.
Throws
TaskConfigurationException If we are unable to create an instance.

protected WebComponent createWebBean (BeanTaskRequestContext btrContext)

This method creates the WebComponent or WebBean from the specified bean type. If no type is specified, then an "untyped" WebComponent is created using the createUntypedWebComponent(BeanTaskRequestContext) method.

Parameters
btrContext The BeanTaskRequestContext object.
Returns
Throws
TaskConfigurationException If we are unable to create a WebBean or WebComponent of the specified type

protected boolean generatesContent (BeanTaskRequestContext btrContext)

This method determines whether the Task is going to generate any content. Some tasks are "write only" in nature: they send data to the backend, but return nothing (other than a status).

Parameters
btrContext The BeanTaskRequestContext object.
Returns
  • true if we can determine that content could be generated by this Task; false, otherwise.
Throws
TaskException if the style parameter is not correctly specified.

protected BeanInfo getBeanInfo ()

Returns the BeanInfo object associated with this BeanTask.

Returns
  • The BeanInfo object associated with this BeanTask.

protected String getStyleName (BeanTaskRequestContext btrContext)

protected void handleEvent (BeanTaskRequestContext btrContext)

This method instructs the WebBean to handle the event. It is called from processRequest(TaskRequestContext, TaskOutput).

Parameters
btrContext The BeanTaskRequestContext that contains the WebBean instance.
Throws
TaskException If something fails in the process of handling the event.
TaskRequestMalformedException If there was an exception raised while handling the event.

protected boolean isSuccessfullyInitialized ()

Returns whether the BeanTask was successfully initialized or not.

Returns
  • Whether the BeanTask was successfully initialized or not.

protected void overrideActualParameters (BeanTaskRequestContext btrContext, TransformInstance instance)

Overrides any actual parameters specified in the Bean Task XML. This method is called by the serializeResult(BeanTaskRequestContext, TaskOutput) method.

Parameters
btrContext The BeanTaskRequestContext to use.
instance The TransformInstance to operate on.

protected void prepareArgumentRequestKeys (RequestKeys requestKeys)

This method prepares the RequestKeys by adding the necessary "event argument" parameters. This method is called in the prepareEventRequestKeys(RequestKeys) method.

Parameters
requestKeys The RequestKeys object to add keys to.

protected void prepareArgumentRequestKeys (RequestKeys requestKeys, EventInfo[] events)

protected void prepareBean (BeanTaskRequestContext btrContext)

This method prepares the WebBean for execution. It is called by the processRequest(TaskRequestContext, TaskOutput) method. It performs the following actions:

  1. Creates a new WebBean instance and adds it to the context. (calls createWebBean(BeanTaskRequestContext))
  2. Sets any bean properties. (calls setBeanProperties(BeanTaskRequestContext))
  3. Restores any bean state. (calls restoreBeanState(BeanTaskRequestContext))

Parameters
btrContext The BeanTaskRequestContext to use.
Throws
TaskException If anything fails along the way.

protected void prepareEventOrderRequestKeys (RequestKeys requestKeys)

The method sets the request keys necessary for multiple events. This method is called in the prepareEventRequestKeys(RequestKeys) method.

Parameters
requestKeys The RequestKeys instance to add keys to.

protected void prepareEventOrderRequestKeys (RequestKeys requestKeys, EventInfo[] events)

protected void prepareEventRequestKeys (RequestKeys requestKeys)

This method prepares the RequestKeys by adding the necessary keys for events. If there is only one event, then the URL_EVENT_NAME key is added. Otherwise, the prepareEventOrderRequestKeys(RequestKeys) method is called. Next, it calls the prepareArgumentRequestKeys(RequestKeys) method to add any keys defined for Event Arguments in the Bean Task XML.

Parameters
requestKeys The RequestKeys object to add keys to.

protected void prepareEventRequestKeys (RequestKeys requestKeys, EventInfo[] events)

protected void prepareParameterRequestKeys (RequestKeys requestKeys)

This method prepares the RequestKeys by adding any default values for parameters.

Parameters
requestKeys The RequestKeys instance to add the default values to.

protected void prepareRequestKeys (BeanTaskRequestContext btrContext)

Prepares the RequestKeys for handling the event. This method is called inside processRequest(TaskRequestContext, TaskOutput). This method, in turn, calls:

  1. prepareParameterRequestKeys(RequestKeys)
  2. prepareEventRequestKeys(RequestKeys)

Parameters
btrContext The BeanTaskRequestContext object.

protected void registerParameterMetadata (TaskParameterMetadata parameterMetadata)

Registers a specific Task parameter metadata. This method is called by registerTaskMetadata(TaskMetadata). It is helpful to override in a Task so that a specific TaskParameterMetadata may be saved for later use.

Parameters
parameterMetadata The TaskParameterMetadata object being saved.

protected void registerTaskMetadata (TaskMetadata sourceMetadata)

This method is used to register the task metadata. It is a method invoked by the init(ContainerServices) method. This method in turn calls registerParameterMetadata(TaskParameterMetadata) for each task parameter.

Parameters
sourceMetadata The TaskMetadata object being registered.

protected boolean requiresIServerSession ()

Returns whether this Task requires an Intelligence Server session.

Returns
  • True if this Task requires an Intelligence Server session; otherwise, false. The base implementation simply checks whether the session state parameter is defined for this Task.

protected void restoreBeanState (BeanTaskRequestContext btrContext)

Restores the state of a previously serialized WebBean. This method is called by prepareBean(BeanTaskRequestContext) and calls the restoreStateFromRequest(RequestKeys) method on the WebBean.

Parameters
btrContext The BeanTaskRequestContext object to use.

protected void serializeResult (BeanTaskRequestContext btrContext, TaskOutput taskOutput)

This method attempts to serialize the results to the supplied TaskOutput object. This method is called by processRequest(TaskRequestContext, TaskOutput) and in turn does the following:

  1. Add the Transform. If there is no transform specified, an empty MarkupOutput is returned. (calls addTransform(BeanTaskRequestContext))
  2. Override any actual parameters specified in the Bean Task XML. (calls overrideActualParameters(BeanTaskRequestContext, TransformInstance))
  3. Transforms the WebBean using the Transform. (calls transformBean(BeanTaskRequestContext, TaskOutput))

Parameters
btrContext The BeanTaskRequestContext object.
taskOutput The TaskOutput object to populate.
Throws
TaskException If something fails along the way.

protected void setBeanContext (BeanTaskRequestContext btrContext)

Set the BeanContext associated with the Bean. This method is called by the setBeanProperties(BeanTaskRequestContext) method.

Parameters
btrContext The BeanTaskRequestContext object to use.

protected void setBeanInfo (BeanInfo beanInfo)

Sets the BeanInfo object associated with this BeanTask.

Parameters
beanInfo The BeanInfo object associated with this BeanTask.

protected void setBeanName (BeanTaskRequestContext btrContext)

Sets the Bean's name. This method is called by setBeanProperties(BeanTaskRequestContext).

Parameters
btrContext The BeanTaskRequestContext object to use.

protected void setBeanProperties (BeanTaskRequestContext btrContext)

Set any properties on the Bean. This method is called by the prepareBean(BeanTaskRequestContext) method and performs the following actions:

  1. Sets the Bean Name. (calls setBeanName(BeanTaskRequestContext))
  2. Sets the Bean Session. (calls setBeanSession(BeanTaskRequestContext))
  3. Sets the Bean Context. (calls setBeanContext(BeanTaskRequestContext))

Parameters
btrContext The BeanTaskRequestContext object to use.
Throws
TaskException If any of the subordinate methods raise an exception while setting a specific property of the Bean.

protected void setBeanSession (BeanTaskRequestContext btrContext)

Set the WebIServerSession object to use with the WebBean. This method is called by the setBeanProperties(BeanTaskRequestContext) method.

Parameters
btrContext The BeanTaskRequestContext object to use.
Throws
TaskException If there is not enough information to create a WebIServerSession instance.

protected void setSuccessfullyInitialized (boolean successfullyInitialized)

Sets whether the BeanTask was successfully initialized or not.

Parameters
successfullyInitialized Whether the BeanTask was successfully initialized or not.

protected void transformBean (BeanTaskRequestContext btrContext, TaskOutput taskOutput)

This method wraps a call to transform(). It is called by the serializeResult(BeanTaskRequestContext, TaskOutput) method and simply calls the 'transform' method.

Parameters
btrContext The BeanTaskRequestContext object.
taskOutput The TaskOutput instance to generate into.
Throws
TaskConfigurationException If the Transform does not exist.