/usr/share/doc/red5/html/new-applications.html is in red5-doc 1.0~svn4374-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter 9. Create new applications in Red5</title><link rel="stylesheet" type="text/css" href="html.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Red5 - Reference Documentation"><link rel="up" href="core-components.html" title="Part II. Red5 Core Components"><link rel="prev" href="core-components.html" title="Part II. Red5 Core Components"><link rel="next" href="logging-setup.html" title="Chapter 10. Logging Setup"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div xmlns="http://www.w3.org/TR/xhtml1/transitional" style="background-color:white;border:none;height:73px;border:1px solid black;"><a style="border:none;" href="http://osflash.org/red5" title="Red5 Open Source Flash Server"><img style="border:none;" src="images/red5-banner.png"></img></a><a style="border:none;" href="http://osflash.org/red5" title="Red5 Open Source Flash Server"><img style="border:none;position:absolute;padding-top:5px;right:42px;" src="images/red5-banner-logo.png"></img></a></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="new-applications"></a>Chapter 9. Create new applications in Red5</h2></div></div></div>
<p>This document describes how new applications can be created in Red5. It applies to the
new API introduced by Red5 0.4. </p>
<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e1482"></a>9.1. The application directory</h2></div></div></div>
<p>Red5 stores all application definitions as folders inside the "webapps" directory beneath the
root of Red5. So the first thing you will have to do in order to create a new application, is to
create a new subfolder in "webapps". By convention this folder should get the same name
the application will be reached later. </p>
<p>Inside your new application, you will need a folder "WEB-INF" containing configuration files
about the classes to use. You can use the templates provided by Red5 in the folder "doc/
templates/myapp". </p>
<p>During the start of Red5, all folders inside "webapps" are searched for a directory "WEB-
INF" containing the configuration files. </p>
</div>
<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e1487"></a>9.2. Configuration</h2></div></div></div>
<p>The main configuration file that is loaded is "web.xml". It contains the following parameters: </p>
<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e1490"></a>9.2.1. webAppRootKey</h3></div></div></div>
<p>Unique name for this application, should be the public name: </p>
<pre class="programlisting">
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>/myapp</param-value>
</context-param>
</pre>
</div>
</div>
<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e1494"></a>9.3. Handler configuration</h2></div></div></div>
<p>Every handler configuration file must contain at least three beans: </p>
<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e1497"></a>9.3.1. Context</h3></div></div></div>
<p>The context bean has the reserved name web.context and is used to map paths to scopes,
lookup services and handlers. The default class for this is org.red5.server.Context. </p>
<p>By default this bean is specified as: </p>
<pre class="programlisting">
<bean id="web.context" class="org.red5.server.Context"
autowire="byType" />
</pre>
<p>Every application can only have one context. However this context can be shared across
multiple scopes. </p>
</div>
<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e1503"></a>9.3.2. Scopes</h3></div></div></div>
<p>Every application needs at least one scope that links the handler to the context and the
server. The scopes can be used to build a tree where clients can connect to every node
and share objects inside this scope (like shared objects or live streams). You can see the
scopes as rooms or instances. </p>
<p>The default scope usually has the name web.scope, but the name can be chosen
arbitrarily. </p>
<p>The bean has the following properties: </p>
<p>- server
This references the global server red5.server.
- parent
References the parent for this scope and usually is global.scope.
- context
The server context for this scope, use the web.context from above.
- handler
The handler for this scope (see below).
- contextPath
The path to use when connecting to this scope.
- virtualHosts
A comma separated list of hostnames or ip addresses this scope runs at. </p>
<p>A sample definition looks like this: </p>
<pre class="programlisting">
<bean id="web.scope" class="org.red5.server.WebScope"
init-method="register">
<property name="server" ref="red5.server" />
<property name="parent" ref="global.scope" />
<property name="context" ref="web.context" />
<property name="handler" ref="web.handler" />
<property name="contextPath" value="/myapp" />
<property name="virtualHosts" value="localhost, 127.0.0.1" />
</bean>
</pre>
<p>You can move the values for contextPath and virtualHosts to a separate properties file and
use parameters. In that case you need another bean: </p>
<pre class="programlisting">
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
Create new applications in Red5
<property name="location" value="/WEB-INF/red5-web.properties" />
</bean>
</pre>
<p>Assuming a red5-web.properties containing the following data: </p>
<div class="literallayout"><p><br>
webapp.contextPath=/myapp <br>
webapp.virtualHosts=localhost, 127.0.0.1 <br>
</p></div>
<p>the properties of the scope can now be changed to: </p>
<pre class="programlisting">
<property name="contextPath" value="${webapp.contextPath}" />
<property name="virtualHosts" value="${webapp.virtualHosts}" />
</pre>
<p>The contextPath specified in the configuration can be seen as "root" path of the scope. </p>
<p>You can add additional elements after the configured path when connecting to dynamically
create extra scopes. </p>
<p>These extra scopes all use the same handler but have their own properties, shared objects
and live streams. </p>
</div>
</div>
<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e1520"></a>9.4. Handlers</h2></div></div></div>
<p>Every context needs a handler that implements the methods called when a client
connects to the scope, leaves it and that contains additional methods that can be
called by the client. The interface these handlers need to implement is specified by
org.red5.server.api.IScopeHandler, however you can implement other interfaces if you
want to control access to shared objects or streams. </p>
<p>A sample implementation that can be used as base class can be found at
org.red5.server.adapter.ApplicationAdapter. Please refer to the javadoc documentation for
further details. </p>
<p>The bean for a scope handler is configured by: </p>
<pre class="programlisting">
<bean id="web.handler"
class="the.path.to.my.Application"
singleton="true" />
</pre>
</div>
<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e1526"></a>9.5. Logging</h2></div></div></div>
<p>
<a class="ulink" href="Documentation/Tutorials/LoggingSetup" target="_top">Logging Setup Tutorial</a>
</p>
</div>
</div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navfooter"><hr></hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="core-components.html">Prev</a> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right"> <a accesskey="n" href="logging-setup.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part II. Red5 Core Components </td><td width="20%" align="center"><span style="color:white;font-size:90%;"><a href="http://osflash.org/red5" title="Red5">Red5 Open Source Flash Server</a></span></td><td width="40%" align="right" valign="top"> Chapter 10. Logging Setup</td></tr></table></div></body></html>
|