@Override
 public void applicationStarted(ComponentContext context) {
   if (namingContext != null) {
     return;
   }
   namingContext = NuxeoContainer.getRootContext();
   // allocate datasource sub-contexts
   Name comp;
   try {
     comp = new CompositeName(DataSourceHelper.getDataSourceJNDIPrefix());
   } catch (NamingException e) {
     throw new RuntimeException(e);
   }
   Context ctx = namingContext;
   for (int i = 0; i < comp.size(); i++) {
     try {
       ctx = (Context) ctx.lookup(comp.get(i));
     } catch (NamingException e) {
       try {
         ctx = ctx.createSubcontext(comp.get(i));
       } catch (NamingException e1) {
         throw new RuntimeException(e1);
       }
     }
   }
   // bind datasources
   for (DataSourceDescriptor datasourceDesc : datasources.values()) {
     bindDataSource(datasourceDesc);
   }
   // bind links
   for (DataSourceLinkDescriptor linkDesc : links.values()) {
     bindDataSourceLink(linkDesc);
   }
 }
 public DataTable generateDataTable(Query query, HttpServletRequest request)
     throws DataSourceException {
   String url = request.getParameter("url");
   System.out.println(
       new Timestamp((new java.util.Date()).getTime())
           + "\t--\tAZ\tRead datasource from "
           + url
           + "\treadCSVdatasource");
   if (StringUtils.isEmpty(url)) {
     System.out.println(
         new Timestamp((new java.util.Date()).getTime())
             + "\t--\tERR\tURL parameter not provided\treadCSVdatasource");
     url = getServletContext().getRealPath("data1.csv");
     // throw new DataSourceException(ReasonType.INVALID_REQUEST, "url parameter not provided");
   }
   // System.out.println("reading file "+ url);
   Reader reader;
   try {
     reader = new BufferedReader(new InputStreamReader(new URL(url).openStream()));
   } catch (MalformedURLException e) {
     System.out.println(
         new Timestamp((new java.util.Date()).getTime())
             + "\t--\tERR\tURL is malformed: "
             + url
             + "\treadCSVdatasource");
     throw new DataSourceException(ReasonType.INVALID_REQUEST, "url is malformed: " + url);
   } catch (IOException e) {
     System.out.println(
         new Timestamp((new java.util.Date()).getTime())
             + "\t--\tERR\tCouldn't open URL: "
             + url
             + "  "
             + e.getMessage()
             + "\treadCSVdatasource");
     throw new DataSourceException(ReasonType.INVALID_REQUEST, "Couldn't read from url: " + url);
   }
   DataTable dataTable = null;
   ULocale requestLocale = DataSourceHelper.getLocaleFromRequest(request);
   try {
     // Note: We assume that all the columns in the CSV file are text columns. In cases where the
     // column types are known in advance, this behavior can be overridden by passing a list of
     // ColumnDescription objects specifying the column types. See CsvDataSourceHelper.read() for
     // more details.
     dataTable = CsvDataSourceHelper.read(reader, null, true, requestLocale);
   } catch (IOException e) {
     System.out.println(
         new Timestamp((new java.util.Date()).getTime())
             + "\t--\tERR\tCouldn't read from URL: "
             + url
             + "  "
             + e.getMessage()
             + "\treadCSVdatasource");
     throw new DataSourceException(ReasonType.INVALID_REQUEST, "Couldn't read from url: " + url);
   }
   System.out.println(
       new Timestamp((new java.util.Date()).getTime())
           + "\t--\tAZ\tRead from "
           + url
           + " FINISHED.\treadCSVdatasource");
   return dataTable;
 }