Proxy Package Penalty for; / * * Proxy mode: The original object (by proxy class) of some functions proxy class to handle * * Security Agent: direct access to the real role of shielding * Remote Agent: RMI calls through a proxy class handles the remote method * Delayed load: lightweight proxy object to load, reload the real object through the proxy object if necessary * dynamically generated proxy class (reflection needed), static generated proxy class * * * / public class ProxyTest { public static void main (String [] args ) { server server = new new server (); // 1. the real server to proxy class ProxyServer proxyServer = new new ProxyServer (server); // 2. let proxy class networking, in essence, is to make a real server networking proxyServer.browse ( ); } } Interface NetWork { public void the Browse (); } // the proxy class class NetWork Server the implements { @Override public void the Browse () { the System. OUT .println ( " Server Access Network " ); } } // proxy class class the implements NetWork {ProxyServer Private NetWork Work; public ProxyServer (NetWork Work) { the this .work = Work; } public void Check () { . The System OUT .println (" Before the inspection Networking " ); } @Override public void the Browse () { Check (); work.browse (); } }
java-based - Interface and factory pattern
Guess you like
Origin www.cnblogs.com/zsben991126/p/12148139.html
Recommended
Ranking