Example usage for org.apache.commons.chain Command getClass

List of usage examples for org.apache.commons.chain Command getClass

Introduction

In this page you can find the example usage for org.apache.commons.chain Command getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:info.magnolia.module.workflow.MgnlParticipant.java

/**
 * @see openwfe.org.embed.engine.EmbeddedParticipant#consume(openwfe.org.engine.workitem.WorkItem)
 *//*  w  w w .j  a  va 2s  .  com*/
public void consume(WorkItem wi) throws Exception {

    // get participant name
    if (log.isDebugEnabled()) {
        log.debug("enter consume()..");
    }
    if (wi == null) {
        log.error("work item is null");
        return;
    }
    String parName = ((InFlowWorkItem) (wi)).getParticipantName();
    if (log.isDebugEnabled()) {
        log.debug("participant name = " + parName);
    }
    if (parName.startsWith(WorkflowConstants.PARTICIPANT_PREFIX_COMMAND)) // handle commands
    {
        log.info("consume command " + parName + "...");
        if (log.isDebugEnabled()) {
            log.debug("command name is " + parName);
        }

        try {
            String name = StringUtils.removeStart(parName, WorkflowConstants.PARTICIPANT_PREFIX_COMMAND);
            Command c = CommandsManager.getInstance().getCommand(name);
            if (c != null) {
                log.info("Command has been found through the magnolia catalog:" + c.getClass().getName());

                // set parameters in the context
                Context context = MgnlContext.getInstance();

                context = new WorkItemContext(context, wi);

                // execute
                c.execute(context);

                WorkflowModule.getEngine().reply((InFlowWorkItem) wi);

            } else {
                // not found, do in the old ways
                log.error("No command has been found through the magnolia catalog for name:" + parName);
            }

            log.info("consume command " + parName + " end.");
        } catch (Exception e) {
            log.error("consume command failed", e);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("storage = " + this.storage);
        }
        this.storage.storeWorkItem("", (InFlowWorkItem) wi);
    }

    if (log.isDebugEnabled()) {
        log.debug("leave consume()..");
    }

}