org.springframework.cglib.core.CodeGenerationException Java Examples

The following examples show how to use org.springframework.cglib.core.CodeGenerationException. 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: ReflectUtil.java    From mica with 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 File: Enhancer.java    From spring-analysis-note with 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 File: Enhancer.java    From java-technology-stack with 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 File: BeanUtil.java    From blade-tool with 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
Source File: ReflectUtil.java    From blade-tool with 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[] 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);
	}
}