????SetProxyFactory ??????????????????? getSetProxy()???????????????? Set ?????????????????????? Set —— ??????????????????????????????????????????SetProxyFactory ???????????????£?????????????????????????? Set ??????????????????????????????????????????????????????????? —— ??????????? Set ????????????????????????t???????t?????????????????????????????????????????????????????е????????????

????????????????????

?????????? SetProxyFactory ???????????????????????????и???????? —— ???????????????????????Χ??С???????????????????????????????????????????????????????????????????????????????ε???????????????????嵥 3 ??????????壬????????????????????л???????????????????????????????????? IDE ??????????????????? Adapter ????

?????嵥 3. ???????????


1.public interface ServiceCallback {  
2. public void doCallback();  
3. }  
4.public interface Service {  
5. public void serviceMethod(ServiceCallback callback);  
6. }  
7.public class ServiceConsumer implements ServiceCallback {  
8. private Service service;  
9....  
10. public void someMethod() {  
11. ...  
12. service.serviceMethod(this);  
13. }  
14. }

????ServiceConsumer ??????? ServiceCallback???????????????????????????????? this ???????? serviceMethod() ?????????á??????????????????л????????? Service ???? ServiceCallback ????? ServiceConsumer???????? ServiceConsumer ????? Service ????????????????????????????? —— ??????????????????????????????????????????????д???????????????????????????嵥 4 ?е? ServiceCallbackAdapter?????? ServiceCallbackAdapter ??? ServiceConsumer??ServiceCallbackAdapter ??? Service ?? ServiceCallback ????? ServiceConsumer??

?????嵥 4. ?????????????????????????????????????????????????

1.public class ServiceCallbackAdapter implements ServiceCallback {  
2. private final ServiceCallback cb;  
3.public ServiceCallbackAdapter(ServiceCallback cb) {  
4. this.cb = cb;  
5. }  
6.public void doCallback() {  
7. cb.doCallback();  
8. }  
9. }