Re: [Simple-support] More on dropped annotations
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2008-07-11 06:10:19
|
Hi,
This seems really strange that JBoss would do this, strange that it would treat annotations differently to normal classes. What type of object are you annotating? Is it CGLIB generated or something similar? Anyway, yes you can tell Simple to do this. Simple always tries the Thread.currentThread().getContextClassLoader(). So before write or read do this.
ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader():
try {
Thread.currentThread().setContextClassLoader(myClassLoader);
persister.write(myObject, myStream);
}finally {
Thread.currentThread().setContextClassLoader(previousClassLoader);
}
This will work for you with a custom class loader. However, I think there has to be a better solution than this, either JBoss is manupulating the class with CGLIB or something similar, or there is some other subtle issue as to why JBoss drops annotations. If not then JBoss is just plain crap.
Hope this helps,
Niall
--- On Thu, 7/10/08, Quirino Zagarese <qu...@la...> wrote:
> From: Quirino Zagarese <qu...@la...>
> Subject: [Simple-support] More on dropped annotations
> To: sim...@li...
> Date: Thursday, July 10, 2008, 9:36 AM
> I'm trying to find a solution, but I can't get out
> of it for now.
> I toke a look at Simple serialization mechanism: maybe I
> lost some steps,
> but the key is:
>
> 1) I use persister.write(annotatedObject,
> anOutputStream,etc)
> 2) Persister calls Traverser which should be the root of
> all serialization
> operations
> 3) Traverser gets source-object's class and starts
> scanning process to find
> annotations and whatever
>
> Now, if JBoss drops annotations during class loading,
> it's impossible for
> Simple to find them.
> Anyway we could reload the class with a custom classloader
> and make Simple
> use the loaded Class object
> as annotation scanning map. So my question is:
> Is it possible to tell Persister to do something like
> write(Object source,
> Class reloadedClass, OutputStream stream) ?
>
> Thanks in advance
>
> --
> Quirino Zagarese
>
> LaszloItalia Founder (www.laszloitalia.org)
> Software Development Manager - Galilaeus s.r.l.
> (www.galilaeus.net)-------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE
> NOW!
> Studies have shown that voting for your favorite open
> source project,
> along with a healthy diet, reduces your potential for
> chronic lameness
> and boredom. Vote Now at
> http://www.sourceforge.net/community/cca08_______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
|