Package de.sosd.mediaserver.util

Source Code of de.sosd.mediaserver.util.DidlChangeMap

package de.sosd.mediaserver.util;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;

import de.sosd.mediaserver.dao.DidlDao;
import de.sosd.mediaserver.domain.db.DidlDomain;

@Configurable
public class DidlChangeMap {

  private final Map<String, DidlDomain>   map  = new HashMap<String, DidlDomain>();
 
  @Autowired
  private DidlDao storage;
 
  public boolean hasDidl(String id) {
    return map.containsKey(id);   
  }
   
  public DidlDomain getDidl(String id) {
    DidlDomain didl = map.get(id);
    if (didl == null) {
      // is not cached
      didl = storage.getDidl(id);
      return addDidl(id, didl);
    } else {
      return didl;
    }
  }
 
  public DidlDomain addDidl(String id, DidlDomain didl) {
    map.put(id, didl);
    return didl;
  }
}
TOP

Related Classes of de.sosd.mediaserver.util.DidlChangeMap

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.