/** * Send the queue item to the event. * * @param item item */ private void sendToEventManager(T item) { if (debug) { logger.debug("EventBusQueueAdapter::sendToEventManager({})", item); } try { if (lock.tryLock()) { eventManager.sendArguments(channel, item); } else { lock.lock(); eventManager.sendArguments(channel, item); } } finally { lock.unlock(); } }
/** * Send records over record event channel. */ public void addRecords(List<Record> records) { eventManager.sendArguments("NEW_RECORD_LIST", records); }
/** * Send records over record event channel. */ public void addRecords(List<Record> records) { eventManager.sendArguments("NEW_RECORD_LIST", records); }
@Override public <T> T createProxyWithChannelPrefix(final EventManager eventManager, final Class<T> eventBusProxyInterface, final String channelPrefix) { if (!eventBusProxyInterface.isInterface()) { throw new IllegalArgumentException("Must be an interface for eventBusProxyInterface argument"); } final Map<String, String> methodToChannelMap = createMethodToChannelMap(channelPrefix, eventBusProxyInterface); final InvocationHandler invocationHandler = (proxy, method, args) -> { if (flushMethodNameSet.contains(method.getName())) { flushServiceProxy(eventManager); return null; } final String channelName = methodToChannelMap.get(method.toString()); eventManager.sendArguments(channelName, args); return null; }; final Object o = Proxy.newProxyInstance(eventBusProxyInterface.getClassLoader(), new Class[]{eventBusProxyInterface, ClientProxy.class}, invocationHandler); //noinspection unchecked return (T) o; }
/** * Send the queue item to the event. * @param item item */ private void sendToEventManager(T item) { if (debug) { logger.debug("EventBusQueueAdapter::sendToEventManager({})", item); } try { if (lock.tryLock()) { eventManager.sendArguments(channel, item); } else { lock.lock(); eventManager.sendArguments(channel, item); } }finally { lock.unlock(); } }
/** * Send the queue item to the event. * * @param item item */ private void sendToEventManager(T item) { if (debug) { logger.debug("EventBusQueueAdapter::sendToEventManager({})", item); } try { if (lock.tryLock()) { eventManager.sendArguments(channel, item); } else { lock.lock(); eventManager.sendArguments(channel, item); } } finally { lock.unlock(); } }
@Override public <T> T createProxyWithChannelPrefix(final EventManager eventManager, final Class<T> eventBusProxyInterface, final String channelPrefix) { if (!eventBusProxyInterface.isInterface()) { throw new IllegalArgumentException("Must be an interface for eventBusProxyInterface argument"); } final Map<String, String> methodToChannelMap = createMethodToChannelMap(channelPrefix, eventBusProxyInterface); final InvocationHandler invocationHandler = (proxy, method, args) -> { if (flushMethodNameSet.contains(method.getName())) { flushServiceProxy(eventManager); return null; } final String channelName = methodToChannelMap.get(method.toString()); eventManager.sendArguments(channelName, args); return null; }; final Object o = Proxy.newProxyInstance(eventBusProxyInterface.getClassLoader(), new Class[]{eventBusProxyInterface, ClientProxy.class}, invocationHandler); //noinspection unchecked return (T) o; }
@Override public <T> T createProxyWithChannelPrefix(final EventManager eventManager, final Class<T> eventBusProxyInterface, final String channelPrefix) { if (!eventBusProxyInterface.isInterface()) { throw new IllegalArgumentException("Must be an interface for eventBusProxyInterface argument"); } final Map<String, String> methodToChannelMap = createMethodToChannelMap(channelPrefix, eventBusProxyInterface); final InvocationHandler invocationHandler = (proxy, method, args) -> { if (flushMethodNameSet.contains(method.getName())) { flushServiceProxy(eventManager); return null; } final String channelName = methodToChannelMap.get(method.toString()); eventManager.sendArguments(channelName, args); return null; }; final Object o = Proxy.newProxyInstance(eventBusProxyInterface.getClassLoader(), new Class[]{eventBusProxyInterface, ClientProxy.class}, invocationHandler); //noinspection unchecked return (T) o; }