protected void addMetaMethodToIndex(MetaMethod method, MetaMethodIndex.Header header) { checkIfStdMethod(method); String name = method.getName(); MetaMethodIndex.Entry e = metaMethodIndex.getOrPutMethods(name, header); if (method.isStatic()) { e.staticMethods = metaMethodIndex.addMethodToList(e.staticMethods, method); } e.methods = metaMethodIndex.addMethodToList(e.methods, method); }
public MetaProperty createStaticVersion() { boolean mf = field==null || field.isStatic(); boolean mg = getter==null || getter.isStatic(); if (mf && mg) return this; if (mg) { MultipleSetterProperty newMsp = new MultipleSetterProperty(name); newMsp.setGetter(getter); return newMsp; } else if (mf) { MultipleSetterProperty newMsp = new MultipleSetterProperty(name); newMsp.setField(field); return newMsp; } return null; } }
public void onModule(final ExtensionModule module) { if (moduleRegistry.hasModule(module.getName())) { ExtensionModule loadedModule = moduleRegistry.getModule(module.getName()); if (loadedModule.getVersion().equals(module.getVersion())) { // already registered return; } else { throw new GroovyRuntimeException("Conflicting module versions. Module [" + module.getName() + " is loaded in version " + loadedModule.getVersion() + " and you are trying to load version " + module.getVersion()); } } moduleRegistry.addModule(module); // register MetaMethods List<MetaMethod> metaMethods = module.getMetaMethods(); for (MetaMethod metaMethod : metaMethods) { CachedClass cachedClass = metaMethod.getDeclaringClass(); List<MetaMethod> methods = map.get(cachedClass); if (methods == null) { methods = new ArrayList<MetaMethod>(4); map.put(cachedClass, methods); } methods.add(metaMethod); if (metaMethod.isStatic()) { staticMethods.add(metaMethod); } else { instanceMethods.add(metaMethod); } } } }
private void refreshInheritedMethods(ExpandoMetaClass superExpando) { List<MetaMethod> metaMethods = superExpando.getExpandoMethods(); for (MetaMethod metaMethod : metaMethods) { if (metaMethod.isStatic()) { if (superExpando.getTheClass() != getTheClass()) continue; // don't inherit static methods except our own registerStaticMethod(metaMethod.getName(), (Closure) ((ClosureStaticMetaMethod) metaMethod).getClosure().clone()); } else addSuperMethodIfNotOverridden(metaMethod); } Collection<MetaProperty> metaProperties = superExpando.getExpandoProperties(); for (Object metaProperty : metaProperties) { MetaBeanProperty property = (MetaBeanProperty) metaProperty; expandoProperties.put(property.getName(), property); addMetaBeanProperty(property); } }
if (method == null && genericGetMethod != null && !(!genericGetMethod.isStatic() && isStatic)) { arguments = new Object[]{name}; method = genericGetMethod;
if (method == null && genericSetMethod != null && !(!genericSetMethod.isStatic() && isStatic)) { arguments = new Object[]{name, newValue}; method = genericSetMethod;
if (genericGetMethod != null && !(!genericGetMethod.isStatic() && isStatic)) { method = genericGetMethod; return new GetMethodMetaProperty(name, method);
/** * Called from ExpandoMetaClassCreationHandle in the registry if it exists to setup inheritance * handling * * @param modifiedSuperExpandos A list of modified super ExpandoMetaClass */ public void refreshInheritedMethods(Set modifiedSuperExpandos) { for (Iterator i = modifiedSuperExpandos.iterator(); i.hasNext();) { ExpandoMetaClass superExpando = (ExpandoMetaClass) i.next(); if(superExpando != this) { List metaMethods = superExpando.getExpandoMethods(); for (Iterator j = metaMethods.iterator(); j.hasNext();) { MetaMethod metaMethod = (MetaMethod) j.next(); if(metaMethod.isStatic()) continue; // don't inherit static methodsw addSuperMethodIfNotOverriden(metaMethod); } Collection metaProperties = superExpando.getExpandoProperties(); for (Iterator j = metaProperties.iterator(); j.hasNext();) { MetaBeanProperty property = (MetaBeanProperty) j.next(); expandoProperties.put(property.getName(),property); addMetaBeanProperty(property); } } } }
public static void addExtensionMethods(ExtensionModule module) { MetaClassRegistry metaClassRegistry = GroovySystem.getMetaClassRegistry(); ((MetaClassRegistryImpl) metaClassRegistry).getModuleRegistry().addModule(module); Map<CachedClass, List<MetaMethod>> classMap = new HashMap<>(); for (MetaMethod metaMethod : module.getMetaMethods()){ if (classMap.containsKey(metaMethod.getDeclaringClass())){ classMap.get(metaMethod.getDeclaringClass()).add(metaMethod); } else { List<MetaMethod> methodList = new ArrayList<>(); methodList.add(metaMethod); classMap.put(metaMethod.getDeclaringClass(), methodList); } if (metaMethod.isStatic()){ ((MetaClassRegistryImpl)metaClassRegistry).getStaticMethods().add(metaMethod); } else { ((MetaClassRegistryImpl)metaClassRegistry).getInstanceMethods().add(metaMethod); } LOG.debug("registered method: {}", metaMethod); } for (Map.Entry<CachedClass, List<MetaMethod>> cachedClassEntry : classMap.entrySet()) { cachedClassEntry.getKey().addNewMopMethods(cachedClassEntry.getValue()); } }
private void refreshInheritedMethods(ExpandoMetaClass superExpando) { List metaMethods = superExpando.getExpandoMethods(); for (Iterator j = metaMethods.iterator(); j.hasNext();) { MetaMethod metaMethod = (MetaMethod) j.next(); if(metaMethod.isStatic()) { if (superExpando.getTheClass() != getTheClass()) continue; // don't inherit static methods except our own registerStaticMethod(metaMethod.getName(), (Closure) ((ClosureStaticMetaMethod)metaMethod).getClosure().clone()); } else addSuperMethodIfNotOverriden(metaMethod); } Collection metaProperties = superExpando.getExpandoProperties(); for (Iterator j = metaProperties.iterator(); j.hasNext();) { MetaBeanProperty property = (MetaBeanProperty) j.next(); expandoProperties.put(property.getName(),property); addMetaBeanProperty(property); } }
protected void addMetaMethodToIndex(MetaMethod method, MetaMethodIndex.Header header) { checkIfStdMethod(method); String name = method.getName(); MetaMethodIndex.Entry e = metaMethodIndex.getOrPutMethods(name, header); if (method.isStatic()) { e.staticMethods = metaMethodIndex.addMethodToList(e.staticMethods, method); } e.methods = metaMethodIndex.addMethodToList(e.methods, method); }
protected void addMetaMethodToIndex(MetaMethod method, MetaMethodIndex.Header header) { checkIfStdMethod(method); String name = method.getName(); MetaMethodIndex.Entry e = metaMethodIndex.getOrPutMethods(name, header); if (method.isStatic()) { e.staticMethods = metaMethodIndex.addMethodToList(e.staticMethods, method); } e.methods = metaMethodIndex.addMethodToList(e.methods, method); }
private void addMetaMethodToIndex(MetaMethod method, MetaMethodIndex.Header header) { checkIfStdMethod(method); String name = method.getName(); MetaMethodIndex.Entry e = metaMethodIndex.getOrPutMethods(name, header); if (method.isStatic()) { e.staticMethods = metaMethodIndex.addMethodToList(e.staticMethods, method); } e.methods = metaMethodIndex.addMethodToList(e.methods, method); }
private void addMetaMethodToSuperIndex(MetaMethod method, MetaMethodIndex.Header header) { checkIfStdMethod(method); String name = method.getName(); MetaMethodIndex.Entry e = metaMethodIndex.getOrPutMethods(name, header); if (method.isStatic()) { e.staticMethods = metaMethodIndex.addMethodToList(e.staticMethods, method); } e.methodsForSuper = metaMethodIndex.addMethodToList(e.methodsForSuper, method); }
protected void addMetaMethodToIndex(MetaMethod method, MetaMethodIndex.Header header) { checkIfStdMethod(method); String name = method.getName(); MetaMethodIndex.Entry e = metaMethodIndex.getOrPutMethods(name, header); if (method.isStatic()) { e.staticMethods = metaMethodIndex.addMethodToList(e.staticMethods, method); } e.methods = metaMethodIndex.addMethodToList(e.methods, method); }
private void refreshInheritedMethods(ExpandoMetaClass superExpando) { List<MetaMethod> metaMethods = superExpando.getExpandoMethods(); for (MetaMethod metaMethod : metaMethods) { if (metaMethod.isStatic()) { if (superExpando.getTheClass() != getTheClass()) continue; // don't inherit static methods except our own registerStaticMethod(metaMethod.getName(), (Closure) ((ClosureStaticMetaMethod) metaMethod).getClosure().clone()); } else addSuperMethodIfNotOverridden(metaMethod); } Collection<MetaProperty> metaProperties = superExpando.getExpandoProperties(); for (Object metaProperty : metaProperties) { MetaBeanProperty property = (MetaBeanProperty) metaProperty; expandoProperties.put(property.getName(), property); addMetaBeanProperty(property); } }
private void refreshInheritedMethods(ExpandoMetaClass superExpando) { List<MetaMethod> metaMethods = superExpando.getExpandoMethods(); for (MetaMethod metaMethod : metaMethods) { if (metaMethod.isStatic()) { if (superExpando.getTheClass() != getTheClass()) continue; // don't inherit static methods except our own registerStaticMethod(metaMethod.getName(), (Closure) ((ClosureStaticMetaMethod) metaMethod).getClosure().clone()); } else addSuperMethodIfNotOverriden(metaMethod); } Collection<MetaProperty> metaProperties = superExpando.getExpandoProperties(); for (Object metaProperty : metaProperties) { MetaBeanProperty property = (MetaBeanProperty) metaProperty; expandoProperties.put(property.getName(), property); addMetaBeanProperty(property); } }