1 package fr.in2p3.jsaga.adaptor;
2
3 import fr.in2p3.jsaga.adaptor.base.defaults.Default;
4 import fr.in2p3.jsaga.adaptor.base.usage.Usage;
5 import fr.in2p3.jsaga.adaptor.security.SecurityCredential;
6 import org.ogf.saga.error.*;
7
8 import java.util.Map;
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public abstract class WaitForEverAdaptorAbstract implements ClientAdaptor {
23 private static boolean s_isHanging = false;
24
25 public Usage getUsage() {
26 return null;
27 }
28 public Default[] getDefaults(Map attributes) throws IncorrectStateException {
29 return null;
30 }
31 public int getDefaultPort() {
32 return NO_PORT;
33 }
34 public Class[] getSupportedSecurityCredentialClasses() {
35 return null;
36 }
37 public void setSecurityCredential(SecurityCredential credential) {
38
39 }
40
41 public void connect(String userInfo, String host, int port, String basePath, Map attributes) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, BadParameterException, TimeoutException, NoSuccessException {
42 mayHang(attributes);
43 }
44 public void disconnect() throws NoSuccessException {
45
46 }
47
48 public static void hang() {
49 try {
50
51 s_isHanging = true;
52
53
54 for (;;) {
55 Thread.currentThread().sleep(100);
56 }
57 } catch (InterruptedException e) {
58 }
59 public static boolean isHanging() {
60
61 boolean ret = s_isHanging;
62
63
64 s_isHanging = false;
65
66
67 return ret;
68 }
69 protected static void mayHang(Map attributes) {
70 if (attributes.containsKey("hangatconnect")) {
71 hang();
72 }
73 }
74 protected static void mayHang(String additionalArgs) {
75 if ("hangatconnect".equals(additionalArgs)) {
76 hang();
77 }
78 }
79 }