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

Java MetaClassRegistryImpl类代码示例

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

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



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

示例1: getMetaClass

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
/**
 * Gives the meta class to an Object.
 */
public void getMetaClass() {
    Object receiver = args[0];
    if (receiver == null) {
        mc = NullObject.getNullObject().getMetaClass();
    } else if (receiver instanceof GroovyObject) {
        mc = ((GroovyObject) receiver).getMetaClass();
    } else if (receiver instanceof Class) {
        Class c = (Class) receiver;
        ClassLoader cl = c.getClassLoader();
        try {
            Class.forName(c.getName(), true, cl);
        } catch (ClassNotFoundException e) {}
        mc = GroovySystem.getMetaClassRegistry().getMetaClass(c);
        this.cache &= !ClassInfo.getClassInfo(c).hasPerInstanceMetaClasses();
    } else {
        mc = ((MetaClassRegistryImpl) GroovySystem.getMetaClassRegistry()).getMetaClass(receiver);
        this.cache &= !ClassInfo.getClassInfo(receiver.getClass()).hasPerInstanceMetaClasses();
    }
    mc.initialize();
}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:Selector.java


示例2: invokePropertyOrMissing

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
private Object invokePropertyOrMissing(Object object, String methodName, Object[] originalArguments, boolean fromInsideClass, boolean isCallToSuper) {
    // if no method was found, try to find a closure defined as a field of the class and run it
    Object value = null;
    final MetaProperty metaProperty = this.getMetaProperty(methodName, false);
    if (metaProperty != null)
      value = metaProperty.getProperty(object);
    else {
        if (object instanceof Map)
          value = ((Map)object).get(methodName);
    }

    if (value instanceof Closure) {  // This test ensures that value != this If you ever change this ensure that value != this
        Closure closure = (Closure) value;
        MetaClass delegateMetaClass = closure.getMetaClass();
        return delegateMetaClass.invokeMethod(closure.getClass(), closure, CLOSURE_DO_CALL_METHOD, originalArguments, false, fromInsideClass);
    }

    if (object instanceof Script) {
        Object bindingVar = ((Script) object).getBinding().getVariables().get(methodName);
        if (bindingVar != null) {
            MetaClass bindingVarMC = ((MetaClassRegistryImpl) registry).getMetaClass(bindingVar);
            return bindingVarMC.invokeMethod(bindingVar, CLOSURE_CALL_METHOD, originalArguments);
        }
    }
    return invokeMissingMethod(object, methodName, originalArguments, null, isCallToSuper);
}
 
开发者ID:apache,项目名称:groovy,代码行数:27,代码来源:MetaClassImpl.java


示例3: setMetaClass

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
/**
 * Set the metaclass for an object.
 * @param self the object whose metaclass we want to set
 * @param metaClass the new metaclass value
 * @since 1.6.0
 */
public static void setMetaClass(Object self, MetaClass metaClass) {
    if (metaClass instanceof HandleMetaClass)
        metaClass = ((HandleMetaClass)metaClass).getAdaptee();

    if (self instanceof Class) {
        GroovySystem.getMetaClassRegistry().setMetaClass((Class) self, metaClass);
    } else {
        ((MetaClassRegistryImpl)GroovySystem.getMetaClassRegistry()).setMetaClass(self, metaClass);
    }
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:17,代码来源:DefaultGroovyMethods.java


示例4: clean

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
public synchronized void clean() {
    try {
        cleaning = true;
        MetaClassRegistryImpl registry = (MetaClassRegistryImpl) GroovySystem.getMetaClassRegistry();
        cleanMetaClassOfClass(registry);
        cleanMetaClassOfInstance(registry);
    } finally {
        cleaning = false;
    }
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:11,代码来源:MetaClassRegistryCleaner.java


示例5: cleanMetaClassOfInstance

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
private void cleanMetaClassOfInstance(MetaClassRegistryImpl registry) {
    List<IdentityWeakReference> keys = new ArrayList<IdentityWeakReference>(alteredInstances.keySet());
    for (IdentityWeakReference key : keys) {
        Object instance = key.get();
        if (instance != null) {
            Object alteredMetaClass = alteredInstances.get(key);
            if (alteredMetaClass == NO_CUSTOM_METACLASS) {
                alteredMetaClass = null;
            }
            registry.setMetaClass(instance, (MetaClass) alteredMetaClass);
        }
    }
    alteredInstances.clear();
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:15,代码来源:MetaClassRegistryCleaner.java


示例6: cleanMetaClassOfClass

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
private void cleanMetaClassOfClass(MetaClassRegistryImpl registry) {
    Set<Class> classes = new HashSet<Class>(alteredClasses.keySet());
    for (Class aClass : classes) {
        Object alteredMetaClass = alteredClasses.get(aClass);
        if (alteredMetaClass == NO_CUSTOM_METACLASS) {
            registry.removeMetaClass(aClass);
        }
        else {
            registry.setMetaClass(aClass, (MetaClass) alteredMetaClass);
        }
    }
    alteredClasses.clear();
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:14,代码来源:MetaClassRegistryCleaner.java


示例7: getMetaClass

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
private MetaClass getMetaClass(Object proxy) {
    MetaClass mc = metaClass;
    if (mc == null) {
        mc = ((MetaClassRegistryImpl) GroovySystem.getMetaClassRegistry()).getMetaClass(proxy);
        metaClass = mc;
    }
    return mc;
}
 
开发者ID:apache,项目名称:groovy,代码行数:9,代码来源:ConversionHandler.java


示例8: getProperty

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
public static Object getProperty(Object object, String property) {
    if (object == null) {
        object = NullObject.getNullObject();
    }

    if (object instanceof GroovyObject) {
        GroovyObject pogo = (GroovyObject) object;
        return pogo.getProperty(property);
    } else if (object instanceof Class) {
        Class c = (Class) object;
        return metaRegistry.getMetaClass(c).getProperty(object, property);
    } else {
        return ((MetaClassRegistryImpl) metaRegistry).getMetaClass(object).getProperty(object, property);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:InvokerHelper.java


示例9: setProperty

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
public static void setProperty(Object object, String property, Object newValue) {
    if (object == null) {
        object = NullObject.getNullObject();
    }

    if (object instanceof GroovyObject) {
        GroovyObject pogo = (GroovyObject) object;
        pogo.setProperty(property, newValue);
    } else if (object instanceof Class) {
        metaRegistry.getMetaClass((Class) object).setProperty((Class) object, property, newValue);
    } else {
        ((MetaClassRegistryImpl) GroovySystem.getMetaClassRegistry()).getMetaClass(object).setProperty(object, property, newValue);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:15,代码来源:InvokerHelper.java


示例10: findDGMMethodsForClassNode

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
/**
 * @deprecated Use {@link #findDGMMethodsForClassNode(ClassLoader, ClassNode,String)} instead
 */
@Deprecated
protected static Set<MethodNode> findDGMMethodsForClassNode(ClassNode clazz, String name) {
    return findDGMMethodsForClassNode(MetaClassRegistryImpl.class.getClassLoader(), clazz,  name);
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:StaticTypeCheckingSupport.java


示例11: findDGMMethodsByNameAndArguments

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
/**
 * @deprecated Use {@link #findDGMMethodsByNameAndArguments(ClassLoader, ClassNode, String, ClassNode[], List)} instead
 */
@Deprecated
public static List<MethodNode> findDGMMethodsByNameAndArguments(final ClassNode receiver, final String name, final ClassNode[] args) {
    return findDGMMethodsByNameAndArguments(MetaClassRegistryImpl.class.getClassLoader(), receiver, name, args);
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:StaticTypeCheckingSupport.java


示例12: getMetaClass

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
public static MetaClass getMetaClass(Object object) {
    if (object instanceof GroovyObject)
        return ((GroovyObject) object).getMetaClass();
    else
        return ((MetaClassRegistryImpl) GroovySystem.getMetaClassRegistry()).getMetaClass(object);
}
 
开发者ID:apache,项目名称:groovy,代码行数:7,代码来源:InvokerHelper.java


示例13: testRegistry

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
public void testRegistry () {
    final MetaClassRegistryImpl metaClassRegistry = new MetaClassRegistryImpl();
    final Object [] instanceMethods = metaClassRegistry.getInstanceMethods().getArray();
    assertTrue(instanceMethods.length > 0);
}
 
开发者ID:apache,项目名称:groovy,代码行数:6,代码来源:TestDgmConverter.java


示例14: ExpectObjectWrapperWrapper

import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; //导入依赖的package包/类
public ExpectObjectWrapperWrapper(Object realValue){
  this.realValue = realValue;
  registry = MetaClassRegistryImpl.getInstance(MetaClassRegistryImpl.LOAD_DEFAULT);
}
 
开发者ID:detectiveframework,项目名称:detective,代码行数:5,代码来源:ExpectObjectWrapperWrapper.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ArtifactType类代码示例发布时间:2022-05-22
下一篇:
Java NotFoundException类代码示例发布时间: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