发表于: 2017-11-18 23:05:27
0 695
一.今日完成
1.使用tuscany在本地做分布式,分离service和web
(1)SCA Java运行时由core和extension组成。Core本质上来说是一个多VM的wiring引擎。该引擎使用IOC(控制反转)和DI(依赖注入)原则来连接组件。
Core
Core在性能方面是简单而有限的。它将功能单元连接在一起,并提供可以和extension交互的SPI机制。例如象服务发现,可靠性,对传输协议的支持等特性都是通过extension来做的。
Extension
Extension增强SCA运行时的功能。Extesion类型不是固定的。而core则是通过提供对extension模块开放支持来使得设计尽量灵活。
组件实现类型,例如:Spring, Groovy 和Javascript
绑定类型,比如:Axis, CXF ,AMQP ,ActiveMQ, JXTA
数据绑定类型,比如:JAXB, SDO ,XmlBean
接口绑定类型,比如:WSDL, Java
(2)项目结构如下:
serviceX和serviceY中引入的spring依赖和tuscany sca依赖版本分别为3.0.5.RELEASE和2.0.1.为引入tuscany sca,需要在每个service子模块中额外增加两个配置文件
spring-tusacny.xml
<?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:sca="http://www.springframework.org/schema/sca"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/sca
http://www.osoa.org/xmlns/sca/1.0/spring-sca.xsd" >
<sca:service name="StudentServiceX" type="com.jnshu.serviceImpl.StudentService" target="StudentServiceX"/>
<bean id="StudentServiceX" name="StudentServiceX" class="com.jnshu.serviceImpl.StudentServiceimpl"/>
<import resource="springConfig.xml"/>
</beans>
studentserviceX.xml
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="UserService" targetNamespace="http://StudentService">
<component name="StudentComponent">
<implementation.spring location="spring-tuscany.xml"/>
<service name="StudentServiceX" >
<tuscany:binding.rmi uri="rmi://127.0.0.1:9090/StudentSrviceX"/>
</service>
</component>
</composite>
(3)为了方便在本地部署服务,直接写一个测试类,启动rmi端口服务
public class ServiceXtest {
private static Logger logger = LogManager.getLogger(ServiceXtest.class);
public static void main(String[ ] args) throws IOException, NotBoundException {
Node node = NodeFactory.newInstance().createNode("StudentServiceX.composite");
node.start();
logger .info("serviceX启动");
StudentService studentService = (StudentService) Naming.lookup("//127.0.0.1:9090/StudentServiceX");
logger .info("查询所有用户信息");
List<Student> stuList = studentService.getAllStu();
logger .info(stuList);
}
}
(4)运行test#main();时报错,
Exception in thread "main" java.lang.IllegalStateException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'StudentServiceX': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.jnshu.dao.StudentDao com.jnshu.serviceImpl.StudentServiceimpl.studentDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.jnshu.dao.StudentDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
计划明天根据报错信息解决bug,提交任务9.
二.明日计划
1.梳理HTTP相关知识点,准备小课堂
2.调试代码,提交任务9
三.遇到问题
暂无.
四.收获
以上.
进度:今天提交任务9,比原计划延迟两天.
评论