Example usage for org.apache.ibatis.parsing XNode getBooleanAttribute

List of usage examples for org.apache.ibatis.parsing XNode getBooleanAttribute

Introduction

In this page you can find the example usage for org.apache.ibatis.parsing XNode getBooleanAttribute.

Prototype

public Boolean getBooleanAttribute(String name, Boolean def) 

Source Link

Usage

From source file:com.baomidou.mybatisplus.MybatisXMLMapperBuilder.java

License:Apache License

private void cacheElement(XNode context) throws Exception {
    if (context != null) {
        String type = context.getStringAttribute("type", "PERPETUAL");
        Class<? extends Cache> typeClass = typeAliasRegistry.resolveAlias(type);
        String eviction = context.getStringAttribute("eviction", "LRU");
        Class<? extends Cache> evictionClass = typeAliasRegistry.resolveAlias(eviction);
        Long flushInterval = context.getLongAttribute("flushInterval");
        Integer size = context.getIntAttribute("size");
        boolean readWrite = !context.getBooleanAttribute("readOnly", false);
        boolean blocking = context.getBooleanAttribute("blocking", false);
        Properties props = context.getChildrenAsProperties();
        builderAssistant.useNewCache(typeClass, evictionClass, flushInterval, size, readWrite, blocking, props);
    }//from  w ww .ja v a 2  s. co  m
}

From source file:com.dmm.framework.basedb.apache.ibatis.builder.xml.XMLMapperBuilder.java

License:Apache License

private void cacheElement(XNode context) throws Exception {
    if (context != null) {
        String type = context.getStringAttribute("type", "PERPETUAL");
        Class<? extends Cache> typeClass = typeAliasRegistry.resolveAlias(type);
        String eviction = context.getStringAttribute("eviction", "LRU");
        Class<? extends Cache> evictionClass = typeAliasRegistry.resolveAlias(eviction);
        Long flushInterval = context.getLongAttribute("flushInterval");
        Integer size = context.getIntAttribute("size");
        boolean readWrite = !context.getBooleanAttribute("readOnly", false);
        Properties props = context.getChildrenAsProperties();
        builderAssistant.useNewCache(typeClass, evictionClass, flushInterval, size, readWrite, props);
    }/*from w w w.  ja  v a  2s  .  co  m*/
}

From source file:com.ibatis.sqlmap.engine.builder.XmlSqlMapConfigParser.java

License:Apache License

@NodeEvent("/sqlMapConfig/settings")
public void sqlMapConfigsettings(XNode context) throws Exception {
    boolean classInfoCacheEnabled = context.getBooleanAttribute("classInfoCacheEnabled", true);
    MetaClass.setClassCacheEnabled(classInfoCacheEnabled);

    boolean lazyLoadingEnabled = context.getBooleanAttribute("lazyLoadingEnabled", true);
    config.setLazyLoadingEnabled(lazyLoadingEnabled);

    boolean statementCachingEnabled = context.getBooleanAttribute("statementCachingEnabled", true);
    if (statementCachingEnabled) {
        config.setDefaultExecutorType(ExecutorType.REUSE);
    }//from w  ww  .ja v a  2s  . c  o m

    boolean batchUpdatesEnabled = context.getBooleanAttribute("batchUpdatesEnabled", true);
    if (batchUpdatesEnabled) {
        config.setDefaultExecutorType(ExecutorType.BATCH);
    }

    boolean cacheModelsEnabled = context.getBooleanAttribute("cacheModelsEnabled", true);
    config.setCacheEnabled(cacheModelsEnabled);

    boolean useColumnLabel = context.getBooleanAttribute("useColumnLabel", false);
    config.setUseColumnLabel(useColumnLabel);

    boolean forceMultipleResultSetSupport = context.getBooleanAttribute("forceMultipleResultSetSupport", true);
    config.setMultipleResultSetsEnabled(forceMultipleResultSetSupport);

    useStatementNamespaces = context.getBooleanAttribute("useStatementNamespaces", false);

    Integer defaultTimeout = context.getIntAttribute("defaultStatementTimeout");
    config.setDefaultStatementTimeout(defaultTimeout);
}

From source file:com.ibatis.sqlmap.engine.builder.XmlSqlMapConfigParser.java

License:Apache License

@NodeEvent("/sqlMapConfig/transactionManager/end()")
public void sqlMapConfigtransactionManagerend(XNode context) throws Exception {
    String type = context.getStringAttribute("type");
    Class txClass = config.getTypeAliasRegistry().resolveAlias(type);
    boolean commitRequired = context.getBooleanAttribute("commitRequired", false);

    TransactionConfig txConfig = (TransactionConfig) txClass.newInstance();
    txConfig.setDataSource(config.getDataSource());
    txConfig.setProperties(transactionManagerProps);
    txConfig.setForceCommit(commitRequired);
    config.setTransactionManager(new TransactionManager(config, txConfig));
}

From source file:com.ibatis.sqlmap.engine.builder.XmlSqlMapParser.java

License:Apache License

@NodeEvent("/sqlMap/cacheModel")
public void sqlMapcacheModel(XNode context) throws Exception {
    String id = applyNamespace(context.getStringAttribute("id"));
    String type = context.getStringAttribute("type");
    Boolean readOnly = context.getBooleanAttribute("readOnly", true);
    Boolean serialize = context.getBooleanAttribute("serialize", true);
    Class clazz = config.getTypeAliasRegistry().resolveAlias(type);
    cacheBuilder = new CacheBuilder(id);
    cacheBuilder.addDecorator(clazz);/* w  w w  . j a  va  2 s . c  o m*/

    //LOCAL_READ_WRITE (serializable=false, readOnly=false)
    //SHARED_READ_ONLY (serializable=false, readOnly=true)
    //SHARED_READ_WRITE (serializable=true, readOnly=false)
    if (serialize) {
        if (readOnly) {
            cacheBuilder.readWrite(false);
        } else {
            cacheBuilder.readWrite(true);
        }
    } else {
        if (readOnly) {
            cacheBuilder.readWrite(false);
        } else {
            cacheBuilder = null;
        }
    }
}

From source file:org.mybatis.spring.utils.XMLMapperBuilder.java

License:Apache License

private void cacheElement(XNode context) throws Exception {
    if (context != null) {
        String type = context.getStringAttribute("type", "PERPETUAL");
        Class<? extends Cache> typeClass = typeAliasRegistry.resolveAlias(type);
        String eviction = context.getStringAttribute("eviction", "LRU");
        Class<? extends Cache> evictionClass = typeAliasRegistry.resolveAlias(eviction);
        Long flushInterval = context.getLongAttribute("flushInterval");
        Integer size = context.getIntAttribute("size");
        boolean readWrite = !context.getBooleanAttribute("readOnly", false);
        Properties props = context.getChildrenAsProperties();
        builderAssistant.useNewCache(typeClass, evictionClass, flushInterval, size, readWrite, readWrite,
                props);//from ww  w . j  a  va2  s. c  om
    }
}