code: public static PersistenceBrokerInternal currentPersistenceBroker(PBKey key)
              throws PBFactoryException, PersistenceBrokerException
      {
          HashMap map = (HashMap) currentBrokerMap.get();
          WeakHashMap set;
          PersistenceBrokerInternal broker = null;
  
          if(map == null)
          {
              return null;
          }
  
          set = (WeakHashMap) map.get(key);
          if(set == null)
          {
              return null;
          }
  
          // seek for an open broker, preferably in transaction
          for(Iterator it = set.keySet().iterator(); it.hasNext();)
          {
              PersistenceBrokerInternal tmp = (PersistenceBrokerInternal) it.next();
              if(tmp == null || tmp.isClosed())
              {
                  it.remove();
                  continue;
              }
              broker = tmp;
              if(tmp.isInTransaction())
              {
                  break; // the best choice found
              }
          }
          return broker;
      }
docs: Return the current open {@link org.apache.ojb.broker.PersistenceBroker}
  instance for the given {@link org.apache.ojb.broker.PBKey}, if any.
  
  @param key
  @return null if no open {@link org.apache.ojb.broker.PersistenceBroker} found.