View Javadoc

1   package com.atlassian.sal.api.events;
2   
3   import javax.annotation.Nullable;
4   import javax.annotation.concurrent.Immutable;
5   import javax.servlet.http.HttpSessionListener;
6   
7   /**
8    * Represents an event published when a http session is destroyed.  Implementers should fire this event accordingly.
9    * @see HttpSessionListener
10   */
11  @Immutable
12  public class SessionDestroyedEvent
13  {
14      private final String sessionId;
15      private final String userName;
16  
17      private SessionDestroyedEvent(final String sessionId, final String userName)
18      {
19          this.sessionId = sessionId;
20          this.userName = userName;
21      }
22  
23      public static Builder builder()
24      {
25          return new Builder();
26      }
27  
28      public String getSessionId()
29      {
30          return sessionId;
31      }
32  
33      @Nullable
34      public String getUserName()
35      {
36          return userName;
37      }
38  
39      public static class Builder
40      {
41          private String sessionId;
42          private String userName;
43  
44          private Builder()
45          {
46          }
47  
48          public Builder sessionId(final String sessionId)
49          {
50              if (sessionId == null)
51              {
52                  throw new NullPointerException("Session ID must be supplied");
53              }
54              this.sessionId = sessionId;
55              return this;
56          }
57  
58          public Builder userName(@Nullable final String userName)
59          {
60              this.userName = userName;
61              return this;
62          }
63  
64  
65          public SessionDestroyedEvent build()
66          {
67              if (sessionId == null)
68              {
69                  throw new NullPointerException("Session ID must be supplied");
70              }
71              return new SessionDestroyedEvent(sessionId, userName);
72          }
73      }
74  
75  }
76