发表于: 2020-01-09 20:08:09
1 1068
今天做了什么
写dal的demo:
在video_dao.xml中编写sql语句
<object name="com.jnshu.model.Video"
listenerClass="" strategyProperty="">
<list name="getVideoTitleById"
sqlitem="select id from video where status=? order by update_at desc"
keyProperty="status" valueProperty="id" keyColumn="status"/>
</object>
在application.xml中加入sca和bean
<sca:service name="videoService"
type="com.jnshu.service.VideoService"
target="videoService"/>
<bean id="videoService"
parent="baseDaoService">
</bean>
<bean id="dao" <bean id="baseDaoService"
<property name="dao" ref="dao"/>
</bean>
core中加入service
@Remotable
public interface VideoService extends BaseDaoService {
public List<Video> gertVideoListByIds(List<Long> ids) throws ServiceException,ServiceDaoException;
public boolean delete(Long id) throws ServiceException, ServiceDaoException;
public boolean insert() throws ServiceException,ServiceDaoException;
public boolean update() throws ServiceException,ServiceDaoException;
public Video getVideoById() throws ServiceException,ServiceDaoException;
}
然后加入Tuscany框架的client,继承封装的BaseDaoService
@Remotable
public interface VideoService extends BaseDaoService {
public List<Video> gertVideoListByIds(List<Long> ids) throws ServiceException,ServiceDaoException;
public boolean delete(Long id) throws ServiceException, ServiceDaoException;
public boolean insert() throws ServiceException,ServiceDaoException;
public boolean update() throws ServiceException,ServiceDaoException;
public Video getVideoById() throws ServiceException,ServiceDaoException;
}
server中引入自定义的core包
实现类写在sever中
添加server.properties配置文件
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
xmlns:scallop="http://scallop/xmlns/sca/1.0" xmlns:aop="http://www.springframework.org/schema/aop"
targetNamespace="http://FansAdminComponent" xmlns:sample="http://FansAdminComponent"
name="FansAdminComponent">
<component name="DalAdminService">
<implementation.spring location="META-INF/applicationContext-server.xml"/>
</component>
<service name="videoService" promote="DalAdminService/VideoService">
<interface.java interface="com.jnshu.service.VideoService"/>
<scallop:binding.rmi host="localhost" port="11551" serviceName="VideoRMIService"/>
</service>
</composite>
最后添加公司内部注册中心Scallop
scallop.registry.center = http://scallop.resource.center:8102
scallop.performace.rmi.processTimeThreshold=200
scallop.performace.rmi.showParameters=false
scallop.performace.rmi.executeTimesPrintInterval=600
controller中直接调用服务
收获
问题
明天的计划
评论