Introduction:
In this tutorial, we will just have a simple look in How to create Applications for containers… This tutorial explains How to compile the RED5 source into WAR and insert your own code to make the application flexible for the development in J2EE web servers .
Pre-requisites:
Following are the prerequisites for our mission(!) to be accomplished…
1. JDK 1.5
2. Apache Ant
3. The Web Archive source from RED5 ..
The JDK can be downloaded http://java.sun.com/j2se/1.5.0/download.html Apache Ant version 1.6.2 can be downloaded (http://archive.apache.org/dist/ant/binaries/ . The Red source can be downloaded from http://svn1.cvsdude.com/osflash/red5/java/war/trunk/... You may need eclipse to download the entire content
Getting the War source from eclipse:
Open the eclipse , Select Fileà Import à Other à Checkout Projects from SVN à Create a new Repository Location à URL http://svn1.cvsdude.com/osflash/red5/java/war/ à Select Cancel (As we are going to build using ANT)
Now Window à Open Perspective à Other à SVN Repository Exploring
A perspective window is opened with content http://svn1.cvsdude.com/osflash/red5/java/war/
Expand the branch you will see three child nodes 1. branches 2.tags 3. trunk

Right click on Node trunk & select Export
Select a directory , where do you need to keep the source….After the progress is over , switch to next step…
Building a web context (Virtual directory):
Open the source directory on your local computer {src dir } à trunk à www à WEB-INF .. Now we are going to create a scope , I am going to name it samplescope , open a text editor and type the below content..
| version="1.0" encoding="UTF-8"?> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:lang="http://www.springframework.org/schema/lang" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd"> init-method="register"> value="*,localhost, localhost:5080, 127.0.0.1:5080" /> |
Save this content in a file … “samplescope-context.xml” under WEB-INF folder .. The first bean is to define the context, next bean is to define the scope of the context, and the third denotes the handler for the context
Starting a simple Application:
We are going to create the Handler(application) now…
Goto {src-dir} à trunk à src à { create the src files here}
As we have mentioned my.first.Application
Create directories my à first under src..
Create a java file named Application.java and place it under
{src-dir} à trunk à src à myà first à Application.java
| package my.first; import org.red5.server.adapter.ApplicationAdapter; public class Application extends ApplicationAdapter { public String getmyName(){ return “I don’t Know”; } public String Congratulate(String b){ return "Alka " + b; } //Add as many functions as you need….. } |
Building the source:
Make sure Path variables are pointing to the bin directories of Jdk & ANT installations.. Now open build.xml (present in {src-dir} à trunk à build.xml..
Create a property tag
and insert under
save build.xml
In command prompt either in win or linux
Goto the directory…
{src-dir} à trunk
enter ant and hit the enter key
don’t worry abt minor warnings , verify at last red5.war is finished….
If yes…then fine… if not send a mail to red5 …
The war file will be present in {src-dir} à trunk à red5.war
Deploying WAR file in Tomcat..:
Open the Tomcat manager… usually will be
http://localhost:8080/manager/html
it will prompts for admin username & password , provide it….
And now under a table “ WAR file to upload “ upload the newly build war file…
…That’s it , Our WAR file has been deployed in Tomcat usually deployed with the name of the WAR file….
So it can be accessed via http://localhost:8080/red5
If you have problem in accessing tomcat manager ..
Download the Administration Web Application: of tomcat from http://tomcat.apache.org/download-55.cgi it is usually a zip copy consists of two folders ..
conf & server..
Stop your Tomcat service and replace the two folders in your Tomcat installation directory.. and start service again… and try to deploy the WAR file..
Simple client :
Open flash IDE , use the below code to invoke the functions
| nc = new NetConnection(); nc.connect("rtmp://localhost/samplescope"); nc.onStatus = function(info) { trace("Level: " + info.level + " Code: " + info.code ); } nc.onResult = function(obj) { trace("The result is " + obj); } nc.call("Congratulate", nc, “ Me”); |
The result will be “ Congratulate Me”
No comments:
Post a Comment