KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tomcat > jni > OS


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.tomcat.jni;
19
20 /** OS
21  *
22  * @author Mladen Turk
23  * @version $Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
24  */

25
26 public class OS {
27
28     /* OS Enums */
29     private static final int UNIX = 1;
30     private static final int NETWARE = 2;
31     private static final int WIN32 = 3;
32     private static final int WIN64 = 4;
33     private static final int LINUX = 5;
34     private static final int SOLARIS = 6;
35     private static final int BSD = 7;
36
37     public static final int LOG_EMERG = 1;
38     public static final int LOG_ERROR = 2;
39     public static final int LOG_NOTICE = 3;
40     public static final int LOG_WARN = 4;
41     public static final int LOG_INFO = 5;
42     public static final int LOG_DEBUG = 6;
43
44     /**
45      * Check for OS type.
46      * @param type OS type to test.
47      */

48     private static native boolean is(int type);
49
50     public static final boolean IS_UNIX = is(UNIX);
51     public static final boolean IS_NETWARE = is(NETWARE);
52     public static final boolean IS_WIN32 = is(WIN32);
53     public static final boolean IS_WIN64 = is(WIN64);
54     public static final boolean IS_LINUX = is(LINUX);
55     public static final boolean IS_SOLARIS = is(SOLARIS);
56     public static final boolean IS_BSD = is(BSD);
57
58     /**
59      * Get the name of the system default characer set.
60      * @param pool the pool to allocate the name from, if needed
61      */

62     public static native String JavaDoc defaultEncoding(long pool);
63
64     /**
65      * Get the name of the current locale character set.
66      * Defers to apr_os_default_encoding if the current locale's
67      * data can't be retreved on this system.
68      * @param pool the pool to allocate the name from, if needed
69      */

70     public static native String JavaDoc localeEncoding(long pool);
71
72     /**
73      * Generate random bytes.
74      * @param buf Buffer to fill with random bytes
75      * @param len Length of buffer in bytes
76      */

77     public static native int random(byte [] buf, int len);
78
79     /**
80      * Gather system info.
81      * <PRE>
82      * On exit the inf array will be filled with:
83      * inf[0] - Total usable main memory size
84      * inf[1] - Available memory size
85      * inf[2] - Total page file/swap space size
86      * inf[3] - Page file/swap space still available
87      * inf[4] - Amount of shared memory
88      * inf[5] - Memory used by buffers
89      * inf[6] - Memory Load
90      *
91      * inf[7] - Idle Time in microseconds
92      * inf[8] - Kernel Time in microseconds
93      * inf[9] - User Time in microseconds
94      *
95      * inf[10] - Process creation time (apr_time_t)
96      * inf[11] - Process Kernel Time in microseconds
97      * inf[12] - Process User Time in microseconds
98      *
99      * inf[13] - Current working set size.
100      * inf[14] - Peak working set size.
101      * inf[15] - Number of page faults.
102      * </PRE>
103      * @param inf array that will be filled with system information.
104      * Array length must be at least 16.
105      */

106     public static native int info(long [] inf);
107
108     /**
109      * Expand environment variables.
110      * @param str String to expand
111      * @return Expanded string with replaced environment variables.
112      */

113     public static native String JavaDoc expand(String JavaDoc str);
114
115     /**
116      * Initialize system logging.
117      * @param domain String that will be prepended to every message
118      */

119     public static native void sysloginit(String JavaDoc domain);
120
121     /**
122      * Log message.
123      * @param level Log message severity. See LOG_XXX enums.
124      * @param message Message to log
125      */

126     public static native void syslog(int level, String JavaDoc message);
127
128 }
129
Popular Tags