Search in sources :

Example 1 with ParsingContext

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();
}
Also used : ParsingContext(org.glassfish.hk2.classmodel.reflect.ParsingContext) IOException(java.io.IOException) Parser(org.glassfish.hk2.classmodel.reflect.Parser)

Example 2 with ParsingContext

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);
            }
        }
    }
}
Also used : Types(org.glassfish.hk2.classmodel.reflect.Types) ParsingContext(org.glassfish.hk2.classmodel.reflect.ParsingContext) IOException(java.io.IOException) Parser(org.glassfish.hk2.classmodel.reflect.Parser)

Aggregations

IOException (java.io.IOException)2 Parser (org.glassfish.hk2.classmodel.reflect.Parser)2 ParsingContext (org.glassfish.hk2.classmodel.reflect.ParsingContext)2 Types (org.glassfish.hk2.classmodel.reflect.Types)1