写法一:
多个服务的请求参数JavaBean和返回响应javaBean有共同的抽象类。可以采用泛型的方式。
代码写法如下:
INotifyReq、INotifyRes为抽象类
NotifyAccept、NotifyAcceptRes为抽象类的具体实现类
public
interface
ICapitalCustodyFrontEndNotifyCallbackService<T
extends
INotifyReq,K
extends
INotifyRes> {
K notifyHander(T
notifyReq)
throws
ServiceException;
}
public
interface
CapitalCustodyFrontEndNotifyCallbackServiceImpl<NotifyAccept, NotifyAcceptRes>
extends
ICapitalCustodyFrontEndNotifyCallbackService<INotifyReq, INotifyRes>{
NotifyAcceptRes notifyHander(NotifyAccept
notifyReq)
throws
ServiceException;
}
dubbo中暴露服务为CapitalCustodyFrontEndNotifyCallbackServiceImpl。抽象的服务ICapitalCustodyFrontEndNotifyCallbackService不暴露出去。
写法二:
public
interface
ICapitalCustodyFrontEndNotifyCallbackService{
<T
extends
INotifyRes> T notifyHander(INotifyReq
notifyReq,Class<T>
t)
throws
ServiceException;
}