Make Java objects returned by Sigar class Serializable

This commit is contained in:
Doug MacEachern 2007-02-24 16:19:17 +00:00
parent 6a926ec91d
commit 30c1d35714
6 changed files with 38 additions and 7 deletions

View File

@ -1,3 +1,7 @@
2007-02-24 Doug MacEachern <dougm@hyperic.com>
* Make Java objects returned by Sigar class Serializable
2007-02-21 Doug MacEachern <dougm@hyperic.com>
* Perl binding updates

View File

@ -28,6 +28,15 @@ sub supported_platforms {
return join ", ", @platforms;
}
sub hash {
use integer;
my $hash = 0;
for (split //, shift) {
$hash = $hash*31 + ord $_;
}
return $hash;
}
#this script generates jni code and java classes for the following table
my %classes = (
@ -1395,6 +1404,13 @@ EOF
my $cache_field_ids = 1;
my $uid = 0;
for my $field (@$fields) {
$field->{type} ||= 'Long';
$uid += hash($field->{type}) + hash($field->{name});
}
print JFH <<EOF;
package $package;
@ -1404,7 +1420,9 @@ import java.util.Map;
/**
* $name sigar class.
*/
public class $name {
public class $name implements java.io.Serializable {
private static final long serialVersionUID = ${uid}L;
public $name() { }
@ -1499,7 +1517,7 @@ DESTROY(obj)
EOF
for my $field (@$fields) {
my $type = $field->{type} || 'Long';
my $type = $field->{type};
my $name = $field->{name};
my $member = $field->{member} || $name;
my $desc = $field->{desc} || $name;

View File

@ -21,7 +21,10 @@ package org.hyperic.sigar;
/**
* CPU percentage usage
*/
public class CpuPerc {
public class CpuPerc implements java.io.Serializable {
private static final long serialVersionUID = 02242007L;
private double user;
private double sys;
private double nice;

View File

@ -22,13 +22,15 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
public class FileInfo extends FileAttrs {
public class FileInfo extends FileAttrs implements java.io.Serializable {
private static final long serialVersionUID = 02242007L;
private static final SimpleDateFormat DATE_FORMAT =
new SimpleDateFormat("MMM dd HH:mm");
String name;
private Sigar sigar;
private transient Sigar sigar;
private boolean dirStatEnabled = false;
private DirStat stat = null;
private boolean lstat;

View File

@ -18,7 +18,9 @@
package org.hyperic.sigar;
public class NetStat {
public class NetStat implements java.io.Serializable {
private static final long serialVersionUID = 02242007L;
protected int[] tcpStates;
protected int tcpInboundTotal, tcpOutboundTotal;

View File

@ -21,7 +21,9 @@ package org.hyperic.sigar;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class NfsFileSystem extends FileSystem {
public class NfsFileSystem extends FileSystem implements java.io.Serializable {
private static final long serialVersionUID = 02242007L;
private static final int NFS_PROGRAM = 100003;