openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevan Miller <kevan.mil...@gmail.com>
Subject Re: svn commit: r561970 - in /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa: enhance/PCRegistry.java util/ImplHelper.java
Date Thu, 02 Aug 2007 12:43:55 GMT

On Aug 1, 2007, at 8:17 PM, Marc Prud'hommeaux wrote:

>
> I think the problem is that a class registers itself exactly once  
> with the PCRegistry. So if we unregister it with EMF.close(), then  
> if we were to subsequently create a new EMF, the class would no  
> longer be registered.
>
> If we are interested in discussing alternate approaches, though,  
> the following just occurred to me: if the only problem preventing  
> us from having PCRegistry classes as weak keys is that their value  
> graph eventually hits on the template instance of the entity, we  
> could just remove the template instance from the PCRegistry graph,  
> and instead keep around a separate Map<Class:Object> of the class  
> to the template instance in the EntityManagerFactory/BrokerFactory  
> itself (which could be lazily initialized whenever the template  
> instances are needed). That way, when the EMF is destroyed, there  
> would be no template instances around to prevent the weak  
> PCRegistry class keys from getting cleaned up.
>
> The only hitch is that the registration of the template instance  
> occurs in the enhancement bytecode of the entity itself, which  
> allows us to deal with private/protected no-arg constructors (which  
> we synthetically add if none exists) without having to muck around  
> with security. We'd need to consider whether we are willing to  
> sacrifice that.

IIUC, the template instance is (or is contained by) the  
PersistenceCapable object? Sounds right since you say it's part of  
the enhancement bytecode...

Sounds like this would work -- as long as the Object in  
Map<Class:Object> (I assume this a WEAK keyed Map) does not reference  
an Object or Class that is loaded in an application ClassLoader. So,  
JRE classes, OpenJPA classes, OpenJPA dependent libraries (e.g.  
commons library, etc) would all be good. It just can't reach an  
application (or enhanced application) class...

--kevan




Mime
View raw message