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


Java MetaClassRegistry类代码示例

本文整理汇总了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;未经允许,请勿转载。