Search in sources :

Example 1 with CacheConfiguration

use of org.wso2.caching.CacheConfiguration in project wso2-synapse by wso2.

the class CacheMessageBuilderDispatchandler method invoke.

@Override
public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
    InvocationResponse invocationResponse = super.invoke(messageContext);
    EndpointReference toEPR = messageContext.getTo();
    Pipe pipe = (Pipe) messageContext.getProperty(PassThroughConstants.PASS_THROUGH_PIPE);
    if (pipe != null && messageContext.getAxisMessage() != null) {
        CacheConfiguration cacheCfg = null;
        Parameter ccfgParam = messageContext.getAxisMessage().getParameter(CachingConstants.CACHE_CONFIGURATION);
        if (ccfgParam != null && ccfgParam.getValue() instanceof CacheConfiguration) {
            cacheCfg = (CacheConfiguration) ccfgParam.getValue();
            // even though we found a cache config, if the timeout is <= 0, caching is disabled
            if (cacheCfg.getTimeout() <= 0) {
                return invocationResponse;
            }
            try {
                RelayUtils.buildMessage(messageContext, false);
            } catch (Exception e) {
                log.error("Error while executing the message at cache message builder handler", e);
            }
        }
    }
    return invocationResponse;
}
Also used : Parameter(org.apache.axis2.description.Parameter) Pipe(org.apache.synapse.transport.passthru.Pipe) CacheConfiguration(org.wso2.caching.CacheConfiguration) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Aggregations

EndpointReference (org.apache.axis2.addressing.EndpointReference)1 Parameter (org.apache.axis2.description.Parameter)1 Pipe (org.apache.synapse.transport.passthru.Pipe)1 CacheConfiguration (org.wso2.caching.CacheConfiguration)1