I have developed a generic business service using spring framework. this service must be accessed from different channels i.e. web and mobile channels. each channel has its own business rules that must be added dynamically to generic service functionality. for example if web channel do some additional validation and then call generic service. if mobile channel call service A, then service B then generic service. My question is what's the best design pattern/way to implement such service mediation without using an ESB?
Asked
Active
Viewed 42 times
1 Answers
1
I think you are looking for decorator pattern where you can attach the additional responsibility at run time.What you can do is
Public Class GenricValidationService extends ValidationService{
public void Validate(){
// do stuff here
}
}
Public Class WebChannelService extends ValidationService{
public WebChannelService (ValidationService validationService){
this.validationService= validationService;
}
ValidationService validationService;
public void Validate(){
genericValidationService.validate();
// extra validation
}
}
similarly
Public Class ServiceB extends ValidationService{
public ServiceB (ValidationService validationService){
this.validationService= validationService;
}
ValidationService validationService;
public void Validate(){
validationService.validate();
// extra validation
}
}
see
-
I want to add this type of functionality using a config file and be able to use existing services – hkazemi Jul 12 '14 at 10:23