org.apache.lenya.cms.usecase
Interface UsecaseInvoker

All Known Implementing Classes:
TestUsecaseInvoker, UsecaseInvokerImpl

public interface UsecaseInvoker

This service allows to invoke a usecase in a convenient way. A typical usage scenario is the composition of usecases - you can invoke one or multiple "child" usecases from another usecase.

Example:

     UsecaseInvoker invoker = null;
     try {
         invoker = (UsecaseInvoker) this.manager.lookup(UsecaseInvoker.ROLE);
         Map params = new HashMap();
         params.put(..., ...);
         invoker.invoke(getSourceUrl(), childUsecaseName, params);
     
         if (invoker.getResult() != UsecaseInvoker.SUCCESS) {
             List messages = invoker.getErrorMessages();
             for (Iterator i = messages.iterator(); i.hasNext();) {
                 UsecaseMessage message = (UsecaseMessage) i.next();
                 addErrorMessage(message.getMessage(), message.getParameters());
             }
         }
     } finally {
         if (invoker != null) {
             this.manager.release(invoker);
         }
     }
     
 

Version:
$Id: UsecaseInvoker.java 507914 2007-02-15 12:15:30Z andreas $

Field Summary
static int EXECUTION_CONDITIONS_FAILED
          The execution condition check failed.
static int EXECUTION_FAILED
          The execution itself failed.
static int POSTCONDITIONS_FAILED
          The postcondition check failed.
static int PRECONDITIONS_FAILED
          The precondition check failed.
static java.lang.String ROLE
          The Avalon role.
static int SUCCESS
          The invocation was successful.
 
Method Summary
 java.util.List getErrorMessages()
          Returns the error messages from the previous operation.
 java.util.List getInfoMessages()
          Returns the info messages from the previous operation.
 int getResult()
           
 java.lang.String getTargetUrl()
           
 void invoke(java.lang.String webappUrl, java.lang.String usecaseName, java.util.Map parameters)
          Invokes a usecase.
 void setTestSession(org.apache.lenya.cms.repository.Session session)
           
 

Field Detail

ROLE

static final java.lang.String ROLE
The Avalon role.


SUCCESS

static final int SUCCESS
The invocation was successful.

See Also:
Constant Field Values

PRECONDITIONS_FAILED

static final int PRECONDITIONS_FAILED
The precondition check failed.

See Also:
Constant Field Values

EXECUTION_CONDITIONS_FAILED

static final int EXECUTION_CONDITIONS_FAILED
The execution condition check failed.

See Also:
Constant Field Values

EXECUTION_FAILED

static final int EXECUTION_FAILED
The execution itself failed.

See Also:
Constant Field Values

POSTCONDITIONS_FAILED

static final int POSTCONDITIONS_FAILED
The postcondition check failed.

See Also:
Constant Field Values
Method Detail

invoke

void invoke(java.lang.String webappUrl,
            java.lang.String usecaseName,
            java.util.Map parameters)
            throws UsecaseException
Invokes a usecase.

Parameters:
webappUrl - The URL to invoke the usecase on.
usecaseName - The name of the usecase.
parameters - The parameters.
Throws:
UsecaseException - if an error occurs.

getResult

int getResult()
Returns:
The result of the invocation.

getErrorMessages

java.util.List getErrorMessages()
Returns the error messages from the previous operation. Error messages prevent the operation from being executed.

Returns:
A list of UsecaseMessage objects.

getInfoMessages

java.util.List getInfoMessages()
Returns the info messages from the previous operation. Info messages do not prevent the operation from being executed.

Returns:
A list of UsecaseMessage objects.

getTargetUrl

java.lang.String getTargetUrl()
Returns:
The target URL of the usecase, based on the success. This method throws a RuntimeException if the usecase hasn't been executed yet.

setTestSession

void setTestSession(org.apache.lenya.cms.repository.Session session)
Parameters:
session - The test session to use.


Copyright © $ Apache Software Foundation. All Rights Reserved.