Search in sources :

Example 1 with BytecodeProvider

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());
}
Also used : SessionFactoryObserverForBytecodeEnhancer(org.hibernate.bytecode.internal.SessionFactoryObserverForBytecodeEnhancer) BytecodeProvider(org.hibernate.bytecode.spi.BytecodeProvider) SessionFactoryImpl(org.hibernate.internal.SessionFactoryImpl) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry)

Example 2 with BytecodeProvider

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);
}
Also used : BytecodeProvider(org.hibernate.bytecode.spi.BytecodeProvider) ReflectionOptimizer(org.hibernate.bytecode.spi.ReflectionOptimizer) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 3 with BytecodeProvider

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);
}
Also used : BytecodeProvider(org.hibernate.bytecode.spi.BytecodeProvider) ReflectionOptimizer(org.hibernate.bytecode.spi.ReflectionOptimizer) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 4 with BytecodeProvider

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);
}
Also used : BytecodeProvider(org.hibernate.bytecode.spi.BytecodeProvider) ReflectionOptimizer(org.hibernate.bytecode.spi.ReflectionOptimizer) Test(org.junit.Test)

Example 5 with BytecodeProvider

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);
}
Also used : BytecodeProvider(org.hibernate.bytecode.spi.BytecodeProvider) ReflectionOptimizer(org.hibernate.bytecode.spi.ReflectionOptimizer) Test(org.junit.Test)

Aggregations

BytecodeProvider (org.hibernate.bytecode.spi.BytecodeProvider)8 ReflectionOptimizer (org.hibernate.bytecode.spi.ReflectionOptimizer)4 Test (org.junit.Test)4 TestForIssue (org.hibernate.testing.TestForIssue)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)1 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)1 SessionFactoryObserverForBytecodeEnhancer (org.hibernate.bytecode.internal.SessionFactoryObserverForBytecodeEnhancer)1 BytecodeProviderImpl (org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl)1 SessionFactoryImpl (org.hibernate.internal.SessionFactoryImpl)1 HibernateProxy (org.hibernate.proxy.HibernateProxy)1 ServiceRegistryImplementor (org.hibernate.service.spi.ServiceRegistryImplementor)1