`
ahua186186
  • 浏览: 554814 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

GAEA-58服务端初始化生成的服务“动态代理类”和“代理工厂类”

 
阅读更多
以服务实现类NewsService为例:


思考:不明白作者为什么要这样生成服务代理类,根据服务名用反射获取服务实例不行吗?性能貌似也不低啊。 还是说为了热部署才这么做的,我能想到的只有这么个需求才会这么做。



ProxyFactoryCreater类动态生成的代码:


//动态代理工厂类

public class  ProxyFactory1439795760927 implements IProxyFactory{

	private IProxyStub proxyNewsServicedemo =null;
	private IProxyStub demo1 =null;
	private IProxyStub demo2 =null;
	
	public void IProxyFactory(java.util.List $1);
	{	
		proxyNewsServicedemo=(com.bj58.spat.gaea.server.contract.context.IProxyStub)$1.get(0);
		demo1=(com.bj58.spat.gaea.server.contract.context.IProxyStub)$1.get(1);
		demo2=(com.bj58.spat.gaea.server.contract.context.IProxyStub)$1.get(2);
	}
	
	//动态生成代理工程的getProxy方法
	public IProxyStub getProxy(String lookup) {
	
		if(lookup.equalsIgnoreCase("NewsService"))
			{
				return proxyNewsServicedemo;
			}
			
			if(..){
				..
			}
			if(..){
				..
			}
			if(..){
				..
			}
			return null;
		}
	}

}






ProxyClassCreater类动态生成的代码:




//动态代理类
						
						
public class NewsServiceProxyStub1439795944146{			
	/******************服务实现类对象start*************************/
	private static INewsService serviceProxy = new NewsService();
	
	/******************服务实现类对象end*************************/
	
	/**********************具体的服务调用start********************************************/
	public GaeaResponse getNewsByID(GaeaContext context) ServiceFrameException 
	{
		IConvert convert = ConvertFacotry.getConvert(context.getGaeaRequest().getProtocol());
		RequestProtocol request = (RequestProtocol)context.getGaeaRequest().getProtocol().getSdpEntity();
		java.util.List listKV = request.getParaKVList();
		if(listKV.size() == 1 && (((KeyValuePair)listKV.get(0)).getKey().toString().equalsIgnoreCase("int")|| ((KeyValuePair)listKV.get(0)).getKey().toString().equalsIgnoreCase("Integer")))
		
		{
						
						java.util.List listOutPara = new java.util.ArrayList();
						int arg0 = 0;
						try {
							arg0 = convert.convertToint(((KeyValuePair)listKV.get(0)).getValue());
						} 
						catch (Exception e) 
						{
						throw new ServiceFrameException("method:NewsServiceProxyStub1439546304065.getNewsByID--msg:parse gaeaRequest error", 
							context.getChannel().getRemoteIP(), 
							context.getChannel().getLocalIP(), 
							context.getGaeaRequest().getProtocol().getSdpEntity(), 
							com.bj58.spat.gaea.server.util.ErrorState.ParaException, e);
						
						}
						
						
						try {
							entity.News returnValue = serviceProxy.getNewsByID(arg0);
							return new com.bj58.spat.gaea.server.contract.context.GaeaResponse(returnValue, listOutPara);
						} 
						catch (Exception e) {
							throw new ServiceFrameException("method:NewsServiceProxyStub1439546304065.getNewsByID--msg:invoke real service error", 
							context.getChannel().getRemoteIP(), 
							context.getChannel().getLocalIP(),
							context.getGaeaRequest().getProtocol().getSdpEntity(),
							com.bj58.spat.gaea.server.util.ErrorState.ServiceException, e);
						  }
		}
		 
		throw newServiceFrameException("method:NewsServiceProxyStub1439546304065.getNewsByID--msg:not fond method error", 
	 	context.getChannel().getRemoteIP(),
	  context.getChannel().getLocalIP(), 
	  context.getGaeaRequest().getProtocol().getSdpEntity(), 
	  com.bj58.spat.gaea.server.util.ErrorState.NotFoundMethodException, null);
		  
	}
		//............省去多个服务

		/**********************具体的服务调用end ********************************************/
	public GaeaResponse invoke(GaeaContext context) throws ServiceFrameException 
	{
		String methodName = ((RequestProtocol)context.getGaeaRequest().getProtocol().getSdpEntity()).getMethodName();
		if(methodName.equalsIgnoreCase("getNewsByID"))
		{
			return getNewsByID(context);
		}
		if(methodName.equalsIgnoreCase("getNewsByCateID"))
		{
			return getNewsByCateID(context);
		}
		
		if(..){
			..
		}
		if(..){
			..
		}
		if(..){
			..
		}
		if(..){
			..
		}
		
		throw new ServiceFrameException("method:NewsServiceProxyStub1439547291816.invoke--msg:not found method ("+methodName+")", 
		context.getChannel().getRemoteIP(), 
		context.getChannel().getLocalIP(),
		context.getGaeaRequest().getProtocol().getSdpEntity(),
		com.bj58.spat.gaea.server.util.ErrorState.NotFoundMethodException, null);
	
	}

}
分享到:
评论

相关推荐

    PyPI 官网下载 | gaea-0.1.15.tar.gz

    资源来自pypi官网。 资源全名:gaea-0.1.15.tar.gz

    Gaea 服务通讯框架

    Gaea是服务通讯框架(Service Communication Framework)支持跨平台具有高并发、高性能、高可靠性,并提供异步、多协议、事件驱动的中间层服务框架。

    Python库 | gaea-1.6.6.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:gaea-1.6.6.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Gaea - Object Database Viewer-开源

    Gaea允许您使用JDO标准查看/修改对象数据库。 动态执行实例和类结构。 一个几乎完整的OQL库嵌入在项目中,可以轻松地被第三方软件用来实现OQL兼容性

    Python库 | gaea-0.1.22.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:gaea-0.1.22.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    gaea:自动生成工具,基于md数据字典生成SQL语句,后台管理系统页面等

    生成api项目gaea [项目类型] create -n apiserver //创建基础的 api 项目➜ gaea api create -n ./apiserver//创建带登录和菜单组件的api项目(常用)➜ gaea api create -login " http://192.168.5.93:6688|B128F...

    gaea 和JDBC z整合

    gaea 和JDBC 整合

    Gaea:Gaea是一个mysql代理,由小米b2c-dev团队开发

    简介Gaea是小米中国区电商研发部研发的基于MySQL协议的数据库中间件,目前在小米商城大陆和海外得到广泛使用,包括订单,社区,活动等多项业务。Gaea支持分库分表,sql路由,读写分离等基本特性,更多详细功能可以...

    GAEA词库释义.zip

    此文件中包含有GAEA软件各个功能的释义,有助于你更好、更方便、更快捷地学习并掌握GAEA软件各个功能点。

    灰度图生成地形导出obj模型

    直接raw格式灰度图生成地形,先创建地形,属性设置栏,导入灰度图,Terrain-Export To Obj ,选择保存位置即可导出,灰度图片png加贴图创建地形,导出obj格式,运行状态下点击界面按钮等待即可保存

    服务通讯框架Gaea.zip

    Gaea是服务通讯框架(Service Communication Framework)支持跨平台具有高并发、高性能、高可靠性,并提供异步、多协议、事件驱动的中间层服务框架。 标签:Gaea

    Gaea决策引擎产品白皮书_专家系统_

    它能将业务决策逻辑从系统逻辑中抽离出来,使两种逻辑可以独立于彼此而变化,使非技术业务人员能直接参与到业务规则管理工作中,使受限于复杂多变且不断发展的业务规则的应用程序和流程实现灵活的决策自动化。...

    proxy与mycat对比测试

    该压缩包中包含了测试proxy和mycat对mysql主从的方法,测试环境的搭建步骤和测试对比结果

    gaea:Gaea是一个基于Gin的Web框架,参考gin https

    文档安装安装脚手架通过脚手架可一键创建Gaea模板的api项目生成框架此处以“ myproject”为项目名称$ rigger new api myproject正克隆到 ' /winshare/go/src/myproject ' ...myprojec项目已创建完成, 使用: cd /...

    gaea

    华盛顿大学基础学院

    anji-plus-AJ-Captcha-Images-master.zip

    滑动验证码,Java后端。。可以在vue使用,iOS,安卓,小程序使用。后端使用Java编写。maven工程,下载就可以使用

    gaeaplus:Gaea +是基于NASA World Wind的开源虚拟地球仪

    它由的Gaea +团队提供,该是该地区发展最快的ICT公司之一,在领导和执行软件项目方面拥有丰富的经验。 该项目扩展了World Wind Java核心,具有对地理空间信息的高级实时渲染至关重要的功能,包括优化的Render-to-...

    template-spring-boot-gae:Google App Engine 上 Spring Boot 的引导程序模板

    App Engine 服务 Bean @Autowired MemcacheService memcache; @Autowired Queue defaultQueue; 抛出异常时的 JSON 响应 { " code " : 500 , " message " : " Something happen! " , " url " : " ...

    spring-boot-gae-blank:Maven原型为Spring Boot Application创建一个GAE配置的maven项目

    Sprint BootGAE空白 Maven原型为Spring Boot Application创建一个GAE配置的maven项目 请注意,该项目并未针对GAE进行优化。 如何使用 与重击 mvn archetype:generate\ -DarchetypeGroupId=am.ik.archetype\ ...

    PHP框架Gaeaphp.zip

    |  |  |  |-libs/ 工具类库|  |  |  |-model/ 模型类库项目开发技巧Core文件Core::config($file,[$key,[$dafault = false,[$reload = false]]]) 获取配置文件Core::load_func($func,[$path= '']) 加载函数Core...

Global site tag (gtag.js) - Google Analytics