All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.restup.service.AnnotatedRepositoryMethodCommand Maven / Gradle / Ivy

There is a newer version: 0.0.5
Show newest version
package com.github.restup.service;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.restup.errors.RequestErrorException;
import com.github.restup.registry.Resource;
import com.github.restup.util.Assert;

public class AnnotatedRepositoryMethodCommand extends FilterChainContextMethodCommand {

    private final static Logger log = LoggerFactory.getLogger(AnnotatedRepositoryMethodCommand.class);

    private final Resource resource;

    public AnnotatedRepositoryMethodCommand(Resource resource, Object objectInstance, Class methodAnnotation, Method method, Object[] arguments) {
        super(objectInstance, methodAnnotation, method, arguments);
        Assert.notNull(resource, "A resource instance is required");
        this.resource = resource;
    }

    @Override
    protected RuntimeException handle(Throwable t) {
        return RequestErrorException.of(resource, t);
    }

    @Override
    protected void debug(Object[] params) {
        log.debug("Executing {} method for {} resource {}.{}(...)", getLabel(), resource, getObjectInstance().getClass(), getMethod().getName());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy