/** * Returns current {@link VariableEnvironment} object contains all the variables in current application. */ public static VariableEnvironment container(){ return AppContext.factory().getBean(VariableEnvironment.class); }
public EntityModule(DaoModule daoModule, MetaEntity meta, MApiModel am, EntityMapping em) { this.daoModule = daoModule; this.runtimeApi = daoModule.api.getDyna(); this.dao = daoModule.dao; this.meta = meta; this.am = am; this.em = em; this.mef = daoModule.factory.getBean(ModelExecutorFactory.class); }
/** * Returns the primary bean of the given type in current app context. * * @see BeanFactory#getBean(Class) */ public static <T> T getBean(Class<T> type) throws NoSuchBeanException { return factory().getBean(type); }
/** * Returns the default {@link ExpressionLanguage} bean in current app. */ public static ExpressionLanguage getAppDefaultExpressionLanguage() { return AppContext.factory().getBean(ExpressionLanguage.class); }
public void setFilteredIfByString(String expr) { expr = EL.removePrefixAndSuffix(expr); this.filteredIf = beanFactory.getBean(ExpressionLanguage.class).createExpression(expr); } }
public static void main(String[] args) throws Exception { CliCommander commander = AppContext.factory().getBean(CliCommander.class); registerCommands(commander); commander.run(); }
/** * Returns the cached {@link Db} instance for the {@link DataSource} managed by {@link DataSourceManager}. * * @see DataSourceManager#getDataSource(String) */ public static Db getInstance(String name) throws NestedSQLException,UnsupportedDbPlatformException,ObjectNotFoundException { DataSourceManager dsm = AppContext.factory().getBean(DataSourceManager.class); return getInstance(name, dsm.getDataSource(name)); }
protected String getNonApiRoutes(BeanFactory factory, Map<RequestMappingInfo, Object> mappings) { Routes routes = factory.getBean(RouteManager.class).createRoutes(); PathTemplateFactory ptf = factory.getBean(PathTemplateFactory.class); mappings.forEach((info, handler) -> { routes.add(mappingToRoute(ptf, info, handler)); }); DefaultRoutesPrinter printer = new DefaultRoutesPrinter(); printer.setPrintView(false); return routes.size() + " non-api routes (not at swagger.json) : \n\n" + printer.print(routes); }
public static OrmContext context(Class<?> entityClass) { OrmRegistry registry = AppContext.factory().getBean(OrmRegistry.class); for(OrmContext context : registry.contexts()) { if(context.getMetadata().tryGetEntityMapping(entityClass) != null) { return context; } } throw new IllegalStateException("Orm context not found for entity class '" + entityClass + "'"); }
protected static OrmContext getContext(String name,boolean primary){ OrmRegistry registry = AppContext.factory().getBean(OrmRegistry.class); OrmContext context = primary ? registry.getDefaultContext() : null; if(null != context) { return context; } return registry.getContext(name); }
/** * Returns the cached {@link Db} instance for the default {@link DataSource} managed by {@link DataSourceManager}. * * @see DataSourceManager#getDefaultDataSource() */ public static Db getInstance() { DataSourceManager dsm = AppContext.factory().getBean(DataSourceManager.class); return getInstance(DataSourceManager.DEFAULT_DATASOURCE_NAME, dsm.getDefaultDataSource()); }
protected void doConfiguration(App app, ApiConfigurator c) { if(null == c.config().getFailureHandler()) { c.setFailureHandler(app.factory().getBean(ApiFailureHandler.class)); } //todo : oauth //todo : cors commonResponses.forEach(c::putCommonResponse); }
protected void initBeans(String name,DataSource ds,boolean primary) { if(ds instanceof Lazy) { return; } Db db = factory.tryGetBean(Db.class,name); if(null == db){ db = DbFactory.getInstance(name,ds); factory.addBean(Db.class,db,name,primary); } Assert.isTrue(db == factory.getBean(Db.class,name)); }
@Override public void postInject(BeanFactory factory) { _readonly.check(); if(null == jdbcExecutor){ jdbcExecutor = factory.getBean(JdbcExecutorFactory.class).createJdbcExecutor(ormContext); } if(null == transactionProvider) { transactionProvider = transactionManager.getProvider(ormContext.getDataSource()); } }
@Override public void preAppStart(App app) throws Throwable { if (app.config().getBooleanProperty(Config.PROP_START, true)) { Engine engine = app.factory().getBean(Engine.class); engine.start(); } }
@Override public Dao dao() { OrmContext tlOrmContext = ModelRegistry.getThreadLocalContext(); if(null != tlOrmContext){ return tlOrmContext.getAppContext().getBeanFactory().getBean(Dao.class,tlOrmContext.getName()); } return dao_; }
protected void registerDefaults(final BeanFactory beanFactory) { registerVariable("env",new EnvPropertyResolver(beanFactory.getBean(VariableEnvironment.class))); registerVariable("beans",new BeansPropertyResolver(beanFactory)); }
@Override public void prepare(MetadataContext context, Sql sql) { processor = context.getAppContext().getBeanFactory().tryGetBean(SqlTagProcessor.class, name); if(null == processor) { throw new SqlConfigException("Sql tag processor '" + name + "' not exists, check it : " + toString()); }else{ processor.prepareTag(context, sql, this); } el = context.getAppContext().getBeanFactory().getBean(ExpressionLanguage.class); }