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

com.cloudimpl.outstack.spring.service.ReactiveServiceProxyHandler Maven / Gradle / Ivy

There is a newer version: 4.0.551
Show newest version
package com.cloudimpl.outstack.spring.service;

import com.cloudimpl.outstack.spring.component.Cluster;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class ReactiveServiceProxyHandler implements InvocationHandler {
    private Cluster cluster;
    private Class serviceType;
    public ReactiveServiceProxyHandler(Class serviceType,Cluster cluster)
    {
        this.serviceType = serviceType;
        this.cluster = cluster;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if(method.getReturnType() == Flux.class)
        {
            return cluster.requestStreamEx(serviceType.getName(),method.getName(),(String)args[0],args[1]);
        }
        else {
            return cluster.requestReplyEx(serviceType.getName(),method.getName(),(String)args[0],args[1]);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy