Java 类org.springframework.orm.jpa.persistenceunit.PersistenceUnitManager 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:JpaBaseConfiguration.java   
@Bean
@ConditionalOnMissingBean
public EntityManagerFactoryBuilder entityManagerFactoryBuilder(
        JpaVendorAdapter jpaVendorAdapter,
        ObjectProvider<PersistenceUnitManager> persistenceUnitManagerProvider) {
    EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilder(
            jpaVendorAdapter, this.properties.getProperties(),
            persistenceUnitManagerProvider.getIfAvailable());
    builder.setCallback(getVendorCallback());
    return builder;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AbstractJpaAutoConfigurationTests.java   
@Test
public void customPersistenceUnitManager() throws Exception {
    setupTestConfiguration(TestConfigurationWithCustomPersistenceUnitManager.class);
    this.context.refresh();
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = this.context
            .getBean(LocalContainerEntityManagerFactoryBean.class);
    Field field = LocalContainerEntityManagerFactoryBean.class
            .getDeclaredField("persistenceUnitManager");
    field.setAccessible(true);
    assertThat(field.get(entityManagerFactoryBean))
            .isEqualTo(this.context.getBean(PersistenceUnitManager.class));
}
项目:invesdwin-context-persistence    文件:PersistenceUnitContext.java   
/**
 * Package private so that only PersistenceProperties class can initialize this one.
 */
public PersistenceUnitContext(final PersistenceUnitManager persistenceUnitManager,
        final PersistenceUnitContextManager persistenceUnitContextManager, final String persistenceUnitName) {
    this.persistenceUnitManager = persistenceUnitManager;
    this.persistenceUnitContextManager = persistenceUnitContextManager;
    this.systemProperties = new SystemProperties(getClass());
    this.persistenceUnitName = persistenceUnitName;
}
项目:discoursedb-core    文件:BaseConfiguration.java   
@Bean(name="corePersistenceUnitManager")
@Primary
public PersistenceUnitManager corePersistenceUnitManager(DatabaseSelector dataSource) {
    DefaultPersistenceUnitManager persistenceUnitManager = new DefaultPersistenceUnitManager();
    persistenceUnitManager.setDefaultDataSource(dataSource);
    persistenceUnitManager.setPackagesToScan("edu.cmu.cs.lti.discoursedb.core.model");
    persistenceUnitManager.setDefaultPersistenceUnitName("corePersistenceUnitManager");
    return persistenceUnitManager;
}
项目:discoursedb-core    文件:SystemDbConfiguration.java   
@Bean(name="systemPersistenceUnitManager")
public PersistenceUnitManager systemPersistenceUnitManager() {
    DefaultPersistenceUnitManager persistenceUnitManager = new DefaultPersistenceUnitManager();
    persistenceUnitManager.setDefaultDataSource(this.systemDataSource());
    persistenceUnitManager.setPackagesToScan("edu.cmu.cs.lti.discoursedb.system.model");
    persistenceUnitManager.setDefaultPersistenceUnitName("systemPersistenceUnitManager");
    return persistenceUnitManager;
}
项目:spring-boot-concourse    文件:JpaBaseConfiguration.java   
@Bean
@ConditionalOnMissingBean
public EntityManagerFactoryBuilder entityManagerFactoryBuilder(
        JpaVendorAdapter jpaVendorAdapter,
        ObjectProvider<PersistenceUnitManager> persistenceUnitManagerProvider) {
    EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilder(
            jpaVendorAdapter, this.properties.getProperties(),
            persistenceUnitManagerProvider.getIfAvailable());
    builder.setCallback(getVendorCallback());
    return builder;
}
项目:spring-boot-concourse    文件:AbstractJpaAutoConfigurationTests.java   
@Test
public void customPersistenceUnitManager() throws Exception {
    setupTestConfiguration(TestConfigurationWithCustomPersistenceUnitManager.class);
    this.context.refresh();
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = this.context
            .getBean(LocalContainerEntityManagerFactoryBean.class);
    Field field = LocalContainerEntityManagerFactoryBean.class
            .getDeclaredField("persistenceUnitManager");
    field.setAccessible(true);
    assertThat(field.get(entityManagerFactoryBean))
            .isEqualTo(this.context.getBean(PersistenceUnitManager.class));
}
项目:contestparser    文件:AbstractJpaAutoConfigurationTests.java   
@Test
public void customPersistenceUnitManager() throws Exception {
    setupTestConfiguration(TestConfigurationWithCustomPersistenceUnitManager.class);
    this.context.refresh();
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = this.context
            .getBean(LocalContainerEntityManagerFactoryBean.class);
    Field field = LocalContainerEntityManagerFactoryBean.class
            .getDeclaredField("persistenceUnitManager");
    field.setAccessible(true);
    assertThat(field.get(entityManagerFactoryBean),
            equalTo((Object) this.context.getBean(PersistenceUnitManager.class)));
}
项目:pedal-dialect    文件:JpaConfiguration.java   
/**
 * @return Introduce custom persistence unit manager so that we can use the orm.xml file to rename the table
 * mapping for Student.java and verify that we pick up the renamed mapping via ProviderAccess.
 */
@Bean
public PersistenceUnitManager persistenceUnitManager(DataSource dataSource) {
    DefaultPersistenceUnitManager manager = new DefaultPersistenceUnitManager();
    manager.setPersistenceXmlLocation("classpath:META-INF/pedal-test-persistence.xml");
    manager.setDefaultDataSource(dataSource);
    return manager;
}
项目:pedal-dialect    文件:JpaConfiguration.java   
/**
 * @return Introduce custom persistence unit manager so that we can use the orm.xml file to rename the table
 * mapping for Student.java and verify that we pick up the renamed mapping via ProviderAccess.
 */
@Bean
public PersistenceUnitManager persistenceUnitManager(DataSource dataSource) {
    DefaultPersistenceUnitManager manager = new DefaultPersistenceUnitManager();
    manager.setPersistenceXmlLocation("classpath:META-INF/pedal-test-persistence.xml");
    manager.setDefaultDataSource(dataSource);
    return manager;
}
项目:kuali_rice    文件:RiceLocalContainerEntityManagerFactoryBean.java   
private PersistenceUnitManager preparePersistentUnitManager(Config config, String prefix, DataSource datasource) {
    DefaultPersistenceUnitManager persistenceUnitManager = new DefaultPersistenceUnitManager();
    persistenceUnitManager.setDefaultDataSource(datasource);
    persistenceUnitManager.setPersistenceXmlLocations(new String[] {determineConfigProperty(config, prefix, "PersistenceXmlLocation", "META-INF/persistence.xml")});
    persistenceUnitManager.setDefaultPersistenceUnitRootLocation(determineConfigProperty(config, prefix, "PersistenceUnitRootLocation", "classpath:"));
    RicePersistenceUnitPostProcessor postProcessor = new RicePersistenceUnitPostProcessor();
    postProcessor.setJtaDataSource(datasource);
    persistenceUnitManager.setPersistenceUnitPostProcessors(new RicePersistenceUnitPostProcessor[] { postProcessor });
    persistenceUnitManager.afterPropertiesSet();
    return persistenceUnitManager;
}
项目:invesdwin-context-persistence    文件:PersistenceUnitContextManager.java   
public PersistenceUnitContextManager(final PersistenceUnitManager persistenceUnitManager,
        final IDialectSpecificDelegate[] dialectSpecificDelegates) {
    Assertions.assertThat(persistenceUnitManager).isNotNull();
    this.persistenceUnitManager = persistenceUnitManager;
    associateDelegates(dialectSpecificDelegates);
}
项目:contestparser    文件:EntityManagerFactoryBuilder.java   
Delegate(JpaVendorAdapter jpaVendorAdapter, Map<String, ?> jpaProperties,
        PersistenceUnitManager persistenceUnitManager) {
    super(jpaVendorAdapter, jpaProperties, persistenceUnitManager);
}
项目:lams    文件:LocalContainerEntityManagerFactoryBean.java   
/**
 * Determine the PersistenceUnitInfo to use for the EntityManagerFactory
 * created by this bean.
 * <p>The default implementation reads in all persistence unit infos from
 * {@code persistence.xml}, as defined in the JPA specification.
 * If no entity manager name was specified, it takes the first info in the
 * array as returned by the reader. Otherwise, it checks for a matching name.
 * @param persistenceUnitManager the PersistenceUnitManager to obtain from
 * @return the chosen PersistenceUnitInfo
 */
protected PersistenceUnitInfo determinePersistenceUnitInfo(PersistenceUnitManager persistenceUnitManager) {
    if (getPersistenceUnitName() != null) {
        return persistenceUnitManager.obtainPersistenceUnitInfo(getPersistenceUnitName());
    }
    else {
        return persistenceUnitManager.obtainDefaultPersistenceUnitInfo();
    }
}
项目:spring4-understanding    文件:LocalContainerEntityManagerFactoryBean.java   
/**
 * Determine the PersistenceUnitInfo to use for the EntityManagerFactory
 * created by this bean.
 * <p>The default implementation reads in all persistence unit infos from
 * {@code persistence.xml}, as defined in the JPA specification.
 * If no entity manager name was specified, it takes the first info in the
 * array as returned by the reader. Otherwise, it checks for a matching name.
 * @param persistenceUnitManager the PersistenceUnitManager to obtain from
 * @return the chosen PersistenceUnitInfo
 */
protected PersistenceUnitInfo determinePersistenceUnitInfo(PersistenceUnitManager persistenceUnitManager) {
    if (getPersistenceUnitName() != null) {
        return persistenceUnitManager.obtainPersistenceUnitInfo(getPersistenceUnitName());
    }
    else {
        return persistenceUnitManager.obtainDefaultPersistenceUnitInfo();
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EntityManagerFactoryBuilder.java   
/**
 * Create a new instance passing in the common pieces that will be shared if multiple
 * EntityManagerFactory instances are created.
 * @param jpaVendorAdapter a vendor adapter
 * @param jpaProperties JPA properties to be passed to the persistence provider.
 * @param persistenceUnitManager optional source of persistence unit information (can
 * be null)
 */
public EntityManagerFactoryBuilder(JpaVendorAdapter jpaVendorAdapter,
        Map<String, ?> jpaProperties, PersistenceUnitManager persistenceUnitManager) {
    this.jpaVendorAdapter = jpaVendorAdapter;
    this.persistenceUnitManager = persistenceUnitManager;
    this.jpaProperties = new LinkedHashMap<String, Object>(jpaProperties);
}
项目:spring-boot-concourse    文件:EntityManagerFactoryBuilder.java   
/**
 * Create a new instance passing in the common pieces that will be shared if multiple
 * EntityManagerFactory instances are created.
 * @param jpaVendorAdapter a vendor adapter
 * @param jpaProperties JPA properties to be passed to the persistence provider.
 * @param persistenceUnitManager optional source of persistence unit information (can
 * be null)
 */
public EntityManagerFactoryBuilder(JpaVendorAdapter jpaVendorAdapter,
        Map<String, ?> jpaProperties, PersistenceUnitManager persistenceUnitManager) {
    this.jpaVendorAdapter = jpaVendorAdapter;
    this.persistenceUnitManager = persistenceUnitManager;
    this.jpaProperties = new LinkedHashMap<String, Object>(jpaProperties);
}
项目:contestparser    文件:EntityManagerFactoryBuilder.java   
/**
 * Create a new instance passing in the common pieces that will be shared if multiple
 * EntityManagerFactory instances are created.
 * @param jpaVendorAdapter a vendor adapter
 * @param jpaProperties JPA properties to be passed to the persistence provider.
 * @param persistenceUnitManager optional source of persistence unit information (can
 * be null)
 */
public EntityManagerFactoryBuilder(JpaVendorAdapter jpaVendorAdapter,
        Map<String, ?> jpaProperties, PersistenceUnitManager persistenceUnitManager) {
    this.jpaVendorAdapter = jpaVendorAdapter;
    this.persistenceUnitManager = persistenceUnitManager;
    this.jpaProperties = new LinkedHashMap<String, Object>(jpaProperties);
}
项目:class-guard    文件:LocalContainerEntityManagerFactoryBean.java   
/**
 * Determine the PersistenceUnitInfo to use for the EntityManagerFactory
 * created by this bean.
 * <p>The default implementation reads in all persistence unit infos from
 * {@code persistence.xml}, as defined in the JPA specification.
 * If no entity manager name was specified, it takes the first info in the
 * array as returned by the reader. Otherwise, it checks for a matching name.
 * @param persistenceUnitManager the PersistenceUnitManager to obtain from
 * @return the chosen PersistenceUnitInfo
 */
protected PersistenceUnitInfo determinePersistenceUnitInfo(PersistenceUnitManager persistenceUnitManager) {
    if (getPersistenceUnitName() != null) {
        return persistenceUnitManager.obtainPersistenceUnitInfo(getPersistenceUnitName());
    }
    else {
        return persistenceUnitManager.obtainDefaultPersistenceUnitInfo();
    }
}
项目:lams    文件:LocalContainerEntityManagerFactoryBean.java   
/**
 * Set the PersistenceUnitManager to use for obtaining the JPA persistence unit
 * that this FactoryBean is supposed to build an EntityManagerFactory for.
 * <p>The default is to rely on the local settings specified on this FactoryBean,
 * such as "persistenceXmlLocation", "dataSource" and "loadTimeWeaver".
 * <p>For reuse of existing persistence unit configuration or more advanced forms
 * of custom persistence unit handling, consider defining a separate
 * PersistenceUnitManager bean (typically a DefaultPersistenceUnitManager instance)
 * and linking it in here. {@code persistence.xml} location, DataSource
 * configuration and LoadTimeWeaver will be defined on that separate
 * DefaultPersistenceUnitManager bean in such a scenario.
 * @see #setPersistenceXmlLocation
 * @see #setDataSource
 * @see #setLoadTimeWeaver
 * @see org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager
 */
public void setPersistenceUnitManager(PersistenceUnitManager persistenceUnitManager) {
    this.persistenceUnitManager = persistenceUnitManager;
}
项目:spring4-understanding    文件:LocalContainerEntityManagerFactoryBean.java   
/**
 * Set the PersistenceUnitManager to use for obtaining the JPA persistence unit
 * that this FactoryBean is supposed to build an EntityManagerFactory for.
 * <p>The default is to rely on the local settings specified on this FactoryBean,
 * such as "persistenceXmlLocation", "dataSource" and "loadTimeWeaver".
 * <p>For reuse of existing persistence unit configuration or more advanced forms
 * of custom persistence unit handling, consider defining a separate
 * PersistenceUnitManager bean (typically a DefaultPersistenceUnitManager instance)
 * and linking it in here. {@code persistence.xml} location, DataSource
 * configuration and LoadTimeWeaver will be defined on that separate
 * DefaultPersistenceUnitManager bean in such a scenario.
 * @see #setPersistenceXmlLocation
 * @see #setDataSource
 * @see #setLoadTimeWeaver
 * @see org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager
 */
public void setPersistenceUnitManager(PersistenceUnitManager persistenceUnitManager) {
    this.persistenceUnitManager = persistenceUnitManager;
}
项目:kc-rice    文件:KradEntityManagerFactoryBean.java   
/**
 * Creates a JPA-specific entity manager factory bean.
 *
 * @param manager the persistence unit manager to use.
 * @return a JPA-specific entity manager factory bean.
 */
protected LocalContainerEntityManagerFactoryBean createInternalFactoryBean(PersistenceUnitManager manager) {
    LocalContainerEntityManagerFactoryBean delegate = new LocalContainerEntityManagerFactoryBean();
    delegate.setPersistenceUnitManager(manager);
    return delegate;
}
项目:contestparser    文件:EntityManagerFactoryBuilder.java   
/**
 * Create a new instance passing in the common pieces that will be shared if multiple
 * EntityManagerFactory instances are created.
 * @param jpaVendorAdapter a vendor adapter
 * @param properties common configuration options, including generic map for JPA
 * vendor properties
 * @param persistenceUnitManager optional source of persistence unit information (can
 * be null)
 */
public EntityManagerFactoryBuilder(JpaVendorAdapter jpaVendorAdapter,
        JpaProperties properties, PersistenceUnitManager persistenceUnitManager) {
    this.delegate = new Delegate(jpaVendorAdapter, properties.getProperties(),
            persistenceUnitManager);
}
项目:class-guard    文件:LocalContainerEntityManagerFactoryBean.java   
/**
 * Set the PersistenceUnitManager to use for obtaining the JPA persistence unit
 * that this FactoryBean is supposed to build an EntityManagerFactory for.
 * <p>The default is to rely on the local settings specified on this FactoryBean,
 * such as "persistenceXmlLocation", "dataSource" and "loadTimeWeaver".
 * <p>For reuse of existing persistence unit configuration or more advanced forms
 * of custom persistence unit handling, consider defining a separate
 * PersistenceUnitManager bean (typically a DefaultPersistenceUnitManager instance)
 * and linking it in here. {@code persistence.xml} location, DataSource
 * configuration and LoadTimeWeaver will be defined on that separate
 * DefaultPersistenceUnitManager bean in such a scenario.
 * @see #setPersistenceXmlLocation
 * @see #setDataSource
 * @see #setLoadTimeWeaver
 * @see org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager
 */
public void setPersistenceUnitManager(PersistenceUnitManager persistenceUnitManager) {
    this.persistenceUnitManager = persistenceUnitManager;
}
项目:rice    文件:KradEntityManagerFactoryBean.java   
/**
 * Creates a JPA-specific entity manager factory bean.
 *
 * @param manager the persistence unit manager to use.
 * @return a JPA-specific entity manager factory bean.
 */
protected LocalContainerEntityManagerFactoryBean createInternalFactoryBean(PersistenceUnitManager manager) {
    LocalContainerEntityManagerFactoryBean delegate = new LocalContainerEntityManagerFactoryBean();
    delegate.setPersistenceUnitManager(manager);
    return delegate;
}