public void appendPreprocessor(SqlProvider provider) { preprocessors.add(provider); if (provider instanceof ConfigurationAware) { ((ConfigurationAware) provider).setConfiguration(configuration); } }
protected void initProviders() { Arrays.asList(new MySQL(), new PostgreSQL()).forEach(p -> providerMap.put(p.toString(), p)); for (SqlProvider provider : providerMap.values()) { if (provider instanceof ConfigurationAware) { ((ConfigurationAware) provider).setConfiguration(configuration); } } }
protected void initProviders() { providers = Collections.unmodifiableList(Arrays.asList(new InsertEnhancement(), new UpdateEnhancement(), new TableEnhancement(), new NullEnhancement(), new ListParameterEnhancement())); for (SqlProvider p : providers) { if (p instanceof ConfigurationAware) { ((ConfigurationAware) p).setConfiguration(configuration); } } }
@Override public void replace(Connection connection, MetaObject metaObject, MappedStatement mappedStatement, BoundSql boundSql) { if (Objects.equals(boundSql.getSql(), SqlProvider.MYBATIS_BOOST)) { Class<?> providerType = (Class<?>) SystemMetaObject.forObject(mappedStatement.getSqlSource()).getValue("providerType"); SqlProvider provider = providerMap.get(providerType); if (provider == null) { synchronized (providerType) { provider = providerMap.computeIfAbsent(providerType, UncheckedFunction.of(k -> { SqlProvider p = (SqlProvider) providerType.newInstance(); if (p instanceof ConfigurationAware) { ((ConfigurationAware) p).setConfiguration(configuration); } return p; })); } } if (provider != null) { provider.replace(connection, metaObject, mappedStatement, boundSql); } } } }