Java 类org.springframework.orm.jpa.LocalEntityManagerFactoryBean 实例源码

项目:openmeetings    文件:InstallWizard.java   
@Override
protected void onSubmit() {
    try {
        ConnectionPropertiesPatcher.patch(getModelObject());
        XmlWebApplicationContext ctx = (XmlWebApplicationContext)getWebApplicationContext(Application.get().getServletContext());
        if (ctx == null) {
            form.error(new StringResourceModel("install.wizard.db.step.error.patch", InstallWizard.this).setParameters("Web context is NULL").getObject());
            log.error("Web context is NULL");
            return;
        }
        LocalEntityManagerFactoryBean emb = ctx.getBeanFactory().getBean(LocalEntityManagerFactoryBean.class);
        emb.afterPropertiesSet();
        dbType = getModelObject().getDbType();
    } catch (Exception e) {
        form.error(new StringResourceModel("install.wizard.db.step.error.patch", InstallWizard.this).setParameters(e.getMessage()).getObject());
        log.error("error while patching", e);
    }
}
项目:Camel    文件:JpaEndpoint.java   
protected EntityManagerFactory createEntityManagerFactory() {
    LocalEntityManagerFactoryBean emfBean = new LocalEntityManagerFactoryBean();
    emfBean.setPersistenceUnitName(persistenceUnit);
    emfBean.setJpaPropertyMap(getEntityManagerProperties());
    emfBean.afterPropertiesSet();
    return emfBean.getObject();
}
项目:Camel    文件:JpaRouteSharedEntityManagerTest.java   
private int getBrokerCount() {
    LocalEntityManagerFactoryBean entityManagerFactory = applicationContext.getBean("&entityManagerFactory", LocalEntityManagerFactoryBean.class);

    //uses Spring EL so we don't need to reference the classes
    StandardEvaluationContext context = new StandardEvaluationContext(entityManagerFactory);
    context.setBeanResolver(new BeanFactoryResolver(applicationContext));
    SpelExpressionParser parser = new SpelExpressionParser();
    Expression expression = parser.parseExpression("nativeEntityManagerFactory.brokerFactory.openBrokers"); 
    List<?> brokers = expression.getValue(context, List.class);

    return brokers.size();
}
项目:mint4j    文件:JpaDaoTestContextConfiguration.java   
@Bean
public LocalEntityManagerFactoryBean entityManagerFactory() {

    LocalEntityManagerFactoryBean bean = new LocalEntityManagerFactoryBean();
    bean.setPersistenceUnitName(unitName);
    return bean;
}