Commit 1078548fafa91ad8e10340deee765d99650c91b6
1 parent
2a12b812
Exists in
master
and in
5 other branches
Melhorando carga do módulo jni a pedido de usuário.
Showing
1 changed file
with
29 additions
and
7 deletions
Show diff stats
src/java/terminal.java
| ... | ... | @@ -31,6 +31,9 @@ package pw3270; |
| 31 | 31 | |
| 32 | 32 | public class terminal |
| 33 | 33 | { |
| 34 | + // Is native library loaded? | |
| 35 | + private static boolean loaded = false; | |
| 36 | + | |
| 34 | 37 | // lib3270's session handle |
| 35 | 38 | private long nativeHandle; |
| 36 | 39 | |
| ... | ... | @@ -228,6 +231,14 @@ public class terminal |
| 228 | 231 | public native int erase_eof(); |
| 229 | 232 | |
| 230 | 233 | |
| 234 | + /** | |
| 235 | + * Open print dialog. | |
| 236 | + * <p> | |
| 237 | + * Only valid if connected to a remote window | |
| 238 | + * | |
| 239 | + * @return reserved | |
| 240 | + * | |
| 241 | + */ | |
| 231 | 242 | public native int print(); |
| 232 | 243 | |
| 233 | 244 | // Connect/Disconnect |
| ... | ... | @@ -260,12 +271,28 @@ public class terminal |
| 260 | 271 | public native int disconnect(); |
| 261 | 272 | |
| 262 | 273 | /** |
| 274 | + * Load native module. | |
| 275 | + * | |
| 276 | + */ | |
| 277 | + private synchronized void load() { | |
| 278 | + | |
| 279 | + if(!loaded) { | |
| 280 | + System.loadLibrary("jni3270"); | |
| 281 | + loaded = true; | |
| 282 | + } | |
| 283 | + | |
| 284 | + } | |
| 285 | + | |
| 286 | + /** | |
| 263 | 287 | * Creates a tn3270 terminal without associating it |
| 264 | 288 | * with any pw3270 window. |
| 265 | 289 | * |
| 266 | 290 | */ |
| 267 | 291 | public terminal() { |
| 292 | + | |
| 293 | + load(); | |
| 268 | 294 | init(); |
| 295 | + | |
| 269 | 296 | } |
| 270 | 297 | |
| 271 | 298 | /** |
| ... | ... | @@ -383,7 +410,7 @@ public class terminal |
| 383 | 410 | * @return Selected file name. |
| 384 | 411 | * |
| 385 | 412 | */ |
| 386 | - public native String file_chooser_dialog(int action, String title, String extension, String filename); | |
| 413 | + public native String file_chooser_dialog(int action, String title, String extension, String filename); | |
| 387 | 414 | |
| 388 | 415 | public native int set_copy(String text); |
| 389 | 416 | public native String get_copy(); |
| ... | ... | @@ -399,7 +426,7 @@ public class terminal |
| 399 | 426 | /** |
| 400 | 427 | * Get connection SSL state |
| 401 | 428 | * |
| 402 | - * @return State of SSL connection (0 = Inseguro, 1 = CA válido, 2 = CA inválido ou auto-assinado, 3 = Negociando, 4 = Indefinido) | |
| 429 | + * @return State of SSL connection (0 = Unsafe, 1 = Valid CA, 2 = Invalid CA or self-signed, 3 = Negotiating, 4 = Undefined) | |
| 403 | 430 | * |
| 404 | 431 | */ |
| 405 | 432 | public native int get_secure(); |
| ... | ... | @@ -419,9 +446,4 @@ public class terminal |
| 419 | 446 | deinit(); |
| 420 | 447 | } |
| 421 | 448 | |
| 422 | - static | |
| 423 | - { | |
| 424 | - System.loadLibrary("jni3270"); | |
| 425 | - } | |
| 426 | - | |
| 427 | 449 | }; | ... | ... |