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

org.webpieces.aws.storage.impl.ChannelWrapper Maven / Gradle / Ivy

The newest version!
package org.webpieces.aws.storage.impl;

import java.lang.reflect.Proxy;
import java.nio.channels.Channel;
import javax.inject.Inject;
import javax.inject.Provider;

public class ChannelWrapper {

    private Provider invocHandlerProvider;

    @Inject
    public ChannelWrapper(Provider invocHandlerProvider) {
        this.invocHandlerProvider = invocHandlerProvider;
    }

    public  T newChannelProxy(Class intf, T channel) {
        ChannelInvocationHandler invocHandler = invocHandlerProvider.get();
        invocHandler.setChannel(channel);

        return (T) Proxy.newProxyInstance(channel.getClass().getClassLoader(),
                new Class[] {intf, Channel.class},
                invocHandler);
    }



}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy