项目要求集成SCA(Tuscany),还要结合Spring使用(把Spring容器管理的ServiceBean公开为SCA服务),问题是SCA有自己独立的容器,直接访问Spring容器内部的Beans比较困难,因为它们不在同一容器内。所以简单研究了下代码,改一下Tuscany源码,直接访问Spring容器中的Beans,这样的话 事务包装 也可以直接通过Spring解决了
图:
修改的源码片段:
org.apache.tuscany.sca.implementation.spring.runtime.context
...
public SpringContextTie(SpringImplementationStub implementation, List<URL> resource, boolean annotationSupport, String versionSupported) throws Exception {
...
// edit by fengjc
// springContext = createApplicationContext(scaParentContext, resource);
springContext = (AbstractApplicationContext) org.springframework.web.context.ContextLoader.getCtx();
// end
}
或许改源码不是好的解决方式,但是项目需求就这样,没办法,暂时找不到更好的解决办法
另外,在Tuscany中取得ApplicationContext的代码:
org.springframework.web.context.ContextLoader.getCtx();
也是修改了Spring的ContextLoader.java的代码
getCtx()返回ApplicationContext的引用,罪过,这块不是我改的,我实在觉得改源码不好
补充:修改org.apache.tuscany.sca.implementation.spring.invocation.SpringInvoker
中的如下代码可以生成class文件(只适合JDK Proxy的情况),使用反编译软件查看Spring生成的代理类
// Lazy-load the method to avoid timing problems with the Spring Context
private void setupMethod() throws SpringInvocationException{
try {
bean = springContext.getBean(beanElement.getId());
// add by fengjc for test
{
byte[] proxyClassFile = sun.misc.ProxyGenerator.generateProxyClass(
bean.getClass().getName(),
bean.getClass().getInterfaces());
System.out.println(bean.getClass().getName());
try {
FileOutputStream fos = new FileOutputStream(new File(bean.getClass().getName() + ".class"));
fos.write(proxyClassFile, 0, proxyClassFile.length);
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
// end
Class<?> beanClass = bean.getClass();
如果Spring是使用CGLIB生成的代理类,请参考CGLIB源码,net.sf.cglib.core.AbstractClassGenerator类中的如下代码:
byte[] b = strategy.generate(this);
- 大小: 103.9 KB
分享到:
相关推荐
apache-tuscany-sca-1.6.zip
Tuscany SCA与Spring、Hibernate整合实例-简洁方法。为了控制大小,把项目lib中的jar都删了...
NULL 博文链接:https://hnzhoujunmei.iteye.com/blog/1410089
Addison.Wesley.Understanding.SCA.Service.Component.Architecture.Jun.2009.rar
利用连续凸逼近(SCA)优化D2D对和CU用户的功率,使得D2D对的速率和最大,同时满足CU的速率要求
SCA服务构件架构Spring构件实现规范,SOA规范
开源SCA项目调研.pdf
是tuscany与spring,axis整合所有的jar包,已解决冲突问题。
Apache Tuscany SCA 用户指南
soa sca服务构件架构spring构件实现方案
变频器说明书大全系列-SCA-05.rar
Tuscany SCA in Action
apache-tuscany-sca-1.6.2 包括源码实例
SCA100T系列是基于3D-MEMS的高精度双轴倾角传感器芯片,它提供了水平测量仪表级别的性能。双轴高精度倾角传感器芯片的传感元件在测量时需要与测量平台保持平行,并且传感器双轴需相互垂直。
该规则是fortify2020最新规则更新,可以添加到fortify中进行代码静态扫描,进行代码漏洞bug静态分析,提醒开发人员进行漏洞修复
使用Spring Framework 设计和开发 SCA 组件,第 1 部分.pdf.pdf 使用Spring Framework 设计和开发 SCA 组件,第 1 部分.pdf.pdf
soa apache-TUSCANY 源码 SCA目前实现的框架
软件路由系统中SCA的实施,邓红,,SCA(Service Component Architecture)是一种面向服务组件的架构,核心是服务及其相关实现,其具有跨平台、跨语言、松散耦合的特性。软件路
应用于岩石物理模型中的函数计算,可适用于各向同性和各向异性