<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       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">

	<!-- This file just wires together the context tree. Its accessed by ContextSingletonBeanFactoryLocator -->

	<!-- First we load the common context, its shared between all the other contexts -->
	<!-- Global context serves are the parent to all child contexts. -->
	<bean id="red5.common"
  	    class="org.springframework.context.support.FileSystemXmlApplicationContext">
    	<constructor-arg><list><value>classpath:/red5-common.xml</value></list></constructor-arg>
	</bean>
	
	<!-- Then we load the core context, with the common as parent --> 
	<!-- Context holding all the networking, users should need to edit. -->
	<bean id="red5.core"
  	    class="org.springframework.context.support.FileSystemXmlApplicationContext">
    	<constructor-arg><list><value>classpath:/red5-core.xml</value></list></constructor-arg>
    	<constructor-arg><ref bean="red5.common" /></constructor-arg>
	</bean>

	<!-- Then we load the global contexts, note its important this happens before jetty loads -->
	<bean id="context.loader" 
		class="org.red5.server.ContextLoader"
		init-method="init">
		<property name="parentContext" ref="red5.common" />
		<property name="contextsConfig" value="red5.globals" />
	</bean>	
	
	<!-- Now we can load the servlet engine, this has to happen after the context are loaded -->
	<!-- bean id="jetty6.server" class="org.red5.server.JettyLoader" init-method="init" autowire="byType" / -->

	<bean id="tomcat.server" class="org.red5.server.TomcatLoader" init-method="init" destroy-method="shutdown" autowire="byType">
	    <!-- Use this to configure Tomcat via Spring -->
	    <property name="embedded">
	    	<bean class="org.apache.catalina.startup.Embedded" />
	    </property>

	    <!-- You should set jvmRoute to support load-balancing via AJP ie : - - >
	    <property name="engine.standalone">
			<bean class="org.apache.catalina.core.StandardEngine">
		        <property name="defaultHost" value="localhost" />
		        <property name="jvmRoute" value="jvm1" />
			</bean>	   
	    </property>		
	    --> 
	  
	    <!-- Top level container in our container hierarchy -->
	    <property name="engine">
			<bean class="org.apache.catalina.core.StandardEngine">
		        <property name="name" value="red5Engine" />
		        <property name="defaultHost" value="localhost" />
			</bean>	  
	    </property>
	    
	    <!-- This Realm uses the UserDatabase configured in the global JNDI
	        resources under the key "UserDatabase". Any edits that are performed
	        against this UserDatabase are immediately available for use by the Realm. - - > 
	    <property name="realm">
		    <bean class="org.apache.catalina.realm.UserDatabaseRealm">
		        <property name="resourceName">
		            <bean id="UserDatabase" class="org.apache.catalina.UserDatabase">
		                <property name="auth" value="Container" />
		                <property name="factory" value="org.apache.catalina.users.MemoryUserDatabaseFactory" />
		                <property name="pathname" value="conf/tomcat-users.xml" />             
		            </bean>
		        </property>
		    </bean>            
		</property>
		-->
	    
	    <!-- Comment out the old realm but leave here for now in case we
	       need to go back quickly -->
	    <property name="realm">
	    	<bean class="org.apache.catalina.realm.MemoryRealm" />
		</property>
			      
	    <!-- Replace the above Realm with one of the following to get a Realm
	       stored in a database and accessed via JDBC - - >
	    <property name="realm">   
		    <bean class="org.apache.catalina.realm.JDBCRealm">
		        <property name="driverName">
		            <bean id="UserDatabase" class="org.gjt.mm.mysql.Driver">
		                <property name="connectionURL" value="jdbc:mysql://localhost/authority" />
		                <property name="connectionName" value="test" />
		                <property name="connectionPassword" value="test" />
		                <property name="userTable" value="users" />
		                <property name="userNameCol" value="user_name" />
		                <property name="userCredCol" value="user_pass" />             
		                <property name="userRoleTable" value="user_roles" />             
		                <property name="roleNameCol" value="role_name" />             
					</bean>
		        </property>
		    </bean>  
	    </property>
	    -->      
	      
		<!-- Non-SSL HTTP/1.1 Connector -->
	    <property name="connector">
			<bean class="org.apache.catalina.connector.Connector">
		        <property name="port"><value>5080</value></property>
		        <property name="redirectPort"><value>8443</value></property>
		        <property name="enableLookups"><value>false</value></property>
		        <!-- 
		        <property name="scheme"><value>http</value></property>
		        <property name="secure" value="false" />
		        <property name="proxyName" value="??" />
		        <property name="proxyPort" value="8090" />
		        <property name="maxPostSize" value="2048" />
		        <property name="maxSavePostSize" value="4" />
 				-->
			</bean>
	    </property>
	    	
	    <!-- SSL HTTP/1.1 Connector - - >
	    <property name="connector.https">
			<bean class="org.apache.catalina.connector.Connector">
		        <property name="port"><value>8443</value></property>
		        <property name="scheme"><value>https</value></property>
		        <property name="secure"><value>true</value></property>
		        <property name="clientAuth"><value>false</value></property>
		        <property name="sslProtocol"><value>TLS</value></property>
			</bean>	  
	    </property>		  
		-->
	
	    <!-- An AJP 1.3 Connector - - >
	    <property name="connector.ajp">
			<bean class="org.apache.coyote.tomcat5.CoyoteConnector">
		        <property name="port"><value>8009</value></property>
		        <property name="protocol"><value>AJP/1.3</value></property>
		        <property name="protocolHandlerClassName">
		            <bean class="org.apache.jk.server.JkCoyoteHandler" />
		        </property>
			</bean>	   
	    </property>
	    -->

        <property name="baseHost">
	       <bean class="org.apache.catalina.core.StandardHost">
	           <property name="name" value="localhost" />
	           <property name="unpackWARs" value="true" />
	           <property name="autoDeploy" value="true" />
	           <property name="xmlValidation" value="false" />
	           <property name="xmlNamespaceAware" value="false" />
	       </bean>	   
	    </property>		

		<property name="valves">
      		<list>
      			<!-- 
	    		<bean id="valve.access" class="org.apache.catalina.valves.AccessLogValve">
	                <property name="directory" value="." />
	                <property name="prefix" value="localhost_access." />
	                <property name="suffix" value=".log" />
	                <property name="pattern" value="common" />
	                <property name="resolveHosts" value="false" />
	                <property name="rotatable" value="true" />
	        	</bean>
	    		<bean id="valve.extended" class="org.apache.catalina.valves.ExtendedAccessLogValve">
	                <property name="directory" value="." />
	                <property name="prefix" value="localhost_ext." />
	                <property name="suffix" value=".log" />
	                <property name="pattern" value="common" />
	                <property name="rotatable" value="true" />
	                <property name="fileDateFormat" value="[MM/dd/yyyy HH:mm:ss:SSS zz]" />
	        	</bean>
	    		<bean id="valve.reqs" class="org.apache.catalina.valves.RequestDumperValve" />
 				-->
        	</list>
        </property>
	    
        <property name="contexts">
		    <map>
		      <entry>
		        <key><value></value></key>
		        <value>/root</value>
		      </entry>
		      <entry>
		        <key><value>oflaDemo</value></key>
		        <value>/oflaDemo</value>
		      </entry>
		      <entry>
		        <key><value>SOSample</value></key>
		        <value>/SOSample</value>
		      </entry>		      
		    </map>
  		</property>

	</bean>     	
	
	<!-- Default context. This can be shared between web app contexts -->
	<!--
	<bean id="default.context"
  	    class="org.springframework.context.support.FileSystemXmlApplicationContext">
    	<constructor-arg><value>/webapps/red5-default.xml</value></constructor-arg>
    	<constructor-arg><ref bean="red5.common" /></constructor-arg>
	</bean>
	-->
	<!-- You can add further contexts here. This allows for multiple separate global scopes --> 	
	
</beans>
