本文整理了Java中groovy.lang.MetaClass.initialize()
方法的一些代码示例,展示了MetaClass.initialize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MetaClass.initialize()
方法的具体详情如下:
包路径:groovy.lang.MetaClass
类名称:MetaClass
方法名:initialize
[英]complete the initlialisation process. After this method is called no methods should be added to the meta class. Invocation of methods or access to fields/proeprties is forbidden unless this method is called. This method should contain any initialisation code, taking a longer time to complete. An example is the creation of the Reflector. It is suggested to synchronize this method.
[中]完成初始化过程。调用此方法后,不应将任何方法添加到元类中。除非调用此方法,否则禁止调用方法或访问字段/项目。此方法应包含任何初始化代码,需要较长时间才能完成。反射镜的创建就是一个例子。建议同步此方法。
代码示例来源:origin: org.codehaus.groovy/groovy
public void initialize() {
delegate.initialize();
}
代码示例来源:origin: org.codehaus.groovy/groovy
public synchronized void initialize() {
this.adaptee.initialize();
}
代码示例来源:origin: org.codehaus.groovy/groovy
public void initialize() {
replaceDelegate();
delegate.initialize();
}
代码示例来源:origin: spockframework/spock
private void saveMetaClassesInto(Set<Class<?>> toSave, Map<Class<?>, MetaClass> into) {
MetaClassRegistry registry = GroovySystem.getMetaClassRegistry();
for (Class<?> clazz : toSave) {
into.put(clazz, registry.getMetaClass(clazz));
MetaClass newMetaClass = new ExpandoMetaClass(clazz, true, true);
newMetaClass.initialize();
registry.setMetaClass(clazz, newMetaClass);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* 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();
}
代码示例来源:origin: spockframework/spock
@Override
public void intercept(IMethodInvocation invocation) throws Throwable {
MetaClassRegistry registry = GroovySystem.getMetaClassRegistry();
for (Class<?> clazz : classes) {
originalMetaClasses.add(registry.getMetaClass(clazz));
MetaClass temporaryMetaClass = new ExpandoMetaClass(clazz, true, true);
temporaryMetaClass.initialize();
registry.setMetaClass(clazz, temporaryMetaClass);
}
try {
invocation.proceed();
} finally {
for (MetaClass original : originalMetaClasses)
registry.setMetaClass(original.getTheClass(), original);
}
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
public GroovyObject replaceDelegate() {
if (object == null) {
if (!(delegate instanceof ExpandoMetaClass)) {
delegate = new ExpandoMetaClass(delegate.getTheClass(), true, true);
delegate.initialize();
}
DefaultGroovyMethods.setMetaClass(delegate.getTheClass(), delegate);
}
else {
if (object != NONE) {
final MetaClass metaClass = delegate;
delegate = new ExpandoMetaClass(delegate.getTheClass(), false, true);
if (metaClass instanceof ExpandoMetaClass) {
ExpandoMetaClass emc = (ExpandoMetaClass) metaClass;
for (MetaMethod method : emc.getExpandoMethods())
((ExpandoMetaClass)delegate).registerInstanceMethod(method);
}
delegate.initialize();
MetaClassHelper.doSetMetaClass(object, delegate);
object = NONE;
}
}
return (GroovyObject)delegate;
}
代码示例来源:origin: org.codehaus.groovy/groovy
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;
}
代码示例来源:origin: org.codehaus.groovy/groovy
emcMetaClass.initialize();
ClassInfo.getClassInfo(ExpandoMetaClass.class).setStrongMetaClass(emcMetaClass);
代码示例来源:origin: org.codehaus.groovy/groovy
mc.initialize();
((ExpandoMetaClass)mc).define(closure);
metaClassRegistry.setMetaClass(self, mc);
代码示例来源:origin: org.gperfutils/gprof
@Override
public void initialize() {
adaptee.initialize();
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
public synchronized void initialize() {
this.adaptee.initialize();
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
public void initialize() {
delegate.initialize();
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
public void initialize() {
replaceDelegate();
delegate.initialize();
}
代码示例来源:origin: com.disney.groovity/groovity-core
public ScriptHelper(Groovity groovity, GroovityClassLoader groovityClassLoader) {
this.groovity=groovity;
this.groovityClassLoader=groovityClassLoader;
this.metaClass = new MetaClassImpl(ScriptHelper.class);
metaClass.initialize();
}
代码示例来源:origin: disney/groovity
public ScriptHelper(Groovity groovity, GroovityClassLoader groovityClassLoader) {
this.groovity=groovity;
this.groovityClassLoader=groovityClassLoader;
this.metaClass = new MetaClassImpl(ScriptHelper.class);
metaClass.initialize();
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
public void initialize() {
replaceDelegate();
delegate.initialize();
}
代码示例来源:origin: org.kohsuke.droovy/groovy
public void initialize() {
replaceDelegate();
delegate.initialize();
}
代码示例来源:origin: org.gmock/gmock
public static void startProxy(Class clazz, Class adapteeClass) throws IntrospectionException {
MetaClassRegistry registry = GroovySystem.getMetaClassRegistry();
MetaClass metaClass = registry.getMetaClass(clazz);
if (!(metaClass instanceof GeneratedClassProxyMetaClass)) { // has not started proxy yet
metaClass = new GeneratedClassProxyMetaClass(registry, clazz, adapteeClass);
metaClass.initialize();
registry.setMetaClass(clazz, metaClass);
}
}
代码示例来源:origin: org.gperfutils/gprof
private ExpandoMetaClass expandableDelegate() {
if (!(adaptee instanceof ExpandoMetaClass)) {
GroovySystem.getMetaClassRegistry().setMetaClass(adaptee.getTheClass(), adaptee);
adaptee = new ExpandoMetaClass(adaptee.getTheClass(), false, true);
adaptee.initialize();
GroovySystem.getMetaClassRegistry().setMetaClass(adaptee.getTheClass(), this);
}
return (ExpandoMetaClass) adaptee;
}
内容来源于网络,如有侵权,请联系作者删除!