@SuppressWarnings("rawtypes")
  public void updated(String pid, Dictionary properties) throws ConfigurationException {
    DataSourceEntry dsEntry = dataSources.get(pid);
    if (dsEntry != null) {
      dsEntry.getServiceRegistration().unregister();
      dataSources.remove(pid);
    }

    try {

      Properties dsProperties = filterDataSourceProperties(properties);
      DataSource ds = datasourceFactory.createDataSource(dsProperties);

      Dictionary<String, String> registrationProperties = new Hashtable<String, String>();
      String databaseName = (String) properties.get(DataSourceFactory.JDBC_DATABASE_NAME);
      String datasourceName = (String) properties.get(DataSourceFactory.JDBC_DATASOURCE_NAME);
      if (datasourceName != null)
        registrationProperties.put(DataSourceFactory.JDBC_DATASOURCE_NAME, datasourceName);
      registrationProperties.put(DataSourceFactory.JDBC_SERVER_NAME, databaseName);
      ServiceRegistration serviceRegistration =
          bundleContext.registerService(DataSource.class.getName(), ds, registrationProperties);
      dsEntry = new DataSourceEntry(ds, serviceRegistration);
      dataSources.put(pid, dsEntry);
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
 @Override
 public DataSource create(DataSourceFactory dsf, Properties props) throws SQLException {
   try {
     DataSource ds = dsf.createDataSource(getNonPoolProps(props));
     DataSourceConnectionFactory connFactory = new DataSourceConnectionFactory((DataSource) ds);
     PoolableConnectionFactory pcf = new PoolableConnectionFactory(connFactory, null);
     GenericObjectPoolConfig conf = new GenericObjectPoolConfig();
     BeanConfig.configure(conf, getPoolProps(props));
     BeanConfig.configure(pcf, getPrefixed(props, FACTORY_PREFIX));
     GenericObjectPool<PoolableConnection> pool =
         new GenericObjectPool<PoolableConnection>(pcf, conf);
     pcf.setPool(pool);
     return new PoolingDataSource<PoolableConnection>(pool);
   } catch (Throwable e) {
     LOG.error("Error creating pooled datasource" + e.getMessage(), e);
     if (e instanceof SQLException) {
       throw (SQLException) e;
     } else if (e instanceof RuntimeException) {
       throw (RuntimeException) e;
     } else {
       throw new RuntimeException(e.getMessage(), e);
     }
   }
 }