-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
155 additions
and
375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...oyment/src/main/java/io/quarkiverse/jasperreports/deployment/AbstractJandexProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package io.quarkiverse.jasperreports.deployment; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import org.jboss.jandex.ClassInfo; | ||
import org.jboss.jandex.DotName; | ||
|
||
import io.quarkus.deployment.builditem.CombinedIndexBuildItem; | ||
import io.quarkus.logging.Log; | ||
|
||
abstract class AbstractJandexProcessor { | ||
|
||
protected List<String> collectClassesInPackage(CombinedIndexBuildItem combinedIndex, String packageName) { | ||
final List<String> classes = new ArrayList<>(); | ||
final List<DotName> packages = new ArrayList<>(combinedIndex.getIndex().getSubpackages(packageName)); | ||
packages.add(DotName.createSimple(packageName)); | ||
for (DotName aPackage : packages) { | ||
final List<String> packageClasses = combinedIndex.getIndex() | ||
.getClassesInPackage(aPackage) | ||
.stream() | ||
.map(ClassInfo::toString) | ||
.toList(); | ||
classes.addAll(packageClasses); | ||
} | ||
Log.debugf("Package Classes: %s", classes); | ||
return classes; | ||
} | ||
|
||
protected List<String> collectInterfacesInPackage(CombinedIndexBuildItem combinedIndex, String packageName) { | ||
final List<String> classes = new ArrayList<>(); | ||
final List<DotName> packages = new ArrayList<>(combinedIndex.getIndex().getSubpackages(packageName)); | ||
packages.add(DotName.createSimple(packageName)); | ||
for (DotName aPackage : packages) { | ||
final List<String> packageClasses = combinedIndex.getIndex() | ||
.getClassesInPackage(aPackage) | ||
.stream() | ||
.filter(ClassInfo::isInterface) // Filter only interfaces | ||
.map(ClassInfo::toString) | ||
.toList(); | ||
classes.addAll(packageClasses); | ||
} | ||
Log.debugf("Package Interfaces: %s", classes); | ||
return classes; | ||
} | ||
|
||
protected List<String> collectSubclasses(CombinedIndexBuildItem combinedIndex, String className) { | ||
List<String> classes = combinedIndex.getIndex() | ||
.getAllKnownSubclasses(DotName.createSimple(className)) | ||
.stream() | ||
.map(ClassInfo::toString) | ||
.collect(Collectors.toList()); | ||
classes.add(className); | ||
Log.debugf("Subclasses: %s", classes); | ||
return classes; | ||
} | ||
|
||
protected List<String> collectImplementors(CombinedIndexBuildItem combinedIndex, String className) { | ||
Set<String> classes = combinedIndex.getIndex() | ||
.getAllKnownImplementors(DotName.createSimple(className)) | ||
.stream() | ||
.map(ClassInfo::toString) | ||
.collect(Collectors.toCollection(HashSet::new)); | ||
classes.add(className); | ||
Set<String> subclasses = new HashSet<>(); | ||
for (String implementationClass : classes) { | ||
subclasses.addAll(collectSubclasses(combinedIndex, implementationClass)); | ||
} | ||
classes.addAll(subclasses); | ||
Log.debugf("Implementors: %s", classes); | ||
return new ArrayList<>(classes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
deployment/src/main/java/io/quarkiverse/jasperreports/deployment/JaxenProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package io.quarkiverse.jasperreports.deployment; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.builditem.CombinedIndexBuildItem; | ||
import io.quarkus.deployment.builditem.IndexDependencyBuildItem; | ||
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; | ||
import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedPackageBuildItem; | ||
import io.quarkus.logging.Log; | ||
|
||
/** | ||
* A build step class responsible for registering classes related to the Jaxen library | ||
* for reflection and runtime initialization during the Quarkus build process. | ||
* <p> | ||
* Jaxen supports 4 XML libs DOM, DOM4J, JDOM, XOM but we want to use native DOM so we exclude all the other 3rd party libs from | ||
* classloading. | ||
* </p> | ||
*/ | ||
class JaxenProcessor extends AbstractJandexProcessor { | ||
|
||
@BuildStep | ||
void indexTransitiveDependencies(BuildProducer<IndexDependencyBuildItem> index) { | ||
//index.produce(new IndexDependencyBuildItem("jaxen", "jaxen")); | ||
} | ||
|
||
@BuildStep | ||
void runtimeJaxenInitializedClasses(CombinedIndexBuildItem combinedIndex, | ||
BuildProducer<RuntimeInitializedPackageBuildItem> runtimeInitializedPackages) { | ||
//@formatter:off | ||
List<String> classes = new ArrayList<>(Stream.of( | ||
org.jaxen.dom4j.DocumentNavigator.class.getPackageName(), | ||
org.jaxen.jdom.DocumentNavigator.class.getPackageName(), | ||
org.jaxen.xom.DocumentNavigator.class.getPackageName() | ||
).toList()); | ||
//@formatter:on | ||
Log.warnf("Jaxen Runtime: %s", classes); | ||
classes.stream() | ||
.map(RuntimeInitializedPackageBuildItem::new) | ||
.forEach(runtimeInitializedPackages::produce); | ||
} | ||
|
||
@BuildStep | ||
void registerJaxenForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, | ||
CombinedIndexBuildItem combinedIndex) { | ||
final List<String> classNames = new ArrayList<>(collectClassesInPackage(combinedIndex, | ||
net.sf.jasperreports.jaxen.util.xml.JaxenXPathExecuterFactory.class.getPackageName())); | ||
classNames.add(net.sf.jasperreports.jaxen.data.JaxenXmlDataSource.class.getName()); | ||
classNames.add(org.jaxen.saxpath.base.XPathReader.class.getName()); | ||
|
||
Log.warnf("Jaxen Reflection: %s", classNames); | ||
// methods and fields | ||
reflectiveClass.produce( | ||
ReflectiveClassBuildItem.builder(classNames.toArray(new String[0])).methods().fields().build()); | ||
} | ||
} |
Oops, something went wrong.