コード例 #1
0
/** Copyright All Rights Reserved. Created: christo 12/10/2006 15:50:59 */
public class DefaultOfBizConnectionFactory implements OfBizConnectionFactory {
  private final TenantReference tenantReference = MultiTenantContext.getTenantReference();
  private final EntityConfigUtil entityConfigUtil = EntityConfigUtil.getInstance();

  public Connection getConnection() throws SQLException, DataAccessException {
    try {
      return ConnectionFactory.getConnection(getDatabaseConfig().getDatasourceName());
    } catch (GenericEntityException e) {
      throw new DataAccessException(e);
    }
  }

  @Override
  public DatasourceInfo getDatasourceInfo() {
    return entityConfigUtil.getDatasourceInfo(getDatabaseConfig().getDatasourceName());
  }

  @Override
  public String getDelegatorName() {
    return getDatabaseConfig().getDelegatorName();
  }

  private DatabaseConfig getDatabaseConfig() {
    return tenantReference.get().getConfig(DatabaseConfig.class);
  }
}
コード例 #2
0
 @Override
 public DatasourceInfo getDatasourceInfo() {
   return entityConfigUtil.getDatasourceInfo(getDatabaseConfig().getDatasourceName());
 }