Java Code Examples for io.micronaut.aop.MethodInvocationContext#getParameterValueMap()

The following examples show how to use io.micronaut.aop.MethodInvocationContext#getParameterValueMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractQueryInterceptor.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
private <RT> Map buildParameterValues(MethodInvocationContext<T, R> context, StoredQuery<?, RT> storedQuery) {
    Map<String, Object> parameterValueMap = context.getParameterValueMap();
    Map<?, ?> parameterBinding = storedQuery.getParameterBinding();
    Map parameterValues = new HashMap<>(parameterBinding.size());
    for (Map.Entry entry : parameterBinding.entrySet()) {
        Object name = entry.getKey();
        String argument = (String) entry.getValue();
        storeInParameterValues(context, storedQuery, parameterValueMap, name, argument, parameterValues);

    }
    return parameterValues;
}
 
Example 2
Source File: DefaultSaveOneReactiveInterceptor.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
@Override
public Object intercept(RepositoryMethodKey methodKey, MethodInvocationContext<Object, Object> context) {
    Class<?> rootEntity = getRequiredRootEntity(context);
    Map<String, Object> parameterValueMap = context.getParameterValueMap();

    Flowable<Object> publisher = Flowable.fromCallable(() -> {
        Object o = instantiateEntity(rootEntity, parameterValueMap);
        return getInsertOperation(context, o);
    }).flatMap(reactiveOperations::persist);
    return Publishers.convertPublisher(publisher, context.getReturnType().getType());
}
 
Example 3
Source File: DefaultSaveOneInterceptor.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
@Override
public Object intercept(RepositoryMethodKey methodKey, MethodInvocationContext<T, Object> context) {
    Class<?> rootEntity = getRequiredRootEntity(context);
    Map<String, Object> parameterValueMap = context.getParameterValueMap();
    Object instance = instantiateEntity(rootEntity, parameterValueMap);
    return operations.persist(getInsertOperation(context, instance));
}
 
Example 4
Source File: DefaultSaveOneAsyncInterceptor.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
@Override
public CompletionStage<Object> intercept(RepositoryMethodKey methodKey, MethodInvocationContext<T, CompletionStage<Object>> context) {
    Class<?> rootEntity = getRequiredRootEntity(context);
    Map<String, Object> parameterValueMap = context.getParameterValueMap();
    Executor executor = asyncDatastoreOperations.getExecutor();
    return CompletableFuture.supplyAsync(() -> {
        Object o = instantiateEntity(rootEntity, parameterValueMap);
        return getInsertOperation(context, o);
    }, executor).thenCompose(asyncDatastoreOperations::persist);
}