[
https://issues.apache.org/jira/browse/ARIES-736?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13091719#comment-13091719
]
Christoph Läubrich commented on ARIES-736:
------------------------------------------
Okay, I understand the Problem, thanks for your fast reply.
I was not aware about the fact that Aries JPA is not "OSGi-JPA" compilant,
because it refers to the spec on the modules project page.
Also I was not aware that the concept of incomplete persitence units where
bound to the unmanaged part of the spec.
I think you can either close this bug or change it to a "new feature" one :)
> How should the Aries container decide when to wait for a DataSourceFactory
> service rather than passing
> the JDBC properties on to the persistence provider?
As mentioned above IMO there is a level of indirection needed for this case.
Case 1) There is a PersistenceProvider registered in the system and the
persitence unit is not bound or bound to this specific provider the current
aproach would fit (and won't break backward compatibility)
Case 2) There is no (or no matching) PersitenceProvider registered in the
system, but a suitable DataSourceFactory, then a DataSource Object is obtained
from this factory using the JDBC properties of the persistence unit and passed
to a Service in the OSGi system implementing for example the following
interface:
public interface PersistenceProviderBinder {
/**
* @return a PersistenceProvider bound to this DataSource or <code>null</code>
if binding failed
*/
PersistenceProvider bindProvider(DataSource source, Map<?, ?> properties);
}
Aries the could try each service providing this interface and the first which
matches wins, and register the returned PersitenceProvider as "bound to this
DataSourceFactory".
Of course, as soon as the DataSourceFactory becomes unavaiable it shoudl
unregister and close the PersistenceProvider.
> Aries does not take into account the concept of complete/incomplete
> Persistence Units
> -------------------------------------------------------------------------------------
>
> Key: ARIES-736
> URL: https://issues.apache.org/jira/browse/ARIES-736
> Project: Aries
> Issue Type: Bug
> Components: JPA
> Affects Versions: 0.3
> Reporter: Christoph Läubrich
>
> The OSGi spec states (r4.2 127.3.1):
> "Entity Manager Factory service - Provides an EntityManagerFactory object
> that depends on a complete
> Persistence Unit. That is, it is associated with a registered Data Source
> Factory service."
> The current behaiviour is, that aries registers a Entity Manager Factory
> service regardles of the precence of a matching Data Source Factory service
> (Also see 127.5.3 Data Source Factory Service Matching).
> If no such matching is performed, it alternateively must register a Entity
> Manager Factory Builder service (not currently supported by Aries see
> ARIES-735 for reference).
> What infact is unclear to me is:
> 127.5.3 states that: "Once the Data Source Factory is obtained, the JPA
> Provider must obtain a DataSource object. This
> Data Source object must then be used for all relational database access."
> It does not state how this DataSource could be handed over to the
> PersistenceProvider for later usage.
> It might be suitable to insert a level of indirection here:
> - Aries just reads the persitence units and registers an Entity Manager
> Factory Builder service
> - PersistencProvider specific bundles match these with the required data
> source and register the Entity Manager Factory service
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira