[jboss-user] [JBoss Seam] - Re: coerceToType / javaassist error

paulkossler do-not-reply at jboss.com
Mon Oct 15 14:33:40 EDT 2007


I am mainly saying that the implementation documentation leads people to the wrong conclusions.  The example exercises all target direct use of the Proxy.  This is incorrect for the GoF proxy pattern.  

Seam handles some aspects of it for you; however, if you pass a Proxy AS A Subject to the View Layer through JSF; its lifecycle requires saving and reconstituting your objects.  The coerceToType error occurs because the Proxy fails the to be converted to the Subject... because it is not one.  This is correct.  The problem is that you have to use a commonly implemented interface or tell the JPA/Hibernate/Ibatis et al. not to use the Auto-Proxy.  Then it will build the actual Subject each time.  Unfortunately, as I mentioned in my first posting on the topic, this seriously affects the caching paradigm.

Read GoF: Design Patterns.  Proxy Pattern.
Use a common interface.  (Eclipse can help you "Extract interfaces")  Just read carefully into how to connect the interface to the mapped version.  I mentioned that the annotation:
@org.hibernate.annotations.Proxy(proxyClass = myProxyInterface.class)
Does seem to function properly.  I have not had the time to formally test this out.  (on my todo list.)

:)


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4095365#4095365

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4095365



More information about the jboss-user mailing list