コード例 #1
0
  @Override
  public void insertOrUpdateAssociation(
      AssociationKey key, Association association, AssociationContext associationContext) {
    Map<SerializableRowKey, Map<String, Object>> associationRows =
        ((SerializableMapAssociationSnapshot) association.getSnapshot()).getUnderlyingMap();

    for (AssociationOperation action : association.getOperations()) {
      switch (action.getType()) {
        case CLEAR:
          associationRows.clear();
        case PUT:
          associationRows.put(
              new SerializableRowKey(action.getKey()),
              MapHelpers.associationRowToMap(action.getValue()));
          break;
        case REMOVE:
          associationRows.remove(new SerializableRowKey(action.getKey()));
          break;
      }
    }

    final Cache<AK> associationCache = getCacheManager().getAssociationCache(key.getMetadata());
    associationCache.put(
        new Element(getKeyProvider().getAssociationCacheKey(key), associationRows));
  }