Search in sources :

Example 61 with ModuleLoadException

use of org.jboss.modules.ModuleLoadException in project jboss-modules by jboss-modules.

the class __RedirectedUtils method loadProvider.

static <T> Supplier<T> loadProvider(String id, Class<T> intf, ModuleLoader moduleLoader, String name) {
    Module module;
    try {
        module = moduleLoader.loadModule(id);
    } catch (ModuleLoadException e) {
        getModuleLogger().providerUnloadable(id, null);
        return null;
    }
    ModuleClassLoader classLoader = module.getClassLoader();
    return loadProvider(intf, classLoader, name);
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) ModuleClassLoader(org.jboss.modules.ModuleClassLoader) Module(org.jboss.modules.Module)

Example 62 with ModuleLoadException

use of org.jboss.modules.ModuleLoadException in project pentaho-platform by pentaho.

the class SystemPackageExtrapolatorTest method testJBossProvider.

@Test
public void testJBossProvider() {
    SystemPackageExtrapolator.JBossModulePackageProvider jBossModulePackageProvider = new SystemPackageExtrapolator.JBossModulePackageProvider();
    Set<String> packages = jBossModulePackageProvider.getPackages();
    assertThat(packages, is(empty()));
    ModuleIdentifier moduleIdentifier = ModuleIdentifier.create("org.pentaho.test.module");
    ModuleSpec.Builder builder = ModuleSpec.build(moduleIdentifier);
    builder.addDependency(DependencySpec.createSystemDependencySpec(new HashSet<String>(Arrays.asList("org.apache", "org.apache.logging.log4j"))));
    final ModuleSpec moduleSpec = builder.create();
    ModuleLoader loader = new ModuleLoader(new ModuleFinder[] { new ModuleFinder() {

        @Override
        public ModuleSpec findModule(ModuleIdentifier moduleIdentifier, ModuleLoader moduleLoader) throws ModuleLoadException {
            return moduleSpec;
        }
    } });
    try {
        Module module = loader.loadModule(moduleIdentifier);
        jBossModulePackageProvider.setModule(module);
    } catch (ModuleLoadException e) {
        e.printStackTrace();
    }
    packages = jBossModulePackageProvider.getPackages();
    assertThat(packages, contains("org.apache.logging.log4j", "org.apache"));
    assertThat(packages, not(contains("org.not.there")));
}
Also used : ModuleLoadException(org.jboss.modules.ModuleLoadException) ModuleLoader(org.jboss.modules.ModuleLoader) ModuleFinder(org.jboss.modules.ModuleFinder) ModuleSpec(org.jboss.modules.ModuleSpec) ModuleIdentifier(org.jboss.modules.ModuleIdentifier) Module(org.jboss.modules.Module) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ModuleLoadException (org.jboss.modules.ModuleLoadException)62 Module (org.jboss.modules.Module)30 IOException (java.io.IOException)17 ModuleIdentifier (org.jboss.modules.ModuleIdentifier)13 ModuleSpec (org.jboss.modules.ModuleSpec)12 ModuleLoader (org.jboss.modules.ModuleLoader)10 Test (org.junit.Test)9 URL (java.net.URL)8 File (java.io.File)7 InputStream (java.io.InputStream)7 ArrayList (java.util.ArrayList)7 ModuleClassLoader (org.jboss.modules.ModuleClassLoader)7 HashSet (java.util.HashSet)6 OperationFailedException (org.jboss.as.controller.OperationFailedException)6 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)6 ModelNode (org.jboss.dmr.ModelNode)6 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)5 TldMetaData (org.jboss.metadata.web.spec.TldMetaData)5 ModuleNotFoundException (org.jboss.modules.ModuleNotFoundException)5 HashMap (java.util.HashMap)4