Search in sources :

Example 11 with Types

use of org.glassfish.hk2.classmodel.reflect.Types 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

Types (org.glassfish.hk2.classmodel.reflect.Types)6 ArrayList (java.util.ArrayList)3 AnnotationModel (org.glassfish.hk2.classmodel.reflect.AnnotationModel)3 AnnotationType (org.glassfish.hk2.classmodel.reflect.AnnotationType)3 Type (org.glassfish.hk2.classmodel.reflect.Type)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Properties (java.util.Properties)2 MultiException (org.glassfish.hk2.api.MultiException)2 Parser (org.glassfish.hk2.classmodel.reflect.Parser)2 ParsingContext (org.glassfish.hk2.classmodel.reflect.ParsingContext)2 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)1 Cluster (com.sun.enterprise.config.serverbeans.Cluster)1 Method (java.lang.reflect.Method)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 PrivilegedActionException (java.security.PrivilegedActionException)1 Collection (java.util.Collection)1 Hashtable (java.util.Hashtable)1 LinkedList (java.util.LinkedList)1