/** * Get the {@link ErraiService} singleton, or if not yet active provide a valid proxy. */ public static ErraiService getService() { return isActive() ? service : proxy; }
public static ErraiService initSingleton(final ErraiServiceConfigurator configurator) { synchronized (monitor) { if (isActive()) throw new IllegalStateException("service already set into singleton"); service = ErraiServiceFactory.create(configurator); proxy.closeProxy(service); Iterator<InitCallbackBlock> it = callbacks.iterator(); while(it.hasNext()) { InitCallbackBlock block = it.next(); block.callback.onInit(service); if(!block.persistent) { it.remove(); } } return service; } }
/** * Register an init callback that will be executed upon initialization. * * @param callback valid callback. * @param persistent should the callback persist after the singleton is initialized, will be removed if false. */ public static void registerInitCallback(ErraiInitCallback callback, boolean persistent) { synchronized (monitor) { InitCallbackBlock block = new InitCallbackBlock(callback, persistent); if (isActive()) { callback.onInit(getService()); if(persistent) { callbacks.add(block); } } else { callbacks.add(block); } } }
/** * Get the {@link ErraiService} singleton, or if not yet active provide a valid proxy. */ public static ErraiService getService() { return isActive() ? service : proxy; }
private static ErraiService initService(final InitConfig config) { synchronized (getServiceLock) { if (ErraiServiceSingleton.isActive()) { return ErraiServiceSingleton.getService();
public DefaultErraiWebSocketChannel(Session session, HttpSession httpSession) { this.session = session; this.httpSession = httpSession; if (ErraiServiceSingleton.isActive()) { erraiService = ErraiServiceSingleton.getService(); } else { throw new IllegalStateException( "Errai Bus should be initialized at this time. Default servlet configured?"); } }
public DefaultErraiWebSocketChannel(Session session, HttpSession httpSession) { this.session = session; this.httpSession = httpSession; if (ErraiServiceSingleton.isActive()) { erraiService = ErraiServiceSingleton.getService(); } else { throw new IllegalStateException( "Errai Bus should be initialized at this time. Default servlet configured?"); } }
public static ErraiService initSingleton(final ErraiServiceConfigurator configurator) { synchronized (monitor) { if (isActive()) throw new IllegalStateException("service already set into singleton"); service = ErraiServiceFactory.create(configurator); proxy.closeProxy(service); Iterator<InitCallbackBlock> it = callbacks.iterator(); while(it.hasNext()) { InitCallbackBlock block = it.next(); block.callback.onInit(service); if(!block.persistent) { it.remove(); } } return service; } }
/** * Register an init callback that will be executed upon initialization. * * @param callback valid callback. * @param persistent should the callback persist after the singleton is initialized, will be removed if false. */ public static void registerInitCallback(ErraiInitCallback callback, boolean persistent) { synchronized (monitor) { InitCallbackBlock block = new InitCallbackBlock(callback, persistent); if (isActive()) { callback.onInit(getService()); if(persistent) { callbacks.add(block); } } else { callbacks.add(block); } } }
private static ErraiService initService(final InitConfig config) { synchronized (getServiceLock) { if (ErraiServiceSingleton.isActive()) { return ErraiServiceSingleton.getService();