File: jsvc.xml

package info (click to toggle)
commons-daemon 1.0.1-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,764 kB
  • ctags: 1,770
  • sloc: ansic: 15,466; sh: 2,530; xml: 1,504; java: 1,042; makefile: 81
file content (177 lines) | stat: -rw-r--r-- 5,345 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?xml version="1.0"?>

<document>

 <properties>
  <title>Daemon : Java Service</title>
  <author email="jfrederic.clere@fujitsu-siemens.con">Jean-Frederic Clere</author>
 </properties>

<body>
<section name="Introduction">
<p>
      Actualy only the UNIX like platforms are supported.
      The sources are located in the src/native/unix subdirectory of the
      project sources.
      For win32 platfroms the cygwin emulation layer is used. See
      <a href="http://www.cygwin.com/"> cygwin</a> for more informations.
</p>
<p>
      In the futur <a href="http://apr.apache.org/"> APR </a> may be used
      to provide more convinient platform support.
</p>
</section>

<section name="Building from cvs">
<p>
To build under an UNIX operating system you will need:
<ul>
  <li>GNU AutoConf (at least version 2.53)</li>
  <li>An ANSI-C compliant compiler (GCC is good)</li>
  <li>GNU Make</li>
  <li>A Java Platform 2 compliant SDK</li>
</ul>


You need to build the "configure" program with:

   sh support/buildconf.sh
(Note it is possible to replace sh by any compatible shell like bash, ksh).

The result should be something like:
<source>
support/buildconf.sh
support/buildconf.sh: configure script generated successfully
</source>
Once the configure script is generated, follow the next section.
</p>
</section>

<section name="Building for a release tarball">
<p>
To build the binary under an UNIX operating system you will need:
<ul>
  <li>An ANSI-C compliant compiler (GCC is good)</li>
  <li>GNU Make</li>
  <li>A Java Platform 2 compliant SDK</li>
</ul>

You have to specify the JAVA_HOME of the SDK
either the --with-java=&lt;dir&gt; parameter or set the JAVA_HOME environment
to point to your SDK installation. For example:
<source>
  ./configure --with-java=/usr/java
</source>
or
<source>
  export JAVA_HOME
  ./configure
</source>

If your operating system is supported, configure will go thru cleanly,
otherwise it will report an error (please send us the details of your
OS/JDK, or a patch against the sources). To build the binaries and
libraries simply do:
<source>
  make
</source>
This will generate the executable file jsvc.
</p>
</section>

<section name="Starting jsvc">
<p>
To check the allowed parameters for the jsvc binary simply do:
<source>
./jsvc -help
Usage: jsvc [-options] class [args...]

Where options include:

    -jvm &lt;JVM name&gt;
        use a specific Java Virtual Machine. Available JVMs:
            'client' 'server'
    -cp / -classpath &lt;directories and zip/jar files&gt;
        set search path for service classes and resouces
    -home &lt;directory&gt;
        set the path of your JDK or JRE installation (or set
        the JAVA_HOME environment variable)
    -version
        show the current Java environment version (to check
        correctness of -home and -jvm. Implies -nodetach)
    -help / -?
        show this help page (implies -nodetach)
    -nodetach
        don't detach from parent process and become a daemon
    -debug
        verbosely print debugging information
    -check
        only check service (implies -nodetach)
    -user &lt;user&gt;
        user used to run the daemon (defaults to current user)
    -verbose[:class|gc|jni]
        enable verbose output
    -outfile &lt;/full/path/to/file&gt;
        Location for output from stdout (defaults to /dev/null)
        Use the value '&amp;2' to simulate '1&gt;&amp;2'
    -errfile &lt;/full/path/to/file&gt;
        Location for output from stderr (defaults to /dev/null)
        Use the value '&amp;1' to simulate '2&gt;&amp;1'
    -pidfile &lt;/full/path/to/file&gt;
        Location for output from the file containing the pid of jsvc
        (defaults to /var/run/jsvc.pid)
    -D&lt;name&gt;=&lt;value&gt;
        set a Java system property
    -X&lt;option&gt;
        set Virtual Machine specific option
    -wait &lt;waittime&gt;
        wait waittime seconds for the service to start
        waittime should multiple of 10 (min=10)
    -stop
        stop the service using the file given in the -pidfile option

</source>
</p>

</section>
<section name="Using jsvc">
<p>
There two ways to use jsvc: via a Class that implements the Daemon interface or
via  calling a Class that have the required methods.
For example Tomcat-4.1.x uses the Daemon interface
and Tomcat-5.0.x provide a Class whose methods are called by jsvc directly.
</p>
<subsection name="Via Daemon interface">
<p>
You have to do the following.
<ul>
  <li>Write a Class that implements the Daemon interface (MyClass).</li>
  <li>Put it in the jarfile (my.jar).</li>
  <li>Call jsvc like:
  <source>
    ./jsvc -cp commons-daemon.jar:my.jar MyClass
  </source>
  </li>
</ul>
</p>
</subsection>
<subsection name="Directly">
<p>
You have to write a Class (MyClass) that implements the following methods:
<ul>
  <li>void init(String[] arguments): Here open the configuration files, create the trace file, create
      the ServerSockets, the Threads</li>
  <li>void start(): Start the Thread, accept incomming connections</li>
  <li>void stop(): Inform the Thread to live the run(), close the ServerSockets</li>
  <li>void destroy(): Destroy any object created in init()</li>
</ul>
Store it in a jarfile and use as above:
<source>
  ./jsvc -cp commons-daemon.jar:my.jar MyClass
</source>
</p>
</subsection>
</section>

</body>
</document>