/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public <T> T createRingBufferProxy( final Class<T> proxyInterface, final Disruptor<ProxyMethodInvocation> disruptor, final OverflowStrategy overflowStrategy, final T implementation) { validator.validateAll(disruptor, proxyInterface); disruptor.handleEventsWith(createSingleImplementationHandlerChain(implementation)); final ArgumentHolderGenerator argumentHolderGenerator = new ArgumentHolderGenerator(classPool); argumentHolderGenerator.createArgumentHolderClass(proxyInterface); prefillArgumentHolderObjects(disruptor.getRingBuffer(), argumentHolderGenerator); final Map<Method, Invoker> methodToInvokerMap = createMethodToInvokerMap(proxyInterface, argumentHolderGenerator); return generateProxy( proxyInterface, disruptor.getRingBuffer(), methodToInvokerMap, overflowStrategy, argumentHolderGenerator); }
/** {@inheritDoc} */ @Override @SuppressWarnings("unchecked") public <T> T createRingBufferProxy( final Class<T> proxyInterface, final Disruptor<ProxyMethodInvocation> disruptor, final OverflowStrategy overflowStrategy, final T... implementations) { validator.validateAll(disruptor, proxyInterface); if (implementations.length < 1) { throw new IllegalArgumentException("Must have at least one implementation"); } else if (implementations.length == 1) { return createRingBufferProxy(proxyInterface, disruptor, overflowStrategy, implementations[0]); } final EventHandler<ProxyMethodInvocation>[] handlers = new EventHandler[implementations.length]; for (int i = 0; i < implementations.length; i++) { handlers[i] = createMultipleImplementationHandlerChain(implementations[i]); disruptor.handleEventsWith(handlers[i]); } disruptor.after(handlers).then(new ResetHandler()); final ArgumentHolderGenerator argumentHolderGenerator = new ArgumentHolderGenerator(classPool); argumentHolderGenerator.createArgumentHolderClass(proxyInterface); prefillArgumentHolderObjects(disruptor.getRingBuffer(), argumentHolderGenerator); final Map<Method, Invoker> methodToInvokerMap = createMethodToInvokerMap(proxyInterface, argumentHolderGenerator); return generateProxy( proxyInterface, disruptor.getRingBuffer(), methodToInvokerMap, overflowStrategy, argumentHolderGenerator); }