16 Aralık 2021 Perşembe

Servlet HttpSessionActivationListener Arayüzü

Giriş
Şu satırı dahil ederiz
import javax.servlet.http.HttpSessionActivationListener;
Açıklaması şöyle
Objects that are bound to a session may listen to container events notifying them that sessions will be passivated and activated. A container that migrates sessions between VMs or persists sessions is required to notify all attributes bound to sessions implementing the HttpSessionActivationListener interface.
Örnek
Şöyle yaparız
import java.io.Serializable;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionActivationListener;

public class MyHttpSessionActivationListener implements HttpSessionActivationListener,
Serializable {

  @Override
  public void sessionDidActivate(HttpSessionEvent event) {
    System.out.println("session activated");
  }

  @Override
  public void sessionWillPassivate(HttpSessionEvent event) {
    System.out.println("session passivated");
  }

}

Hiç yorum yok:

Yorum Gönder

Bean Validation @GroupSequence Anotasyonu

Örnek Elimizde şöyle bir kod olsun public class SampleRequest {   @NotNull   LocalDate startDate;   @NotNull   LocalDate endDate;   @AssertT...