123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585 |
- <html><head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <title>Chapter 1. Admin Guide</title><meta name="generator" content="DocBook XSL Stylesheets V1.77.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="d6e1"></a>Chapter 1. Admin Guide</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#d6e3">Overview</a></span></dt><dt><span class="section"><a href="#d6e6">Dependencies</a></span></dt><dd><dl><dt><span class="section"><a href="#d6e8">Kamailio Modules</a></span></dt><dt><span class="section"><a href="#d6e15">External Libraries or Applications</a></span></dt></dl></dd><dt><span class="section"><a href="#d6e67">Java runtime</a></span></dt><dd><dl><dt><span class="section"><a href="#d6e69"></a></span></dt></dl></dd><dt><span class="section"><a href="#d6e72">Parameters</a></span></dt><dd><dl><dt><span class="section"><a href="#d6e74"><code class="varname">class_name</code> (string)</a></span></dt><dt><span class="section"><a href="#d6e87"><code class="varname">child_init_method</code> (string)</a></span></dt><dt><span class="section"><a href="#d6e98"><code class="varname">java_options</code> (string)</a></span></dt><dt><span class="section"><a href="#d6e123"><code class="varname">force_kam_cmd_exec</code> (int)</a></span></dt></dl></dd><dt><span class="section"><a href="#d6e135">Functions</a></span></dt><dd><dl><dt><span class="section"><a href="#d6e137">
- Common requirements
- </a></span></dt><dt><span class="section"><a href="#d6e146">java_method_exec(method, method_signature, [param1[, param2[, ...]]])</a></span></dt><dt><span class="section"><a href="#d6e181">java_staticmethod_exec(method, method_signature, [param1[, param2[, ...]]])</a></span></dt><dt><span class="section"><a href="#d6e216">java_s_method_exec(method, method_signature, [param1[, param2[, ...]]])</a></span></dt><dt><span class="section"><a href="#d6e254">java_s_staticmethod_exec(method, method_signature, [param1[, param2[, ...]]])</a></span></dt></dl></dd><dt><span class="section"><a href="#d6e292">Java Module API</a></span></dt><dd><dl><dt><span class="section"><a href="#d6e295">Minimal program skeleton</a></span></dt></dl></dd></dl></div>
-
-
-
-
- <div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d6e3"></a>Overview</h2></div></div></div>
-
- <p>
- This module allows executing Java compiled classes from config file, exporting
- functions to access the SIP message from Java using Java Native Interface (JNI).
- </p>
- </div>
-
-
-
- <div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d6e6"></a>Dependencies</h2></div></div></div>
-
-
- <div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d6e8"></a>Kamailio Modules</h3></div></div></div>
-
- <p>
- The following modules must be loaded before this module:
- </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- <p>
- <span class="emphasis"><em>none</em></span>.
- </p>
- </li></ul></div><p>
- </p>
- </div>
-
-
-
- <div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d6e15"></a>External Libraries or Applications</h3></div></div></div>
-
- <p>
-
- </p><div class="itemizedlist"><p><span class="emphasis"><em>The following packages are runtime libraries, required to launch</em></span></p><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem" style="list-style-type: disc"><p><span class="emphasis"><em>java-common</em></span> Base of all Java packages.</p></li><li class="listitem" style="list-style-type: disc"><p><span class="emphasis"><em>default-jre</em></span> Standard Java or Java compatible Runtime.</p></li><li class="listitem" style="list-style-type: disc"><p><span class="emphasis"><em>gcj-jre</em></span> Java runtime environment using GIJ/classpath.</p></li><li class="listitem" style="list-style-type: disc"><p><span class="emphasis"><em>libgcj12 (>=12)</em></span> Java runtime library for use with gcj.</p></li></ul></div><p>
- </p><div class="itemizedlist"><p><span class="emphasis"><em>The following packages are optional, required for development</em></span></p><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem" style="list-style-type: square"><p><span class="emphasis"><em>ant</em></span> Java based build tool like make.</p></li><li class="listitem" style="list-style-type: square"><p><span class="emphasis"><em>ant-contrib</em></span> Collection of tasks, types and other tools for Apache Ant.</p></li><li class="listitem" style="list-style-type: square"><p><span class="emphasis"><em>ant-gcj</em></span> Java based build tool like make (GCJ).</p></li><li class="listitem" style="list-style-type: square"><p><span class="emphasis"><em>default-jdk</em></span> Standard Java or Java compatible Development Kit</p></li><li class="listitem" style="list-style-type: square"><p><span class="emphasis"><em>gcj-jdk</em></span> gcj and classpath development tools for Java(TM)</p></li><li class="listitem" style="list-style-type: square"><p><span class="emphasis"><em>libgcj13-dev (>=12)</em></span> Java development headers for use with gcj</p></li><li class="listitem" style="list-style-type: square"><p><span class="emphasis"><em>jdk</em></span> JDK Development Kit (either oracle jdk or openjdk)</p></li></ul></div><p>
- </p>
- <p>
- The following libraries or applications must be compiled before
- running Kamailio with this module loaded:
- </p><div class="itemizedlist"><p><span class="emphasis"><em>The following packages are runtime libraries, required to launch</em></span></p><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem" style="list-style-type: circle"><p><span class="emphasis"><em><class_name></em></span>.class</p></li><li class="listitem" style="list-style-type: circle"><p><span class="emphasis"><em>kamailio</em></span>.jar</p></li></ul></div><p>
- </p>
- </div>
-
- </div>
-
-
-
- <div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d6e67"></a>Java runtime</h2></div></div></div>
-
- <div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d6e69"></a></h3></div></div></div>
-
- <p>Java runtime library (JRE or JDK) is required to use this module.</p>
- </div>
- </div>
-
-
-
- <div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d6e72"></a>Parameters</h2></div></div></div>
-
-
- <div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d6e74"></a><code class="varname">class_name</code> (string)</h3></div></div></div>
-
- <p>
- The class name should have the same compiled file name.
- If the value is <span class="emphasis"><em>"Kamailio"</em></span>, then the compiled file should be named as <span class="emphasis"><em>"Kamailio.class"</em></span>.
- </p>
- <p>
- <span class="emphasis"><em>
- Default value is <span class="quote">“<span class="quote">Kamailio</span>”</span>.
- </em></span>
- </p>
- <div class="example"><a name="d6e83"></a><p class="title"><b>Example 1.1. Set <code class="varname">class_name</code> parameter</b></p><div class="example-contents">
-
- <pre class="programlisting">
- ...
- modparam("app_java", "class_name", "Kamailio")
- ...
- </pre>
- </div></div><br class="example-break">
- </div>
-
- <div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d6e87"></a><code class="varname">child_init_method</code> (string)</h3></div></div></div>
-
- <p>
- TBD.
- </p>
- <p>
- <span class="emphasis"><em>
- Default value is <span class="quote">“<span class="quote">child_init</span>”</span>.
- </em></span>
- </p>
- <div class="example"><a name="d6e94"></a><p class="title"><b>Example 1.2. Set <code class="varname">child_init_method</code> parameter</b></p><div class="example-contents">
-
- <pre class="programlisting">
- ...
- modparam("app_java", "child_init_method", "my_mod_init")
- ...
- </pre>
- </div></div><br class="example-break">
- </div>
-
- <div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d6e98"></a><code class="varname">java_options</code> (string)</h3></div></div></div>
-
- <p>
- Java options for Java Virtual Machine.
- For more info read <a class="ulink" href="http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html" target="_top"><em class="citetitle">java docs</em></a>
- </p>
- <p>
- <span class="emphasis"><em>
- Default value is <span class="quote">“<span class="quote">-Djava.compiler=NONE</span>”</span>.
- </em></span>
- </p>
- <div class="example"><a name="d6e107"></a><p class="title"><b>Example 1.3. Set <code class="varname">java_options</code> parameter</b></p><div class="example-contents">
-
- <pre class="programlisting">
- ...
- modparam("app_java", "java_options", "-Djava.compiler=NONE")
- ...
- </pre>
- </div></div><br class="example-break">
- <div class="example"><a name="d6e111"></a><p class="title"><b>Example 1.4. Set <code class="varname">java_options</code> parameter (live configuration)</b></p><div class="example-contents">
-
- <pre class="programlisting">
- ...
- # Assumes "application java folder" is located at /opt/kamailio/java
- modparam("app_java", "java_options", "-Djava.compiler=NONE -Djava.class.path=/path/to/kamailio/modules:/opt/kamailio/java:/opt/kamailio/java/kamailio.jar")
- ...
- </pre>
- </div></div><br class="example-break">
- <div class="example"><a name="d6e115"></a><p class="title"><b>Example 1.5. Set <code class="varname">java_options</code> parameter (verbose configuration)</b></p><div class="example-contents">
-
- <pre class="programlisting">
- ...
- # Assumes "application java folder" is located at /opt/kamailio/java
- modparam("app_java", "java_options", "-verbose:gc,class,jni -Djava.compiler=NONE -Djava.class.path=/path/to/kamailio/modules:/opt/kamailio/java:/opt/kamailio/java/kamailio.jar")
- ...
- </pre>
- </div></div><br class="example-break">
- <div class="example"><a name="d6e119"></a><p class="title"><b>Example 1.6. Set <code class="varname">java_options</code> parameter (debug configuration)</b></p><div class="example-contents">
-
- <pre class="programlisting">
- ...
- # Assumes "application java folder" is located at /opt/kamailio/java
- modparam("app_java", "java_options", "-Xdebug -verbose:gc,class,jni -Djava.compiler=NONE -Djava.class.path=/path/to/kamailio/modules:/opt/kamailio/java:/opt/kamailio/java/kamailio.jar")
- ...
- </pre>
- </div></div><br class="example-break">
- </div>
-
- <div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d6e123"></a><code class="varname">force_kam_cmd_exec</code> (int)</h3></div></div></div>
-
- <p>
- This parameter forces execution a kamailio comnmand with java native method <span class="quote">“<span class="quote">KamExec</span>”</span>.
- # Note: this is an untested yet feature, may cause (but may not) a memory leaks if used from embedded languages.
- </p>
- <p>
- <span class="emphasis"><em>
- Default value is <span class="quote">“<span class="quote">0 (off)</span>”</span>.
- </em></span>
- </p>
- <div class="example"><a name="d6e131"></a><p class="title"><b>Example 1.7. Set <code class="varname">force_kam_cmd_exec</code> parameter</b></p><div class="example-contents">
-
- <pre class="programlisting">
- ...
- modparam("app_java", "force_kam_cmd_exec", 1)
- ...
- </pre>
- </div></div><br class="example-break">
- </div>
- </div>
-
-
-
- <div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d6e135"></a>Functions</h2></div></div></div>
-
-
-
- <div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d6e137"></a>
- Common requirements
- </h3></div></div></div>
-
- <p>Each function has a required parameter <span class="quote">“<span class="quote">method_signature</span>”</span>. For more info
- see <a class="ulink" href="http://www.rgagnon.com/javadetails/java-0286.html" target="_top"><em class="citetitle">Determine the signature of a method</em></a>.
- Signature represents the variable type. The mapping between the Java type and C type
- is
- </p><pre class="programlisting">
- Type Chararacter
- boolean Z
- byte B
- char C
- double D
- float F
- int I
- long J
- object L
- short S
- void V
- Note that to specify an object, the "L" is followed by the object's class name and ends with a semi-colon, ';' .
- </pre><p>
- </p>
- <p> app_java supports the following signatures:
- </p><pre class="programlisting">
- Primitives: Z,B,C,D,F,I,J,L,S,V
- Objects:
- Ljava/lang/Boolean;
- Ljava/lang/Byte;
- Ljava/lang/Character;
- Ljava/lang/Double;
- Ljava/lang/Float;
- Ljava/lang/Integer;
- Ljava/lang/Long;
- Ljava/lang/Short;
- Ljava/lang/String;
- NULL parameter: V
- Each parameter passed to function will be cast according to given signature.
-
- Parameters are optional, ommitting a parameter meant the passed value is NULL.
- Parameters count should be exactly the same as signature count.
- Note 1: Arrays representation (symbol '[') is not supported yet.
- Note 2: You shall use a correct signature, e.g. the following examples of combinations are invalid:
- java_method_exec("ExampleMethod", "ZI", "False");
- java_method_exec("ExampleMethod", "LI", "something", "5");
- </pre><p>
- </p>
-
- </div>
-
-
-
- <div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d6e146"></a>java_method_exec(method, method_signature, [param1[, param2[, ...]]])</h3></div></div></div>
-
- <p>Executes a java class method <span class="emphasis"><em>method</em></span>. Parameter <span class="emphasis"><em>method_signature</em></span> is required.</p>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- <div class="example"><a name="d6e153"></a><p class="title"><b>Example 1.8. Signature: "V"</b></p><div class="example-contents">
-
- <p>Kamailio prototype</p>
- <pre class="programlisting">java_method_exec("ExampleMethod", "V");</pre>
- <p>Java prototype</p>
- <pre class="programlisting">public int ExampleMethod();</pre>
- <p>Example of usage:</p>
- <pre class="programlisting">
- # Kamailio
- java_method_exec("ExampleMethod", "V");
- # Java
- public int ExampleMethod()
- {
- ... do something;
- return 1;
- }
- </pre>
- </div></div><br class="example-break">
- </li><li class="listitem">
- <div class="example"><a name="d6e162"></a><p class="title"><b>Example 1.9. Signature: "Ljava/lang/String;I"</b></p><div class="example-contents">
-
- <p>Kamailio prototype</p>
- <pre class="programlisting">java_method_exec("ExampleMethod", "Ljava/lang/String;I", "Hello world", "5");</pre>
- <p>Java prototype</p>
- <pre class="programlisting">public int ExampleMethod(String param1, int param2);</pre>
- <p>In the above scenario parameter 2 ("5") will be cast to integer representation.</p>
- <p>Example of usage:</p>
- <pre class="programlisting">
- # Kamailio
- java_method_exec("ExampleMethod", "Ljava/lang/String;I", "$mb", "$ml");
- # Java
- public int ExampleMethod(String SipMessageBuffer, int SipMessageLenght)
- {
- ... do something with buffer;
- return 1;
- }
- </pre>
- </div></div><br class="example-break">
- </li><li class="listitem">
- <div class="example"><a name="d6e172"></a><p class="title"><b>Example 1.10. Signature: "ZB"</b></p><div class="example-contents">
-
- <p>Kamailio prototype</p>
- <pre class="programlisting">java_method_exec("ExampleMethod", "ZB", "true", "0x05");</pre>
- <p>Java prototype</p>
- <pre class="programlisting">public int ExampleMethod(boolean param1, byte param2);</pre>
- <p>In the above scenario parameter 1 ("true") will be cast to boolean representation.</p>
- <p>Example of usage:</p>
- <pre class="programlisting">
- # Kamailio
- java_method_exec("ExampleMethod", "ZB", "true", "0x05");
- # Java
- public int ExampleMethod(boolean flagSet, byte bFlag);
- {
- if (flagSet)
- {
- ... do something with flags;
- }
- return 1;
- }
- </pre>
- </div></div><br class="example-break">
- </li></ul></div>
- </div>
-
-
- <div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d6e181"></a>java_staticmethod_exec(method, method_signature, [param1[, param2[, ...]]])</h3></div></div></div>
-
- <p>Executes a java static method <span class="emphasis"><em>method</em></span>. Parameter <span class="emphasis"><em>method_signature</em></span> is required.</p>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- <div class="example"><a name="d6e188"></a><p class="title"><b>Example 1.11. Signature: "V"</b></p><div class="example-contents">
-
- <p>Kamailio prototype</p>
- <pre class="programlisting">java_staticmethod_exec("ExampleMethod", "V");</pre>
- <p>Java prototype</p>
- <pre class="programlisting">public static int ExampleMethod();</pre>
- <p>Example of usage:</p>
- <pre class="programlisting">
- # Kamailio
- java_staticmethod_exec("ExampleMethod", "V");
- # Java
- public static int ExampleMethod()
- {
- ... do something;
- return 1;
- }
- </pre>
- </div></div><br class="example-break">
- </li><li class="listitem">
- <div class="example"><a name="d6e197"></a><p class="title"><b>Example 1.12. Signature: "Ljava/lang/String;I"</b></p><div class="example-contents">
-
- <p>Kamailio prototype</p>
- <pre class="programlisting">java_staticmethod_exec("ExampleMethod", "Ljava/lang/String;I", "Hello world", "5");</pre>
- <p>Java prototype</p>
- <pre class="programlisting">public static int ExampleMethod(String param1, int param2);</pre>
- <p>In the above scenario parameter 2 ("5") will be cast to integer representation.</p>
- <p>Example of usage:</p>
- <pre class="programlisting">
- # Kamailio
- java_staticmethod_exec("ExampleMethod", "Ljava/lang/String;I", "$mb", "$ml");
- # Java
- public static int ExampleMethod(String SipMessageBuffer, int SipMessageLenght)
- {
- ... do something with buffer;
- return 1;
- }
- </pre>
- </div></div><br class="example-break">
- </li><li class="listitem">
- <div class="example"><a name="d6e207"></a><p class="title"><b>Example 1.13. Signature: "ZB"</b></p><div class="example-contents">
-
- <p>Kamailio prototype</p>
- <pre class="programlisting">java_staticmethod_exec("ExampleMethod", "ZB", "true", "0x05");</pre>
- <p>Java prototype</p>
- <pre class="programlisting">public static int ExampleMethod(boolean param1, byte param2);</pre>
- <p>In the above scenario parameter 1 ("true") will be cast to boolean representation.</p>
- <p>Example of usage:</p>
- <pre class="programlisting">
- # Kamailio
- java_staticmethod_exec("ExampleMethod", "ZB", "true", "0x05");
- # Java
- public static int ExampleMethod(boolean flagSet, byte bFlag);
- {
- if (flagSet)
- {
- ... do something with flags;
- }
- return 1;
- }
- </pre>
- </div></div><br class="example-break">
- </li></ul></div>
- </div>
-
-
-
- <div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d6e216"></a>java_s_method_exec(method, method_signature, [param1[, param2[, ...]]])</h3></div></div></div>
-
- <p>Executes a java class synchronized method <span class="emphasis"><em>method</em></span>. Parameter <span class="emphasis"><em>method_signature</em></span> is required.</p>
- <p>For more info see <a class="ulink" href="http://docs.oracle.com/javase/tutorial/essential/concurrency/syncmeth.html" target="_top"><em class="citetitle">Synchronized Methods</em></a></p>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- <div class="example"><a name="d6e226"></a><p class="title"><b>Example 1.14. Signature: "V"</b></p><div class="example-contents">
-
- <p>Kamailio prototype</p>
- <pre class="programlisting">java_s_method_exec("ExampleMethod", "V");</pre>
- <p>Java prototype</p>
- <pre class="programlisting">public synchronized int ExampleMethod();</pre>
- <p>Example of usage:</p>
- <pre class="programlisting">
- # Kamailio
- java_s_method_exec("ExampleMethod", "V");
- # Java
- public synchronized int ExampleMethod()
- {
- ... do something;
- return 1;
- }
- </pre>
- </div></div><br class="example-break">
- </li><li class="listitem">
- <div class="example"><a name="d6e235"></a><p class="title"><b>Example 1.15. Signature: "Ljava/lang/String;I"</b></p><div class="example-contents">
-
- <p>Kamailio prototype</p>
- <pre class="programlisting">java_s_method_exec("ExampleMethod", "Ljava/lang/String;I", "Hello world", "5");</pre>
- <p>Java prototype</p>
- <pre class="programlisting">public synchronized int ExampleMethod(String param1, int param2);</pre>
- <p>In the above scenario parameter 2 ("5") will be cast to integer representation.</p>
- <p>Example of usage:</p>
- <pre class="programlisting">
- # Kamailio
- java_s_method_exec("ExampleMethod", "Ljava/lang/String;I", "$mb", "$ml");
- # Java
- public synchronized int ExampleMethod(String SipMessageBuffer, int SipMessageLenght)
- {
- ... do something with buffer;
- return 1;
- }
- </pre>
- </div></div><br class="example-break">
- </li><li class="listitem">
- <div class="example"><a name="d6e245"></a><p class="title"><b>Example 1.16. Signature: "ZB"</b></p><div class="example-contents">
-
- <p>Kamailio prototype</p>
- <pre class="programlisting">java_s_method_exec("ExampleMethod", "ZB", "true", "0x05");</pre>
- <p>Java prototype</p>
- <pre class="programlisting">public synchronized int ExampleMethod(boolean param1, byte param2);</pre>
- <p>In the above scenario parameter 1 ("true") will be cast to boolean representation.</p>
- <p>Example of usage:</p>
- <pre class="programlisting">
- # Kamailio
- java_s_method_exec("ExampleMethod", "ZB", "true", "0x05");
- # Java
- public synchronized int ExampleMethod(boolean flagSet, byte bFlag);
- {
- if (flagSet)
- {
- ... do something with flags;
- }
- return 1;
- }
- </pre>
- </div></div><br class="example-break">
- </li></ul></div>
- </div>
-
-
-
- <div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d6e254"></a>java_s_staticmethod_exec(method, method_signature, [param1[, param2[, ...]]])</h3></div></div></div>
-
- <p>Executes a java synchronized static method <span class="emphasis"><em>method</em></span>. Parameter <span class="emphasis"><em>method_signature</em></span> is required.</p>
- <p>For more info see <a class="ulink" href="http://docs.oracle.com/javase/tutorial/essential/concurrency/syncmeth.html" target="_top"><em class="citetitle">Synchronized Methods</em></a></p>
- <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
- <div class="example"><a name="d6e264"></a><p class="title"><b>Example 1.17. Signature: "V"</b></p><div class="example-contents">
-
- <p>Kamailio prototype</p>
- <pre class="programlisting">java_s_staticmethod_exec("ExampleMethod", "V");</pre>
- <p>Java prototype</p>
- <pre class="programlisting">public static synchronized int ExampleMethod();</pre>
- <p>Example of usage:</p>
- <pre class="programlisting">
- # Kamailio
- java_s_staticmethod_exec("ExampleMethod", "V");
- # Java
- public static synchronized int ExampleMethod()
- {
- ... do something;
- return 1;
- }
- </pre>
- </div></div><br class="example-break">
- </li><li class="listitem">
- <div class="example"><a name="d6e273"></a><p class="title"><b>Example 1.18. Signature: "Ljava/lang/String;I"</b></p><div class="example-contents">
-
- <p>Kamailio prototype</p>
- <pre class="programlisting">java_s_staticmethod_exec("ExampleMethod", "Ljava/lang/String;I", "Hello world", "5");</pre>
- <p>Java prototype</p>
- <pre class="programlisting">public static synchronized int ExampleMethod(String param1, int param2);</pre>
- <p>In the above scenario parameter 2 ("5") will be cast to integer representation.</p>
- <p>Example of usage:</p>
- <pre class="programlisting">
- # Kamailio
- java_s_staticmethod_exec("ExampleMethod", "Ljava/lang/String;I", "$mb", "$ml");
- # Java
- public static synchronized int ExampleMethod(String SipMessageBuffer, int SipMessageLenght)
- {
- ... do something with buffer;
- return 1;
- }
- </pre>
- </div></div><br class="example-break">
- </li><li class="listitem">
- <div class="example"><a name="d6e283"></a><p class="title"><b>Example 1.19. Signature: "ZB"</b></p><div class="example-contents">
-
- <p>Kamailio prototype</p>
- <pre class="programlisting">java_s_staticmethod_exec("ExampleMethod", "ZB", "true", "0x05");</pre>
- <p>Java prototype</p>
- <pre class="programlisting">public static synchronized int ExampleMethod(boolean param1, byte param2);</pre>
- <p>In the above scenario parameter 1 ("true") will be cast to boolean representation.</p>
- <p>Example of usage:</p>
- <pre class="programlisting">
- # Kamailio
- java_s_staticmethod_exec("ExampleMethod", "ZB", "true", "0x05");
- # Java
- public static synchronized int ExampleMethod(boolean flagSet, byte bFlag);
- {
- if (flagSet)
- {
- ... do something with flags;
- }
- return 1;
- }
- </pre>
- </div></div><br class="example-break">
- </li></ul></div>
- </div>
-
- </div>
-
-
-
- <div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d6e292"></a>Java Module API</h2></div></div></div>
-
- <p></p>
-
-
- <div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d6e295"></a>Minimal program skeleton</h3></div></div></div>
-
- <p></p>
- <div class="example"><a name="d6e298"></a><p class="title"><b>Example 1.20. Minimal program skeleton</b></p><div class="example-contents">
-
- <p></p>
- <pre class="programlisting">
- import org.siprouter.*;
- import org.siprouter.NativeInterface.*;
- public class Kamailio extends NativeMethods
- {
- /* Here you should specify a full path to app_java.so */
- static
- {
- System.load("/opt/kamailio/lib/kamailio/modules/app_java.so");
- }
- /* Constructor. Do not remove !!! */
- public Kamailio()
- {
- }
- /*
- This method should be executed for each children process, immediately after forking.
- Required. Do not remove !!!
- */
- public int child_init(int rank)
- {
- return 1;
- }
- }
- </pre>
- </div></div><br class="example-break">
- </div>
-
-
- </div>
-
-
- </div></body></html>
|