private Services manager() { if (_manager == null) { _manager = Services.current(); } return _manager; } }
static ServicesAmp current() { return (ServicesAmp) Services.current(); }
static ServiceRef valueOf(String address) { if (address == null || address.isEmpty()) { return null; } else { return Services.current().service(address); } }
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 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); } } }
@OnInit public void onActive() { FileChangeService listener = new FileChangeService(); Services manager = Services.current(); _fileTable.addListener(manager.newService(listener).as(TableListener.class)); // _dirTable.addListener(new DirChangeListener()); }
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); }
@OnInit public void onInit() throws Exception { String address = ServiceRef.current().address() + _id; _logger.log(Level.CONFIG, "onInit: id=" + _id + ", service address=" + address); _jdbcConfig = JdbcConfig.from(_config, address); _logger.log(Level.CONFIG, "onInit: config=" + _jdbcConfig); Properties props = new Properties(); if (_jdbcConfig.user() != null) { props.setProperty("user", _jdbcConfig.user()); if (_jdbcConfig.pass() != null) { props.setProperty("password", _jdbcConfig.pass()); } } Supplier<JdbcConnection> supplier = new ConnectionSupplier(_jdbcConfig.url(), props, _jdbcConfig.testQueryBefore(), _jdbcConfig.testQueryAfter()); ServiceBuilder builder = Services.current().newService(JdbcConnection.class, supplier); ServiceRef ref = builder.workers(_jdbcConfig.poolSize()).start(); _conn = ref.as(JdbcConnection.class); }