red5中使用remoteObject

red5 0.6.3中echo目录中有remoteObject的配置,copy过来,改下就行了,根据别人那个http://tj007-bo.iteye.com/blog/312425,和http://www.iteye.com/post/402053

package com;

import org.red5.server.adapter.ApplicationAdapter;

public class Hello extends ApplicationAdapter {
	public String echo(String name){
		System.out.println("diaoyong");
		return name+name;
	}
}

  red5-web.xml中

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
	
	<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
	    <property name="location" value="/WEB-INF/red5-web.properties" />
	</bean>
	
	<bean id="web.context" class="org.red5.server.Context" 
		autowire="byType" />
	
	<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="${webapp.contextPath}" />
		<property name="virtualHosts" value="${webapp.virtualHosts}" />
	</bean>

	<bean id="web.handler" 
	    class="com.Hello" 
		singleton="true"/>
	

	<!-- enable support for mx:RemoteObject requests -->
	<bean id="flexMessaging.service" 
	    class="org.red5.server.net.remoting.FlexMessagingService" 
		singleton="true">
		<property name="serviceInvoker" ref="global.serviceInvoker" />
		<!-- add an entry for all possible "destination" attributes of your
			 mx:RemoteObject sources -->
		<property name="endpoints">
			<map>
				<entry key="Red5Echo">
					<!-- object that handles requests sent to this endpoint -->
					<ref bean="web.handler" />
				</entry>
			</map>
		</property>
	</bean>
    

</beans>

 

 client调用

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="echo()">
	<mx:RemoteObject id="echoService"
		destination="Red5Echo"
		endpoint="http://localhost:5080/red5Remote/gateway"
		showBusyCursor="true">
		<mx:method name="echo"/>
	</mx:RemoteObject>
	<mx:Script>
		<![CDATA[
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;
			private function echo(){
				echoService.addEventListener(FaultEvent.FAULT,fault);
				echoService.addEventListener(ResultEvent.RESULT,result);
				echoService.echo("name");
			}
			private function fault(e:FaultEvent){
				trace(e.message);
			}
			private function result(e:ResultEvent){
				trace(e.result.toString());
			}
			
		]]>
	</mx:Script>
</mx:Application>

 都写了吧 red5-web.properties,log4j.properties什么也不写

webapp.contextPath=/red5Remote
webapp.virtualHosts=localhost, 127.0.0.1,localhost:5080

 上传我的和cairgorom调用remoteObject

你可能感兴趣的:(spring,bean,Web,log4j,xml)