<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<tt>(Using this list since I couldn't find a place to ask JBoss
Modules question anywhere else, feel free to direct me there if
there's one)<br>
<br>
Hello everyone :)<br>
<br>
I have been using JBoss Modules for one of the projects I'm
involved in. The usage there is pretty much similar to how we use
it for setting up classloaders in WildFly server for deployments.
A new module M1 gets dynamically created and assigned to a
component and this module is added with dependencies to some
pre-defined static modules A, B, C and such. M1 also gets N
number of resource roots (backed by ResourceLoaderSpec), each
pointing to a jar file within some well known directory. So to put
in some sort of a code, it looks like:<br>
<br>
// add each jar as a resource root for the module<br>
for (final File jar : jars) {<br>
final ResourceLoader jarResourceLoader;<br>
try {<br>
jarResourceLoader =
ResourceLoaders.createJarResourceLoader(jar.getName(), new
JarFile(jar));<br>
} catch (IOException e) {<br>
// log and continue<br>
logger.warn("....", e);<br>
continue;<br>
}<br>
moduleSpecBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(jarResourceLoader));<br>
}<br>
<br>
<br>
<br>
All works fine without any issues and the module M1 has access to
the resources in these jars. Now there are times where the
components for which I've created this module M1 and attach these
jars, "accidentally" ship/package jars which have resources
(classes to be precise) which are also exposed/present in one of
the dependency modules (remember A, B, C...). So this then leads
to the same old thing where I have go back and tell my users not
to package such jars.<br>
<br>
I want to try and make this a bit more robust and get away with
having to tell users not to package xyz jars. I had a look at the
ResourceLoaderSpec interface and it takes a PathFilter
<a class="moz-txt-link-freetext" href="https://github.com/jboss-modules/jboss-modules/blob/1.x/src/main/java/org/jboss/modules/ResourceLoaderSpec.java#L48">https://github.com/jboss-modules/jboss-modules/blob/1.x/src/main/java/org/jboss/modules/ResourceLoaderSpec.java#L48</a>
which gets me one step closer to what I want to achieve. So if I
know that static module A, B, C etc... expose classes belonging to
package foo.bar.blah, I can setup a PathFilter on these jar
resource loader to skip/decline the path in the accept() method. I
think that should work out fine (I need to test it out tonight)
and I wouldn't have to worry that some jar packaged within that
component will introduce these classes belonging to the foo.bar.blah
package. <br>
<br>
However, although it might work, I then have to keep a very close
vigil or rather keep inspecting what packages (or resources in
general) the modules A, B and C provide. Instead what I'm thinking
of is a "smart" PathFilter or anything along those lines whose
semantics would be to "skip/don't accept/filter out all those
resources, from a resource root, if the resource is provided by
any of the specified modules". So something like:<br>
<br>
ResourceLoaderSpec.createResourceLoaderSpec(jarResourceLoader, <b>PathFilters.excludeResourcesExposedByModules("A</b><b>:slot",
"B:slot", "C:slot" ...)</b>);<br>
<br>
<br>
Having looked at the JBoss Modules code, I don't think this is
possible currently. But that's OK. What I really want to check is,
is this something that would be feasible to implement (doesn't
have to be in JBoss Modules itself) and is there any obvious
issues with the approach? Also, is this something that would be
useful to have in JBoss Modules itself?<br>
<br>
<br>
-Jaikiran <br>
</tt>
</body>
</html>