use of org.glassfish.hk2.classmodel.reflect.ParsingContext in project Payara by payara.
the class JavaEEScanner method initTypes.
protected void initTypes(File file) throws IOException {
ParsingContext context = new ParsingContext.Builder().build();
Parser cp = new Parser(context);
cp.parse(file, null);
try {
cp.awaitTermination();
} catch (InterruptedException e) {
throw new IOException(e);
}
types = cp.getContext().getTypes();
}
use of org.glassfish.hk2.classmodel.reflect.ParsingContext in project Payara by payara.
the class ApplicationLifecycle method getDeployableTypes.
@Override
public Types getDeployableTypes(DeploymentContext context) throws IOException {
synchronized (context) {
Types types = context.getTransientAppMetaData(Types.class.getName(), Types.class);
if (types != null) {
return types;
} else {
try {
// scan the jar and store the result in the deployment context.
ParsingContext parsingContext = new ParsingContext.Builder().logger(context.getLogger()).executorService(executorService).build();
Parser parser = new Parser(parsingContext);
ReadableArchiveScannerAdapter scannerAdapter = new ReadableArchiveScannerAdapter(parser, context.getSource());
parser.parse(scannerAdapter, null);
for (ReadableArchive externalLibArchive : getExternalLibraries(context)) {
ReadableArchiveScannerAdapter libAdapter = null;
try {
libAdapter = new ReadableArchiveScannerAdapter(parser, externalLibArchive);
parser.parse(libAdapter, null);
} finally {
if (libAdapter != null) {
libAdapter.close();
}
}
}
parser.awaitTermination();
scannerAdapter.close();
context.addTransientAppMetaData(Types.class.getName(), parsingContext.getTypes());
context.addTransientAppMetaData(Parser.class.getName(), parser);
return parsingContext.getTypes();
} catch (InterruptedException e) {
throw new IOException(e);
}
}
}
}
Aggregations