groovy.lang.DelegatingMetaClass Java Examples

The following examples show how to use groovy.lang.DelegatingMetaClass. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroovyScriptFactoryTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public void customize(GroovyObject goo) {
	DelegatingMetaClass dmc = new DelegatingMetaClass(goo.getMetaClass()) {
		@Override
		public Object invokeMethod(Object arg0, String mName, Object[] arg2) {
			if (mName.contains("Missing")) {
				throw new IllegalStateException("Gotcha");
			}
			else {
				return super.invokeMethod(arg0, mName, arg2);
			}
		}
	};
	dmc.initialize();
	goo.setMetaClass(dmc);
}
 
Example #2
Source File: GroovyScriptFactoryTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
public void customize(GroovyObject goo) {
	DelegatingMetaClass dmc = new DelegatingMetaClass(goo.getMetaClass()) {
		@Override
		public Object invokeMethod(Object arg0, String mName, Object[] arg2) {
			if (mName.contains("Missing")) {
				throw new IllegalStateException("Gotcha");
			}
			else {
				return super.invokeMethod(arg0, mName, arg2);
			}
		}
	};
	dmc.initialize();
	goo.setMetaClass(dmc);
}
 
Example #3
Source File: GroovyScriptFactoryTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public void customize(GroovyObject goo) {
	DelegatingMetaClass dmc = new DelegatingMetaClass(goo.getMetaClass()) {
		@Override
		public Object invokeMethod(Object arg0, String mName, Object[] arg2) {
			if (mName.contains("Missing")) {
				throw new IllegalStateException("Gotcha");
			}
			else {
				return super.invokeMethod(arg0, mName, arg2);
			}
		}
	};
	dmc.initialize();
	goo.setMetaClass(dmc);
}
 
Example #4
Source File: ProxyGenerator.java    From groovy with Apache License 2.0 5 votes vote down vote up
private static void setMetaClass(final MetaClass metaClass) {
    final MetaClass newMetaClass = new DelegatingMetaClass(metaClass) {
        @Override
        public Object invokeStaticMethod(Object object, String methodName, Object[] arguments) {
            return InvokerHelper.invokeMethod(INSTANCE, methodName, arguments);
        }
    };
    GroovySystem.getMetaClassRegistry().setMetaClass(ProxyGenerator.class, newMetaClass);
}