View Javadoc
1   /*
2    * Copyright (c) 2006 JMockit developers
3    * This file is subject to the terms of the MIT license (see LICENSE.txt).
4    */
5   package mockit.internal.injection.full;
6   
7   import javax.enterprise.context.Conversation;
8   
9   final class TestConversation implements Conversation {
10      private boolean currentlyTransient;
11      private int counter;
12      private String currentId;
13      private long currentTimeout;
14  
15      TestConversation() {
16          currentlyTransient = true;
17      }
18  
19      @Override
20      public void begin() {
21          counter++;
22          currentId = String.valueOf(counter);
23          currentlyTransient = false;
24      }
25  
26      @Override
27      public void begin(String id) {
28          counter++;
29          currentId = id;
30          currentlyTransient = false;
31      }
32  
33      @Override
34      public void end() {
35          currentlyTransient = true;
36          currentId = null;
37      }
38  
39      @Override
40      public String getId() {
41          return currentId;
42      }
43  
44      @Override
45      public long getTimeout() {
46          return currentTimeout;
47      }
48  
49      @Override
50      public void setTimeout(long milliseconds) {
51          currentTimeout = milliseconds;
52      }
53  
54      @Override
55      public boolean isTransient() {
56          return currentlyTransient;
57      }
58  }