private boolean isAutoScanEnabled(ErraiServiceConfiguratorImpl config) { return ErraiConfigAttribs.AUTO_DISCOVER_SERVICES.getBoolean(config); }
this.hostedModeTesting = ErraiConfigAttribs.HOSTED_MODE_TESTING.getBoolean(config); this.doLongPolling = !hostedModeTesting && ErraiConfigAttribs.DO_LONG_POLL.getBoolean(config); this.messageQueueTimeoutSecs = ErraiConfigAttribs.MESSAGE_QUEUE_TIMEOUT_SECS.getInt(config); this.sseEnabled = ErraiConfigAttribs.ENABLE_SSE_SUPPORT.getBoolean(config); this.webSocketServer = ErraiConfigAttribs.ENABLE_WEB_SOCKET_SERVER.getBoolean(config); webSocketServlet = ErraiConfigAttribs.WEBSOCKET_SERVLET_ENABLED.getBoolean(config); useSecureWebsocket = ErraiConfigAttribs.FORCE_SECURE_WEBSOCKET.getBoolean(config) || ErraiConfigAttribs.SECURE_WEB_SOCKET_SERVER.getBoolean(config); webSocketPath = ErraiConfigAttribs.WEBSOCKET_SERVLET_CONTEXT_PATH.get(config); webSocketPort = -1; webSocketPath = ErraiConfigAttribs.WEB_SOCKET_URL.get(config); webSocketPort = ErraiConfigAttribs.WEB_SOCKET_PORT.getInt(config); final Integer bufferSize = ErraiConfigAttribs.BUS_BUFFER_SIZE.getInt(config); Integer segmentSize = ErraiConfigAttribs.BUS_BUFFER_SEGMENT_SIZE.getInt(config); Integer segmentCount = ErraiConfigAttribs.BUS_BUFFER_SEGMENT_COUNT.getInt(config); final String allocMode = ErraiConfigAttribs.BUS_BUFFER_ALLOCATION_MODE.get(config); + ErraiConfigAttribs.BUS_BUFFER_ALLOCATION_MODE.get(config)); clustering = ErraiConfigAttribs.ENABLE_CLUSTERING.getBoolean(config); final String clusteringProviderCls = ErraiConfigAttribs.CLUSTERING_PROVIDER.get(config);
public boolean getBoolean(final ErraiServiceConfigurator configurator) { setDefaultValue(configurator); return configurator.getBooleanProperty(getAttributeName()); }
private void configureSettings() { final ErraiServiceConfigurator config = service.getConfiguration(); final boolean hostedModeTesting = ErraiConfigAttribs.HOSTED_MODE_TESTING.getBoolean(config); longPollingEnabled = !hostedModeTesting && ErraiConfigAttribs.DO_LONG_POLL.getBoolean(config); longPollTimeout = ErraiConfigAttribs.LONG_POLL_TIMEOUT.getInt(config); sseTimeout = ErraiConfigAttribs.SSE_TIMEOUT.getInt(config); csrfSecurityCheck = (ErraiConfigAttribs.ENABLE_CSRF_BUS_TOKEN.getBoolean(config) ? CSRFTokenCheck.INSTANCE : RequestSecurityCheck.noCheck()); }
/** * Build a {@link io.netty.handler.ssl.SslHandler} when the side band server * is configured to use ssl for websocket. * * @param esc * @return the ssl handler, never null. */ public static SslHandler buildSslHandler(ErraiServiceConfigurator esc) { keyPassword = StringUtils.isEmpty(keyPassword) ? ErraiConfigAttribs.WEB_SOCKET_KEY_PASSWORD.get(esc) : keyPassword; if (keyStore == null) { final String keyStorePath = ErraiConfigAttribs.WEB_SOCKET_KEYSTORE.get(esc); final String keystoreType = ErraiConfigAttribs.WEB_SOCKET_KEYSTORE_TYPE.get(esc); if (StringUtils.isEmpty(keyStorePath)) { throw new IllegalStateException( "when ssl is activated for the sideband server, key store information is necessary"); } String keyStorePassword = ErraiConfigAttribs.WEB_SOCKET_KEYSTORE_PASSWORD.get(esc); if (StringUtils.isEmpty(keyStorePassword)) { throw new IllegalStateException( "keystore configured for sideband websocket server, but missing keystore password"); } if (StringUtils.isEmpty(keyPassword)) { keyPassword = keyStorePassword; } keyStore = KeystoreFactory.getKeyStore(keyStorePath, keyStorePassword, keystoreType); } return new SslHandler(getSslEngine(keyStore, keyPassword)); }
private void setDefaultValue(final ErraiServiceConfigurator configurator) { if (defaultValue != null && !configurator.hasProperty(getAttributeName())) { configurator.setProperty(getAttributeName(), defaultValue); } }
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); } }
ErraiConfigAttribs.AUTO_DISCOVER_SERVICES.set(configurator, autoDiscoverServices); ErraiConfigAttribs.WEBSOCKET_SERVLET_ENABLED.set(configurator, webSocketsEnabled); ErraiConfigAttribs.FORCE_SECURE_WEBSOCKET.set(configurator, forceSecureWebsockets); ErraiConfigAttribs.WEBSOCKET_SERVLET_CONTEXT_PATH.set(configurator, context.getContextPath() + "/" + pathElement);
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); final ServerBootstrap bootstrap = new ServerBootstrap(); final WebSocketServerHandler webSocketHandler = new WebSocketServerHandler(svc);
/** * Constructs a new PooledExecutorService with the specified queue size. * * @param queueSize The size of the underlying worker queue. */ public PooledExecutorService(int queueSize) { this(queueSize, SaturationPolicy.valueOf( ErraiConfigAttribs.SATURATION_POLICY.get(new ErraiServiceConfiguratorImpl()))); }
public void set(final ErraiServiceConfigurator configurator, final String value) { configurator.setProperty(getAttributeName(), value); }
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); } }
ErraiConfigAttribs.AUTO_DISCOVER_SERVICES.set(configurator, autoDiscoverServices); ErraiConfigAttribs.WEBSOCKET_SERVLET_ENABLED.set(configurator, webSocketsEnabled); ErraiConfigAttribs.FORCE_SECURE_WEBSOCKET.set(configurator, forceSecureWebsockets); ErraiConfigAttribs.WEBSOCKET_SERVLET_CONTEXT_PATH.set(configurator, context.getContextPath() + "/" + pathElement);
@Override public void init(final ErraiServiceConfigurator config) { csrfCheck = (ErraiConfigAttribs.ENABLE_CSRF_BUS_TOKEN.getBoolean(config) ? CSRFTokenCheck.INSTANCE : RequestSecurityCheck.noCheck()); }
private void configureSettings() { final ErraiServiceConfigurator config = service.getConfiguration(); final boolean hostedModeTesting = ErraiConfigAttribs.HOSTED_MODE_TESTING.getBoolean(config); longPollingEnabled = !hostedModeTesting && ErraiConfigAttribs.DO_LONG_POLL.getBoolean(config); longPollTimeout = ErraiConfigAttribs.LONG_POLL_TIMEOUT.getInt(config); sseTimeout = ErraiConfigAttribs.SSE_TIMEOUT.getInt(config); csrfSecurityCheck = (ErraiConfigAttribs.ENABLE_CSRF_BUS_TOKEN.getBoolean(config) ? CSRFTokenCheck.INSTANCE : RequestSecurityCheck.noCheck()); }
this.hostedModeTesting = ErraiConfigAttribs.HOSTED_MODE_TESTING.getBoolean(config); this.doLongPolling = !hostedModeTesting && ErraiConfigAttribs.DO_LONG_POLL.getBoolean(config); this.messageQueueTimeoutSecs = ErraiConfigAttribs.MESSAGE_QUEUE_TIMEOUT_SECS.getInt(config); this.sseEnabled = ErraiConfigAttribs.ENABLE_SSE_SUPPORT.getBoolean(config); this.webSocketServer = ErraiConfigAttribs.ENABLE_WEB_SOCKET_SERVER.getBoolean(config); webSocketServlet = ErraiConfigAttribs.WEBSOCKET_SERVLET_ENABLED.getBoolean(config); useSecureWebsocket = ErraiConfigAttribs.FORCE_SECURE_WEBSOCKET.getBoolean(config) || ErraiConfigAttribs.SECURE_WEB_SOCKET_SERVER.getBoolean(config); webSocketPath = ErraiConfigAttribs.WEBSOCKET_SERVLET_CONTEXT_PATH.get(config); webSocketPort = -1; webSocketPath = ErraiConfigAttribs.WEB_SOCKET_URL.get(config); webSocketPort = ErraiConfigAttribs.WEB_SOCKET_PORT.getInt(config); final Integer bufferSize = ErraiConfigAttribs.BUS_BUFFER_SIZE.getInt(config); Integer segmentSize = ErraiConfigAttribs.BUS_BUFFER_SEGMENT_SIZE.getInt(config); Integer segmentCount = ErraiConfigAttribs.BUS_BUFFER_SEGMENT_COUNT.getInt(config); final String allocMode = ErraiConfigAttribs.BUS_BUFFER_ALLOCATION_MODE.get(config); + ErraiConfigAttribs.BUS_BUFFER_ALLOCATION_MODE.get(config)); clustering = ErraiConfigAttribs.ENABLE_CLUSTERING.getBoolean(config); final String clusteringProviderCls = ErraiConfigAttribs.CLUSTERING_PROVIDER.get(config);
public Integer getInt(final ErraiServiceConfigurator configurator) { setDefaultValue(configurator); return configurator.getIntProperty(getAttributeName()); }
@Override protected void configure() { final Class<? extends RequestDispatcher> dispatcherImplementation; final String dispatcherImpl = ErraiConfigAttribs.ERRAI_DISPATCHER_IMPLEMENTATION.get(config); try { dispatcherImplementation = Class.forName(dispatcherImpl).asSubclass(RequestDispatcher.class); } catch (Exception e) { throw new ErraiBootstrapFailure("could not load request dispatcher implementation class", e); } log.info("using dispatcher implementation: " + dispatcherImplementation.getName()); bind(RequestDispatcher.class).to(dispatcherImplementation); bind(ErraiService.class).toInstance(context.getService()); bind(MessageBus.class).toInstance(context.getBus()); bind(ErraiServiceConfigurator.class).toInstance(config); } }).getInstance(RequestDispatcher.class);
private void setDefaultValue(final ErraiServiceConfigurator configurator) { if (defaultValue != null && !configurator.hasProperty(getAttributeName())) { configurator.setProperty(getAttributeName(), defaultValue); } }
private void boostrap() { BootstrapContext context = new BootstrapContext(this, bus, config); new OrderedBootstrap().execute(context); if (ErraiConfigAttribs.ENABLE_WEB_SOCKET_SERVER.getBoolean(config)) { WebSocketServer server = new WebSocketServer(this); server.start(); } }