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

io.katharsis.repository.RepositoryMethodParameterProvider Maven / Gradle / Ivy

There is a newer version: 2.6.3
Show newest version
package io.katharsis.repository;

import java.lang.reflect.Method;

/**
 * Provides additional parameters for an annotated repository method. The method can accept more than the required
 * parameters for a functionality. For example:
 * 
 * {@code
 *  @JsonApiFindOne
 *  public Resource findOne(Long id) {
 *    ...
 *  }
 *  }
 * 
* This method has {@link io.katharsis.repository.annotations.JsonApiFindOne} annotation which require the first * parameter to be a resource identifier to be found. However, it is not the only parameter that can be defined. * It's possible to pass additional, web framework dependant objects associated with a request. When using JAX-RS * integration, it's possible to pass javax.ws.rs.core.SecurityContext. To allow doing that, JAX-RS adapter * has implemented {@link RepositoryMethodParameterProvider} to pass several framework classes to the repository method. * An example below shows a sample repository which makes use of JAX-RS integration: *
 * {@code
 *  @JsonApiFindOne
 *  public Resource findOne(Long id, @HeaderParam("X-Token") String auth Token, SecurityContext securityContext) {
 *    ...
 *  }
 *  }
 * 
*

* This interface has to be implemented for every Katharsis web framework integration. *

*/ public interface RepositoryMethodParameterProvider { /** * Return an instance of a custom parameter. * @param method repository method which contain the parameter * @param parameterIndex index of the parameter in the method parameters * @param Type of a parameter * @return parameter value or null if not found */ T provide(Method method, int parameterIndex); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy