use of org.hibernate.bytecode.spi.BytecodeProvider in project hibernate-orm by hibernate.
the class SessionFactoryBuilderImpl method build.
@Override
public SessionFactory build() {
final StandardServiceRegistry serviceRegistry = metadata.getMetadataBuildingOptions().getServiceRegistry();
BytecodeProvider bytecodeProvider = serviceRegistry.getService(BytecodeProvider.class);
addSessionFactoryObservers(new SessionFactoryObserverForBytecodeEnhancer(bytecodeProvider));
return new SessionFactoryImpl(metadata, buildSessionFactoryOptions());
}
use of org.hibernate.bytecode.spi.BytecodeProvider in project hibernate-orm by hibernate.
the class ReflectionOptimizerTest method testInterface.
@Test
@TestForIssue(jiraKey = "HHH-12584")
public void testInterface() {
BytecodeProvider provider = Environment.getBytecodeProvider();
ReflectionOptimizer reflectionOptimizer = provider.getReflectionOptimizer(Interface.class, new String[] { "getProperty" }, new String[] { "setProperty" }, new Class[] { String.class });
assertNotNull(reflectionOptimizer);
}
use of org.hibernate.bytecode.spi.BytecodeProvider in project hibernate-orm by hibernate.
the class ReflectionOptimizerTest method testAbstractClass.
@Test
@TestForIssue(jiraKey = "HHH-12584")
public void testAbstractClass() {
BytecodeProvider provider = Environment.getBytecodeProvider();
ReflectionOptimizer reflectionOptimizer = provider.getReflectionOptimizer(AbstractClass.class, new String[] { "getProperty" }, new String[] { "setProperty" }, new Class[] { String.class });
assertNotNull(reflectionOptimizer);
}
use of org.hibernate.bytecode.spi.BytecodeProvider in project hibernate-orm by hibernate.
the class ReflectionOptimizerTest method testReflectionOptimization.
@Test
public void testReflectionOptimization() {
BytecodeProvider provider = Environment.getBytecodeProvider();
ReflectionOptimizer optimizer = provider.getReflectionOptimizer(Bean.class, BeanReflectionHelper.getGetterNames(), BeanReflectionHelper.getSetterNames(), BeanReflectionHelper.getTypes());
assertNotNull(optimizer);
assertNotNull(optimizer.getInstantiationOptimizer());
assertNotNull(optimizer.getAccessOptimizer());
Object instance = optimizer.getInstantiationOptimizer().newInstance();
assertEquals(instance.getClass(), Bean.class);
Bean bean = (Bean) instance;
optimizer.getAccessOptimizer().setPropertyValues(bean, BeanReflectionHelper.TEST_VALUES);
assertEquals(bean.getSomeString(), BeanReflectionHelper.TEST_VALUES[0]);
Object[] values = optimizer.getAccessOptimizer().getPropertyValues(bean);
assertEquivalent(values, BeanReflectionHelper.TEST_VALUES);
}
use of org.hibernate.bytecode.spi.BytecodeProvider in project hibernate-orm by hibernate.
the class ReflectionOptimizerTest method testReflectionOptimization.
@Test
public void testReflectionOptimization() {
BytecodeProvider provider = Environment.getBytecodeProvider();
ReflectionOptimizer optimizer = provider.getReflectionOptimizer(Bean.class, BeanReflectionHelper.getGetterNames(), BeanReflectionHelper.getSetterNames(), BeanReflectionHelper.getTypes());
assertNotNull(optimizer);
assertNotNull(optimizer.getInstantiationOptimizer());
assertNotNull(optimizer.getAccessOptimizer());
Object instance = optimizer.getInstantiationOptimizer().newInstance();
assertEquals(instance.getClass(), Bean.class);
Bean bean = (Bean) instance;
optimizer.getAccessOptimizer().setPropertyValues(bean, BeanReflectionHelper.TEST_VALUES);
assertEquals(bean.getSomeString(), BeanReflectionHelper.TEST_VALUES[0]);
Object[] values = optimizer.getAccessOptimizer().getPropertyValues(bean);
assertEquivalent(values, BeanReflectionHelper.TEST_VALUES);
}
Aggregations