Bean Proxy Approach
This approach wraps spring beans with proxies to allow the beans to be treated as regular objects without worries of serializing the entire spring container when a model object is cloned for versioning or replicated across a cluster.
This approach also allows us to centralize all static lookups in the page objects (or in a single base page) instead of having them spread out over other objects (such as models).
Pros:
  • Allows models and other components to be decoupled from any spring based code and lookups
  • Spring beans can be treated as regular objects without worries about serialization/cluster replication
Cons:
  • Slightly increased session size due to storage of bean proxies
Interesting classes:

Below is comparison of detachable models from the direct approach and the proxy approach. Notice that the proxy model has no knowledge of application subclass or spring, it simply knows about the DAO object it needs and stores it as a field variable.
public class ProxyModel extends ContactDetachableModel {
	private ContactDao dao;

	public ProxyModel(Contact contact, ContactDao dao) {
		super(contact);
		this.dao = dao;
	}

	protected ContactDao getContactDao() {
		return dao;
	}
}
public class DirectModel extends ContactDetachableModel {

	public DirectModel(Contact contact) {
		super(contact);
	}

	protected ContactDao getContactDao() {
		return ((ExampleApplication) Application.get()).getContactDao();
	}
}