private boolean isRemote(BeanContext beanContext) {
   switch (info.getRefType()) {
     case REMOTE:
       return true;
     case LOCAL:
       return false;
     case UNKNOWN:
       {
         for (Class clazz : beanContext.getInterfaces(InterfaceType.BUSINESS_REMOTE)) {
           if (clazz.getName().equals(info.getInterface())) return true;
         }
       }
       ;
     default:
       return false;
   }
 }
  public Object getObject() throws NamingException {
    if (reference != null) {
      return reference.getObject();
    }

    SystemInstance systemInstance = SystemInstance.get();

    EjbResolver resolver = systemInstance.getComponent(EjbResolver.class);

    String deploymentId = resolver.resolve(info, moduleUri);

    if (deploymentId == null) {
      String key = "lazyEjbRefNotResolved";
      if (info.getHome() != null) {
        key += ".home";
      }
      String message =
          messages.format(
              key, info.getName(), info.getEjbLink(), info.getHome(), info.getInterface());
      throw new NameNotFoundException(message);
    }

    ContainerSystem containerSystem = systemInstance.getComponent(ContainerSystem.class);

    BeanContext beanContext = containerSystem.getBeanContext(deploymentId);

    if (beanContext == null) {
      String message = messages.format("deploymentNotFound", info.getName(), deploymentId);
      throw new NameNotFoundException(message);
    }

    InterfaceType type = null;
    switch (info.getRefType()) {
      case LOCAL:
        type = InterfaceType.BUSINESS_LOCAL;
        break;
      case REMOTE:
        type = InterfaceType.BUSINESS_REMOTE;
        break;
    }

    String jndiName =
        "openejb/Deployment/" + JndiBuilder.format(deploymentId, info.getInterface(), type);

    if (useCrossClassLoaderRef && isRemote(beanContext)) {
      reference = new CrossClassLoaderJndiReference(jndiName);
    } else {
      reference = new IntraVmJndiReference(jndiName);
    }

    return reference.getObject();
  }