All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.spring.common.session.SessionUpdateRemappingFunction Maven / Gradle / Ivy

There is a newer version: 15.1.0.Dev03
Show newest version
package org.infinispan.spring.common.session;

import org.springframework.session.MapSession;

import java.io.Serializable;
import java.time.Duration;
import java.time.Instant;
import java.util.Map;
import java.util.function.BiFunction;

public class SessionUpdateRemappingFunction implements BiFunction, Serializable {

   private static final long serialVersionUID = 1L;

   private Instant lastAccessedTime;
   private Duration maxInactiveInterval;
   private Map delta;

   @Override
   public MapSession apply(final String key, final MapSession value) {
      if (value == null) {
         return null;
      }
      if (this.lastAccessedTime != null) {
         value.setLastAccessedTime(this.lastAccessedTime);
      }
      if (this.maxInactiveInterval != null) {
         value.setMaxInactiveInterval(this.maxInactiveInterval);
      }
      if (this.delta != null) {
         for (final Map.Entry attribute : this.delta.entrySet()) {
            if (attribute.getValue() != null) {
               value.setAttribute(attribute.getKey(), attribute.getValue());
            } else {
               value.removeAttribute(attribute.getKey());
            }
         }
      }
      return value;
   }

   Instant getLastAccessedTime() {
      return lastAccessedTime;
   }

   void setLastAccessedTime(final Instant lastAccessedTime) {
      this.lastAccessedTime = lastAccessedTime;
   }

   Duration getMaxInactiveInterval() {
      return maxInactiveInterval;
   }

   void setMaxInactiveInterval(final Duration maxInactiveInterval) {
      this.maxInactiveInterval = maxInactiveInterval;
   }

   Map getDelta() {
      return delta;
   }

   void setDelta(final Map delta) {
      this.delta = delta;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy