예제 #1
0
 /**
  * Tests Connection of the data source
  *
  * @param dsmInfo The meta information of the data source to be tested.
  */
 public boolean testDataSourceConnection(DataSourceMetaInfo dsmInfo) throws DataSourceException {
   if (log.isDebugEnabled()) {
     log.debug("Testing connection of data source: " + dsmInfo.getName());
   }
   DataSourceReader dsReader =
       DataSourceManager.getInstance().getDataSourceReader(dsmInfo.getDefinition().getType());
   try {
     return dsReader.testDataSourceConnection(
         DataSourceUtils.elementToString(
             (Element) dsmInfo.getDefinition().getDsXMLConfiguration()));
   } catch (DataSourceException e) {
     log.error(e.getMessage(), e);
     throw e;
   }
 }
예제 #2
0
 private Object createDataSourceObject(DataSourceMetaInfo dsmInfo, boolean isUseDataSourceFactory)
     throws DataSourceException {
   DataSourceReader dsReader =
       DataSourceManager.getInstance().getDataSourceReader(dsmInfo.getDefinition().getType());
   if (dsReader == null) {
     throw new DataSourceException(
         "A data source reader cannot be found for the type '"
             + dsmInfo.getDefinition().getType()
             + "'");
   }
   /* sets the current data source's (tenantId + ":" + name) as a thread local value
    * so it can be read by data source readers */
   DataSourceUtils.setCurrentDataSourceId(this.getTenantId() + ":" + dsmInfo.getName());
   return dsReader.createDataSource(
       DataSourceUtils.elementToString((Element) dsmInfo.getDefinition().getDsXMLConfiguration()),
       isUseDataSourceFactory);
 }