org.apache.ibatis.builder.xml.XMLConfigBuilder Java Examples
The following examples show how to use
org.apache.ibatis.builder.xml.XMLConfigBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XmlConfigBuilderTest.java From mybatis with Apache License 2.0 | 6 votes |
@Test public void registerJavaTypeInitializingTypeHandler() { final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\n" + "<configuration>\n" + " <typeHandlers>\n" + " <typeHandler javaType=\"org.apache.ibatis.builder.XmlConfigBuilderTest$MyEnum\"\n" + " handler=\"org.apache.ibatis.builder.XmlConfigBuilderTest$EnumOrderTypeHandler\"/>\n" + " </typeHandlers>\n" + "</configuration>\n"; XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG)); builder.parse(); TypeHandlerRegistry typeHandlerRegistry = builder.getConfiguration().getTypeHandlerRegistry(); TypeHandler<MyEnum> typeHandler = typeHandlerRegistry.getTypeHandler(MyEnum.class); assertTrue(typeHandler instanceof EnumOrderTypeHandler); assertArrayEquals(MyEnum.values(), ((EnumOrderTypeHandler) typeHandler).constants); }
Example #2
Source File: XmlConfigBuilderTest.java From mybaties with Apache License 2.0 | 6 votes |
@Test public void registerJavaTypeInitializingTypeHandler() { final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\n" + "<configuration>\n" + " <typeHandlers>\n" + " <typeHandler javaType=\"org.apache.ibatis.builder.XmlConfigBuilderTest$MyEnum\"\n" + " handler=\"org.apache.ibatis.builder.XmlConfigBuilderTest$EnumOrderTypeHandler\"/>\n" + " </typeHandlers>\n" + "</configuration>\n"; XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG)); builder.parse(); TypeHandlerRegistry typeHandlerRegistry = builder.getConfiguration().getTypeHandlerRegistry(); TypeHandler<MyEnum> typeHandler = typeHandlerRegistry.getTypeHandler(MyEnum.class); assertTrue(typeHandler instanceof EnumOrderTypeHandler); assertArrayEquals(MyEnum.values(), ((EnumOrderTypeHandler) typeHandler).constants); }
Example #3
Source File: ProcessEngineConfigurationImpl.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public Configuration initMybatisConfiguration(Environment environment, Reader reader, Properties properties) { XMLConfigBuilder parser = new XMLConfigBuilder(reader, "", properties); Configuration configuration = parser.getConfiguration(); if(databaseType != null) { configuration.setDatabaseId(databaseType); } configuration.setEnvironment(environment); initMybatisTypeHandlers(configuration); initCustomMybatisMappers(configuration); configuration = parseMybatisConfiguration(configuration, parser); return configuration; }
Example #4
Source File: AbstractEngineConfiguration.java From flowable-engine with Apache License 2.0 | 6 votes |
public Configuration initMybatisConfiguration(Environment environment, Reader reader, Properties properties) { XMLConfigBuilder parser = new XMLConfigBuilder(reader, "", properties); Configuration configuration = parser.getConfiguration(); if (databaseType != null) { configuration.setDatabaseId(databaseType); } configuration.setEnvironment(environment); initCustomMybatisMappers(configuration); initMybatisTypeHandlers(configuration); initCustomMybatisInterceptors(configuration); if (isEnableLogSqlExecutionTime()) { initMyBatisLogSqlExecutionTimePlugin(configuration); } configuration = parseMybatisConfiguration(parser); return configuration; }
Example #5
Source File: AbstractEngineConfiguration.java From flowable-engine with Apache License 2.0 | 6 votes |
public Configuration parseMybatisConfiguration(XMLConfigBuilder parser) { Configuration configuration = parser.parse(); if (dependentEngineMybatisTypeAliasConfigs != null) { for (MybatisTypeAliasConfigurator typeAliasConfig : dependentEngineMybatisTypeAliasConfigs) { typeAliasConfig.configure(configuration.getTypeAliasRegistry()); } } if (dependentEngineMybatisTypeHandlerConfigs != null) { for (MybatisTypeHandlerConfigurator typeHandlerConfig : dependentEngineMybatisTypeHandlerConfigs) { typeHandlerConfig.configure(configuration.getTypeHandlerRegistry()); } } parseDependentEngineMybatisXMLMappers(configuration); parseCustomMybatisXMLMappers(configuration); return configuration; }
Example #6
Source File: FormEngineConfiguration.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public Configuration initMybatisConfiguration(Environment environment, Reader reader, Properties properties) { XMLConfigBuilder parser = new XMLConfigBuilder(reader, "", properties); Configuration configuration = parser.getConfiguration(); if (databaseType != null) { configuration.setDatabaseId(databaseType); } configuration.setEnvironment(environment); initCustomMybatisMappers(configuration); configuration = parseMybatisConfiguration(configuration, parser); return configuration; }
Example #7
Source File: SqlSessionFactoryBean.java From gocd with Apache License 2.0 | 5 votes |
private SqlSessionFactory buildSqlSessionFactory() throws IOException { SqlSessionFactoryBuilder factoryBuilder = new SqlSessionFactoryBuilder(); XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder(configLocation.getInputStream()); Configuration configuration = xmlConfigBuilder.getConfiguration(); configuration.setEnvironment(new Environment(getClass().getSimpleName(), new SpringManagedTransactionFactory(), this.dataSource)); xmlConfigBuilder.parse(); return factoryBuilder.build(configuration); }
Example #8
Source File: XmlConfigBuilderTest.java From mybatis with Apache License 2.0 | 5 votes |
@Test public void shouldSuccessfullyLoadMinimalXMLConfigFile() throws Exception { String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); XMLConfigBuilder builder = new XMLConfigBuilder(inputStream); Configuration config = builder.parse(); assertNotNull(config); }
Example #9
Source File: XmlConfigBuilderTest.java From mybaties with Apache License 2.0 | 5 votes |
@Test public void shouldSuccessfullyLoadMinimalXMLConfigFile() throws Exception { String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); XMLConfigBuilder builder = new XMLConfigBuilder(inputStream); Configuration config = builder.parse(); assertNotNull(config); }
Example #10
Source File: MyBatisDataStore.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
/** * Loads the MyBatis configuration for this store. */ @VisibleForTesting protected Configuration loadMyBatisConfiguration(final Environment environment) throws IOException { if (directories == null) { info("Using default MyBatis configuration"); return new Configuration(); } Path configPath = myBatisConfigPath(environment); info("Loading MyBatis configuration from {}", configPath); try (InputStream in = newInputStream(configPath); TcclBlock block = begin(getClass())) { return new XMLConfigBuilder(in, null, new Properties()).parse(); } }
Example #11
Source File: ProcessEngineConfigurationImpl.java From flowable-engine with Apache License 2.0 | 5 votes |
protected Configuration initMybatisConfiguration(Environment environment, Reader reader, Properties properties) { XMLConfigBuilder parser = new XMLConfigBuilder(reader, "", properties); Configuration configuration = parser.getConfiguration(); configuration.setEnvironment(environment); initMybatisTypeHandlers(configuration); initCustomMybatisMappers(configuration); configuration = parseMybatisConfiguration(configuration, parser); return configuration; }
Example #12
Source File: DmnEngineConfiguration.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public Configuration initMybatisConfiguration(Environment environment, Reader reader, Properties properties) { XMLConfigBuilder parser = new XMLConfigBuilder(reader, "", properties); Configuration configuration = parser.getConfiguration(); if (databaseType != null) { configuration.setDatabaseId(databaseType); } configuration.setEnvironment(environment); initCustomMybatisMappers(configuration); configuration = parseMybatisConfiguration(configuration, parser); return configuration; }
Example #13
Source File: ProcessEngineConfigurationImpl.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected Configuration initMybatisConfiguration(Environment environment, Reader reader, Properties properties) { XMLConfigBuilder parser = new XMLConfigBuilder(reader,"", properties); Configuration configuration = parser.getConfiguration(); configuration.setEnvironment(environment); initMybatisTypeHandlers(configuration); initCustomMybatisMappers(configuration); configuration = parseMybatisConfiguration(configuration, parser); return configuration; }
Example #14
Source File: DmnEngineConfiguration.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public Configuration parseMybatisConfiguration(Configuration configuration, XMLConfigBuilder parser) { return parseCustomMybatisXMLMappers(parser.parse()); }
Example #15
Source File: ProcessEngineConfigurationImpl.java From flowable-engine with Apache License 2.0 | 4 votes |
protected Configuration parseMybatisConfiguration(Configuration configuration, XMLConfigBuilder parser) { return parseCustomMybatisXMLMappers(parser.parse()); }
Example #16
Source File: ProcessEngineConfigurationImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public Configuration parseMybatisConfiguration(Configuration configuration, XMLConfigBuilder parser) { return parseCustomMybatisXMLMappers(parser.parse()); }
Example #17
Source File: ProcessEngineConfigurationImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
protected Configuration parseMybatisConfiguration(Configuration configuration, XMLConfigBuilder parser) { return parseCustomMybatisXMLMappers(parser.parse()); }
Example #18
Source File: FormEngineConfiguration.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public Configuration parseMybatisConfiguration(Configuration configuration, XMLConfigBuilder parser) { return parseCustomMybatisXMLMappers(parser.parse()); }
Example #19
Source File: ConfigurationProxy.java From HotswapAgent with GNU General Public License v2.0 | 4 votes |
public static ConfigurationProxy getWrapper(XMLConfigBuilder configBuilder) { if (!proxiedConfigurations.containsKey(configBuilder)) { proxiedConfigurations.put(configBuilder, new ConfigurationProxy(configBuilder)); } return proxiedConfigurations.get(configBuilder); }
Example #20
Source File: ConfigurationProxy.java From HotswapAgent with GNU General Public License v2.0 | 4 votes |
private ConfigurationProxy(XMLConfigBuilder configBuilder) { this.configBuilder = configBuilder; }
Example #21
Source File: MultipleSqlSessionFactoryBean.java From super-cloudops with Apache License 2.0 | 3 votes |
/** * Apply setting default configuration. * * <pre> * mybatis-config.xml: * * <?xml version="1.0" encoding="UTF-8" ?> * <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> * <configuration> * <settings> * <!-- LOGBACK|SLF4J|LOG4J|LOG4J2|JDK_LOGGING|COMMONS_LOGGING|STDOUT_LOGGING|NO_LOGGING --> * <setting name="logImpl" value="LOGBACK" /> * ... * </settings> * </configuration> * </pre> * * @throws IOException */ private void applyDefaultConfiguration() throws IOException { Resource configLocation = (Resource) getField(configLocationField, this); if (nonNull(configLocation)) { Properties props = (Properties) getField(configPropertiesField, this); XMLConfigBuilder builder = new XMLConfigBuilder(configLocation.getInputStream(), null, props); Configuration config = builder.getConfiguration(); // Register support for logback. config.getTypeAliasRegistry().registerAlias("LOGBACK", LogbackImpl.class); setConfiguration(config); } }