Resource encapsulation

mark.reinhold at mark.reinhold at
Thu Dec 10 01:21:45 UTC 2015

2015/10/12 8:01 -0700, peter.kriens at
> I think I understand how a module aware JPA can use the Module API to
> load resources and classes. This sounds similar to how OSGi works.
> For the service loader scenario I am not clear how you would then
> discover and load the persistence.xml resources. Would you then not
> still be forced to go through the Module API anyway to read resources
> since the javax.persistence.Configuration implementation would not
> allow the JPA provider to read the persistence.xml? Isn’t using the
> service loader sounds like an unnecessary indirection?

The javax.persistence.Configuration service interface would expose
whatever methods are needed to provide the required configuration
information.  It could declare a method that returns an InputStream
intended to be the content of a raw persistence.xml file, or returns an
XML DOM structure, or returns an instance of some related class which
represents, in a statically-typed way, the content of persistence.xml.
In the long run persistence.xml could even be abandoned in favor of
actual code that initializes the Configuration object explicitly, if
so desired.

There are many options, but none requires external access to a client
module's internal persistence.xml resource, if any.

- Mark

More information about the jpms-spec-experts mailing list