docs: @Override
      public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> env)
                      throws Exception {
          final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
  
          // -----------------------------------------------------------------------
          // Is obj a Reference?
          // -----------------------------------------------------------------------
          if (!(obj instanceof Reference)) {
              return null;
          }
  
          Reference ref = (Reference) obj;
  
          // -----------------------------------------------------------------------
          // Is the right factory for this reference?
          // -----------------------------------------------------------------------
          if (!ivInstanceClassName.equals(ref.getFactoryClassName())) {
              return null;
          }
  
          // -----------------------------------------------------------------------
          // Is address null?
          // -----------------------------------------------------------------------
          RefAddr addr = ref.get(Addr_Type);
          if (addr == null) {
              NamingException nex = new NamingException("The address for this Reference is empty (null)");
              throw nex;
          }
  
          // -----------------------------------------------------------------------
          // Reference has the right factory and non empty address, so it is OK
          // to generate the EntityManager or EntityManagerFactory object now.
          // -----------------------------------------------------------------------
  
          Object retObj = null;
  
          JPAJndiLookupInfo info = (JPAJndiLookupInfo) addr.getContent();
          if (isTraceOn && tc.isDebugEnabled())
              Tr.debug(tc, "getting EntityManagerFactory for " + info);
  
          JPAPuId puId = info.getPuId(); // d424494
          J2EEName j2eeName = info.getJ2EEName(); // d510184
          String refName = info.getReferenceName(); // d510184
          boolean isSFSB = checkSFSBAccess(info, info.isSFSB()); // F743-30682
          JPAComponent jpaService = JPAAccessor.getJPAComponent();
  
          //Check to see see if we can delegate to the OSGi-aware JPA container
          JPALookupDelegate delegate = lookupDelegate.get();
  
          // If we find a delegate then call it to see if it can provide the Object
          if (delegate != null) {
              // Call the right method
              if (info.isFactory())
                  retObj = delegate.getEntityManagerFactory(puId.getPuName(), j2eeName);
              else
                  retObj = delegate.getEntityManager(puId.getPuName(), j2eeName, info.isExtendedContextType(), info.getPersistenceProperties());
          }
  
          if (retObj == null) {
              if (info.isFactory()) {
                  retObj = jpaService.getEntityManagerFactory(puId,
                                                              j2eeName,
                                                              USE_EMF_PROXY_VALUE || isSFSB); // d706751
              } else {
                  Map<?, ?> pCtxtProperties = info.getPersistenceProperties();
                  retObj = jpaService.getEntityManager(puId,
                                                       j2eeName,
                                                       refName,
                                                       info.isExtendedContextType(),
                                                       info.isUnsynchronized(),
                                                       pCtxtProperties);
  
              }
          }
  
          return retObj;
      }