org.hibernate.testing.boot.ClassLoaderAccessTestingImpl Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of hibernate-testing Show documentation
                Show all versions of hibernate-testing Show documentation
Support for testing Hibernate ORM functionality
                
             The newest version!
        
        /*
 * SPDX-License-Identifier: Apache-2.0
 * Copyright Red Hat Inc. and Hibernate Authors
 */
package org.hibernate.testing.boot;
import java.net.URL;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.boot.spi.ClassLoaderAccess;
/**
 * @author Steve Ebersole
 */
public class ClassLoaderAccessTestingImpl implements ClassLoaderAccess {
	/**
	 * Singleton access
	 */
	public static final ClassLoaderAccessTestingImpl INSTANCE = new ClassLoaderAccessTestingImpl();
	@Override
	@SuppressWarnings("unchecked")
	public  Class classForName(String name) {
		try {
			return (Class) getClass().getClassLoader().loadClass( name );
		}
		catch (ClassNotFoundException e) {
			throw new ClassLoadingException( "Could not load class by name : " + name, e );
		}
	}
	@Override
	public URL locateResource(String resourceName) {
		return getClass().getClassLoader().getResource( resourceName );
	}
}
       © 2015 - 2025 Weber Informatics LLC | Privacy Policy