Hello,<br>I have the following requirement to implement:<br><ul><li>I have a server that:</li><ul><li> creates at runtime new classloaders that must see only parts of the server classpath (kind of private ClassLoader):</li>
<li>these new classloaders must not see each others<br></li></ul></ul><p>Reading and testing JBoss Modules it seems to me the solution to my issue.</p>I configured a set of modules and succeeded starting my Server with a module.<br>
<br>Now I am trying to create dynamically the new classloaders which are composed of :<br><ul><li>Server public API</li><li>Set of JARs embedded in an archive and only visible to the newly created ClassLoader</li></ul><p>
So my idea was to do the following:</p><ul><li>Create a new Module that would have as dependencies:</li><ul><li> the server module (which has only exported a subset of classes)</li><li>a set of new JARs <br></li></ul></ul>
<p>So code would look something like:</p><p> ModuleIdentifier identifier = ModuleIdentifier.fromString("my new class loader");<br> Builder builder = ModuleSpec.build(identifier);<br> DependencySpec dependencySpec = <br>
DependencySpec.createModuleDependencySpec(<br> ModuleIdentifier.create("com.ubikingenierie.myserver"));<br> builder.addDependency(dependencySpec);</p><div style="background-color:transparent" class="line" id="LC78">
<span class="n">builder</span><span class="o">.</span><span class="na">addResourceRoot</span><span class="o">(</span><span class="n">ResourceLoaderSpec</span><span class="o">.</span><span class="na">createResourceLoaderSpec</span><span class="o">(</span><span class="n">ResourceLoaders</span><span class="o">.</span><span class="na">createJarResourceLoader</span><span class="o">(</span></div>
<div style="background-color:transparent" class="line" id="LC79"> <span class="s">"name-of-jar1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">JarFile</span><span class="o">(</span><span class="k">new</span> <span class="n">File</span><span class="o">(</span><span class="s">"path to jar1"</span><span class="o">)))));</span></div>
<div style="background-color:transparent" class="line" id="LC78"><span class="n">builder</span><span class="o">.</span><span class="na">addResourceRoot</span><span class="o">(</span><span class="n">ResourceLoaderSpec</span><span class="o">.</span><span class="na">createResourceLoaderSpec</span><span class="o">(</span><span class="n">ResourceLoaders</span><span class="o">.</span><span class="na">createJarResourceLoader</span><span class="o">(</span></div>
<div style="background-color:transparent" class="line" id="LC79"> <span class="s">"name-of-jar2"</span><span class="o">,</span> <span class="k">new</span> <span class="n">JarFile</span><span class="o">(</span><span class="k">new</span> <span class="n">File</span><span class="o">(</span><span class="s">"path to jar2"</span><span class="o">)))));</span></div>
<p><br> ModuleSpec moduleSpec = builder.create();<br>...> > What's next ??????<br></p><p><br></p><p>I am stuck here because I don't understand how from this to create the ClassLoader as I need a Module Loader to build the Module then access ClassLoader<br>
</p><p>And the issue is which one ? cause to get access to "com.ubikingenierie.myserver" I need the root one which I could access like this:</p><ul><li>Module mod = ((ModuleClassLoader)Thread.currentThread.getContextClassLoaderr()).getModule().getModuleLoader() => which is a LocalModuleLoader<br>
</li></ul><p>But I don't see how to make it load my module , cause If I call loadModule it won't find ""my new class loader" as it's not in it.</p><p><br></p><p>And If I create a new subclass of ModuleLoader I don't see how to make it use LocalModuleLoader for existing modules.<br>
</p>I looked at ClassifyingModuleLoader which seemed to be a solution but I don't understand how to use it (no doc , no test case ...)<br><p><br></p><p>Anyone can help ?</p><p>Thanks</p><p>Regards<br></p>-- <br>Cordialement.<br>
Philippe M.<br><br><br><br>