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;
}
}
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;
}
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();
}
}
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);
}
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);
}
Aggregations