@Override public SessionProvider getSessionProvider() { return service.getSessionProvider(); }
/** * Is the {@link ErraiService} still active. * * @return true if we aren't null and we have a valid {@link ErraiService#getBus()}. */ public static boolean isActive() { return service != null && service.getBus() != null; }
@Override public void store(Message message) { service.store(message); }
public void closeProxy(ErraiService service) { this.service = service; messageBusProxy.closeProxy(service.getBus()); requestDispatcherProxy.closeProxy(service.getDispatcher()); } }
public void start() { final ErraiServiceConfigurator esc = svc.getConfiguration(); useSecureWebSocket = ErraiConfigAttribs.SECURE_WEB_SOCKET_SERVER.getBoolean(esc); final int port = ErraiConfigAttribs.WEB_SOCKET_PORT.getInt(esc); svc.addShutdownHook(new Runnable() { @Override public void run() {
@SuppressWarnings("unchecked") @Override protected void configure() { bind(MessageBus.class).toInstance(context.getBus()); bind(RequestDispatcher.class).toInstance(context.getService().getDispatcher()); bind(TaskManager.class).toInstance(TaskManagerFactory.get()); // Add any extension bindings. for (Map.Entry<Class<?>, ResourceProvider> entry : config.getExtensionBindings().entrySet()) { bind(entry.getKey()).toProvider(new GuiceProviderProxy(entry.getValue())); } } }).getInstance(clazz);
this.svc = svc; ErraiServiceConfigurator cfg = svc.getConfiguration(); if (svc.getBus() instanceof ServerMessageBusImpl) { ServerMessageBusImpl busImpl = (ServerMessageBusImpl) svc.getBus();
@Override public void stopService() { service.stopService(); }
@Override public ErraiServiceConfigurator getConfiguration() { return service.getConfiguration(); }
@Override public void addShutdownHook(Runnable runnable) { service.addShutdownHook(runnable); }
if (sessionKey != null && (session = svc.getBus().getSessionBySessionId(sessionKey)) != null) { final LocalContext localContext = LocalContext.get(session); WEBSOCKET_ACTIVE.equals(localContext.getAttribute(String.class, SESSION_ATTR_WS_STATUS))) { final MessageQueue queueBySession = svc.getBus().getQueueBySession(sessionKey); queueBySession.setDeliveryHandler(DirectDeliveryHandler.createFor(new NettyQueueChannel(ctx.channel()))); svc.store(msg);
public void closeProxy(ErraiService service) { this.service = service; messageBusProxy.closeProxy(service.getBus()); requestDispatcherProxy.closeProxy(service.getDispatcher()); } }
@Override protected void configure() { bind(MessageBus.class).toInstance(context.getBus()); bind(RequestDispatcher.class).toInstance(context.getService().getDispatcher()); bind(TaskManager.class).toInstance(TaskManagerFactory.get()); // Add any extension bindings. for (Map.Entry<Class<?>, ResourceProvider> entry : config.getExtensionBindings().entrySet()) { bind(entry.getKey()).toProvider(new GuiceProviderProxy(entry.getValue())); } } });
this.svc = svc; ErraiServiceConfigurator cfg = svc.getConfiguration(); if (svc.getBus() instanceof ServerMessageBusImpl) { ServerMessageBusImpl busImpl = (ServerMessageBusImpl) svc.getBus();
@Override public void destroy() { service.stopService(); }
public void start() { final ErraiServiceConfigurator esc = svc.getConfiguration(); useSecureWebSocket = ErraiConfigAttribs.SECURE_WEB_SOCKET_SERVER.getBoolean(esc); final int port = ErraiConfigAttribs.WEB_SOCKET_PORT.getInt(esc); svc.addShutdownHook(new Runnable() { @Override public void run() {
private void handleHttpRequest(final ChannelHandlerContext ctx, final FullHttpRequest req) throws Exception { // Allow only GET methods. if (req.getMethod() != GET) { sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN)); return; } int maxFrameSize = ErraiConfigAttribs.WEB_SOCKET_MAX_FRAME_SIZE.getInt(svc.getConfiguration()); // Handshake final WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory( this.getWebSocketLocation(req), null, false, maxFrameSize); this.handshaker = wsFactory.newHandshaker(req); if (this.handshaker == null) { wsFactory.sendUnsupportedWebSocketVersionResponse(ctx.channel()); } else { this.handshaker.handshake(ctx.channel(), req); } }
/** * Constructs the <tt>AsyncDispatcher</tt> with the specified service. The injection makes it possible to obtain * a reference to the <tt>ErraiService</tt> * * @param service the service where the bus is located */ @Inject public AsyncDispatcher(final ErraiService service) { this.service = service; this.workerFactory = new WorkerFactory(service); service.addShutdownHook(new Runnable() { @Override public void run() { workerFactory.stopPool(); } }); }
@Inject public SimpleDispatcher(ErraiService svc) { this.bus = svc.getBus(); }