返回下载首页
返回新闻首页
欢迎联系我们
站内搜索:
资讯中心
软件下载
热门下载:
迅雷
腾讯QQ
傲游
暴风
MSN
酷我
最新列表
新闻资讯
软件产业
技巧应用
软件评测
教程中心
电脑安全
游戏娱乐
软件学院
编程开发
硬件导购
手机数码
论坛社区
网站地图
首页
>
新闻系统
>
编程开发
>
网络编程
> 文章正文
SCA中Java接口实现Service
2007-11-15 11:33:19 来源:论坛整理 作者:王洪伟 点击:
1、基于Java 的service 接口和实现组件的Java类
1、基于Java 的service 接口和实现组件的Java类
接口
package services.hello;
public interface HelloService {
String hello(String message);
}
实现
package services.hello;
import org.osoa.sca.annotations.*;
@Service(HelloService.class)
public class HelloServiceImpl implements HelloService {
public String hello(String message) {
...
}
}
对应的Componet Type
<?xml version="1.0" encoding="ASCII"?>
<componentType xmlns=http://www.osoa.org/xmlns/sca/1.0>
<service name="HelloService">
<interface.java interface="services.hello.HelloService"/>
</service>
</componentType>
2、自己定义的service接口并实现的Java 实现类
package services.hello;
import org.osoa.sca.annotations.*;
@Service(HelloServiceImpl.class)
public class HelloServiceImpl implements AnotherInterface {
public String hello(String message) {
...
}
…
}
根据@service注解的默认规则:如果一个service只有一个接口,实现了接口就是实现了service。
所以上面的实现还可以改写,如下:
package services.hello;
public class HelloServiceImpl implements AnotherInterface {
public String hello(String message) {
...
}
…
}
对应的Component Type
<?xml version="1.0" encoding="ASCII"?>
<componentType xmlns=http://www.osoa.org/xmlns/sca/1.0>
<service name="HelloService">
<interface.java interface="services.hello.HelloServiceImpl"/>
</service>
</componentType>
3、一个Java实现类实现两个service
package services.hello;
import org.osoa.sca.annotations.*;
@Service(interfaces={HelloService.class, AnotherInterface.class})
public class HelloServiceImpl implements HelloService, AnotherInterface {
public String hello(String message) {
...
}
…
}
对应的Component Type
<?xml version="1.0" encoding="ASCII"?>
<componentType xmlns=http://www.osoa.org/xmlns/sca/1.0>
<service name="HelloService">
<interface.java interface="services.hello.HelloService"/>
</service>
<service name="AnotherService">
<interface.java interface="services.hello.AnotherService"/>
</service>
</componentType>
4、Java实现类通过接口子类关系实现两个service
service 1
package services.hello;
public interface HelloService {
String hello(String message);
}
service 2
package services.hello;
public interface HelloService2 extends HelloService {}
实现
package services.hello;
import org.osoa.sca.annotations.*;
@Service(interfaces={HelloService.class,HelloService2.class})
public class HelloServiceImpl implements HelloService {
public String hello(String message) {
...
}
}
对应Component Type
<?xml version="1.0" encoding="ASCII"?>
<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
<service name="HelloService">
<interface.java interface="services.hello.HelloService"/>
</service>
<service name="HelloService2">
<interface.java interface="services.hello.HelloService2"/>
</service>
</componentType>
相关文章:
相关软件:
Javascript制作拖动网页布局的方法
javaScript作为外部文件引用时要注意
Everyscape:带你用3D视角看北京城
梦幻桌面DeskScapes 2.0 发布
08十大热门IT职位 Java居首
Service Broker 要点
java diff 及wiki相关基础知识
javascript实现WORD里面的斜线表格
根据传入值采用javascript自动显示标签
C#接口基础知识实例讲解
ServiceKeeper 4.8.43
ServiceMill Control 4.6.42 Build
Service Pack Manager 7.1.1.3
Service+ 4.7.65
ServiceTray 1.0.25
ServiceAgent Pro 3.0 简体中文版
ServiceMill 4.6.42 Build 1400
ServiceKeeper 4.0.25 Beta
ServiceMill 3.7.49 Beta
Services/Drivers Configuration T
评论加载中...
loading...
去论坛给我们提意见
本类最新
┆
行业
┆
评测技巧
┆
教程学院
本类热点
┆
本日
┆
本周
┆
本月
本类推荐
┆
本日
┆
本周
┆
本月