@Override protected void applyTo(final App app) { super.applyTo(app); app.jobManager().on(SysEventId.PRE_START, new Runnable() { @Override public void run() { MorphiaService.MorphiaServiceProvider provider = app.getInstance(MorphiaService.MorphiaServiceProvider.class); app.injector().registerProvider(MorphiaService.class, provider); app.injector().registerNamedProvider(MorphiaService.class, provider); } }); }
@Override protected void applyTo(App app) { Set<Class<? extends Annotation>> entityAnnotations = entityAnnotations(); if (!entityAnnotations.isEmpty()) { MasterEntityMetaInfoRepo repo = app.entityMetaInfoRepo(); for (Class<? extends Annotation> annoType : entityAnnotations) { repo.registerEntityAnnotation(annoType); } } }
@Override public void register() { super.register(); registerGlobalMappingFilter(); }
private void initService(String dbId, Map<String, String> conf) { Map<String, String> svcConf = new HashMap<>(); String prefix = "db." + (S.blank(dbId) ? "" : dbId + "."); for (String key : conf.keySet()) { if (key.startsWith(prefix)) { String o = conf.get(key); svcConf.put(key.substring(prefix.length()), o); } } String impl = svcConf.remove("impl"); String svcId = S.empty(dbId) ? DEFAULT : dbId; if (null == impl) { throw new ConfigurationException("Cannot init db service[%s]: implementation not specified", svcId); } DbPlugin plugin = Act.dbManager().plugin(impl); if (null == plugin) { throw new ConfigurationException("Cannot init db service[%s]: implementation not found: %s", svcId, impl); } DbService svc = plugin.initDbService(S.blank(dbId) ? DEFAULT : dbId, app(), svcConf); serviceMap.put(svcId, svc); logger.info("db service[%s] initialized", svcId); }
private void initService(String dbId, Map<String, String> conf) { Map<String, String> svcConf = new HashMap<>(); String prefix = "db." + (S.blank(dbId) ? "" : dbId + "."); for (String key : conf.keySet()) { if (key.startsWith(prefix)) { String o = conf.get(key); svcConf.put(key.substring(prefix.length()), o); } } String impl = svcConf.remove("impl"); String svcId = S.empty(dbId) ? DEFAULT : dbId; if (null == impl) { throw new ConfigurationException("Cannot init db service[%s]: implementation not specified", svcId); } DbPlugin plugin = Act.dbManager().plugin(impl); if (null == plugin) { throw new ConfigurationException("Cannot init db service[%s]: implementation not found: %s", svcId, impl); } DbService svc = plugin.initDbService(S.blank(dbId) ? DEFAULT : dbId, app(), svcConf); serviceMap.put(svcId, svc); logger.info("db service[%s] initialized", svcId); }
@Override protected void applyTo(App app) { super.applyTo(app); app.eventBus().bind(TxStart.class, new ActEventListenerBase<TxStart>() { @Override public void on(TxStart eventObject) { TxInfo info = eventObject.source(); TxScope scope = new TxScope(); scope.setReadOnly(info.readOnly()); HelpScopeTrans.enter(scope); } }).bind(TxStop.class, new ActEventListenerBase() { @Override public void on(EventObject eventObject) throws Exception { HelpScopeTrans.exit(null, 1); } }).bind(TxError.class, new ActEventListenerBase<TxError>() { @Override public void on(TxError eventObject) throws Exception { Throwable cause = eventObject.source(); HelpScopeTrans.exit(cause, Opcodes.ATHROW); } }); }
} else { logger.warn("DB configuration not found. Will try to init default service with the sole db plugin: %s", db); DbService svc = db.initDbService(DEFAULT, app(), new HashMap<String, String>()); serviceMap.put(DEFAULT, svc); return; DbService svc = db.initDbService(DEFAULT, app(), svcConf); serviceMap.put(DEFAULT, svc);
@Override protected void applyTo(App app) { Set<Class<? extends Annotation>> entityAnnotations = entityAnnotations(); if (!entityAnnotations.isEmpty()) { MasterEntityMetaInfoRepo repo = app.entityMetaInfoRepo(); for (Class<? extends Annotation> annoType : entityAnnotations) { repo.registerEntityAnnotation(annoType); } } }
} else { logger.warn("DB configuration not found. Will try to init default service with the sole db plugin: %s", db); DbService svc = db.initDbService(DEFAULT, app(), new HashMap<String, String>()); serviceMap.put(DEFAULT, svc); return; DbService svc = db.initDbService(DEFAULT, app(), svcConf); serviceMap.put(DEFAULT, svc);