|
|
|
@ -117,6 +117,8 @@ public class DefaultPersistenceUnitManager |
|
|
|
|
|
|
|
|
|
|
|
private DataSource defaultDataSource; |
|
|
|
private DataSource defaultDataSource; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private DataSource defaultJtaDataSource; |
|
|
|
|
|
|
|
|
|
|
|
private PersistenceUnitPostProcessor[] persistenceUnitPostProcessors; |
|
|
|
private PersistenceUnitPostProcessor[] persistenceUnitPostProcessors; |
|
|
|
|
|
|
|
|
|
|
|
private LoadTimeWeaver loadTimeWeaver; |
|
|
|
private LoadTimeWeaver loadTimeWeaver; |
|
|
|
@ -241,9 +243,9 @@ public class DefaultPersistenceUnitManager |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Specify the JDBC DataSource that the JPA persistence provider is supposed |
|
|
|
* Specify the JDBC DataSource that the JPA persistence provider is supposed to use |
|
|
|
* to use for accessing the database if none has been specified in |
|
|
|
* for accessing the database if none has been specified in <code>persistence.xml</code>. |
|
|
|
* <code>persistence.xml</code>. |
|
|
|
* This variant indicates no special transaction setup, i.e. typical resource-local. |
|
|
|
* <p>In JPA speak, a DataSource passed in here will be uses as "nonJtaDataSource" |
|
|
|
* <p>In JPA speak, a DataSource passed in here will be uses as "nonJtaDataSource" |
|
|
|
* on the PersistenceUnitInfo passed to the PersistenceProvider, provided that |
|
|
|
* on the PersistenceUnitInfo passed to the PersistenceProvider, provided that |
|
|
|
* none has been registered before. |
|
|
|
* none has been registered before. |
|
|
|
@ -254,20 +256,39 @@ public class DefaultPersistenceUnitManager |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the JDBC DataSource that the JPA persistence provider is supposed |
|
|
|
* Return the JDBC DataSource that the JPA persistence provider is supposed to use |
|
|
|
* to use for accessing the database if none has been specified in |
|
|
|
* for accessing the database if none has been specified in <code>persistence.xml</code>. |
|
|
|
* <code>persistence.xml</code>. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public DataSource getDefaultDataSource() { |
|
|
|
public DataSource getDefaultDataSource() { |
|
|
|
return this.defaultDataSource; |
|
|
|
return this.defaultDataSource; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Specify the JDBC DataSource that the JPA persistence provider is supposed to use |
|
|
|
|
|
|
|
* for accessing the database if none has been specified in <code>persistence.xml</code>. |
|
|
|
|
|
|
|
* This variant indicates that JTA is supposed to be used as transaction type. |
|
|
|
|
|
|
|
* <p>In JPA speak, a DataSource passed in here will be uses as "jtaDataSource" |
|
|
|
|
|
|
|
* on the PersistenceUnitInfo passed to the PersistenceProvider, provided that |
|
|
|
|
|
|
|
* none has been registered before. |
|
|
|
|
|
|
|
* @see javax.persistence.spi.PersistenceUnitInfo#getJtaDataSource() |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void setDefaultJtaDataSource(DataSource defaultJtaDataSource) { |
|
|
|
|
|
|
|
this.defaultJtaDataSource = defaultJtaDataSource; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return the JTA-aware DataSource that the JPA persistence provider is supposed to use |
|
|
|
|
|
|
|
* for accessing the database if none has been specified in <code>persistence.xml</code>. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public DataSource getDefaultJtaDataSource() { |
|
|
|
|
|
|
|
return this.defaultJtaDataSource; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set the PersistenceUnitPostProcessors to be applied to each |
|
|
|
* Set the PersistenceUnitPostProcessors to be applied to each |
|
|
|
* PersistenceUnitInfo that has been parsed by this manager. |
|
|
|
* PersistenceUnitInfo that has been parsed by this manager. |
|
|
|
* <p>Such post-processors can, for example, register further entity |
|
|
|
* <p>Such post-processors can, for example, register further entity classes and |
|
|
|
* classes and jar files, in addition to the metadata read in from |
|
|
|
* jar files, in addition to the metadata read from <code>persistence.xml</code>. |
|
|
|
* <code>persistence.xml</code>. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setPersistenceUnitPostProcessors(PersistenceUnitPostProcessor... postProcessors) { |
|
|
|
public void setPersistenceUnitPostProcessors(PersistenceUnitPostProcessor... postProcessors) { |
|
|
|
this.persistenceUnitPostProcessors = postProcessors; |
|
|
|
this.persistenceUnitPostProcessors = postProcessors; |
|
|
|
@ -342,6 +363,9 @@ public class DefaultPersistenceUnitManager |
|
|
|
if (pui.getPersistenceUnitRootUrl() == null) { |
|
|
|
if (pui.getPersistenceUnitRootUrl() == null) { |
|
|
|
pui.setPersistenceUnitRootUrl(determineDefaultPersistenceUnitRootUrl()); |
|
|
|
pui.setPersistenceUnitRootUrl(determineDefaultPersistenceUnitRootUrl()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (pui.getJtaDataSource() == null) { |
|
|
|
|
|
|
|
pui.setJtaDataSource(this.defaultJtaDataSource); |
|
|
|
|
|
|
|
} |
|
|
|
if (pui.getNonJtaDataSource() == null) { |
|
|
|
if (pui.getNonJtaDataSource() == null) { |
|
|
|
pui.setNonJtaDataSource(this.defaultDataSource); |
|
|
|
pui.setNonJtaDataSource(this.defaultDataSource); |
|
|
|
} |
|
|
|
} |
|
|
|
|