use of org.wildfly.swarm.spi.api.Fraction in project wildfly-swarm by wildfly-swarm.
the class FractionProducingExtension method uninstalledFractionClasses.
@SuppressWarnings("unchecked")
private Set<Class<? extends Fraction>> uninstalledFractionClasses(Set<Type> installedClasses) throws ModuleLoadException, IOException, ClassNotFoundException {
Set<String> installedClassNames = installedClasses.stream().map(Type::getTypeName).collect(Collectors.toSet());
List<String> moduleNames = ApplicationEnvironment.get().bootstrapModules();
ClassLoader cl = Module.getBootModuleLoader().loadModule("swarm.container").getClassLoader();
Set<Class<? extends Fraction>> fractionClasses = new HashSet<>();
for (String moduleName : moduleNames) {
Module module = Module.getBootModuleLoader().loadModule(moduleName);
InputStream indexStream = module.getClassLoader().getResourceAsStream("META-INF/jandex.idx");
if (indexStream != null) {
IndexReader reader = new IndexReader(indexStream);
Index index = reader.read();
Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(Fraction.class.getName()));
for (ClassInfo impl : impls) {
if (!installedClassNames.contains(impl.name().toString())) {
Class<? extends Fraction> fractionClass = (Class<? extends Fraction>) cl.loadClass(impl.name().toString());
fractionClasses.add(fractionClass);
}
}
}
}
return fractionClasses;
}
use of org.wildfly.swarm.spi.api.Fraction in project wildfly-swarm by wildfly-swarm.
the class ExtensionMarshaller method marshal.
public void marshal(List<ModelNode> list) {
List<ModelNode> extensions = new ArrayList<>();
Set<String> seen = new HashSet<>();
for (Fraction each : this.fractions) {
WildFlyExtension anno = each.getClass().getAnnotation(WildFlyExtension.class);
if (anno != null) {
if (anno.module() != null && !anno.module().equals("")) {
String module = anno.module();
if (!seen.contains(module)) {
ModelNode node = new ModelNode();
node.get(OP_ADDR).set(EXTENSION, anno.module());
node.get(OP).set(ADD);
extensions.add(node);
seen.add(module);
}
}
}
}
list.addAll(0, extensions);
}
use of org.wildfly.swarm.spi.api.Fraction in project wildfly-swarm by wildfly-swarm.
the class SubsystemMarshaller method marshal.
public void marshal(List<ModelNode> list) {
for (Fraction each : this.fractions) {
MarshalDMR anno = each.getClass().getAnnotation(MarshalDMR.class);
if (anno != null) {
try {
try (AutoCloseable handle = Performance.time("marshall " + each.getClass().getSimpleName())) {
LinkedList<ModelNode> subList = Marshaller.marshal(each);
if (!isAlreadyConfigured(subList, list)) {
list.addAll(subList);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
WildFlySubsystem subsysAnno = each.getClass().getAnnotation(WildFlySubsystem.class);
if (subsysAnno != null) {
PathAddress address = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, subsysAnno.value()));
if (!isAlreadyConfigured(address.toModelNode(), list)) {
ModelNode node = new ModelNode();
node.get(OP_ADDR).set(address.toModelNode());
node.get(OP).set(ADD);
list.add(node);
}
}
}
}
}
Aggregations