code: @Override
      public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception {
  
          // We only know how to deal with <code>javax.naming.Reference</code>s
          // that specify a class name of "javax.sql.DataSource"
          if ((obj == null) || !(obj instanceof Reference)) {
              return null;
          }
          Reference ref = (Reference) obj;
          if (!"javax.sql.DataSource".equals(ref.getClassName())) {
              return null;
          }
  
          Properties properties = new Properties();
          for (int i = 0; i < ALL_PROPERTIES.length; i++) {
              String propertyName = ALL_PROPERTIES[i];
              RefAddr ra = ref.get(propertyName);
              if (ra != null) {
                  String propertyValue = ra.getContent().toString();
                  properties.setProperty(propertyName, propertyValue);
              }
          }
  
          return createDataSource(properties);
      }
docs: Create and return a new {@link org.apache.commons.dbcp.ManagedBasicDataSource} instance.  If no instance can be created, return <code>null</code>
  instead.
  
  @param obj         The possibly null object containing location or reference information that can be used in creating an object.
  @param name        The name of this object relative to <code>nameCtx</code>.
  @param nameCtx     The context relative to which the <code>name</code> parameter is specified, or <code>null</code> if <code>name</code> is
  relative to the default initial context.
  @param environment The possibly null environment that is used in creating this object.
  @throws Exception if an exception occurs creating the instance.