Search in sources :

Example 11 with ClassLoaderService

use of org.hibernate.boot.registry.classloading.spi.ClassLoaderService in project hibernate-orm by hibernate.

the class ReflectHelper method getConstantValue.

public static Object getConstantValue(String name, SessionFactoryImplementor factory) {
    boolean conventionalJavaConstants = factory.getSessionFactoryOptions().isConventionalJavaConstants();
    Class clazz;
    try {
        if (conventionalJavaConstants && !JAVA_CONSTANT_PATTERN.matcher(name).find()) {
            return null;
        }
        ClassLoaderService classLoaderService = factory.getServiceRegistry().getService(ClassLoaderService.class);
        clazz = classLoaderService.classForName(StringHelper.qualifier(name));
    } catch (Throwable t) {
        return null;
    }
    try {
        return clazz.getField(StringHelper.unqualify(name)).get(null);
    } catch (Throwable t) {
        return null;
    }
}
Also used : ClassLoaderService(org.hibernate.boot.registry.classloading.spi.ClassLoaderService)

Example 12 with ClassLoaderService

use of org.hibernate.boot.registry.classloading.spi.ClassLoaderService in project hibernate-orm by hibernate.

the class Collection method getComparator.

public Comparator getComparator() {
    if (comparator == null && comparatorClassName != null) {
        try {
            final ClassLoaderService classLoaderService = getMetadata().getMetadataBuildingOptions().getServiceRegistry().getService(ClassLoaderService.class);
            setComparator((Comparator) classLoaderService.classForName(comparatorClassName).newInstance());
        } catch (Exception e) {
            throw new MappingException("Could not instantiate comparator class [" + comparatorClassName + "] for collection " + getRole());
        }
    }
    return comparator;
}
Also used : MappingException(org.hibernate.MappingException) ClassLoaderService(org.hibernate.boot.registry.classloading.spi.ClassLoaderService) MappingException(org.hibernate.MappingException)

Example 13 with ClassLoaderService

use of org.hibernate.boot.registry.classloading.spi.ClassLoaderService in project hibernate-orm by hibernate.

the class ToOne method setTypeUsingReflection.

public void setTypeUsingReflection(String className, String propertyName) throws MappingException {
    if (referencedEntityName == null) {
        final ClassLoaderService cls = getMetadata().getMetadataBuildingOptions().getServiceRegistry().getService(ClassLoaderService.class);
        referencedEntityName = ReflectHelper.reflectedPropertyClass(className, propertyName, cls).getName();
    }
}
Also used : ClassLoaderService(org.hibernate.boot.registry.classloading.spi.ClassLoaderService)

Example 14 with ClassLoaderService

use of org.hibernate.boot.registry.classloading.spi.ClassLoaderService in project hibernate-orm by hibernate.

the class SessionFactoryServiceRegistryFactoryImpl method buildServiceRegistry.

@Override
public SessionFactoryServiceRegistry buildServiceRegistry(SessionFactoryImplementor sessionFactory, SessionFactoryOptions options) {
    final ClassLoaderService cls = options.getServiceRegistry().getService(ClassLoaderService.class);
    final SessionFactoryServiceRegistryBuilderImpl builder = new SessionFactoryServiceRegistryBuilderImpl(theBasicServiceRegistry);
    for (SessionFactoryServiceContributor contributor : cls.loadJavaServices(SessionFactoryServiceContributor.class)) {
        contributor.contribute(builder);
    }
    return builder.buildSessionFactoryServiceRegistry(sessionFactory, options);
}
Also used : SessionFactoryServiceContributor(org.hibernate.service.spi.SessionFactoryServiceContributor) ClassLoaderService(org.hibernate.boot.registry.classloading.spi.ClassLoaderService)

Example 15 with ClassLoaderService

use of org.hibernate.boot.registry.classloading.spi.ClassLoaderService in project hibernate-orm by hibernate.

the class EnversServiceImpl method initialize.

@Override
public void initialize(final MetadataImplementor metadata, final MappingCollector mappingCollector) {
    if (initialized) {
        throw new UnsupportedOperationException("EnversService#initialize should be called only once");
    }
    initialized = true;
    this.serviceRegistry = metadata.getMetadataBuildingOptions().getServiceRegistry();
    this.classLoaderService = serviceRegistry.getService(ClassLoaderService.class);
    this.xmlHelper = new XMLHelper(classLoaderService);
    doInitialize(metadata, mappingCollector, serviceRegistry);
}
Also used : XMLHelper(org.hibernate.internal.util.xml.XMLHelper) ClassLoaderService(org.hibernate.boot.registry.classloading.spi.ClassLoaderService)

Aggregations

ClassLoaderService (org.hibernate.boot.registry.classloading.spi.ClassLoaderService)29 HibernateException (org.hibernate.HibernateException)8 MappingException (org.hibernate.MappingException)6 ClassLoadingException (org.hibernate.boot.registry.classloading.spi.ClassLoadingException)6 HashSet (java.util.HashSet)3 ServiceRegistry (org.hibernate.service.ServiceRegistry)3 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 Set (java.util.Set)2 AttributeConverter (javax.persistence.AttributeConverter)2 ClassLoaderAccessImpl (org.hibernate.boot.internal.ClassLoaderAccessImpl)2 ClassLoaderAccess (org.hibernate.boot.spi.ClassLoaderAccess)2 ServiceException (org.hibernate.service.spi.ServiceException)2 BasicTypeRegistry (org.hibernate.type.BasicTypeRegistry)2 File (java.io.File)1 InputStream (java.io.InputStream)1 InvalidObjectException (java.io.InvalidObjectException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Annotation (java.lang.annotation.Annotation)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1