当前位置: 首页>>代码示例>>Java>>正文


Java PluginConfiguration类代码示例

本文整理汇总了Java中org.mybatis.generator.config.PluginConfiguration的典型用法代码示例。如果您正苦于以下问题:Java PluginConfiguration类的具体用法?Java PluginConfiguration怎么用?Java PluginConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PluginConfiguration类属于org.mybatis.generator.config包,在下文中一共展示了PluginConfiguration类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseIbatorPlugin

import org.mybatis.generator.config.PluginConfiguration; //导入依赖的package包/类
private void parseIbatorPlugin(Context context, Node node) {
    PluginConfiguration pluginConfiguration = new PluginConfiguration();

    context.addPluginConfiguration(pluginConfiguration);

    Properties attributes = parseAttributes(node);
    String type = attributes.getProperty("type"); //$NON-NLS-1$

    pluginConfiguration.setConfigurationType(type);

    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node childNode = nodeList.item(i);

        if (childNode.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseProperty(pluginConfiguration, childNode);
        }
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:24,代码来源:IbatorConfigurationParser.java

示例2: parsePlugin

import org.mybatis.generator.config.PluginConfiguration; //导入依赖的package包/类
private void parsePlugin(Context context, Node node) {
    PluginConfiguration pluginConfiguration = new PluginConfiguration();

    context.addPluginConfiguration(pluginConfiguration);

    Properties attributes = parseAttributes(node);
    String type = attributes.getProperty("type"); //$NON-NLS-1$

    pluginConfiguration.setConfigurationType(type);

    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node childNode = nodeList.item(i);

        if (childNode.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
            parseProperty(pluginConfiguration, childNode);
        }
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:24,代码来源:MyBatisGeneratorConfigurationParser.java

示例3: parseIbatorPlugin

import org.mybatis.generator.config.PluginConfiguration; //导入依赖的package包/类
private void parseIbatorPlugin(Context context, Node node) {
	PluginConfiguration pluginConfiguration = new PluginConfiguration();

	context.addPluginConfiguration(pluginConfiguration);

	Properties attributes = parseAttributes(node);
	String type = attributes.getProperty("type"); //$NON-NLS-1$

	pluginConfiguration.setConfigurationType(type);

	NodeList nodeList = node.getChildNodes();
	for (int i = 0; i < nodeList.getLength(); i++) {
		Node childNode = nodeList.item(i);

		if (childNode.getNodeType() != Node.ELEMENT_NODE) {
			continue;
		}

		if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
			parseProperty(pluginConfiguration, childNode);
		}
	}
}
 
开发者ID:fnyexx,项目名称:mybator,代码行数:24,代码来源:IbatorConfigurationParser.java

示例4: parsePlugin

import org.mybatis.generator.config.PluginConfiguration; //导入依赖的package包/类
private void parsePlugin(Context context, Node node) {
	PluginConfiguration pluginConfiguration = new PluginConfiguration();

	context.addPluginConfiguration(pluginConfiguration);

	Properties attributes = parseAttributes(node);
	String type = attributes.getProperty("type"); //$NON-NLS-1$

	pluginConfiguration.setConfigurationType(type);

	NodeList nodeList = node.getChildNodes();
	for (int i = 0; i < nodeList.getLength(); i++) {
		Node childNode = nodeList.item(i);

		if (childNode.getNodeType() != Node.ELEMENT_NODE) {
			continue;
		}

		if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
			parseProperty(pluginConfiguration, childNode);
		}
	}
}
 
开发者ID:fnyexx,项目名称:mybator,代码行数:24,代码来源:MyBatisGeneratorConfigurationParser.java

示例5: getPluginIndex

import org.mybatis.generator.config.PluginConfiguration; //导入依赖的package包/类
/**
 * 获取插件所在位置
 *
 * @param context 上下文
 * @param plugin 插件
 *
 * @return -1:未找到
 */
public static int getPluginIndex(Context context, Class plugin) {
    List<PluginConfiguration> list = getConfigPlugins(context);
    // 检查是否配置了ModelColumnPlugin插件
    for (int i = 0; i < list.size(); i++) {
        PluginConfiguration config = list.get(i);
        if (plugin.getName().equals(config.getConfigurationType())) {
            return i;
        }
    }
    return -1;
}
 
开发者ID:itfsw,项目名称:mybatis-generator-plugin,代码行数:20,代码来源:PluginTools.java

示例6: getConfigPlugins

import org.mybatis.generator.config.PluginConfiguration; //导入依赖的package包/类
/**
 * 获取插件列表
 * @param ctx 上下文
 * @return
 */
public static List<PluginConfiguration> getConfigPlugins(Context ctx) {
    try {
        // 利用反射获取pluginConfigurations属性
        Field field = Context.class.getDeclaredField("pluginConfigurations");
        field.setAccessible(true);
        return (List<PluginConfiguration>) field.get(ctx);
    } catch (Exception e) {
        logger.error("插件检查反射异常", e);
    }
    return new ArrayList<>();
}
 
开发者ID:itfsw,项目名称:mybatis-generator-plugin,代码行数:17,代码来源:PluginTools.java

示例7: getPluginConfiguration

import org.mybatis.generator.config.PluginConfiguration; //导入依赖的package包/类
/**
 * 获取插件配置
 *
 * @param context 上下文
 * @param plugin 插件
 * @return
 */
public static PluginConfiguration getPluginConfiguration(Context context, Class plugin){
    int index = getPluginIndex(context, plugin);
    if (index > -1){
        return getConfigPlugins(context).get(index);
    }
    return null;
}
 
开发者ID:itfsw,项目名称:mybatis-generator-plugin,代码行数:15,代码来源:PluginTools.java

示例8: setContext

import org.mybatis.generator.config.PluginConfiguration; //导入依赖的package包/类
/**
 * Set the context under which this plugin is running.
 *
 * @param context
 *            the new context
 */
@Override
public void setContext(Context context) {
    super.setContext(context);

    // 配置插件使用的模板引擎
    PluginConfiguration cfg = PluginTools.getPluginConfiguration(context, CommentPlugin.class);

    if (cfg == null || cfg.getProperty(CommentPlugin.PRO_TEMPLATE) == null){
        if (context.getCommentGenerator() instanceof DefaultCommentGenerator){
            // 使用默认模板引擎
            commentGenerator = new TemplateCommentGenerator("default-comment.ftl", true);
        } else {
            // 用户自定义
            commentGenerator = context.getCommentGenerator();
        }
    } else {
        TemplateCommentGenerator templateCommentGenerator = new TemplateCommentGenerator(cfg.getProperty(CommentPlugin.PRO_TEMPLATE), false);

        // ITFSW 插件使用的注释生成器
        commentGenerator = templateCommentGenerator;

        // 修正系统插件
        try {
            // 先执行一次生成CommentGenerator操作,然后再替换
            context.getCommentGenerator();

            Field field = Context.class.getDeclaredField("commentGenerator");
            field.setAccessible(true);
            field.set(context, templateCommentGenerator);
        } catch (Exception e) {
            logger.error("反射异常",e);
        }
    }
}
 
开发者ID:itfsw,项目名称:mybatis-generator-plugin,代码行数:41,代码来源:BasePlugin.java

示例9: setDomainObjectName

import org.mybatis.generator.config.PluginConfiguration; //导入依赖的package包/类
/**
 * 设置DomainObjectName和MapperName
 *
 * @param introspectedTable
 * @param context
 * @param domainObjectName
 */
public static void setDomainObjectName(IntrospectedTable introspectedTable, Context context, String domainObjectName) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
    // 配置信息(没啥用)
    introspectedTable.getTableConfiguration().setDomainObjectName(domainObjectName);

    // FullyQualifiedTable修正
    Field domainObjectNameField = FullyQualifiedTable.class.getDeclaredField("domainObjectName");
    domainObjectNameField.setAccessible(true);
    domainObjectNameField.set(introspectedTable.getFullyQualifiedTable(), domainObjectName);

    // 重新修正introspectedTable属性信息
    Method calculateJavaClientAttributes = IntrospectedTable.class.getDeclaredMethod("calculateJavaClientAttributes");
    calculateJavaClientAttributes.setAccessible(true);
    calculateJavaClientAttributes.invoke(introspectedTable);

    Method calculateModelAttributes = IntrospectedTable.class.getDeclaredMethod("calculateModelAttributes");
    calculateModelAttributes.setAccessible(true);
    calculateModelAttributes.invoke(introspectedTable);

    Method calculateXmlAttributes = IntrospectedTable.class.getDeclaredMethod("calculateXmlAttributes");
    calculateXmlAttributes.setAccessible(true);
    calculateXmlAttributes.invoke(introspectedTable);

    // 注意!! 如果配置了ExampleTargetPlugin插件,要修正Example 位置
    PluginConfiguration configuration = PluginTools.getPluginConfiguration(context, ExampleTargetPlugin.class);
    if (configuration != null && configuration.getProperty(ExampleTargetPlugin.PRO_TARGET_PACKAGE) != null) {
        String exampleType = introspectedTable.getExampleType();
        // 修改包名
        JavaModelGeneratorConfiguration javaModelGeneratorConfiguration = context.getJavaModelGeneratorConfiguration();
        String targetPackage = javaModelGeneratorConfiguration.getTargetPackage();
        String newExampleType = exampleType.replace(targetPackage, configuration.getProperty(ExampleTargetPlugin.PRO_TARGET_PACKAGE));

        introspectedTable.setExampleType(newExampleType);
    }
}
 
开发者ID:itfsw,项目名称:mybatis-generator-plugin,代码行数:42,代码来源:IntrospectedTableTools.java

示例10: createPlugin

import org.mybatis.generator.config.PluginConfiguration; //导入依赖的package包/类
public static Plugin createPlugin(Context context,
        PluginConfiguration pluginConfiguration) {
    Plugin plugin = (Plugin) createInternalObject(pluginConfiguration
            .getConfigurationType());
    plugin.setContext(context);
    plugin.setProperties(pluginConfiguration.getProperties());
    return plugin;
}
 
开发者ID:funny5258,项目名称:autocode,代码行数:9,代码来源:ObjectFactory.java

示例11: checkPlugin

import org.mybatis.generator.config.PluginConfiguration; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected boolean checkPlugin(Class<?> clazz, Context context){
    Field field = FieldUtils.getDeclaredField(Context.class,"pluginConfigurations",true);
    try {
        List<PluginConfiguration> pluginConfigurations = (List<PluginConfiguration>) field.get(context);
        for(PluginConfiguration pluginConfiguration : pluginConfigurations){
            if(pluginConfiguration.getConfigurationType().equals(clazz.getTypeName())){
                return true;
            }
        }
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:16,代码来源:XmbgMojoUnitTest.java

示例12: createPlugin

import org.mybatis.generator.config.PluginConfiguration; //导入依赖的package包/类
public static Plugin createPlugin(Context context, PluginConfiguration pluginConfiguration) {
	Plugin plugin = (Plugin) createInternalObject(pluginConfiguration.getConfigurationType());
	plugin.setContext(context);
	plugin.setProperties(pluginConfiguration.getProperties());
	return plugin;
}
 
开发者ID:fnyexx,项目名称:mybator,代码行数:7,代码来源:ObjectFactory.java

示例13: createPlugin

import org.mybatis.generator.config.PluginConfiguration; //导入依赖的package包/类
/**
 * Creates a new Object object.
 *
 * @param context
 *            the context
 * @param pluginConfiguration
 *            the plugin configuration
 * @return the plugin
 */
public static Plugin createPlugin(Context context,
        PluginConfiguration pluginConfiguration) {
    Plugin plugin = (Plugin) createInternalObject(pluginConfiguration
            .getConfigurationType());
    plugin.setContext(context);
    plugin.setProperties(pluginConfiguration.getProperties());
    return plugin;
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:18,代码来源:ObjectFactory.java


注:本文中的org.mybatis.generator.config.PluginConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。