1.4.7. Component request lifecycle

Warning

You are looking at documentation for an older release. Not what you want? See the current release documentation.

Component request lifecycle contract

The component request lifecycle is an interface that defines a contract for a component for being involved into a request:

public interface ComponentRequestLifecycle

{
   /**
    * Start a request.
    * @param container the related container
    */
   void startRequest(ExoContainer container);
 
   /**
    * Ends a request.
    * @param container the related container
    */
   void endRequest(ExoContainer container);
}

The container passed is the container to which the component is related. This contract is often used to set up a thread local based context that will be demarcated by a request.

For instance, in the GateIn portal context, a component request lifecycle is triggered for user requests. Another example is the initial data import in GateIn that demarcates using callbacks made to that interface.

Request lifecycle

The RequestLifeCycle class has several statics methods that are used to schedule the component request lifecycle of components. Its main responsibility is to perform scheduling while respecting the constraint to execute the request lifecycle of a component only once even if it can be scheduled several times.

Scheduling a component request lifecycle

RequestLifeCycle.begin(component);

try
{
   // Do something
}
finally
{
   RequestLifeCycle.end();
}

Scheduling a container request lifecycle

Scheduling a container triggers the component request lifecycle of all the components that implement the ComponentRequestLifeCycle interface. If one of the components has already been scheduled before, it will not be scheduled again. If the local value is true, then the looked components will be those of the containers. If it is false, then the scheduler will also look at the components in the ancestor containers.

RequestLifeCycle.begin(container, local);

try
{
   // Do something
}
finally
{
   RequestLifeCycle.end();
}

When request lifecycle is triggered

Portal request lifecycle

Each portal request triggers the lifecycle of the associated portal container.

JMX request lifecycle

When a JMX bean is invoked, the request lifecycle of the container to which it belongs is scheduled. Indeed, JMX is an entry point of the system that may need component to have a request lifecycle triggered.

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus