org.hibernate.validator.internal.util.privilegedactions.SetContextClassLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bean-validator Show documentation
Show all versions of bean-validator Show documentation
JSR 380's RI, Hibernate Validator version ${hibernate-validator.version} and its dependencies repackaged as OSGi bundle
/*
* Hibernate Validator, declare and validate application constraints
*
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or .
*/
package org.hibernate.validator.internal.util.privilegedactions;
import java.security.PrivilegedAction;
import org.hibernate.validator.internal.util.Contracts;
/**
* Privileged action used to set the Thread context class loader.
*
* @author Guillaume Smet
*/
public final class SetContextClassLoader implements PrivilegedAction {
private final ClassLoader classLoader;
public static SetContextClassLoader action(ClassLoader classLoader) {
Contracts.assertNotNull( classLoader, "class loader must not be null" );
return new SetContextClassLoader( classLoader );
}
private SetContextClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}
@Override
public Void run() {
Thread.currentThread().setContextClassLoader( classLoader );
return null;
}
}