Example #1
0
  /** Returns the map of oids to object datas for the given least-derived type. */
  private Map getMap(ClassMetaData meta) {
    Map m = (Map) _metaOidMaps.get(meta);
    if (m != null) return m;

    // load datas from file and cache them
    Collection datas = _conf.getFileHandler().load(meta);
    m = new HashMap(datas.size());
    for (Iterator itr = datas.iterator(); itr.hasNext(); ) {
      ObjectData data = (ObjectData) itr.next();
      m.put(data.getId(), data);
    }
    _metaOidMaps.put(meta, m);
    return m;
  }
Example #2
0
  /**
   * End the datastore transaction.
   *
   * @param updates {@link ObjectData} instances to insert or update
   * @param deletes {@link ObjectData} instances to delete
   */
  public synchronized void endTransaction(Collection updates, Collection deletes) {
    // track dirty types
    Set dirty = new HashSet();
    try {
      // commit updates
      if (updates != null) {
        for (Iterator itr = updates.iterator(); itr.hasNext(); ) {
          ObjectData data = (ObjectData) itr.next();
          ClassMetaData meta = getLeastDerived(data.getMetaData());
          getMap(meta).put(data.getId(), data);
          dirty.add(meta);
        }
      }

      // commit deletes
      if (deletes != null) {
        for (Iterator itr = deletes.iterator(); itr.hasNext(); ) {
          ObjectData data = (ObjectData) itr.next();
          ClassMetaData meta = getLeastDerived(data.getMetaData());
          getMap(meta).remove(data.getId());
          dirty.add(meta);
        }
      }

      // write changes to dirty extents back to file
      XMLFileHandler fh = _conf.getFileHandler();
      for (Iterator itr = dirty.iterator(); itr.hasNext(); ) {
        ClassMetaData meta = (ClassMetaData) itr.next();
        fh.store(meta, getMap(meta).values());
      }
    } finally {
      // unlock store
      notify();
      _locked = false;
    }
  }
Example #3
0
 /**
  * Creates an instance of {@link AbstractInternalContext}. The internal context is meant to hold
  * the configuration and state informations, but not necessarily retrieving those values...
  */
 public AbstractInternalContext() {
   _configuration = XMLConfiguration.newInstance();
   _javaNaming = new JavaNamingImpl();
 }