Version 2

    Component request life cycle contract

    The component request life cycle 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 setup a thread local based context that will be demarcated by a request.

     

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

    Request life cycle

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

    Scheduling a component request life cycle

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

    Scheduling a container request life cycle

    Scheduling a container triggers the component request life cyle of all the components that implement the interface ComponentRequestLifeCycle. If one of the component has already been scheduled before then that component will not be scheduled again. When the local value is true then the looked components will be those of the container, when 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 life cycle is triggered

    Portal request life cycle

    Each portal request triggers the life cycle of the associated portal container.

    JMX request Life Cycle

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