Hi,
to finish this one up, here is a code snipped that does not really resolve the
"real bean", but delivers the expected behaviour:
---
// 0: get the bean (proxy)
Object proxy = FrameworkAdapter.getCurrentInstance().getBean(
beanName);
// 1: un-proxy the Spring Scoped Object
while (proxy instanceof ScopedObject) {
proxy = ((ScopedObject) proxy).getTargetObject();
}
// 2: populate a bean instance of the superclass which the CGLIB proxy
inherits from
Class requiredClass = proxy.getClass().getSuperclass();
Object bean = BeanUtils.instantiateClass(requiredClass);
BeanUtils.copyProperties(proxy, bean);
---
The Variable "bean" now holds an instance of the original class which can then
be marshalled for RMI calls.
My misconception was that I thought, I could get hold of a reference to an
instance of my original bean class when obtaining the Spring ScopedObject's
target. Instead, what you really get is another CGLIB proxy. I assume that
Spring is not aware of this _second_ proxy as this one is crafted by Orchestra.
Hence the condition (proxy instanceof ScopedObject) is false.
Kind regards
malte.
> -----Ursprüngliche Nachricht-----
> Von: simon [mailto:[EMAIL PROTECTED]
> Gesendet: Freitag, 28. Dezember 2007 19:18
> An: MyFaces Discussion
> Betreff: Re: Orchestra: how to access the "real bean" behind
> the proxies?
>
>
> On Fri, 2007-12-28 at 18:11 +0100, Schnack, Malte wrote:
> > In Orchestra, I want to access the "real bean" behind the proxies to
> > make it available in another context (eg a JBPM variable map). This
> > seems to be necessary for serialization when invoking an RMI method
> > using the Orhestra/Spring conversation scoped bean as parameter DTO
> > object. This is what is happening inside my JBPM process definition.
> >
> > I already used the ScopedObject method getTargetObject() included in
> > Spring. This did not resolve to the "real bean" though but to the
> > CurrentConversationAdvice. When trying to perform the RMI call, my
> > Glassfish v2 server log shows the following error message:
>
> I think the CurrentConversationAdvice can also be cast to
> ScopedObject.
> Have you tried this?
> Object bean = ...;
> while (bean instanceof ScopedObject)
> bean = ((ScopedObject) bean).getTargetObject();
>
> Regards,
>
> Simon
>
>