Package com.avaje.ebeaninternal.server.cache

Examples of com.avaje.ebeaninternal.server.cache.CachedBeanData


  /**
   * Put a bean into the bean cache.
   */
  public void beanCachePut(EntityBean bean) {

    CachedBeanData beanData = beanExtractData(bean);

    Object id = desc.getId(bean);
    if (beanLog.isDebugEnabled()) {
      beanLog.debug("   PUT {}({})", cacheName, id);
    }
    getBeanCache().put(id, beanData);
   
    if (beanData.isNaturalKeyUpdate() && naturalKeyCache != null) {
      Object naturalKey = beanData.getNaturalKey();
      if (naturalKey != null) {
        if (natLog.isDebugEnabled()) {
          natLog.debug(" PUT {}({}, {})", cacheName, naturalKey, id);
        }
        naturalKeyCache.put(naturalKey, id);
View Full Code Here


   * Return a bean from the bean cache.
   */
  @SuppressWarnings("unchecked")
  private T beanCacheGetInternal(Object id, Boolean readOnly) {

    CachedBeanData data = (CachedBeanData) getBeanCache().get(id);
    if (data == null) {
      if (beanLog.isTraceEnabled()) {
        beanLog.trace("   GET {}({}) - cache miss", cacheName, id);
      }
      return null;
    }
    if (cacheSharableBeans && !Boolean.FALSE.equals(readOnly)) {
      Object bean = data.getSharableBean();
      if (bean != null) {
        if (beanLog.isTraceEnabled()) {
          beanLog.trace("   GET {}({}) - hit shared bean", cacheName, id);
        }
        return (T) bean;
View Full Code Here

  /**
   * Returns true if it managed to populate/load the bean from the cache.
   */
  public boolean beanCacheLoad(EntityBean bean, EntityBeanIntercept ebi, Object id) {

    CachedBeanData cacheData = (CachedBeanData) getBeanCache().get(id);
    if (cacheData == null) {
      if (beanLog.isTraceEnabled()) {
        beanLog.trace("   LOAD {}({}) - cache miss", cacheName, id);
      }
      return false;
    }
    int lazyLoadProperty = ebi.getLazyLoadPropertyIndex();
    if (lazyLoadProperty > -1 && !cacheData.isLoaded(lazyLoadProperty)) {
      if (beanLog.isTraceEnabled()) {
        beanLog.trace("   LOAD {}({}) - cache miss on property", cacheName, id);
      }
      return false;
    }
View Full Code Here

    // check if the bean itself was updated
    if (!updateRequest.isUpdatedManysOnly()) {
     
      // update the bean cache entry if it exists
      ServerCache cache = getBeanCache();
      CachedBeanData existingData = (CachedBeanData) cache.get(id);
      if (existingData != null) {
       
        if (isCachedDataTooOld(existingData)) {
          // just remove the entry from the cache
          if (beanLog.isDebugEnabled()) {
            beanLog.debug("   REMOVE {}({}) - entry too old", cacheName, id);
          }
          cache.remove(id);
         
        } else {
          // Update the cache data with the changes from our update
          CachedBeanData newData = CachedBeanDataUpdate.update(desc, existingData, updateRequest.getEntityBean());
          if (beanLog.isDebugEnabled()) {
            beanLog.debug("   UPDATE {}({})", cacheName, id);
          }
          cache.put(id, newData);
          if (newData.isNaturalKeyUpdate() && naturalKeyCache != null) {
           
            Object oldKey = newData.getOldNaturalKey();
            Object newKey = newData.getNaturalKey();
            if (natLog.isDebugEnabled()) {
              natLog.debug(".. update {} PUT({}, {}) REMOVE({})", cacheName, newKey, id, oldKey);
            }
   
            if (oldKey != null) {
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  public T createReference(Boolean readOnly, Object id) {

    if (cacheSharableBeans && !Boolean.FALSE.equals(readOnly)) {
      CachedBeanData d = (CachedBeanData) cacheHelp.beanCacheGetData(id);
      if (d != null) {
        Object shareableBean = d.getSharableBean();
        if (shareableBean != null) {
          return (T) shareableBean;
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.avaje.ebeaninternal.server.cache.CachedBeanData

Copyright © 2018 www.massapicom. 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.