Hi All,
With the help of example giving at the link http://asterisk-java.org/development/faq.html (example of using an AGI server in a container like JBoss), I have created web application which contains of servlet and java class which implements BaseAgiScript.
I have run the web application , it works fine (AGI server starting at port 4573) when i deploy the war file of the web application at jboss server , but when i undeploy the war file , the AGI server will not be shutdown and the AGI server port 4573 will remain open.
Any way to help me to fix this issue ?
TestServlet.java
[code]/**
*
*/
package com.asterisk.example;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.asteriskjava.fastagi.AgiServer;
import org.asteriskjava.fastagi.DefaultAgiServer;
/**
*/
public class TestServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
final TestAgi service = new TestAgi();
DefaultAgiServer AGIserver = new DefaultAgiServer(service);
/**
* @see HttpServlet#HttpServlet()
*/
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
public void init() throws ServletException {
System.out.println("Starting the Agi Server at port : "+AGIserver.getPort());
try {
AGIserver.startup();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void destroy() {
System.out.println("Stopping the Agi Server.........");
AGIserver.shutdown();
super.destroy();
}
}[/code]
TestAgi.java
[code]package com.asterisk.example;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import org.asteriskjava.fastagi.AgiChannel;
import org.asteriskjava.fastagi.AgiException;
import org.asteriskjava.fastagi.AgiRequest;
import org.asteriskjava.fastagi.BaseAgiScript;
public class TestAgi extends BaseAgiScript {
public void service(AgiRequest request, AgiChannel chanel)
throws AgiException {
// This is my AGI service implementation
answer();
sayDigits("1234");
streamFile("vm-press");
sayDateTime(1311493265);
// ...and hangup.
hangup();
}
}[/code]