Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » [Teneo,QVTo] QVTo + Teneo + Javassist -- possible or not?
[Teneo,QVTo] QVTo + Teneo + Javassist -- possible or not? [message #908437] Wed, 05 September 2012 11:43 Go to next message
Eclipse UserFriend
Hello,

first off, sorry for cross-posting, I'm afraid this issue is a bit
cross-cutting.

I'm transforming using QVTo and the input model extent is an EMF
resource which is using a Teneo store. For some performance reasons we
recently switch to using Javassist proxies. Now, during the
transformation the QVT compiler seems to choke on those proxies, namely
here:

org.eclipse.m2m.internal.qvt.oml.evaluator.TraceUtil:
private static <K, T> EList<T> createOrGetListElementFromMap(EMap<K,
EList<T>> map, K key) {
EList<T> list = map.get(key);
if (list == null) {
list = new BasicEList<T>();
map.put(key, list);
list = map.get(key);
}
return list;
}

The key is a javassist proxy, what's happening is that list is indeed
null on entry, then a new list is generated and put into the map, but
the second map.get(key) just isn't able to retrieve the value and
returns null. It may very well be that the map.put() didn't even store
the newly created list.

Now, while I understand if that's just how it is and that QVT won't be
able to support this by some reason. In that case, is there a
possibility to unproxy a complete EMF resource? Note that
EcoreUtil.resolveAll() doesn't work, AFAIU this only works with EMF
proxies, not Javassist ones.

TIA for any hints and pointers!

Marius
Re: [Teneo,QVTo] QVTo + Teneo + Javassist -- possible or not? [message #908450 is a reply to message #908437] Wed, 05 September 2012 12:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

My suspicion is that your guess is correct. QVTo will not be happy if
the input or output is unstable, but if you are using EMF resources in a
conventional fashion that should not be a problem.

You are aware that EdoreUtil.resolveAll is what you want. It seems you
need to understand why the same thing cannot be done with Javassist.
Once you can do this for all such proxies, you may then be able to do so
lazily for those that are actually needed.

Regards

Ed Willink

On 05/09/2012 12:43, Marius Gröger wrote:
> Hello,
>
> first off, sorry for cross-posting, I'm afraid this issue is a bit
> cross-cutting.
>
> I'm transforming using QVTo and the input model extent is an EMF
> resource which is using a Teneo store. For some performance reasons we
> recently switch to using Javassist proxies. Now, during the
> transformation the QVT compiler seems to choke on those proxies, namely
> here:
>
> org.eclipse.m2m.internal.qvt.oml.evaluator.TraceUtil:
> private static <K, T> EList<T> createOrGetListElementFromMap(EMap<K,
> EList<T>> map, K key) {
> EList<T> list = map.get(key);
> if (list == null) {
> list = new BasicEList<T>();
> map.put(key, list);
> list = map.get(key);
> }
> return list;
> }
>
> The key is a javassist proxy, what's happening is that list is indeed
> null on entry, then a new list is generated and put into the map, but
> the second map.get(key) just isn't able to retrieve the value and
> returns null. It may very well be that the map.put() didn't even store
> the newly created list.
>
> Now, while I understand if that's just how it is and that QVT won't be
> able to support this by some reason. In that case, is there a
> possibility to unproxy a complete EMF resource? Note that
> EcoreUtil.resolveAll() doesn't work, AFAIU this only works with EMF
> proxies, not Javassist ones.
>
> TIA for any hints and pointers!
>
> Marius
Re: [Teneo,QVTo] QVTo + Teneo + Javassist -- possible or not? [message #908455 is a reply to message #908437] Wed, 05 September 2012 12:11 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Are these like Java dynamic proxies? That's not likely to work to
create proxies that are EObjects. EMF relies on using == to compare
EObject instances.

On 05/09/2012 1:43 PM, Marius Gröger wrote:
> Hello,
>
> first off, sorry for cross-posting, I'm afraid this issue is a bit
> cross-cutting.
>
> I'm transforming using QVTo and the input model extent is an EMF
> resource which is using a Teneo store. For some performance reasons we
> recently switch to using Javassist proxies. Now, during the
> transformation the QVT compiler seems to choke on those proxies, namely
> here:
>
> org.eclipse.m2m.internal.qvt.oml.evaluator.TraceUtil:
> private static <K, T> EList<T> createOrGetListElementFromMap(EMap<K,
> EList<T>> map, K key) {
> EList<T> list = map.get(key);
> if (list == null) {
> list = new BasicEList<T>();
> map.put(key, list);
> list = map.get(key);
> }
> return list;
> }
>
> The key is a javassist proxy, what's happening is that list is indeed
> null on entry, then a new list is generated and put into the map, but
> the second map.get(key) just isn't able to retrieve the value and
> returns null. It may very well be that the map.put() didn't even store
> the newly created list.
>
> Now, while I understand if that's just how it is and that QVT won't be
> able to support this by some reason. In that case, is there a
> possibility to unproxy a complete EMF resource? Note that
> EcoreUtil.resolveAll() doesn't work, AFAIU this only works with EMF
> proxies, not Javassist ones.
>
> TIA for any hints and pointers!
>
> Marius


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [Teneo,QVTo] QVTo + Teneo + Javassist -- possible or not? [message #908533 is a reply to message #908455] Wed, 05 September 2012 14:29 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
I guess that after the javaassist gets resolved its hashcode changes?? (guessing a bit).
So in that case the only solution I see is to make sure that the key objects are resolved before you get to this method.
Javaassist proxies are initialized/resolved by calling any method on them (for example eClass()).

gr. Martin


On 09/05/2012 02:11 PM, Ed Merks wrote:
> Are these like Java dynamic proxies? That's not likely to work to create proxies that are EObjects. EMF relies on
> using == to compare EObject instances.
>
> On 05/09/2012 1:43 PM, Marius Gröger wrote:
>> Hello,
>>
>> first off, sorry for cross-posting, I'm afraid this issue is a bit
>> cross-cutting.
>>
>> I'm transforming using QVTo and the input model extent is an EMF
>> resource which is using a Teneo store. For some performance reasons we
>> recently switch to using Javassist proxies. Now, during the
>> transformation the QVT compiler seems to choke on those proxies, namely
>> here:
>>
>> org.eclipse.m2m.internal.qvt.oml.evaluator.TraceUtil:
>> private static <K, T> EList<T> createOrGetListElementFromMap(EMap<K,
>> EList<T>> map, K key) {
>> EList<T> list = map.get(key);
>> if (list == null) {
>> list = new BasicEList<T>();
>> map.put(key, list);
>> list = map.get(key);
>> }
>> return list;
>> }
>>
>> The key is a javassist proxy, what's happening is that list is indeed
>> null on entry, then a new list is generated and put into the map, but
>> the second map.get(key) just isn't able to retrieve the value and
>> returns null. It may very well be that the map.put() didn't even store
>> the newly created list.
>>
>> Now, while I understand if that's just how it is and that QVT won't be
>> able to support this by some reason. In that case, is there a
>> possibility to unproxy a complete EMF resource? Note that
>> EcoreUtil.resolveAll() doesn't work, AFAIU this only works with EMF
>> proxies, not Javassist ones.
>>
>> TIA for any hints and pointers!
>>
>> Marius
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Teneo,QVTo] QVTo + Teneo + Javassist -- possible or not? [message #908940 is a reply to message #908533] Thu, 06 September 2012 09:13 Go to previous message
Eclipse UserFriend
Hello Martin,

On 05.09.2012 16:29, Martin Taal wrote:
> Hi,
> I guess that after the javaassist gets resolved its hashcode changes??
> (guessing a bit).
> So in that case the only solution I see is to make sure that the key
> objects are resolved before you get to this method.
> Javaassist proxies are initialized/resolved by calling any method on
> them (for example eClass()).

I know, but when I tried that it seemed to me that while I did resolve a
proxy, the model still contained the proxy, and QVT continued choking.
Unfortunately I don't really know how javassist works. I read that it
does byte-code manipulation, so it course do any kind of magic, such as
automatically fixup EList<>s when resolving a proxy. But does it really
work that way? IOW, is:

Iterator<Object> it = EcoreUtil.getAllProperContents(rootObj, true);
while (it.hasNext()) {
Object o = it.next();
if (o instanceof HibernateProxy) {
Class<?> cls = Hibernate.getClass(o);
if (cls != null) {
((HibernateProxy) o).getHibernateLazyInitializer()
.getImplementation();
}
}
}

supposed to work? It didn't for me.

Marius
Previous Topic:applyStereotype on input model elements
Next Topic:EMF Generics and QVT-O
Goto Forum:
  


Current Time: Thu Apr 25 00:41:45 GMT 2024

Powered by FUDForum. Page generated in 0.03583 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top