protected Resource convertToResource(DataSource ds){
  Properties parameters=new Properties();
  PropertyUtils.setPropertyIfNotNull(parameters,"url",ds.getUrl());
  PropertyUtils.setPropertyIfNotNull(parameters,"username",ds.getUsername());
  PropertyUtils.setPropertyIfNotNull(parameters,"password",ds.getPassword());
  parameters.putAll(ds.getConnectionProperties());
  Resource resource=new Resource(ds.getJndiLocation(),ConfigurationEntryType.DATASOURCE);
  PropertyUtils.setPropertyIfNotNull(parameters,"driverClassName",ds.getDriverClass());
  resource.setParameters(PropertyUtils.toMap(parameters));
  return resource;
}

protected Resource convertToResource ( DataSource ds ) { Properties parameters = new Properties ( ) ; PropertyUtils . setPropertyIfNotNull ( parameters , "url" , ds . getUrl ( ) ) ; PropertyUtils . setPropertyIfNotNull ( parameters , "username" , ds . getUsername ( ) ) ; PropertyUtils . setPropertyIfNotNull ( parameters , "password" , ds . getPassword ( ) ) ; parameters . putAll ( ds . getConnectionProperties ( ) ) ; Resource resource = new Resource ( ds . getJndiLocation ( ) , ConfigurationEntryType . DATASOURCE ) ; PropertyUtils . setPropertyIfNotNull ( parameters , "driverClassName" , ds . getDriverClass ( ) ) ; resource . setParameters ( PropertyUtils . toMap ( parameters ) ) ; return resource ; }
this method converts the datasource to a resource used in tomcat .
