dev@glassfish.java.net

Re: [GFv3] Action Required: Avoid split-package

From: Sahoo <Sahoo_at_Sun.COM>
Date: Tue, 27 May 2008 23:44:14 -0700

Bill Shannon wrote:
> > Some of the issues with
>> Require-Bundle are given below:
>> a) difficult to replace an implementation with another.
>
> Wouldn't multiple implementations all use the same bundle name,
> describing the *API* they export? If bundle names describe the
> implementation, then I agree with you.
>
> Maybe the problem is exactly that - that bundle names are names
> of the implementation artifact, but package names are names of the
> API?
>
Yes, that's exactly the problem.
>> b) dependencies of a bundle is not clear - not all of the exported
>> packages of a bundle may be required by the requiring bundle.
>
> I think "bundle" or "module" is a higher-level concept than "package".
> The fact that a module contains multiple packages shouldn't be an issue.
A module exporting more than one package is not at all an issue. The
issue is about import granularity. If modules are not properly designed,
Require-Bundle introduces unnecessary dependencies between modules,
where as Import-Package allows user to specify dependencies more
accurately.
> I would expect the dependency to be in terms of the module.
I beg to differ. Specifying dependency using module name is appropriate
if the module boundary is standardised and module name does not specify
the name of an implementation. Since neither of the above is true,
depending on module severely affects substitutability at runtime. Here
is an example:

jpa-provider-A needs javax.persistence.* packages.
jpa-provider-B also needs javax.persistence.* packages.

Both want to be self sufficient, so they both have their own modules
containing javax.persistence classes. Let's call them jpa-interface-A
and jpa-interface-B respectively. If they use Require-Bundle, then when
both jpa-provider-A and B are simultaneously used, javax.persistence
classes would be loaded twice making any kind of interaction between the
two providers using the javax.persistence classes impossible. Let's
suppose an application uses both the providers simultaneously; it reads
using provider-A and writes using provider-B. It's only going to get
ClassCastException, isn't it?

On the other hand, Import-Package does not have any such issue.

Thanks,
Sahoo