java sample for get last values
authorAlex Kirhenshtein <alk@netxms.org>
Fri, 27 Jan 2012 16:49:47 +0000 (16:49 +0000)
committerAlex Kirhenshtein <alk@netxms.org>
Fri, 27 Jan 2012 16:49:47 +0000 (16:49 +0000)
.gitattributes
sdk/samples/Java/get-dci-from-server/pom.xml [new file with mode: 0644]
sdk/samples/Java/get-dci-from-server/src/main/java/org/netxms/samples/Sample.java [new file with mode: 0644]

index 1d3d3a9..1dae3f9 100644 (file)
@@ -118,6 +118,8 @@ sdk/openssl/lib/x64/ssleay32.lib -text
 sdk/openssl/lib/x86/libeay32.lib -text
 sdk/openssl/lib/x86/ssleay32.lib -text
 sdk/samples/C/subagent/sample-subagent.vcproj -text
+sdk/samples/Java/get-dci-from-server/pom.xml -text
+sdk/samples/Java/get-dci-from-server/src/main/java/org/netxms/samples/Sample.java -text
 src/agent/core/epp.cpp -text
 src/agent/core/nxagentd-unicode.vcproj -text
 src/agent/core/nxagentd.vcproj -text
diff --git a/sdk/samples/Java/get-dci-from-server/pom.xml b/sdk/samples/Java/get-dci-from-server/pom.xml
new file mode 100644 (file)
index 0000000..21158b2
--- /dev/null
@@ -0,0 +1,71 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.netxms.samples</groupId>
+    <artifactId>get-dci-from-server</artifactId>
+    <packaging>jar</packaging>
+    <version>1.0.0</version>
+    <name>get-dci-from-server</name>
+    <url>http://www.netxms.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <mainClass>org.netxms.samples.Sample</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.netxms</groupId>
+            <artifactId>netxms-client</artifactId>
+            <version>1.1.10</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <show>protected</show>
+                </configuration>
+            </plugin>
+        </plugins>
+    </reporting>
+</project>
diff --git a/sdk/samples/Java/get-dci-from-server/src/main/java/org/netxms/samples/Sample.java b/sdk/samples/Java/get-dci-from-server/src/main/java/org/netxms/samples/Sample.java
new file mode 100644 (file)
index 0000000..839c278
--- /dev/null
@@ -0,0 +1,25 @@
+package org.netxms.samples;\r
+\r
+import org.netxms.api.client.NetXMSClientException;\r
+import org.netxms.client.NXCSession;\r
+import org.netxms.client.datacollection.DciValue;\r
+\r
+import java.io.IOException;\r
+\r
+public class Sample {\r
+    private static final long NODE_ID = 11L;\r
+    private static final String SERVER = "127.0.0.1";\r
+    private static final String LOGIN = "admin";\r
+    private static final String PASSWORD = "netxms";\r
+\r
+    public static void main(final String[] args) throws NetXMSClientException, IOException {\r
+        final NXCSession session = new NXCSession(SERVER, LOGIN, PASSWORD);\r
+        session.connect();\r
+        final DciValue[] lastValues = session.getLastValues(NODE_ID);\r
+        for (final DciValue lastValue : lastValues) {\r
+            System.out.printf("%s == %s%n", lastValue.getName(), lastValue.getValue());\r
+        }\r
+        session.disconnect();\r
+    }\r
+\r
+}
\ No newline at end of file