static ServiceRef valueOf(String address) { if (address == null || address.isEmpty()) { return null; } else { return Services.current().service(address); } }
/** * Lookup a child service in the ServiceManager with a relative path. * <p> * The lookup is a convenience method based on the ServiceManager's lookup. * * @param path a relative path to the service. */ default ServiceRef service(String path) { if (!path.startsWith("/")) { throw new IllegalArgumentException(path + " must start with '/'"); } return services().service(address() + path); }
public RepositoryImpl(Class<T> entityClass, Class<ID> idClass, DatabaseService db) { Objects.requireNonNull(entityClass); Objects.requireNonNull(idClass); _entityClass = entityClass; _idClass = idClass; if (db == null) { db = Services.current() .service("bardb:///") .as(DatabaseService.class); } _db = db; }
private Object readResolve() { return Services.current().service(_address).as(_api); } }
@Override public T convert(String key) { return manager().service(_address + key).as(_itemType); }
@OnActive public void onActive() { Services manager = AmpSystem.currentManager(); _linkEventPublisher = manager.service(LinkBartenderEvents.ADDRESS) .as(LinkBartenderEvents.class); }
public PodHeartbeatImpl(BartenderSystem bartender, ServerHeartbeat serverSelf, HeartbeatService heartbeatService, HeartbeatServiceLocal heartbeatLocal) { Objects.requireNonNull(bartender); Objects.requireNonNull(serverSelf); _bartender = bartender; _serverSelf = serverSelf; // _podManager = new PodManagerImpl(_bartender, serverSelf, this); _updatePodSystem = new UpdatePodSystem(_podUpdateMap.values(), _updatePodSystem); // _heartbeatService = heartbeatService; _heartbeatLocal = heartbeatLocal; // EventService eventService = AmpSystem.getCurrent().getEventService(); Services manager = AmpSystem.currentManager(); _podEvents = manager.service(PodOnUpdate.ADDRESS) .as(PodOnUpdate.class); // initPods(podBuilderList); _clusterRoot = getPodProxy(CLUSTER_ROOT + "." + serverSelf.getClusterId()); }
@Override public Object read(JsonReaderImpl in) { if (in.peek() == InJson.Event.VALUE_NULL) { in.next(); return null; } else { String address = in.readString(); System.out.println("JDSR: " + address); Services manager = Services.current(); return manager.service(address); } } }
protected void init(Config systemConfig) { _config = new OauthConfig(); _config.clientId("e1b0014930028455edea"); _config.clientSecret("c67fa0c49a19ebfaf578036257131adf166a488a"); _config.codeUri("https://github.com/login/oauth/authorize"); _config.tokenUri("https://github.com/login/oauth/access_token"); //systemConfig.inject(_config); _config.validate(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("oauth authentication added, codeUri=" + _config.codeUri() + ", tokenUri=" + _config.tokenUri()); } _runnableService = Services.current().service(RunnableService.class); }
public void start() { Services manager = AmpSystem.currentManager(); //EventService events = AmpSystem.getCurrent().getEventService(); EventsSync events = manager.service(EventsSync.class); events.subscriber(ServerOnUpdate.class, s->onServerUpdate(s)); for (ServerHeartbeat server : _serverSelf.getCluster().getServers()) { onServerUpdate(server); } }
@Override public void onActive() { _isReplay = false; if (_isActive) { return; } _isActive = true; _serviceSelf = ServiceRef.current(); if (_journalDelay > 0) { Services manager = _serviceSelf.services(); _timerService = manager.service("timer:").as(Timers.class); Consumer<Cancel> startSave = h->startSave(); _startSaveRef = (Consumer<Cancel>) _serviceSelf.pin(startSave).as(Consumer.class); } super.onActive(); startSave(); }
public void start() { Services manager = AmpSystem.currentManager(); EventsSync events = manager.service(EventsSync.class); /* manager.service("event:///" + ServerOnUpdate.class.getName()) .subscribe(new ServerListener()); */ events.subscriber(ServerOnUpdate.class, new ServerListener()); ServiceRef selfRef = ServiceRef.current(); PodOnUpdate listener = selfRef.pin(new PodUpdateListener()) .as(PodOnUpdate.class); /* manager.service("event:///" + PodOnUpdate.class.getName()) .subscribe(listener); */ events.subscriber(PodOnUpdate.class, listener); }
@Test public void test() { ResultFuture<String> result = new ResultFuture<>(); _services.service("/hello").as(Q_basicService.class).test(result); Assert.assertEquals("Hello World!", result.get(1, TimeUnit.SECONDS)); }