All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.validation.util.GetClassLoader Maven / Gradle / Ivy

Go to download

Module repackaging of the Hibernate validator library and Validation API (JSR 303)

There is a newer version: 3.0-JBoss-4.0.2_03
Show newest version
package org.hibernate.validation.util;

import java.security.PrivilegedAction;

/**
 * @author Emmanuel Bernard
 */
public class GetClassLoader implements PrivilegedAction {
	private final Class clazz;

	public static GetClassLoader fromContext() {
		return new GetClassLoader( null );
	}

	public static GetClassLoader fromClass(Class clazz) {
		if ( clazz == null ) throw new IllegalArgumentException("Class is null");
		return new GetClassLoader( clazz );
	}

	private GetClassLoader(Class clazz) {
		this.clazz = clazz;
	}

	public ClassLoader run() {
		if (clazz != null) {
			return clazz.getClassLoader();
		}
		else {
			return Thread.currentThread().getContextClassLoader();
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy