Reply to Michael Watzek:
[brazil]- PersistenceManagerProxies are cached using PMF instances as keys. Thus, you get the same proxy for the same PMF. I think this pattern disallows applications to implementing a 1:1 mapping for servlets and PMFs because applications would retrieve the same proxy instance with each (possibly concurrent) request.
[clr] Yes, the intent is that you get the same proxy for the same PMF. Since the proxy is thread-safe, this will always work.
[brazil]- PersistenceManagerProxy.close() does nothing. This means that after calling close, it's still possible to successfully call methods like makePersistent() etc. My understanding of javax.jdo.PersistenceManager is that all methods throw exceptions after close() except for isClosed(). Is it a goal to have the same behavior for the proxy class and javax.jdo.PersistenceManager?
[clr] Not exactly a goal, especially since close is a life cycle method and the life cycle of the proxy and the delegate are different. So close will need to be specified separately for the proxy. Since it doesn't make sense to close the proxy, and the life cycle of the delegate is under the control of the server, close should throw an exception. Also you will never get a closed delegate from the proxy.
[brazil]- Why is getPersistenceManagerProxy() a static method on class PersistenceManagerProxy rather than on class JDOHelper? This means that application code must import class PersistenceManagerProxy. If the method is defined on JDOHelper then class PersistenceManagerProxy can have default access modifier and the proxy class can be transparent to application code.
[clr] The intent was that this would not be used by the user, who would use getPersistenceManagerProxy from the factory.
[brazil]- Class PersistenceManagerProxy never calls remove on static field 'persistenceManagerProxies'.
[clr] You are right, the proxies will exist until forever. The number of proxies in the Map is small (one per PersistenceManagerFactory). We should use a weak Map that would allow the Entry to be removed if the key is garbage collected. Thanks for the suggestion.
[brazil]- The JNDI lookup of TransactionSynchronizationRegistry is done in a static initializer which may throw ExceptionInInitializerError. Would it make sense to do the lookup in getPersistenceManagerProxy()?
[clr] Thanks for the suggestion. I'll take a look. I'll need to double check to make sure the resources needed by the code are available at the time the methods are called.