@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); }
@Override public void init(ServicesBuilder builder) { SchemePipeImpl pipeScheme = new SchemePipeImpl("pipe:"); builder.service(pipeScheme) .address("pipe:") .start(); InjectorBuilder injector = builder.injector(); injector.bean(PipeInMethodGenerator.class) .to(Key.of(MethodOnInitGenerator.class, PipeIn.class)); // builder.in //pipeRef.start(); //services. } }