Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.dottydingo.service.endpoint.pipeline;
 
public abstract class AbstractEndpointPhase<C extends EndpointContextimplements Phase<C>
    protected Logger logger = LoggerFactory.getLogger(getClass());
    private TraceManager traceManager;
    private String name;
    public void setTraceManager(TraceManager traceManager)
    {
        this. = traceManager;
    }
    public void setContextStatusRegistry(ContextStatusRegistry contextStatusRegistry)
    {
        this. = contextStatusRegistry;
    }
    public void setName(String name)
    {
        this. = name;
    }
    @Override
    public String getName()
    {
        return ;
    }
    @Override
    public void execute(C phaseContextthrows Exception
    {
        if(phaseContext.isTimedOut())
            throw new EndpointTimeoutException(String.format("Endpoint request timed out."));
        MDC.put("CID",phaseContext.getCorrelationId());
        Trace trace = phaseContext.getTrace();
        if(trace!= null)
            .associateTrace(trace);
        ContextStatus contextStatus = .getContextStatus(phaseContext.getRequestId());
        if(contextStatus != null)
            .associateContextStatus(contextStatus);
        try
        {
            .debug("Starting phase {}",);
            if(contextStatus != null)
                contextStatus.startTimer(String.format("phase:%s",));
            executePhase(phaseContext);
            .debug("Completing phase {}",);
        }
        finally
        {
            MDC.clear();
            if(trace != null)
                .disassociateTrace();
            if(contextStatus != null)
            {
                contextStatus.stopTimer(String.format("phase:%s",));
                .disassociateContextStatus();
            }
        }
    }
    protected abstract void executePhase(C phaseContextthrows Exception;
New to GrepCode? Check out our FAQ X