use of org.jboss.modules.Resource in project wildfly-swarm by wildfly-swarm.
the class Swarm method initializeConfigFiltersFatJar.
private void initializeConfigFiltersFatJar() throws ModuleLoadException, IOException, ClassNotFoundException {
Indexer indexer = new Indexer();
Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME);
Iterator<Resource> iter = appModule.iterateResources(PathFilters.acceptAll());
while (iter.hasNext()) {
Resource each = iter.next();
if (each.getName().endsWith(".class")) {
if (!each.getName().equals("module-info.class")) {
try (InputStream is = each.openStream()) {
indexer.index(is);
} catch (IOException e) {
// ignore
}
}
}
}
Index index = indexer.complete();
Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(ConfigurationFilter.class.getName()));
for (ClassInfo each : impls) {
String name = each.name().toString();
Class<? extends ConfigurationFilter> cls = (Class<? extends ConfigurationFilter>) appModule.getClassLoader().loadClass(name);
try {
ConfigurationFilter filter = cls.newInstance();
this.configView.withFilter(filter);
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
}
}
use of org.jboss.modules.Resource in project ceylon by eclipse.
the class OnDemandLocalLoader method loadResourceLocal.
public List<Resource> loadResourceLocal(String name) {
String[] tokens = name.split("/");
LocalLoader ll = doUpdate(tokens);
return (ll != null ? ll.loadResourceLocal(name) : Collections.<Resource>emptyList());
}
use of org.jboss.modules.Resource 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.Resource in project wildfly by wildfly.
the class ExternalBeanArchiveProcessor method findExportedLocalBeansXml.
private Set<URL> findExportedLocalBeansXml(Module dependencyModule) {
HashSet<URL> ret = new HashSet<>();
Enumeration<URL> exported = dependencyModule.getExportedResources(META_INF_BEANS_XML);
if (exported.hasMoreElements()) {
Set<URL> exportedSet = new HashSet<>(Collections.list(exported));
Collection<Resource> locals = dependencyModule.getClassLoader().loadResourceLocal(META_INF_BEANS_XML);
if (!locals.isEmpty()) {
for (Resource local : locals) {
URL url = local.getURL();
if (exportedSet.contains(url)) {
ret.add(url);
}
}
return ret;
}
}
return null;
}
use of org.jboss.modules.Resource in project wildfly by wildfly.
the class ExternalTldParsingDeploymentProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (!DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
// Skip non web deployments
return;
}
final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
if (warMetaData == null || warMetaData.getMergedJBossWebMetaData() == null) {
return;
}
TldsMetaData tldsMetaData = deploymentUnit.getAttachment(TldsMetaData.ATTACHMENT_KEY);
Map<String, TldMetaData> tlds = tldsMetaData.getTlds();
Set<String> sharedTldUris = new HashSet<>();
for (TldMetaData shared : tldsMetaData.getSharedTlds(deploymentUnit)) {
sharedTldUris.add(shared.getUri());
}
Module module = deploymentUnit.getAttachment(Attachments.MODULE);
try {
Iterator<Resource> resources = module.globResources("META-INF/**.tld");
while (resources.hasNext()) {
final Resource resource = resources.next();
// waste time re-parsing them
if (resource.getURL().toString().contains("com/sun/jsf-impl/main")) {
continue;
}
if (resource.getName().startsWith("META-INF/")) {
if (tlds.containsKey(resource.getName())) {
continue;
}
if (resource.getURL().getProtocol().equals("vfs")) {
continue;
}
final TldMetaData value = parseTLD(resource);
if (sharedTldUris.contains(value.getUri())) {
// don't re-include shared TLD's
continue;
}
String key = "/" + resource.getName();
if (!tlds.containsKey(key)) {
tlds.put(key, value);
}
if (!tlds.containsKey(value.getUri())) {
tlds.put(value.getUri(), value);
}
if (value.getListeners() != null) {
for (ListenerMetaData l : value.getListeners()) {
List<ListenerMetaData> listeners = warMetaData.getMergedJBossWebMetaData().getListeners();
if (listeners == null) {
warMetaData.getMergedJBossWebMetaData().setListeners(listeners = new ArrayList<ListenerMetaData>());
}
listeners.add(l);
}
}
}
}
} catch (ModuleLoadException e) {
throw new DeploymentUnitProcessingException(e);
}
}
Aggregations