diff --git a/README.md b/README.md index 93de839..a1c0dff 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,17 @@ This project provides a Java client to manipulate Mikrotik routers using the rem ## Versions +**The current stable version is 2.2** + This library uses [semantic versioning](http://semver.org/) -**The current stable version is 2.1** +### Changes in version 2.2: -### Changes in version 2.1: +Version 2.2 implements AutoCloseable on ApiConnection to support Java 7's try-with-resources statement. -Version 2.1 adds the ability to use connection and command timeouts as requested by users. To see how to use these, please refer to the examples below. For more information, look at issue [#16](https://github.com/GideonLeGrange/mikrotik-java/issues/16). +#### Previous 2.x versions: -#### Previous 2.0 versions: +* 2.1 added the ability to use connection and command timeouts as. * 2.0.3 Fixed bug #18 - An empty username in ```login()``` caused the API to hang. * 2.0.2 Fixed bug #13 - processor thread wasn't being stopped on disconnect(), causing non-exit of application in some cases. diff --git a/pom.xml b/pom.xml index fef94c5..c93d0e3 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ me.legrange mikrotik - 2.1 + 2.2 jar Mikrotik API Java Client Library diff --git a/src/main/java/examples/Example9.java b/src/main/java/examples/Example9.java index 5870a9c..b9917ee 100644 --- a/src/main/java/examples/Example9.java +++ b/src/main/java/examples/Example9.java @@ -2,27 +2,25 @@ package examples; import java.util.List; import java.util.Map; +import me.legrange.mikrotik.ApiConnection; import me.legrange.mikrotik.MikrotikApiException; /** - * Example 9: Test special characters in usernames + * Example 9: Try with resources * * @author gideon */ -public class Example9 extends Example { +public class Example9 { public static void main(String... args) throws Exception { Example9 ex = new Example9(); - ex.connect(); ex.test(); - ex.disconnect(); } private void test() throws MikrotikApiException, InterruptedException { - List> res = con.execute("/user/add name=çãáõ"); - for (Map r : res) { - System.out.println(r); - } -// con.execute("/ip/firewall/filter/add chain=forward hotspot=!auth protocol=tcp src-port=8000-8084"); + try (ApiConnection con = ApiConnection.connect(Config.HOST, ApiConnection.DEFAULT_PORT, 2000)) { + con.login(Config.USERNAME, Config.PASSWORD); + con.execute("/user/add name=eric"); + } } }