use of org.glassfish.hk2.classmodel.reflect.util.ParsingConfig in project Payara by payara.
the class ApplicationProcessedDocument method getTypes.
public static Types getTypes() throws IOException, InterruptedException {
synchronized (instance) {
if (allTypes == null) {
File userDir = new File(System.getProperty("user.dir"));
File modelDir = new File(userDir, "target" + File.separator + "test-classes");
if (modelDir.exists()) {
ParsingContext pc = (new ParsingContext.Builder().config(new ParsingConfig() {
@Override
public Set<String> getAnnotationsOfInterest() {
return Collections.emptySet();
}
@Override
public Set<String> getTypesOfInterest() {
return Collections.emptySet();
}
@Override
public boolean modelUnAnnotatedMembers() {
return true;
}
})).build();
Parser parser = new Parser(pc);
parser.parse(modelDir, null);
Exception[] exceptions = parser.awaitTermination(100, TimeUnit.DAYS);
if (exceptions != null) {
for (Exception e : exceptions) {
System.out.println("Found Exception ! : " + e);
}
Assert.assertTrue("Exceptions returned", exceptions.length == 0);
}
allTypes = pc.getTypes();
}
}
}
return allTypes;
}
use of org.glassfish.hk2.classmodel.reflect.util.ParsingConfig in project Payara by payara.
the class ApplicationLifecycle method getDeployableParser.
public Parser getDeployableParser(ReadableArchive source, boolean skipScanExternalLibProp, boolean modelUnAnnotatedMembers, StructuredDeploymentTracing tracing, Logger logger) throws IOException {
try {
ResourceLocator locator = determineLocator();
// scan the jar and store the result in the deployment context.
ParsingContext.Builder parsingContextBuilder = new ParsingContext.Builder().logger(logger).executorService(executorService.getUnderlyingExecutorService()).config(new ParsingConfig() {
@Override
public Set<String> getAnnotationsOfInterest() {
return Collections.emptySet();
}
@Override
public Set<String> getTypesOfInterest() {
return Collections.emptySet();
}
@Override
public boolean modelUnAnnotatedMembers() {
return modelUnAnnotatedMembers;
}
});
// workaround bug in Builder
parsingContextBuilder.locator(locator);
ParsingContext parsingContext = parsingContextBuilder.build();
Parser parser = new Parser(parsingContext);
ReadableArchiveScannerAdapter scannerAdapter = new ReadableArchiveScannerAdapter(parser, source);
DeploymentSpan mainScanSpan = tracing.startSpan(DeploymentTracing.AppStage.CLASS_SCANNING, source.getName());
parser.parse(scannerAdapter, () -> mainScanSpan.close());
for (ReadableArchive externalLibArchive : getExternalLibraries(source, skipScanExternalLibProp)) {
ReadableArchiveScannerAdapter libAdapter = null;
try {
DeploymentSpan span = tracing.startSpan(DeploymentTracing.AppStage.CLASS_SCANNING, externalLibArchive.getName());
libAdapter = new ReadableArchiveScannerAdapter(parser, externalLibArchive);
parser.parse(libAdapter, () -> span.close());
} finally {
if (libAdapter != null) {
libAdapter.close();
}
}
}
parser.awaitTermination();
scannerAdapter.close();
return parser;
} catch (InterruptedException e) {
throw new IOException(e);
}
}
Aggregations