<< 如何在Linux/Unix运行一个守护Java程序 | 首页 | WebSphere的SystemOut.log的日志中发现J2CA0075W的警告 >>

The Jakarta Commons Sandbox ——Proxy

Commons Proxy: Dynamic Proxies Made Easy

The Proxy design pattern (GoF) allows you to provide "a surrogate or placeholder for another object to control access to it". Proxies can be used in many ways. Some of which are:

  • Deferred Initialization - the proxy acts as a "stand-in" for the actual implementation allowing it to be instantiated only when absolutely necessary.
  • Security - the proxy object can verify that the user actually has the permission to execute the method (a la EJB).
  • Logging - the proxy can log evey method invocation, providing valuable debugging information.
  • Performance Monitoring - the proxy can log each method invocation to a performance monitor allowing system administrators to see what parts of the system are potentially bogged down.

Commons Proxy supports dynamic proxy generation using proxy factories, object providers, invokers, and interceptors.

使用动态代理可以延迟初始化对象,使程序更安全,记录对象行为,性能监控

标签 :



发表评论 发送引用通报