use of org.jboss.modules.LocalModuleLoader in project wildfly by wildfly.
the class HostExcludesTestCase method retrieveAvailableExtensions.
/**
* Retrieve the list of all modules which export locally a resource that implements a org.jboss.as.controller.Extension.
* This list is considered the list of all available extensions that can be added to a server.
*
* It is assumed that the module which is added as an extension has the org.jboss.as.controller.Extension service as
* a local resource.
*/
private Set<String> retrieveAvailableExtensions() throws IOException {
final Set<String> result = new HashSet<>();
LocalModuleLoader ml = new LocalModuleLoader(getModuleRoots());
Iterator<String> moduleNames = ml.iterateModules((String) null, true);
while (moduleNames.hasNext()) {
String moduleName = moduleNames.next();
Module module;
try {
module = ml.loadModule(moduleName);
List<Resource> resources = module.getClassLoader().loadResourceLocal("META-INF/services/org.jboss.as.controller.Extension");
if (!resources.isEmpty()) {
result.add(moduleName);
}
} catch (ModuleLoadException e) {
Logger.getLogger(HostExcludesTestCase.class).warn("Failed to load module " + moduleName + " to check if it is an extension", e);
}
}
return result;
}
use of org.jboss.modules.LocalModuleLoader in project wildfly by wildfly.
the class PermissionParserExpressionsTestCase method test.
@Test
public void test() throws DeploymentUnitProcessingException {
System.setProperty("CLASS_NAME", "java.io.FilePermission");
System.setProperty("NAME_A", "A");
System.setProperty("NAME_B", "B");
System.setProperty("NAME_C", "C");
System.setProperty("ACTION_READ", "read");
File[] modulePaths = getModulePaths();
LocalModuleLoader ml = new LocalModuleLoader(modulePaths);
List<PermissionFactory> permissionFactories = parsePermissions(fileUnderTest, ml, identifier, functionExpand);
Assert.assertEquals("Unexpected number of permissions", 3, permissionFactories.size());
Permission permission = permissionFactories.get(0).construct();
Assert.assertNotNull(permission);
Assert.assertTrue("Unexpected permission class", permission instanceof FilePermission);
Assert.assertEquals("Unexpected permission name", permission.getName(), "A");
Assert.assertEquals("Unexpected permission action", permission.getActions(), "read");
permission = permissionFactories.get(1).construct();
Assert.assertNotNull(permission);
Assert.assertTrue("Unexpected permission class", permission instanceof FilePermission);
Assert.assertEquals("Unexpected permission name", permission.getName(), "B");
Assert.assertEquals("Unexpected permission action", permission.getActions(), "read");
permission = permissionFactories.get(2).construct();
Assert.assertNotNull(permission);
Assert.assertTrue("Unexpected permission class", permission instanceof FilePermission);
Assert.assertEquals("Unexpected permission name", permission.getName(), "C");
Assert.assertEquals("Unexpected permission action", permission.getActions(), "write");
}
use of org.jboss.modules.LocalModuleLoader in project jboss-modules by jboss-modules.
the class PermissionsTest method setupModuleLoader.
@Before
public void setupModuleLoader() throws Exception {
System.setProperty("jboss.home.dir", JBOSS_HOME_DIR_VALUE);
final File repoRoot = getResource("test/repo");
moduleLoader = new LocalModuleLoader(new File[] { repoRoot });
}
Aggregations