Search in sources :

Example 21 with XNode

use of org.apache.ibatis.parsing.XNode in project alfresco-repository by Alfresco.

the class HierarchicalXMLConfigBuilder method environmentsElement.

private void environmentsElement(XNode context) throws Exception {
    if (context != null) {
        if (environment == null) {
            environment = context.getStringAttribute("default");
        }
        for (XNode child : context.getChildren()) {
            String id = child.getStringAttribute("id");
            if (isSpecifiedEnvironment(id)) {
                TransactionFactory txFactory = transactionManagerElement(child.evalNode("transactionManager"));
                DataSourceFactory dsFactory = dataSourceElement(child.evalNode("dataSource"));
                DataSource dataSource = dsFactory.getDataSource();
                Environment.Builder environmentBuilder = new Environment.Builder(id).transactionFactory(txFactory).dataSource(dataSource);
                configuration.setEnvironment(environmentBuilder.build());
            }
        }
    }
}
Also used : DataSourceFactory(org.apache.ibatis.datasource.DataSourceFactory) XNode(org.apache.ibatis.parsing.XNode) TransactionFactory(org.apache.ibatis.transaction.TransactionFactory) BaseBuilder(org.apache.ibatis.builder.BaseBuilder) XMLMapperBuilder(org.apache.ibatis.builder.xml.XMLMapperBuilder) Environment(org.apache.ibatis.mapping.Environment) DataSource(javax.sql.DataSource)

Example 22 with XNode

use of org.apache.ibatis.parsing.XNode in project alfresco-repository by Alfresco.

the class HierarchicalXMLConfigBuilder method typeAliasesElement.

private void typeAliasesElement(XNode parent) {
    if (parent != null) {
        for (XNode child : parent.getChildren()) {
            if ("package".equals(child.getName())) {
                String typeAliasPackage = child.getStringAttribute("name");
                configuration.getTypeAliasRegistry().registerAliases(typeAliasPackage);
            } else {
                String alias = child.getStringAttribute("alias");
                String type = child.getStringAttribute("type");
                try {
                    Class<?> clazz = Resources.classForName(type);
                    if (alias == null) {
                        typeAliasRegistry.registerAlias(clazz);
                    } else {
                        typeAliasRegistry.registerAlias(alias, clazz);
                    }
                } catch (ClassNotFoundException e) {
                    throw new BuilderException("Error registering typeAlias for '" + alias + "'. Cause: " + e, e);
                }
            }
        }
    }
}
Also used : BuilderException(org.apache.ibatis.builder.BuilderException) XNode(org.apache.ibatis.parsing.XNode)

Aggregations

XNode (org.apache.ibatis.parsing.XNode)22 ArrayList (java.util.ArrayList)5 BuilderException (org.apache.ibatis.builder.BuilderException)5 JdbcType (org.apache.ibatis.type.JdbcType)4 InputStream (java.io.InputStream)3 HashMap (java.util.HashMap)3 IncompleteElementException (org.apache.ibatis.builder.IncompleteElementException)3 List (java.util.List)2 Properties (java.util.Properties)2 DataSource (javax.sql.DataSource)2 BaseBuilder (org.apache.ibatis.builder.BaseBuilder)2 ResultMapResolver (org.apache.ibatis.builder.ResultMapResolver)2 XMLMapperBuilder (org.apache.ibatis.builder.xml.XMLMapperBuilder)2 DataSourceFactory (org.apache.ibatis.datasource.DataSourceFactory)2 Discriminator (org.apache.ibatis.mapping.Discriminator)2 Environment (org.apache.ibatis.mapping.Environment)2 ParameterMapping (org.apache.ibatis.mapping.ParameterMapping)2 ResultFlag (org.apache.ibatis.mapping.ResultFlag)2 ResultMapping (org.apache.ibatis.mapping.ResultMapping)2 XPathParser (org.apache.ibatis.parsing.XPathParser)2