Java Code Examples for org.springframework.cglib.core.CodeGenerationException

The following examples show how to use org.springframework.cglib.core.CodeGenerationException. These examples are extracted from open source projects. 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 Project: mica   Source File: ReflectUtil.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 获取 Bean 的所有 PropertyDescriptor
 *
 * @param type  类
 * @param read  读取方法
 * @param write 写方法
 * @return PropertyDescriptor数组
 */
public static PropertyDescriptor[] getPropertyDescriptors(Class type, boolean read, boolean write) {
	try {
		PropertyDescriptor[] all = BeanUtil.getPropertyDescriptors(type);
		if (read && write) {
			return all;
		} else {
			List<PropertyDescriptor> properties = new ArrayList<>(all.length);
			for (PropertyDescriptor pd : all) {
				if (read && pd.getReadMethod() != null) {
					properties.add(pd);
				} else if (write && pd.getWriteMethod() != null) {
					properties.add(pd);
				}
			}
			return properties.toArray(new PropertyDescriptor[0]);
		}
	} catch (BeansException ex) {
		throw new CodeGenerationException(ex);
	}
}
 
Example 2
Source Project: spring-analysis-note   Source File: Enhancer.java    License: MIT License 6 votes vote down vote up
public EnhancerFactoryData(Class generatedClass, Class[] primaryConstructorArgTypes, boolean classOnly) {
	this.generatedClass = generatedClass;
	try {
		setThreadCallbacks = getCallbacksSetter(generatedClass, SET_THREAD_CALLBACKS_NAME);
		if (classOnly) {
			this.primaryConstructorArgTypes = null;
			this.primaryConstructor = null;
		}
		else {
			this.primaryConstructorArgTypes = primaryConstructorArgTypes;
			this.primaryConstructor = ReflectUtils.getConstructor(generatedClass, primaryConstructorArgTypes);
		}
	}
	catch (NoSuchMethodException e) {
		throw new CodeGenerationException(e);
	}
}
 
Example 3
Source Project: java-technology-stack   Source File: Enhancer.java    License: MIT License 6 votes vote down vote up
public EnhancerFactoryData(Class generatedClass, Class[] primaryConstructorArgTypes, boolean classOnly) {
	this.generatedClass = generatedClass;
	try {
		setThreadCallbacks = getCallbacksSetter(generatedClass, SET_THREAD_CALLBACKS_NAME);
		if (classOnly) {
			this.primaryConstructorArgTypes = null;
			this.primaryConstructor = null;
		}
		else {
			this.primaryConstructorArgTypes = primaryConstructorArgTypes;
			this.primaryConstructor = ReflectUtils.getConstructor(generatedClass, primaryConstructorArgTypes);
		}
	}
	catch (NoSuchMethodException e) {
		throw new CodeGenerationException(e);
	}
}
 
Example 4
Source Project: blade-tool   Source File: BeanUtil.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
private static PropertyDescriptor[] getPropertiesHelper(Class type, boolean read, boolean write) {
	try {
		PropertyDescriptor[] all = BeanUtil.getPropertyDescriptors(type);
		if (read && write) {
			return all;
		} else {
			List<PropertyDescriptor> properties = new ArrayList<>(all.length);
			for (PropertyDescriptor pd : all) {
				if (read && pd.getReadMethod() != null) {
					properties.add(pd);
				} else if (write && pd.getWriteMethod() != null) {
					properties.add(pd);
				}
			}
			return properties.toArray(new PropertyDescriptor[0]);
		}
	} catch (BeansException ex) {
		throw new CodeGenerationException(ex);
	}
}
 
Example 5
/**
 * 获取 Bean 的所有 PropertyDescriptor
 *
 * @param type 类
 * @param read 读取方法
 * @param write 写方法
 * @return PropertyDescriptor数组
 */
public static PropertyDescriptor[] getPropertiesHelper(Class type, boolean read, boolean write) {
	try {
		PropertyDescriptor[] all = BeanUtil.getPropertyDescriptors(type);
		if (read && write) {
			return all;
		} else {
			List<PropertyDescriptor> properties = new ArrayList<>(all.length);
			for (PropertyDescriptor pd : all) {
				if (read && pd.getReadMethod() != null) {
					properties.add(pd);
				} else if (write && pd.getWriteMethod() != null) {
					properties.add(pd);
				}
			}
			return properties.toArray(new PropertyDescriptor[0]);
		}
	} catch (BeansException ex) {
		throw new CodeGenerationException(ex);
	}
}