• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MetaClassRegistry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getMetaClassUnderLock

import groovy.lang.MetaClassRegistry; //导入依赖的package包/类
private MetaClass getMetaClassUnderLock() {
    MetaClass answer = getStrongMetaClass();
    if (answer!=null) return answer;
    
    answer = getWeakMetaClass();
    final MetaClassRegistry metaClassRegistry = GroovySystem.getMetaClassRegistry();
    MetaClassRegistry.MetaClassCreationHandle mccHandle = metaClassRegistry.getMetaClassCreationHandler();
    
    if (isValidWeakMetaClass(answer, mccHandle)) {
        return answer;
    }

    answer = mccHandle.create(classRef.get(), metaClassRegistry);
    answer.initialize();

    if (GroovySystem.isKeepJavaMetaClasses()) {
        setStrongMetaClass(answer);
    } else {
        setWeakMetaClass(answer);
    }
    return answer;
}
 
开发者ID:apache,项目名称:groovy,代码行数:23,代码来源:ClassInfo.java


示例2: setMetaClass

import groovy.lang.MetaClassRegistry; //导入依赖的package包/类
/**
 * Sets the metaclass for a given class.
 *
 * @param self the class whose metaclass we wish to set
 * @param metaClass the new MetaClass
 * @since 1.6.0
 */
public static void setMetaClass(Class self, MetaClass metaClass) {
    final MetaClassRegistry metaClassRegistry = GroovySystem.getMetaClassRegistry();
    if (metaClass == null)
        metaClassRegistry.removeMetaClass(self);
    else {
        if (metaClass instanceof HandleMetaClass) {
            metaClassRegistry.setMetaClass(self, ((HandleMetaClass)metaClass).getAdaptee());
        } else {
            metaClassRegistry.setMetaClass(self, metaClass);
        }
        if (self==NullObject.class) {
            NullObject.getNullObject().setMetaClass(metaClass);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:23,代码来源:DefaultGroovyMethods.java


示例3: createAndRegister

import groovy.lang.MetaClassRegistry; //导入依赖的package包/类
public static MetaClassRegistryCleaner createAndRegister() {

        MetaClassRegistry metaClassRegistry = GroovySystem.getMetaClassRegistry();
        MetaClassRegistryChangeEventListener[] listeners = metaClassRegistry.getMetaClassRegistryChangeEventListeners();
        boolean registered = false;
        for (MetaClassRegistryChangeEventListener listener : listeners) {
            if (listener == INSTANCE) {
                registered = true;break;
            }
        }
        if (!registered) {
            GroovySystem.getMetaClassRegistry().addMetaClassRegistryChangeEventListener(INSTANCE);
        }
        return INSTANCE;
    }
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:16,代码来源:MetaClassRegistryCleaner.java


示例4: isValidWeakMetaClass

import groovy.lang.MetaClassRegistry; //导入依赖的package包/类
/**
 * if EMC.enableGlobally() is OFF, return whatever the cached answer is.
 * but if EMC.enableGlobally() is ON and the cached answer is not an EMC, come up with a fresh answer
 */
private static boolean isValidWeakMetaClass(MetaClass metaClass, MetaClassRegistry.MetaClassCreationHandle mccHandle) {
    if(metaClass==null) return false;
    boolean enableGloballyOn = (mccHandle instanceof ExpandoMetaClassCreationHandle);
    boolean cachedAnswerIsEMC = (metaClass instanceof ExpandoMetaClass);
    return (!enableGloballyOn || cachedAnswerIsEMC);
}
 
开发者ID:apache,项目名称:groovy,代码行数:11,代码来源:ClassInfo.java


示例5: getMetaClass

import groovy.lang.MetaClassRegistry; //导入依赖的package包/类
/**
 * Adds a "metaClass" property to all class objects so you can use the syntax
 * <code>String.metaClass.myMethod = { println "foo" }</code>
 *
 * @param c The java.lang.Class instance
 * @return An MetaClass instance
 * @since 1.5.0
 */
public static MetaClass getMetaClass(Class c) {
    MetaClassRegistry metaClassRegistry = GroovySystem.getMetaClassRegistry();
    MetaClass mc = metaClassRegistry.getMetaClass(c);
    if (mc instanceof ExpandoMetaClass
            || mc instanceof DelegatingMetaClass && ((DelegatingMetaClass) mc).getAdaptee() instanceof ExpandoMetaClass)
        return mc;
    else {
        return new HandleMetaClass(mc);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:19,代码来源:DefaultGroovyMethods.java


示例6: getInstance

import groovy.lang.MetaClassRegistry; //导入依赖的package包/类
/**
 * Singleton of MetaClassRegistry. 
 *
 * @param includeExtension
 * @return the registry
 */
public static synchronized MetaClassRegistry getInstance(int includeExtension) {
    if (includeExtension != DONT_LOAD_DEFAULT) {
        if (instanceInclude == null) {
            instanceInclude = new MetaClassRegistryImpl();
        }
        return instanceInclude;
    } else {
        if (instanceExclude == null) {
            instanceExclude = new MetaClassRegistryImpl(DONT_LOAD_DEFAULT);
        }
        return instanceExclude;
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:20,代码来源:MetaClassRegistryImpl.java


示例7: addAssociationToTarget

import groovy.lang.MetaClassRegistry; //导入依赖的package包/类
private void addAssociationToTarget(String name, Object target, Object obj) {
	if (obj == null) {
		return;
	}

	MetaClassRegistry reg = GroovySystem.getMetaClassRegistry();
	MetaClass mc = reg.getMetaClass(target.getClass());
	final String addMethodName = "addTo" + GrailsNameUtils.getClassNameRepresentation(name);
	mc.invokeMethod(target, addMethodName, obj);
}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:11,代码来源:GrailsDataBinder.java


示例8: MockProxyMetaClass

import groovy.lang.MetaClassRegistry; //导入依赖的package包/类
/**
 * @param adaptee the MetaClass to decorate with interceptability
 */
public MockProxyMetaClass(MetaClassRegistry registry, Class theClass, MetaClass adaptee) {
    this(registry, theClass, adaptee, false);
}
 
开发者ID:apache,项目名称:groovy,代码行数:7,代码来源:MockProxyMetaClass.java


示例9: make

import groovy.lang.MetaClassRegistry; //导入依赖的package包/类
/**
 * convenience factory method allowing interceptConstruction to be set.
 */
public static MockProxyMetaClass make(Class theClass, boolean interceptConstruction) {
    MetaClassRegistry metaRegistry = GroovySystem.getMetaClassRegistry();
    MetaClass meta = metaRegistry.getMetaClass(theClass);
    return new MockProxyMetaClass(metaRegistry, theClass, meta, interceptConstruction);
}
 
开发者ID:apache,项目名称:groovy,代码行数:9,代码来源:MockProxyMetaClass.java


示例10: ClosureMetaClass

import groovy.lang.MetaClassRegistry; //导入依赖的package包/类
public ClosureMetaClass(MetaClassRegistry registry, Class theClass) {
    super(registry, theClass);
}
 
开发者ID:apache,项目名称:groovy,代码行数:4,代码来源:ClosureMetaClass.java


示例11: getMetaRegistry

import groovy.lang.MetaClassRegistry; //导入依赖的package包/类
public static MetaClassRegistry getMetaRegistry() {
    return metaRegistry;
}
 
开发者ID:apache,项目名称:groovy,代码行数:4,代码来源:InvokerHelper.java


示例12: createNormalMetaClass

import groovy.lang.MetaClassRegistry; //导入依赖的package包/类
@Override
protected synchronized MetaClass createNormalMetaClass(Class theClass, MetaClassRegistry registry) {
  VertxExtensionMethodBoostrap.install(registry);
  return super.createNormalMetaClass(theClass, registry);
}
 
开发者ID:vert-x3,项目名称:vertx-lang-groovy,代码行数:6,代码来源:CustomMetaClassCreationHandle.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Button类代码示例发布时间:2022-05-22
下一篇:
Java AnnotatedElementBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap