/** * 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()))); }
@Override public void addBinding(Class<?> type, ResourceProvider provider) { config.getExtensionBindings().put(type, provider); }
@Override public boolean getBooleanProperty(final String key) { return hasProperty(key) && "true".equals(getProperty(key)); }
@Override public void addResourceProvider(String name, ResourceProvider provider) { config.getResourceProviders().put(name, provider); } };
/** * Initializes the <tt>ErraiServiceConfigurator</tt> with a specified <tt>ServerMessageBus</tt> */ @Inject public ErraiServiceConfiguratorImpl() { this.attributeMap = new HashMap<String, String>(); this.extensionBindings = new HashMap<Class<?>, ResourceProvider>(); this.resourceProviders = new HashMap<String, ResourceProvider>(); this.serializableTypes = new HashSet<Class>(); this.scanner = ScannerSingleton.getOrCreateInstance(); loadServiceProperties(); }
public void execute(final BootstrapContext context) { log.info("starting errai bus ..."); try { for (BootstrapExecution execution : bootstrap) { execution.execute(context); } context.executeDeferred(); ((ErraiServiceConfiguratorImpl) context.getConfig()).lockdown(); log.info("errai bus started."); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("server bootstrap failed", e); } } }
public void execute(final BootstrapContext context) { final ErraiServiceConfiguratorImpl config = (ErraiServiceConfiguratorImpl) context .getConfig(); config.getResourceProviders().put(MessageBus.class.getName(), new BusProvider(context.getBus())); config.getResourceProviders().put(RequestDispatcher.class.getName(), new DispatcherProvider(context.getService().getDispatcher())); // configure the server-side taskmanager final TaskManager taskManager = resolveTaskManager(config); TaskManagerFactory.setTaskManagerProvider(new TaskManagerProvider() { public TaskManager get() { return taskManager; } }); LaundryListProviderFactory .setLaundryListProvider(new LaundryListProvider() { public LaundryList getLaundryList(final Object ref) { return ServerLaundryList.get((QueueSession) ref); } }); }
private void loadServiceProperties() { properties = new HashMap<String, String>(); final String bundlePath = System.getProperty("errai.service_config_prefix_path"); try { final ResourceBundle erraiServiceConfig = getBundle(bundlePath == null ? "ErraiService" : bundlePath + ".ErraiService"); final Enumeration<String> keys = erraiServiceConfig.getKeys(); String key; while (keys.hasMoreElements()) { key = keys.nextElement(); properties.put(key, erraiServiceConfig.getString(key)); } } catch (final Exception e) { if (bundlePath == null) { // try to load the default service bundle -- used for testing, etc. System.setProperty("errai.service_config_prefix_path", "org.jboss.errai.bus"); loadServiceProperties(); } } }
public void execute(final BootstrapContext context) { log.info("starting errai bus ..."); try { for (BootstrapExecution execution : bootstrap) { execution.execute(context); } context.executeDeferred(); ((ErraiServiceConfiguratorImpl) context.getConfig()).lockdown(); log.info("errai bus started."); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("server bootstrap failed", e); } } }
final ErraiServiceConfigurator configurator = new ErraiServiceConfiguratorImpl();
@Override public Integer getIntProperty(final String key) { if (hasProperty(key)) { final String val = getProperty(key); try { return Integer.parseInt(val); } catch (final NumberFormatException e) { throw new RuntimeException("expected an integer value for key '" + key + "': but got: " + val); } } return null; }
@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);
@Override public void addResourceProvider(String name, ResourceProvider provider) { config.getResourceProviders().put(name, provider); } };
/** * Initializes the <tt>ErraiServiceConfigurator</tt> with a specified <tt>ServerMessageBus</tt> */ @Inject public ErraiServiceConfiguratorImpl() { this.attributeMap = new HashMap<String, String>(); this.extensionBindings = new HashMap<Class<?>, ResourceProvider>(); this.resourceProviders = new HashMap<String, ResourceProvider>(); this.serializableTypes = new HashSet<Class>(); this.scanner = ScannerSingleton.getOrCreateInstance(); loadServiceProperties(); }
/** * 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()))); }
if (config.hasProperty("errai.auto_load_extensions")) { autoScanModules = Boolean.parseBoolean(config.getProperty("errai.auto_load_extensions"));
@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())); } } });
public void execute(final BootstrapContext context) { final ErraiServiceConfiguratorImpl config = (ErraiServiceConfiguratorImpl) context .getConfig(); config.getResourceProviders().put(MessageBus.class.getName(), new BusProvider(context.getBus())); config.getResourceProviders().put(RequestDispatcher.class.getName(), new DispatcherProvider(context.getService().getDispatcher())); // configure the server-side taskmanager final TaskManager taskManager = resolveTaskManager(config); TaskManagerFactory.setTaskManagerProvider(new TaskManagerProvider() { public TaskManager get() { return taskManager; } }); LaundryListProviderFactory .setLaundryListProvider(new LaundryListProvider() { public LaundryList getLaundryList(final Object ref) { return ServerLaundryList.get((QueueSession) ref); } }); }
private void loadServiceProperties() { properties = new HashMap<String, String>(); final String bundlePath = System.getProperty("errai.service_config_prefix_path"); try { final ResourceBundle erraiServiceConfig = getBundle(bundlePath == null ? "ErraiService" : bundlePath + ".ErraiService"); final Enumeration<String> keys = erraiServiceConfig.getKeys(); String key; while (keys.hasMoreElements()) { key = keys.nextElement(); properties.put(key, erraiServiceConfig.getString(key)); } } catch (final Exception e) { if (bundlePath == null) { // try to load the default service bundle -- used for testing, etc. System.setProperty("errai.service_config_prefix_path", "org.jboss.errai.bus"); loadServiceProperties(); } } }
@Test public void testCSFRProtectionEnabled() throws Exception { final ErraiServiceConfiguratorImpl config = new ErraiServiceConfiguratorImpl(); assertTrue(ErraiConfigAttribs.ENABLE_CSRF_BUS_TOKEN.getBoolean(config)); } }