code: private RemoteBundleContext getRemoteBundleContext()
      {
          if( m_remoteBundleContext == null )
          {
              long startedTrying = System.currentTimeMillis();
              //!! Absolutely necesary for RMI class loading to work
              // TODO maybe use ContextClassLoaderUtils.doWithClassLoader
              Thread.currentThread().setContextClassLoader( this.getClass().getClassLoader() );
              Throwable reason = null;
              try
              {
                  final Registry registry = LocateRegistry.getRegistry( m_rmiPort );
                  do
                  {
                      try
                      {
                          m_remoteBundleContext =
                              (RemoteBundleContext) registry.lookup( RemoteBundleContext.class.getName() );
                      }
                      catch( ConnectException e )
                      {
                          reason = e;
                      }
                      catch( NotBoundException e )
                      {
                          reason = e;
                      }
                  }
                  while( m_remoteBundleContext == null
                         && ( m_rmiLookupTimeout == Constants.WAIT_FOREVER
                              || System.currentTimeMillis() < startedTrying + m_rmiLookupTimeout ) );
              }
              catch( RemoteException e )
              {
                  reason = e;
              }
              if( m_remoteBundleContext == null )
              {
                  throw new TestContainerException( "Cannot get the remote bundle context", reason );
              }
              LOG.info(
                  "Remote bundle context found after " + ( System.currentTimeMillis() - startedTrying ) + " millis"
              );
          }
          return m_remoteBundleContext;
      }
docs: Looks up the {@link RemoteBundleContext} via RMI. The lookup will timeout in the specified number of millis.
  
  @return remote bundle context