<br><tt><font size=2>After writing:</font></tt>
<br>
<br><font size=2 face="sans-serif">&gt;</font><tt><font size=2>I think
ResolutionContext doesn't need any detail</font></tt>
<br>
<br><tt><font size=2>I remembered the class in the interoperation kernel
prototype did have a little detail (but not much):</font></tt>
<br>
<br><tt><font size=2>public interface ResolutionContext extends KernelRelated
{<br>
 &nbsp; &nbsp; <br>
 &nbsp; &nbsp;/**<br>
 &nbsp; &nbsp; * &nbsp;Notify completion.<br>
 &nbsp; &nbsp; */<br>
 &nbsp; &nbsp;void complete();</font></tt>
<br><tt><font size=2><br>
}<br>
</font></tt>
<br><tt><font size=2>I blogged ([1]) the README and class diagrams from
the prototype for ease of reference.</font></tt>
<br><font size=2 face="sans-serif"><br>
Glyn</font>
<br><font size=2 face="sans-serif">[1] http://underlap.blogspot.com/2007/06/module-system-interoperation-kernel.html</font>
<br>
<br><font size=1 face="sans-serif"><b>glyn_normington@uk.ibm.com</b></font><tt><font size=2>
wrote on 31/05/2007 17:15:19:<br>
<br>
&gt; <br>
&gt; Bryan Atsatt &lt;bryan.atsatt@ORACLE.COM&gt; wrote on 30/05/2007 19:11:02:<br>
&gt; <br>
&gt; &gt; Responses inline, and a few clarifications here (I was a bit
tired when<br>
&gt; &gt; I finished this last night :^)...<br>
&gt; &gt; <br>
&gt; &gt; The main point I was trying to make is that resolution must occur
within<br>
&gt; &gt; a specific context, but I don't think my example APIs showed
that well.<br>
&gt; &gt; I was assuming that ImportResolver had a ModuleContext as a field,
but<br>
&gt; &gt; we can make this much cleaner and easier to understand by passing
it as<br>
&gt; &gt; an argument:<br>
&gt; &gt; <br>
&gt; &gt; public abstract class ImportResolver {<br>
&gt; &gt; &nbsp; &nbsp; &nbsp;public abstract Module resolve(ModuleDefinition
def,<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ModuleContext
ctx);<br>
&gt; &gt; }<br>
&gt; &gt; <br>
&gt; &gt; And we can really tie this together by adding a convenience method
to<br>
&gt; &gt; ModuleContext:<br>
&gt; &gt; <br>
&gt; &gt; public abstract class ModuleContext {<br>
&gt; &gt; &nbsp; &nbsp; &nbsp;...<br>
&gt; &gt; &nbsp; &nbsp; &nbsp;public Module resolve(ModuleDefinition def)
{<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return getImportResolver().resolve(def,
this);<br>
&gt; &gt; &nbsp; &nbsp; &nbsp;}<br>
&gt; &gt; }<br>
&gt; &gt; <br>
&gt; &gt; Now resolution becomes simply:<br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp;context.resolve(definition);<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; (I also left out any use of the ImportPolicy, as it isn't yet
clear to<br>
&gt; &gt; me that it should remain a separate type in this model.)<br>
&gt; &gt; <br>
&gt; &gt; // Bryan<br>
&gt; &gt; <br>
&gt; &gt; Glyn Normington wrote:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; *Bryan Atsatt &lt;bryan.atsatt@ORACLE.COM&gt;* wrote on
30/05/2007 07:57:59:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp;&gt; Andy Piper wrote:<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp;&gt; At 23:19 25/05/2007, Stanley M. Ho
wrote:<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp;&gt;&gt; Anyway, it seems the EG consensus
so far is to not add <br>
&gt; import package<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp;&gt;&gt; support. If any EG member disagrees,
please speak up.<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp;&gt; Well, it depends on what the solution
for enabling interoperation<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp;&gt; with JSR 291 is.<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp;&gt; Our requirement is that there must
be a solution, if that requires<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp;&gt; import package, so be it. If not then
not.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; Exactly.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; I think we can all agree that, at minimum, interoperation
means that<br>
&gt; &gt; &gt; &nbsp;&gt; classes and resources are sharable *across* ModuleSystems
at runtime.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; Which implies that *import dependencies must
be resolvable across<br>
&gt; &gt; &gt; &nbsp;&gt; multiple ModuleSystem instances*. (BTW, I think
we should change the<br>
&gt; &gt; &gt; &nbsp;&gt; state name &quot;PREPARING&quot; to &quot;RESOLVING&quot;
in 7.2.1.)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Agreed. We must avoid the trap of thinking that module system
interop.<br>
&gt; &gt; &gt; can be achieved by exposing class loaders (as loadClass
will happily<br>
&gt; &gt; &gt; load unexported classes).<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; So the open issue is the richness of the import
&quot;language&quot;: must we<br>
&gt; &gt; &gt; &nbsp;&gt; support only lowest-common-denominator, or can
we do better without<br>
&gt; &gt; &gt; &nbsp;&gt; over-complicating the design?<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; I for one would like to be able to have a single
module express<br>
&gt; &gt; &gt; &nbsp;&gt; dependencies on modules from both the same and
different ModuleSystems,<br>
&gt; &gt; &gt; &nbsp;&gt; *using the standard semantics of each*. This
may be reaching too far,<br>
&gt; &gt; &gt; &nbsp;&gt; but we should at least explore it seriously while
we figure out what<br>
&gt; &gt; &gt; &nbsp;&gt; interop means here...<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; At this point, I feel that is likely to be reaching too
far, but I'm<br>
&gt; &gt; &gt; happy to play along and see what we can learn along the
way.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; BASICS<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; So far, we only know of two different import
semantics: <br>
&gt; module-name, and<br>
&gt; &gt; &gt; &nbsp;&gt; package-name. For discussion, let's call these:<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; a. import-module<br>
&gt; &gt; &gt; &nbsp;&gt; b. import-package<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; So, to start, we could:<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; 1. Support declaration of both import types.
If 294 supports imports at<br>
&gt; &gt; &gt; &nbsp;&gt; all, it should be relatively easy to support
both, since a superpackage<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; name is a module name, and it contains
member package <br>
&gt; names. (Compiler<br>
&gt; &gt; &gt; &nbsp;&gt; support is clearly the critical issue here, but
it will obviously<br>
&gt; &gt; &gt; &nbsp;&gt; require use of the 277 runtime, so the import
*type* should be<br>
&gt; &gt; &gt; &nbsp;&gt; transparent to it.) At worst, we'd need two new
annotation types.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; A superpackage name is a deployment module name in the JSR
277 model of<br>
&gt; &gt; &gt; one superpackage per deployment module, but I don't see
any reason why a<br>
&gt; &gt; &gt; JSR 291 deployment module should not contain more than one
superpackage.<br>
&gt; &gt; &gt; So if 294 were to support import, then its import-module
would really be<br>
&gt; &gt; &gt; a superpackage import rather than a development module import.<br>
&gt; &gt; <br>
&gt; &gt; If we end up with nested superpackages, might it make sense to
model<br>
&gt; &gt; multiple superpackages by enclosing them in a single top-level
one? <br>
&gt; <br>
&gt; That is an option, but of course each nested superpackage has to <br>
&gt; name its parent, so it wouldn't be possible to combine superpackages<br>
&gt; from independent groups or sources without either modifying their
<br>
&gt; superpackage declarations or getting them to agree on the name of
<br>
&gt; the parent superpackage and code it themselves. <br>
&gt; <br>
&gt; &gt; <br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; 2. Provide API for both import types (e.g. ImportDependency
has<br>
&gt; &gt; &gt; &nbsp;&gt; getModuleName() and getPackageName() methods,
one of which will return<br>
&gt; &gt; &gt; &nbsp;&gt; null on a given instance).<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; However, we know these are necessary but not
sufficient. Leaving aside<br>
&gt; &gt; &gt; &nbsp;&gt; the resolution issue for a moment, support for
import-package also<br>
&gt; &gt; &gt; &nbsp;&gt; suggests that we:<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; 3. Enable a single module to declare different
versions for each of its<br>
&gt; &gt; &gt; &nbsp;&gt; member packages.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; 4. Enable efficient Repository lookup by package
name.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; I think these are relatively easy (but *could*
be considered optional).<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; We also need:<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; 5. Standard Query types for lookup by module
and package name.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; EXISTING DEPENDENCY RESOLUTION MODEL<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; The more interesting issue is dependency resolution.
But this hasn't<br>
&gt; &gt; &gt; &nbsp;&gt; been discussed in any real detail, so lets do
so before talking further<br>
&gt; &gt; &gt; &nbsp;&gt; about import-package. To simplify this discussion,
I'm ignoring<br>
&gt; &gt; &gt; &nbsp;&gt; bundled/custom import policies for now...<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; Resolution in the current spec is delegated to
the associated<br>
&gt; &gt; &gt; &nbsp;&gt; ModuleSystem instance (7.2.2 #8). While the details
are not <br>
&gt; spelled out,<br>
&gt; &gt; &gt; &nbsp;&gt; the expectation appears to be that<br>
&gt; &gt; &gt; &nbsp;&gt; ModuleSystem.getModule(ModuleDefinition) must:<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; - Select an initial repository. Call getRepository()
on the input<br>
&gt; &gt; &gt; parameter.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; Then, for each ImportDependency of the definition:<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; - Select a matching definition. Construct a Query
from the<br>
&gt; &gt; &gt; &nbsp;&gt; ImportDependency and use Repository.find() to
lookup a matching<br>
&gt; &gt; &gt; &nbsp;&gt; ModuleDefinition.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; - Get an instance. Use def.getModuleSystem().getModule(def).
The<br>
&gt; &gt; &gt; &nbsp;&gt; ModuleSystem is expected to return a cached instance
if available, or<br>
&gt; &gt; &gt; &nbsp;&gt; create/cache/return one if not.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I think there also needs to be some 'resolution context'
object which<br>
&gt; &gt; &gt; explicitly denotes a particular resolution so that each
module system<br>
&gt; &gt; &gt; can keep track of the state of a resolution. This is required
when two<br>
&gt; &gt; &gt; or more imports of a given module from another module system
need to<br>
&gt; &gt; &gt; resolve to the same module instance. A resolution context
may also be<br>
&gt; &gt; &gt; needed for back-tracking when a set of module instances
created earlier<br>
&gt; &gt; &gt; in resolution turn out not to satisfy all the necessary
constraints.<br>
&gt; &gt; <br>
&gt; &gt; Yes. I had (briefly :^) thought that we need only a List&lt;Module&gt;
as<br>
&gt; &gt; field in the ImportResolver to hold the resolved modules as we
go. But<br>
&gt; &gt; probably we need to keep some additional state along with each
Module,<br>
&gt; &gt; so a new type may be required. Let's call it ResolutionContext,
and<br>
&gt; &gt; create one at the start of each resolution:<br>
&gt; &gt; <br>
&gt; &gt; public abstract class ImportResolver {<br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp;public Module resolve(ModuleDefinition def,
ModuleContext modCtx) {<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ResolutionContext resCtx =
createResolutionContext();<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return resolve(def, modCtx,
resCtx);<br>
&gt; &gt; &nbsp; &nbsp; &nbsp;}<br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp;protected abstract ResolutionContext createResolutionContext();<br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp; &nbsp;protected abstract Module resolve(ModuleDefinition
def,<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ModuleContext
modCtx,<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ResolutionContext
resCtx);<br>
&gt; &gt; }<br>
&gt; &gt; <br>
&gt; &gt; Does this approach make sense? Any thoughts on details for<br>
&gt; &gt; ResolutionContext? <br>
&gt; <br>
&gt; Seems reasonable. I think ResolutionContext doesn't need any detail
<br>
&gt; - it can simply be used as the key of a map recording the <br>
&gt; resolutions that a module system is currently aware of. <br>
&gt; <br>
&gt; &gt; <br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; (TBD: The PlatformBinding must be taken into
account somehow during<br>
&gt; &gt; &gt; &nbsp;&gt; selection. ModuleDefinition must include an accessor
for it, and either<br>
&gt; &gt; &gt; &nbsp;&gt; Repository.find() should implicitly filter them,
or the caller must<br>
&gt; &gt; &gt; &nbsp;&gt; construct a Query which will do so. I think we
should add a<br>
&gt; &gt; &gt; &nbsp;&gt; CURRENT_PLATFORM constant to Query, which will
evaluate to true if no<br>
&gt; &gt; &gt; &nbsp;&gt; binding is present in a definition.)<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; (The spec also talks about Repository as the
mechanism of isolation<br>
&gt; &gt; &gt; &nbsp;&gt; (6.4). This was the case in the prototype, where
the repository itself<br>
&gt; &gt; &gt; &nbsp;&gt; provided caching. It doesn't appear to work with
the current design.<br>
&gt; &gt; &gt; &nbsp;&gt; There is no need that I can see to isolate ModuleDefinition<br>
&gt; &gt; &gt; &nbsp;&gt; instances--it is Module instances with their
associated <br>
&gt; loaders that may<br>
&gt; &gt; &gt; &nbsp;&gt; require isolation.)<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; (Also note that if ImportDependency was itself
a Query subclass, there<br>
&gt; &gt; &gt; &nbsp;&gt; would be no need to do any mapping. And since
the ModuleDefinition<br>
&gt; &gt; &gt; &nbsp;&gt; subclass must produce ImportDependency instances,
it can even produce<br>
&gt; &gt; &gt; &nbsp;&gt; more specialized Query instances if desired.)<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; REFINEMENT<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; I think we can improve on the existing model
in several ways:<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; A. Provide a model for Module isolation (e.g.
for EE, Applets, etc).<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; B. Encapsulate all selection logic in a single
mechanism.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; C. Eliminate the overhead of the repository lookup
when a cached<br>
&gt; &gt; &gt; &nbsp;&gt; instance exists.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; Let me propose a new class that encapsulates
the caching logic, enables<br>
&gt; &gt; &gt; &nbsp;&gt; lookup using Query, and supports multiple instances
for isolation:<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; public abstract class ModuleContext {<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;// Get the context used to
define JRE modules.<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;public static ModuleContext
getBootstrapContext(){...};<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;// Get the context used to
define the main module.<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;public static ModuleContext
getSystemContext(){...};<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;// Get all contexts.<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;public static List&lt;ModuleContext&gt;
getContexts() {...};<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;// Add a new context.<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;public static void addContext(ModuleContext
ctx) {...}<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;// Remove a context (error
if == default).<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;public static boolean removeContext(ModuleContext
ctx) {...}<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;// Get the parent context
(null if bootstrap).<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;public ModuleContext getParentContext(){...}<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;// Get the name of this context.<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;public String getContextName()
{...}<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;// Create a new Module instance
and store it in the cache.<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;public abstract Module createModule(ModuleDefinition
def);<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;// Find cached Module instances.
Must check parent first.<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;public abstract List&lt;Module&gt;
findModules(Query query);<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;// Set the context used for
JRE modules.<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;static void setBootstrapContext(ModuleContext
ctx){...}<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;// Set the context used to
define the main module.<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;static void setSystemContext(ModuleContext
ctx){...}<br>
&gt; &gt; &gt; &nbsp;&gt; }<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; The JVM will create an appropriate subtype and
call<br>
&gt; &gt; &gt; &nbsp;&gt; setBootstrapContext(). The launcher will create
a child <br>
&gt; context and call<br>
&gt; &gt; &gt; &nbsp;&gt; setSystemContext(). An EE (or similar) environment
can <br>
&gt; create/remove new<br>
&gt; &gt; &gt; &nbsp;&gt; contexts as needed for application isolation.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; And the resolution algorithm can now check the
cache *first*, before<br>
&gt; &gt; &gt; &nbsp;&gt; doing a repository lookup, using the same mechanism
in both. Query<br>
&gt; &gt; &gt; &nbsp;&gt; should be used to express *all* selection criteria
(including<br>
&gt; &gt; &gt; &nbsp;&gt; attributes, which we have not yet directly supported).<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; Caches are no longer tied to ModuleSystem instances.<br>
&gt; &gt; &gt; &nbsp;&gt; ModuleSystem.getModule() can become simply createModule().
The normal<br>
&gt; &gt; &gt; &nbsp;&gt; implementation of ModuleContext.createModule()
just calls<br>
&gt; &gt; &gt; &nbsp;&gt; ModuleSystem.createModule() and caches/returns
the result.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; This class could easily be made concrete, but
it may be useful to<br>
&gt; &gt; &gt; &nbsp;&gt; support subtypes for specialization (e.g. event
generation, lifecycle<br>
&gt; &gt; &gt; &nbsp;&gt; management, specialized diagnostics, etc).<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; RESOLUTION MODELS<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; The current design requires that each ModuleSystem
provide its own<br>
&gt; &gt; &gt; &nbsp;&gt; resolution logic, and that each definition will
be resolved by its<br>
&gt; &gt; &gt; &nbsp;&gt; owning ModuleSystem. This model appears to provide
flexibility for<br>
&gt; &gt; &gt; &nbsp;&gt; significant differences in implementation, but
we really don't know<br>
&gt; &gt; &gt; &nbsp;&gt; enough at this point. Perhaps only an actual
second implementation will<br>
&gt; &gt; &gt; &nbsp;&gt; tell us if this provides useful flexibility.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; It wouldn't surprise me if we have to keep tightening
the <br>
&gt; spec as we go,<br>
&gt; &gt; &gt; &nbsp;&gt; in order to remove inconsistencies that arise
from the separate<br>
&gt; &gt; &gt; &nbsp;&gt; algorithms. And this may eliminate flexibility
to the point where it is<br>
&gt; &gt; &gt; &nbsp;&gt; no longer useful. Much worse, we may not even
discover this until after<br>
&gt; &gt; &gt; &nbsp;&gt; the spec and RI are released, if that second
implementation (e.g. OSGi)<br>
&gt; &gt; &gt; &nbsp;&gt; is not completed beforehand.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; We should at least consider the obvious alternative:
one algorithm (to<br>
&gt; &gt; &gt; &nbsp;&gt; rule them all :^). And I don't mean one hard-coded
algorithm,I mean one<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; replaceable, extensible class, such as:<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; public abstract class ImportResolver {<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;public abstract Module resolve(ModuleDefinition
def);<br>
&gt; &gt; &gt; &nbsp;&gt; }<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; And we add a method to ModuleContext to retrieve
an instance:<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; public abstract class ModuleContext {<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;...<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; &nbsp;public abstract ImportResolver
getImportResolver();<br>
&gt; &gt; &gt; &nbsp;&gt; }<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; (Note that ImportResolver is now in a position
to subsume the<br>
&gt; &gt; &gt; &nbsp;&gt; functionality of both VisibilityPolicy and ImportOverridePolicy.)<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; Repository usage is encapsulated within the implementation
of the<br>
&gt; &gt; &gt; &nbsp;&gt; resolve() method. The full resolution algorithm
becomes:<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; &nbsp; &nbsp; context.getImportResolver().resolve(definition);<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; The launcher uses the &quot;system&quot; context
for this. EE, Applets,etc. make<br>
&gt; &gt; &gt; &nbsp;&gt; and use their own distinct, isolated instances.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; RESOLUTION WITH IMPORT-NAME AND IMPORT-PACKAGE<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; With this scaffolding in place we can easily
take a phased approach to<br>
&gt; &gt; &gt; &nbsp;&gt; supporting import-package: the initial implementation
simply does not<br>
&gt; &gt; &gt; &nbsp;&gt; support it at runtime.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; A phased approach would be particularly beneficial if the
initial phase<br>
&gt; &gt; &gt; could be delivered as part of Java 7 and subsequent phases
implemented<br>
&gt; &gt; &gt; strictly on top of Java 7. But getting the API right up
front might be<br>
&gt; &gt; &gt; tricky unless we can spot some really good abstractions
or prototype the<br>
&gt; &gt; &gt; later phases sufficiently well. Is that the kind of phasing
you had in<br>
&gt; &gt; &gt; mind?<br>
&gt; &gt; <br>
&gt; &gt; Yes. It would be *extremely* useful to have an OSGi<br>
&gt; &gt; implementation/prototype well under way before Java 7 is completed,
so<br>
&gt; &gt; that we can fine tune the model as we learn.<br>
&gt; &gt; <br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; A subsequent implementation may support import-package,
but only within<br>
&gt; &gt; &gt; &nbsp;&gt; the boundaries of the same ModuleSystem.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; And a full blown implementation may support import-package
across<br>
&gt; &gt; &gt; &nbsp;&gt; ModuleSystems.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; We can build in support for selecting/configuring
the ImportResolver as<br>
&gt; &gt; &gt; &nbsp;&gt; a service, just as we plan to do with ModuleSystem
(and Repository, I<br>
&gt; &gt; &gt; &nbsp;&gt; presume).<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; And maybe, just maybe, we can find a way to abstract
and re-use the<br>
&gt; &gt; &gt; &nbsp;&gt; mature resolution logic from the OSGi reference
implementation *as* the<br>
&gt; &gt; &gt; &nbsp;&gt; one implementation to rule them all.<br>
&gt; &gt; &gt; &nbsp;&gt;<br>
&gt; &gt; &gt; &nbsp;&gt; // Bryan<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Glyn<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; ------------------------------------------------------------------------<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; /<br>
&gt; &gt; &gt; /<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; /Unless stated otherwise above:<br>
&gt; &gt; &gt; IBM United Kingdom Limited - Registered in England and Wales
with number<br>
&gt; &gt; &gt; 741598.<br>
&gt; &gt; &gt; Registered office: PO Box 41, North Harbour, Portsmouth,
<br>
&gt; Hampshire PO6 3AU/<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; <br>
&gt; Glyn<br>
&gt; <br>
&gt; <br>
&gt; <br>
</font></tt>
<br><tt><font size=2>&gt; Unless stated otherwise above:<br>
&gt; IBM United Kingdom Limited - Registered in England and Wales with
<br>
&gt; number 741598. <br>
&gt; Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire
PO6 3AU </font></tt>
<br><tt><font size=2>&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
</font></tt><font size=3 face="sans-serif"><br>
</font>
<br><font size=3 face="sans-serif"><br>
</font>
<hr><font size=2 face="sans-serif"><br>
<i><br>
</i></font>
<p><font size=2 face="sans-serif"><i>Unless stated otherwise above:<br>
IBM United Kingdom Limited - Registered in England and Wales with number
741598. <br>
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU</i></font>
<p><font size=2 face="sans-serif"><br>
</font><font size=3 face="sans-serif"><br>
</font>
<br>
<br><font size=3 face="sans-serif"><br>
</font>