2 * Copyright (C) 2007-2012 Mathieu Baudier
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.slc
.detached
;
18 import java
.util
.ArrayList
;
19 import java
.util
.List
;
20 import java
.util
.Vector
;
22 /** A session within the detached context. */
23 public class DetachedSession
{
24 public final static String PROP_DO_IT_AGAIN_POLICY
= "slc.detached.doItAgainPolicy";
25 public final static String SKIP_UNTIL_ERROR
= "skipUntilError";
26 public final static String REPLAY
= "replay";
28 private String uuid
= null;
29 private List requests
= new Vector();
30 private List answers
= new Vector();
31 private String doItAgainPolicy
= REPLAY
;
32 private List refreshedBundleNames
= new ArrayList();
34 public boolean isClosed() {
35 if (answers
.size() > 0) {
36 DetachedAnswer answer
= (DetachedAnswer
) answers
37 .get(answers
.size() - 1);
38 return answer
.getStatus() == DetachedAnswer
.CLOSED_SESSION
;
44 public boolean lastActionIsError() {
45 if (answers
.size() > 0) {
46 DetachedAnswer answer
= (DetachedAnswer
) answers
47 .get(answers
.size() - 1);
48 return answer
.getStatus() == DetachedAnswer
.ERROR
;
54 public int getExecutedStepCount() {
55 if(requests
.size() != answers
.size()) {
56 throw new DetachedException("requests.size() != answers.size() in DetachedSession");
58 return answers
.size();
61 public String
getDoItAgainPolicy() {
62 return doItAgainPolicy
;
65 public void setDoItAgainPolicy(String doItAgainPolicy
) {
66 this.doItAgainPolicy
= doItAgainPolicy
;
69 public List
getRequests() {
73 public String
getUuid() {
77 public void setUuid(String uuid
) {
81 public List
getAnswers() {
85 public List
getRefreshedBundleNames() {
86 return refreshedBundleNames
;
89 public String
toString() {
90 StringBuffer buf
= new StringBuffer(getClass().getName());
91 buf
.append("#").append(uuid
);
92 buf
.append(" doItAgainPolicy=").append(doItAgainPolicy
);
93 return buf
.toString();