KickJava   Java API By Example, From Geeks To Geeks.

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


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 /** Procattr
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 Procattr {
27
28     /**
29      * Create and initialize a new procattr variable
30      * @param cont The pool to use
31      * @return The newly created procattr.
32      */

33     public static native long create(long cont)
34         throws Error JavaDoc;
35
36     /**
37      * Determine if any of stdin, stdout, or stderr should be linked to pipes
38      * when starting a child process.
39      * @param attr The procattr we care about.
40      * @param in Should stdin be a pipe back to the parent?
41      * @param out Should stdout be a pipe back to the parent?
42      * @param err Should stderr be a pipe back to the parent?
43      */

44     public static native int ioSet(long attr, int in, int out, int err);
45     /**
46      * Set the child_in and/or parent_in values to existing apr_file_t values.
47      * <br />
48      * This is NOT a required initializer function. This is
49      * useful if you have already opened a pipe (or multiple files)
50      * that you wish to use, perhaps persistently across multiple
51      * process invocations - such as a log file. You can save some
52      * extra function calls by not creating your own pipe since this
53      * creates one in the process space for you.
54      * @param attr The procattr we care about.
55      * @param in apr_file_t value to use as child_in. Must be a valid file.
56      * @param parent apr_file_t value to use as parent_in. Must be a valid file.
57      */

58     public static native int childInSet(long attr, long in, long parent);
59
60     /**
61      * Set the child_out and parent_out values to existing apr_file_t values.
62      * <br />
63      * This is NOT a required initializer function. This is
64      * useful if you have already opened a pipe (or multiple files)
65      * that you wish to use, perhaps persistently across multiple
66      * process invocations - such as a log file.
67      * @param attr The procattr we care about.
68      * @param out apr_file_t value to use as child_out. Must be a valid file.
69      * @param parent apr_file_t value to use as parent_out. Must be a valid file.
70      */

71     public static native int childOutSet(long attr, long out, long parent);
72
73     /**
74      * Set the child_err and parent_err values to existing apr_file_t values.
75      * <br />
76      * This is NOT a required initializer function. This is
77      * useful if you have already opened a pipe (or multiple files)
78      * that you wish to use, perhaps persistently across multiple
79      * process invocations - such as a log file.
80      * @param attr The procattr we care about.
81      * @param err apr_file_t value to use as child_err. Must be a valid file.
82      * @param parent apr_file_t value to use as parent_err. Must be a valid file.
83      */

84     public static native int childErrSet(long attr, long err, long parent);
85
86     /**
87      * Set which directory the child process should start executing in.
88      * @param attr The procattr we care about.
89      * @param dir Which dir to start in. By default, this is the same dir as
90      * the parent currently resides in, when the createprocess call
91      * is made.
92      */

93     public static native int dirSet(long attr, String JavaDoc dir);
94
95     /**
96      * Set what type of command the child process will call.
97      * @param attr The procattr we care about.
98      * @param cmd The type of command. One of:
99      * <PRE>
100      * APR_SHELLCMD -- Anything that the shell can handle
101      * APR_PROGRAM -- Executable program (default)
102      * APR_PROGRAM_ENV -- Executable program, copy environment
103      * APR_PROGRAM_PATH -- Executable program on PATH, copy env
104      * </PRE>
105      */

106     public static native int cmdtypeSet(long attr, int cmd);
107
108     /**
109      * Determine if the child should start in detached state.
110      * @param attr The procattr we care about.
111      * @param detach Should the child start in detached state? Default is no.
112      */

113     public static native int detachSet(long attr, int detach);
114
115     /**
116      * Specify that apr_proc_create() should do whatever it can to report
117      * failures to the caller of apr_proc_create(), rather than find out in
118      * the child.
119      * @param attr The procattr describing the child process to be created.
120      * @param chk Flag to indicate whether or not extra work should be done
121      * to try to report failures to the caller.
122      * <br />
123      * This flag only affects apr_proc_create() on platforms where
124      * fork() is used. This leads to extra overhead in the calling
125      * process, but that may help the application handle such
126      * errors more gracefully.
127      */

128     public static native int errorCheckSet(long attr, int chk);
129
130     /**
131      * Determine if the child should start in its own address space or using the
132      * current one from its parent
133      * @param attr The procattr we care about.
134      * @param addrspace Should the child start in its own address space? Default
135      * is no on NetWare and yes on other platforms.
136      */

137     public static native int addrspaceSet(long attr, int addrspace);
138
139     /**
140      * Specify an error function to be called in the child process if APR
141      * encounters an error in the child prior to running the specified program.
142      * @param attr The procattr describing the child process to be created.
143      * @param pool The the pool to use.
144      * @param o The Object to call in the child process.
145      * <br />
146      * At the present time, it will only be called from apr_proc_create()
147      * on platforms where fork() is used. It will never be called on other
148      * platforms, on those platforms apr_proc_create() will return the error
149      * in the parent process rather than invoke the callback in the now-forked
150      * child process.
151      */

152     public static native void errfnSet(long attr, long pool, Object JavaDoc o);
153
154     /**
155      * Set the username used for running process
156      * @param attr The procattr we care about.
157      * @param username The username used
158      * @param password User password if needed. Password is needed on WIN32
159      * or any other platform having
160      * APR_PROCATTR_USER_SET_REQUIRES_PASSWORD set.
161      */

162     public static native int userSet(long attr, String JavaDoc username, String JavaDoc password);
163
164     /**
165      * Set the group used for running process
166      * @param attr The procattr we care about.
167      * @param groupname The group name used
168      */

169     public static native int groupSet(long attr, String JavaDoc groupname);
170
171
172 }
173
Popular Tags