Extending Services and adding new method.
Posted: Sat Jun 28, 2014 5:38 am
Hi,
What is the best way to extend an existing service eg: CustomerServiceImpl to MyCustomerServiceImpl and add couple of new methods to it and override some from CustomerServiceImpl . At run time how can I get an instance of MyCustoemrServiceImpl ?
I tried the following but failed,
public interface MyCustomerService extends CustomerService{
my_Method_here
}
MyCustomerServiceImpl extends CustomerServiceImpl implements MyCustomerService {
}
and overriding BLC CustomerService with my in spring ApplicationContext xml file.
Where ever required I try to typecast CustomerService to MyCustomerService which gives me a typecast exception:
java.lang.ClassCastException: $Proxy156 cannot be cast to com.sample.MyCustomerService
What is the best way to extend an existing service eg: CustomerServiceImpl to MyCustomerServiceImpl and add couple of new methods to it and override some from CustomerServiceImpl . At run time how can I get an instance of MyCustoemrServiceImpl ?
I tried the following but failed,
public interface MyCustomerService extends CustomerService{
my_Method_here
}
MyCustomerServiceImpl extends CustomerServiceImpl implements MyCustomerService {
}
and overriding BLC CustomerService with my in spring ApplicationContext xml file.
Where ever required I try to typecast CustomerService to MyCustomerService which gives me a typecast exception:
java.lang.ClassCastException: $Proxy156 cannot be cast to com.sample.MyCustomerService