package org.springframework.beans.propertyeditors;

import java.beans.PropertyEditorSupport;

/**
 * Editor for java.lang.Class, to directly feed a Class property
 * instead of needing an additional class name property.
 * @author Juergen Hoeller
 * @since 13.05.2003
 */
public class ClassEditor extends PropertyEditorSupport {

	public void setAsText(String text) throws IllegalArgumentException {
		Class clazz = null;
		try {
			clazz = Class.forName(text);
		}
		catch (ClassNotFoundException ex) {
			throw new IllegalArgumentException("Invalid class name [" + text + "]: " + ex.getMessage());
		}
		setValue(clazz);
	}

	public String getAsText() {
		return ((Class) getValue()).getName();
	}

}

package org.springframework.beans.propertyeditors;

import java.beans.PropertyEditorSupport;

/**
 * Editor for java.lang.Class, to directly feed a Class property
 * instead of needing an additional class name property.
 * @author Juergen Hoeller
 * @since 13.05.2003
 */
public class ClassEditor extends PropertyEditorSupport {

	public void setAsText(String text) throws IllegalArgumentException {
		Class clazz = null;
		try {
			clazz = Class.forName(text, true, Thread.currentThread().getContextClassLoader());
		}
		catch (ClassNotFoundException ex) {
			throw new IllegalArgumentException("Invalid class name [" + text + "]: " + ex.getMessage());
		}
		setValue(clazz);
	}

	public String getAsText() {
		return ((Class) getValue()).getName();
	}

}

use thread context class loader