65 if (tmp.equals(UNIX)) {
66 t = getFlavor(Flavor.UNIX);
67 }
68 else if (tmp.equals(WIN) | tmp.equals(WINDOWS)) {
69 t = getFlavor(Flavor.WINDOWS);
70 }
71 else if (tmp.equals(NONE) || tmp.equals(OFF) || tmp.equals(FALSE)) {
72 t = new UnsupportedTerminal();
73 }
74 else {
75 if (tmp.equals(AUTO)) {
76 String os = Configuration.getOsName();
77 Flavor flavor = Flavor.UNIX;
78 if (os.contains(WINDOWS)) {
79 flavor = Flavor.WINDOWS;
80 }
81 t = getFlavor(flavor);
82 }
83 else {
84 try {
85 t = (Terminal) Thread.currentThread().getContextClassLoader().loadClass(type).newInstance();
86 }
87 catch (Exception e) {
88 throw new IllegalArgumentException(MessageFormat.format("Invalid terminal type: {0}", type), e);
89 }
90 }
91 }
92 }
93 catch (Exception e) {
94 Log.error("Failed to construct terminal; falling back to unsupported", e);
95 t = new UnsupportedTerminal();
96 }
97
98 Log.debug("Created Terminal: ", t);
99
100 try {
101 t.init();
102 }
103 catch (Throwable e) {
104 Log.error("Terminal initialization failed; falling back to unsupported", e);
105 return new UnsupportedTerminal();
|
65 if (tmp.equals(UNIX)) {
66 t = getFlavor(Flavor.UNIX);
67 }
68 else if (tmp.equals(WIN) | tmp.equals(WINDOWS)) {
69 t = getFlavor(Flavor.WINDOWS);
70 }
71 else if (tmp.equals(NONE) || tmp.equals(OFF) || tmp.equals(FALSE)) {
72 t = new UnsupportedTerminal();
73 }
74 else {
75 if (tmp.equals(AUTO)) {
76 String os = Configuration.getOsName();
77 Flavor flavor = Flavor.UNIX;
78 if (os.contains(WINDOWS)) {
79 flavor = Flavor.WINDOWS;
80 }
81 t = getFlavor(flavor);
82 }
83 else {
84 try {
85 @SuppressWarnings("deprecation")
86 Object o = Thread.currentThread().getContextClassLoader().loadClass(type).newInstance();
87 t = (Terminal) o;
88 }
89 catch (Exception e) {
90 throw new IllegalArgumentException(MessageFormat.format("Invalid terminal type: {0}", type), e);
91 }
92 }
93 }
94 }
95 catch (Exception e) {
96 Log.error("Failed to construct terminal; falling back to unsupported", e);
97 t = new UnsupportedTerminal();
98 }
99
100 Log.debug("Created Terminal: ", t);
101
102 try {
103 t.init();
104 }
105 catch (Throwable e) {
106 Log.error("Terminal initialization failed; falling back to unsupported", e);
107 return new UnsupportedTerminal();
|