-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generation based on all class in a package
(packageName parameter)
- Loading branch information
Showing
12 changed files
with
138 additions
and
63 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
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
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
36 changes: 36 additions & 0 deletions
36
src/main/java/org/fugerit/java/nhg/config/AccessingAllClassesInPackage.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,36 @@ | ||
package org.fugerit.java.nhg.config; | ||
|
||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.fugerit.java.core.cfg.ConfigRuntimeException; | ||
import org.fugerit.java.core.function.SafeFunction; | ||
import org.fugerit.java.core.lang.helpers.ClassHelper; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
@Slf4j | ||
public class AccessingAllClassesInPackage { | ||
|
||
public static Set<Class<?>> findAllClassesUsingClassLoader(String packageName) throws ConfigRuntimeException { | ||
return SafeFunction.get( () -> { | ||
InputStream stream = ClassHelper.getDefaultClassLoader().getResourceAsStream(packageName.replaceAll("[.]", "/")); | ||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); | ||
return reader.lines() | ||
.filter(line -> line.endsWith(".class")) | ||
.map(line -> getClass(line, packageName)) | ||
.collect(Collectors.toSet()); | ||
} ); | ||
} | ||
|
||
private static Class<?> getClass(String className, String packageName) { | ||
return SafeFunction.get( () -> { | ||
log.debug( "packageName : {}, className : {}", packageName, className ); | ||
return Class.forName(packageName+"."+className.substring(0, className.lastIndexOf('.'))); | ||
} ); | ||
} | ||
|
||
} |
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
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
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
11 changes: 11 additions & 0 deletions
11
src/test/resources/tool/config/native-helper-config-package.yaml
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,11 @@ | ||
# native-helper-graalvm generation configuration | ||
--- | ||
reflectConfigJsonOutputPath: target/native-image-package/reflect-config.json | ||
createParentDirectory: true | ||
generate: | ||
- packageName: org.fugerit.java.nhg.reflect.config | ||
excludeClassNames: EntryHelper | ||
mode: getters | ||
- packageName: org.fugerit.java.nhg.config.model | ||
mode: getters_setters | ||
typeReachable: org.fugerit.java.nhg.config.NativeHelperFacade |
This file was deleted.
Oops, something went wrong.