001package org.xbib.elasticsearch.websocket; 002 003import org.elasticsearch.common.collect.Lists; 004import org.elasticsearch.common.inject.AbstractModule; 005import org.xbib.elasticsearch.action.websocket.bulk.BulkDeleteAction; 006import org.xbib.elasticsearch.action.websocket.bulk.BulkFlushAction; 007import org.xbib.elasticsearch.action.websocket.bulk.BulkIndexAction; 008import org.xbib.elasticsearch.action.websocket.pubsub.ForwardAction; 009import org.xbib.elasticsearch.action.websocket.pubsub.PublishAction; 010import org.xbib.elasticsearch.action.websocket.pubsub.SubscribeAction; 011import org.xbib.elasticsearch.action.websocket.pubsub.UnsubscribeAction; 012 013import java.util.List; 014 015/** 016 * The InteractiveActionModule binds all WebSocket actions. 017 */ 018public class InteractiveActionModule extends AbstractModule { 019 020 private List<Class<? extends BaseInteractiveHandler>> websocketActions = Lists.newArrayList(); 021 022 public InteractiveActionModule(List<Class<? extends BaseInteractiveHandler>> websocketActions) { 023 this.websocketActions = websocketActions; 024 } 025 026 @Override 027 protected void configure() { 028 for (Class<? extends BaseInteractiveHandler> websocketAction : websocketActions) { 029 bind(websocketAction).asEagerSingleton(); 030 } 031 bind(PublishAction.class).asEagerSingleton(); 032 bind(SubscribeAction.class).asEagerSingleton(); 033 bind(UnsubscribeAction.class).asEagerSingleton(); 034 bind(ForwardAction.class).asEagerSingleton(); 035 bind(BulkDeleteAction.class).asEagerSingleton(); 036 bind(BulkIndexAction.class).asEagerSingleton(); 037 bind(BulkFlushAction.class).asEagerSingleton(); 038 } 039}