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


Java GroovyCategorySupport.hasCategoryInCurrentThread方法代码示例

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


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

示例1: createPojoMetaClassGetPropertySite

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
private CallSite createPojoMetaClassGetPropertySite(Object receiver) {
    final MetaClass metaClass = InvokerHelper.getMetaClass(receiver);

    CallSite site;
    if (metaClass.getClass() != MetaClassImpl.class || GroovyCategorySupport.hasCategoryInCurrentThread()) {
        site = new PojoMetaClassGetPropertySite(this);
    } else {
        final MetaProperty effective = ((MetaClassImpl) metaClass).getEffectiveGetMetaProperty(receiver.getClass(), receiver, name, false);
        if (effective != null) {
            if (effective instanceof CachedField)
                site = new GetEffectivePojoFieldSite(this, (MetaClassImpl) metaClass, (CachedField) effective);
            else
                site = new GetEffectivePojoPropertySite(this, (MetaClassImpl) metaClass, effective);
        } else {
            site = new PojoMetaClassGetPropertySite(this);
        }
    }

    array.array[index] = site;
    return site;
}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:AbstractCallSite.java

示例2: createPogoMetaClassGetPropertySite

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
private CallSite createPogoMetaClassGetPropertySite(GroovyObject receiver) {
    MetaClass metaClass = receiver.getMetaClass();

    CallSite site;
    if (metaClass.getClass() != MetaClassImpl.class || GroovyCategorySupport.hasCategoryInCurrentThread()) {
        site = new PogoMetaClassGetPropertySite(this, metaClass);
    } else {
        final MetaProperty effective = ((MetaClassImpl) metaClass).getEffectiveGetMetaProperty(this.array.owner, receiver, name, false);
        if (effective != null) {
            if (effective instanceof CachedField)
                site = new GetEffectivePogoFieldSite(this, metaClass, (CachedField) effective);
            else
                site = new GetEffectivePogoPropertySite(this, metaClass, effective);
        } else {
            site = new PogoMetaClassGetPropertySite(this, metaClass);
        }
    }

    array.array[index] = site;
    return site;
}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:AbstractCallSite.java

示例3: getMethodWithCachingInternal

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
private MetaMethod getMethodWithCachingInternal (Class sender, CallSite site, Class [] params) {
    if (GroovyCategorySupport.hasCategoryInCurrentThread())
        return getMethodWithoutCaching(sender, site.getName (), params, false);

    final MetaMethodIndex.Entry e = metaMethodIndex.getMethods(sender, site.getName());
    if (e == null) {
        return null;
    }

    MetaMethodIndex.CacheEntry cacheEntry;
    final Object methods = e.methods;
    if (methods == null)
      return null;

    cacheEntry = e.cachedMethod;
    if (cacheEntry != null && (sameClasses(cacheEntry.params, params))) {
         return cacheEntry.method;
    }

    cacheEntry = new MetaMethodIndex.CacheEntry (params, (MetaMethod) chooseMethod(e.name, methods, params));
    e.cachedMethod = cacheEntry;
    return cacheEntry.method;
}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:MetaClassImpl.java

示例4: createMetaMethodAndMetaProperty

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
private Tuple2<MetaMethod, MetaProperty> createMetaMethodAndMetaProperty(final Class senderForMP, final Class senderForCMG, final String name, final boolean useSuper, final boolean isStatic) {
    MetaMethod method = null;
    MetaProperty mp = getMetaProperty(senderForMP, name, useSuper, isStatic);
    if (mp != null) {
        if (mp instanceof MetaBeanProperty) {
            MetaBeanProperty mbp = (MetaBeanProperty) mp;
            method = mbp.getGetter();
            mp = mbp.getField();
        }
    }

    // check for a category method named like a getter
    if (!useSuper && !isStatic && GroovyCategorySupport.hasCategoryInCurrentThread()) {
        String getterName = GroovyCategorySupport.getPropertyCategoryGetterName(name);
        if (getterName != null) {
            MetaMethod categoryMethod = getCategoryMethodGetter(senderForCMG, getterName, false);
            if (categoryMethod != null)
                method = categoryMethod;
        }
    }

    return new Tuple2<MetaMethod, MetaProperty>(method, mp);
}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:MetaClassImpl.java

示例5: createPogoCallSite

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
/**
 * Create a CallSite
 */
public CallSite createPogoCallSite(CallSite site, Object[] args) {
    if (!GroovyCategorySupport.hasCategoryInCurrentThread() && !(this instanceof AdaptingMetaClass)) {
        Class [] params = MetaClassHelper.convertToTypeArray(args);
        CallSite tempSite = site;
        if (site.getName().equals("call") && GeneratedClosure.class.isAssignableFrom(theClass)) {
            // here, we want to point to a method named "doCall" instead of "call"
            // but we don't want to replace the original call site name, otherwise
            // we loose the fact that the original method name was "call" so instead
            // we will point to a metamethod called "doCall"
            // see GROOVY-5806 for details
            tempSite = new AbstractCallSite(site.getArray(),site.getIndex(),"doCall");
        }
        MetaMethod metaMethod = getMethodWithCachingInternal(theClass, tempSite, params);
        if (metaMethod != null)
           return PogoMetaMethodSite.createPogoMetaMethodSite(site, this, metaMethod, params, args);
    }
    return new PogoMetaClassSite(site, this);
}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:MetaClassImpl.java

示例6: acceptGetProperty

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
public final CallSite acceptGetProperty(Object receiver) {
//        if (GroovyCategorySupport.hasCategoryInCurrentThread() || !(receiver instanceof GroovyObject) || ((GroovyObject)receiver).getMetaClass() != metaClass) {
        if (GroovyCategorySupport.hasCategoryInCurrentThread() || receiver==null || receiver.getClass() != metaClass.getTheClass()
            || version != metaClass.getVersion()) { // metaClass is invalid
            return createGetPropertySite(receiver);
        } else {
            return this;
        }
    }
 
开发者ID:apache,项目名称:groovy,代码行数:10,代码来源:GetEffectivePojoPropertySite.java

示例7: callGetProperty

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
public final Object callGetProperty (Object receiver) throws Throwable {
    if (GroovyCategorySupport.hasCategoryInCurrentThread() || !(receiver instanceof GroovyObject) || ((GroovyObject) receiver).getMetaClass() != metaClass) {
        return createGetPropertySite(receiver).getProperty(receiver);
    } else {
        return getProperty(receiver);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:GetEffectivePogoFieldSite.java

示例8: acceptGetProperty

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
public final CallSite acceptGetProperty(Object receiver) {
    if (GroovyCategorySupport.hasCategoryInCurrentThread() || !(receiver instanceof GroovyObject) || ((GroovyObject)receiver).getMetaClass() != metaClass) {
        return createGetPropertySite(receiver);
    } else {
        return this;
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:GetEffectivePogoFieldSite.java

示例9: callGroovyObjectGetProperty

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
public final Object callGroovyObjectGetProperty (Object receiver) throws Throwable {
    if (GroovyCategorySupport.hasCategoryInCurrentThread() || ((GroovyObject) receiver).getMetaClass() != metaClass) {
        return createGroovyObjectGetPropertySite(receiver).getProperty(receiver);
    } else {
        return getProperty(receiver);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:GetEffectivePogoFieldSite.java

示例10: acceptGroovyObjectGetProperty

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
public final CallSite acceptGroovyObjectGetProperty(Object receiver) {
    if (GroovyCategorySupport.hasCategoryInCurrentThread() || !(receiver instanceof GroovyObject) || ((GroovyObject)receiver).getMetaClass() != metaClass) {
        return createGroovyObjectGetPropertySite(receiver);
    } else {
        return this;
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:GetEffectivePogoFieldSite.java

示例11: callGetProperty

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
public final Object callGetProperty (Object receiver) throws Throwable {
    if (GroovyCategorySupport.hasCategoryInCurrentThread() || !(receiver instanceof GroovyObject) || ((GroovyObject) receiver).getMetaClass() != metaClass) {
        return createGetPropertySite(receiver).getProperty(receiver);
    } else {
        try {
            return effective.getProperty(receiver);
        } catch (GroovyRuntimeException gre) {
            throw ScriptBytecodeAdapter.unwrap(gre);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:GetEffectivePogoPropertySite.java

示例12: callGroovyObjectGetProperty

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
public final Object callGroovyObjectGetProperty (Object receiver) throws Throwable {
    if (GroovyCategorySupport.hasCategoryInCurrentThread() || !(receiver instanceof GroovyObject) || ((GroovyObject) receiver).getMetaClass() != metaClass) {
        return createGetPropertySite(receiver).getProperty(receiver);
    } else {
        try {
            return effective.getProperty(receiver);
        } catch (GroovyRuntimeException gre) {
            throw ScriptBytecodeAdapter.unwrap(gre);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:GetEffectivePogoPropertySite.java

示例13: acceptGetProperty

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
public final CallSite acceptGetProperty(Object receiver) {
    if (GroovyCategorySupport.hasCategoryInCurrentThread() || receiver.getClass() != metaClass.getTheClass()
        || version != metaClass.getVersion()) { // metaClass is invalid
        return createGetPropertySite(receiver);
    } else {
        return this;
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:9,代码来源:GetEffectivePojoFieldSite.java

示例14: getMethodWithCaching

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
public MetaMethod getMethodWithCaching(Class sender, String methodName, Object[] arguments, boolean isCallToSuper) {
    // let's try use the cache to find the method
    if (!isCallToSuper && GroovyCategorySupport.hasCategoryInCurrentThread()) {
        return getMethodWithoutCaching(sender, methodName, MetaClassHelper.convertToTypeArray(arguments), isCallToSuper);
    } else {
        final MetaMethodIndex.Entry e = metaMethodIndex.getMethods(sender, methodName);
        if (e == null)
          return null;

        return isCallToSuper ? getSuperMethodWithCaching(arguments, e) : getNormalMethodWithCaching(arguments, e);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:13,代码来源:MetaClassImpl.java

示例15: createPogoCallCurrentSite

import org.codehaus.groovy.runtime.GroovyCategorySupport; //导入方法依赖的package包/类
/**
 * Create a CallSite
 */
public CallSite createPogoCallCurrentSite(CallSite site, Class sender, Object[] args) {
    if (!GroovyCategorySupport.hasCategoryInCurrentThread() && !(this instanceof AdaptingMetaClass)) {
      Class [] params = MetaClassHelper.convertToTypeArray(args);
      MetaMethod metaMethod = getMethodWithCachingInternal(sender, site, params);
      if (metaMethod != null)
        return PogoMetaMethodSite.createPogoMetaMethodSite(site, this, metaMethod, params, args);
    }
    return new PogoMetaClassSite(site, this);
}
 
开发者ID:apache,项目名称:groovy,代码行数:13,代码来源:MetaClassImpl.java


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