Donnerstag, 31. Januar 2008

Create a SIP Application for Sailfin (Part 1 Database)

I will go step by step through creating a simple SIP application using the NetBeans IDE for the Sailfin Sip application server. In part 1 we will setup the user database where the Sip users will register themselves.

Prerequisites
  1. get the NetBeans IDE from http://www.netbeans.org/community/releases/60/index.html and the NetBeans Sip application development from https://sailfin.dev.java.net/servlets/ProjectDocumentList (in the appdevnb section).
  2. follow the installation instructions in http://blogs.sun.com/nb_sip_sailfin_installation/resource/nb_sip_sailfin_installation.html
  3. The sources are available in cvs using
    cvs -d:pserver:[your java.net account]@cvs.dev.java.net:/cvs co sailfin/sailfin-tests and then can be found then in community/samples/b2bua, or send an email to
    peter.c.klein@siemens.com to get them.

Preparing the database:

  1. Open the database settings in NetBeans with "Tools->Java DB Database->Settings" and select your Java DB installation (normally in sailfin/javadb) and the database location (normally in sailfin/databases).
  2. Start the DB server with "Tools->Java DB Database->Start Server".
  3. Create a new database with "Tools->Java DB Database->Create Database", then enter the database name (b2bua), the username (APP) and password (APP).
  4. You can then connect to the database from the Servers tab. Click on the database connection, right click and then Connect.

The application itself is a simple Sip back-to-back user agent which allows to build up a communication between two Sip phones and acts as a Registrar which handles the registration of the Sip users.


Creating the Data Storage

  1. Create a new project with "File->New Project" and choose Sip and Converged Servlet Application as project type. The project name of our sample is b2bua.
  2. In the project view select Source Packages, right click and choose "New->Sip Servlet", enter RegisterSipServlet as class name and b2bua.sip as package name.
  3. In the project view select Source Packages, right click and choose "New->Entity Class", enter UserData as class name and b2bua.model as package name. In the same dialog box click on "Create Persistence Unit".
  4. Choose "New Data Source" and in the next dialog box set jdbc/b2bua as JNDI name and select the prevously created database connection to b2bua.
  5. Look at the downloaded source code for UserData.java. You will see that the attribute sipURI and its getter and setter methods were added. In sipURI the URI of the registered user is stored.

Deployment of Part 1

  1. Open the projects properties, go to the "Run" page, select Java System Application Server as server and uncheck the "Display Browser on Run" checkbox.
  2. Select "Run->Run Main Project" to deploy the application. Depending on the sailfin version you are using there might be some warnings during deployment. Important is the output line "Enable of b2bua in target server completed successfully".
  3. Check the deployment on the sailfin admin console. Point your browser to http://localhost:4848/ and check "Applications->Sip->Converged Sip Modules" entries. b2bua should be visible as deployed.
  4. Connect to the database, open the USERDATA table, right click and select "View Data". The table should be empty. Add data by entering "insert into USERDATA values ('Bob@test.com', ''); in the SQL window, right click and select "Run Statement".
  5. You can also another SQl client, e.q Squirrel (download from http://squirrel-sql.sourceforge.net/, good instructions can be found in http://db.apache.org/derby/integrate/SQuirreL_Derby.html). Squirrel allows to directly modify the database without using SQL statements

Kommentare:

Eric hat gesagt…

Hi peter, and thanks for your nice tutorial. I'm in trouble at Deployment of Part 1 - Step 4. : there is no USERDATA table in my database. Do I need to create table manually ? I checked your tutorial from the start to the end, but I can't find the solution even if everything is good : I have a persistence unit pointing to my b2bua DB and the Sailfin's admin page returns me my apps is deployed.

jonbaraq hat gesagt…

Hi Peter,

I have the same problem as eric. Could you help us?

Eric hat gesagt…

Solved by forcing the use of JDK/JRE 1.5, in place of 1.6.

Venkata Krishna hat gesagt…

In the deployment of part 1 in step 4
you said connect to the database. I connected to the database but i don't know how to where i can i see the UserData table