From 1078548fafa91ad8e10340deee765d99650c91b6 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Wed, 6 Apr 2016 10:31:13 -0300 Subject: [PATCH] Melhorando carga do módulo jni a pedido de usuário. --- src/java/terminal.java | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/java/terminal.java b/src/java/terminal.java index 7efa5ed..237bb09 100644 --- a/src/java/terminal.java +++ b/src/java/terminal.java @@ -31,6 +31,9 @@ package pw3270; public class terminal { + // Is native library loaded? + private static boolean loaded = false; + // lib3270's session handle private long nativeHandle; @@ -228,6 +231,14 @@ public class terminal public native int erase_eof(); + /** + * Open print dialog. + *

+ * Only valid if connected to a remote window + * + * @return reserved + * + */ public native int print(); // Connect/Disconnect @@ -260,12 +271,28 @@ public class terminal public native int disconnect(); /** + * Load native module. + * + */ + private synchronized void load() { + + if(!loaded) { + System.loadLibrary("jni3270"); + loaded = true; + } + + } + + /** * Creates a tn3270 terminal without associating it * with any pw3270 window. * */ public terminal() { + + load(); init(); + } /** @@ -383,7 +410,7 @@ public class terminal * @return Selected file name. * */ - public native String file_chooser_dialog(int action, String title, String extension, String filename); + public native String file_chooser_dialog(int action, String title, String extension, String filename); public native int set_copy(String text); public native String get_copy(); @@ -399,7 +426,7 @@ public class terminal /** * Get connection SSL state * - * @return State of SSL connection (0 = Inseguro, 1 = CA válido, 2 = CA inválido ou auto-assinado, 3 = Negociando, 4 = Indefinido) + * @return State of SSL connection (0 = Unsafe, 1 = Valid CA, 2 = Invalid CA or self-signed, 3 = Negotiating, 4 = Undefined) * */ public native int get_secure(); @@ -419,9 +446,4 @@ public class terminal deinit(); } - static - { - System.loadLibrary("jni3270"); - } - }; -- libgit2 0.21.2