Search in sources :

Example 1 with ResourceLocator

use of org.glassfish.hk2.classmodel.reflect.util.ResourceLocator 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);
    }
}
Also used : ParsingConfig(org.glassfish.hk2.classmodel.reflect.util.ParsingConfig) ParsingContext(org.glassfish.hk2.classmodel.reflect.ParsingContext) DeploymentSpan(org.glassfish.internal.deployment.analysis.DeploymentSpan) IOException(java.io.IOException) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) ResourceLocator(org.glassfish.hk2.classmodel.reflect.util.ResourceLocator) Parser(org.glassfish.hk2.classmodel.reflect.Parser)

Aggregations

IOException (java.io.IOException)1 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)1 Parser (org.glassfish.hk2.classmodel.reflect.Parser)1 ParsingContext (org.glassfish.hk2.classmodel.reflect.ParsingContext)1 ParsingConfig (org.glassfish.hk2.classmodel.reflect.util.ParsingConfig)1 ResourceLocator (org.glassfish.hk2.classmodel.reflect.util.ResourceLocator)1 DeploymentSpan (org.glassfish.internal.deployment.analysis.DeploymentSpan)1