Package org.glassfish.hk2.utilities

Examples of org.glassfish.hk2.utilities.BuilderHelper


        classLoaderHolder = new Holder.Impl<ClassLoader>(cl);
    }

    public void populate(InhabitantsParsingContextGenerator ipcgen) {
        logger.log(Level.FINER, "Starting to introspect");
        ParsingContext context = ipcgen.getContext();
        InhabitantIntrospectionScanner is = new InhabitantIntrospectionScanner(context);
        try {
            ip.parse(is, classLoaderHolder);
        } catch (IOException e) {
            throw new RuntimeException(e);
View Full Code Here


                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);
                }
            }
        }
View Full Code Here

                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);
                }
            }
        }
View Full Code Here

        Types types = getTypes(context);
        if (types != null) {
            Iterator<Type> typesIter = types.getAllTypes().iterator();
            while (typesIter.hasNext()) {
                Type type = typesIter.next();
                if (!(type instanceof AnnotationType)) {
                    Iterator<AnnotationModel> annotations = type.getAnnotations().iterator();
                    while (annotations.hasNext()) {
                        AnnotationModel am = annotations.next();
                        AnnotationType at = am.getType();
                        if (isCDIEnablingAnnotation(at) && type.wasDefinedIn(paths)) {
                            if (!result.contains(at.getName())) {
                                result.add(at.getName());
                            }
                        }
                    }
View Full Code Here

        Types types = getTypes(context);
        if (types != null) {
            Iterator<Type> typesIter = types.getAllTypes().iterator();
            while (typesIter.hasNext()) {
                Type type = typesIter.next();
                if (!(type instanceof AnnotationType)) {
                    Iterator<AnnotationModel> annotations = type.getAnnotations().iterator();
                    while (annotations.hasNext()) {
                        AnnotationModel am = annotations.next();
                        AnnotationType at = am.getType();
                        if (isCDIEnablingAnnotation(at)) {
                            if (!result.contains(at.getName())) {
View Full Code Here

        Types types = getTypes(context);
        if (types != null) {
            Iterator<Type> typesIter = types.getAllTypes().iterator();
            while (typesIter.hasNext()) {
                Type type = typesIter.next();
                if (!(type instanceof AnnotationType)) {
                    Iterator<AnnotationModel> annotations = type.getAnnotations().iterator();
                    while (annotations.hasNext()) {
                        AnnotationModel am = annotations.next();
                        AnnotationType at = am.getType();
                        if (isCDIEnablingAnnotation(at)) {
                            if (!result.contains(at.getName())) {
                                result.add(type.getName());
                            }
                        }
                    }
                }
            }
View Full Code Here

     * @return true, if there is at least one bean annotated with a qualified annotation in the specified paths
     */
    public static boolean hasCDIEnablingAnnotations(DeploymentContext context, Collection<URI> paths) {
        List<String> result = new ArrayList<String>();

        Types types = getTypes(context);
        if (types != null) {
            Iterator<Type> typesIter = types.getAllTypes().iterator();
            while (typesIter.hasNext()) {
                Type type = typesIter.next();
                if (!(type instanceof AnnotationType)) {
                    Iterator<AnnotationModel> annotations = type.getAnnotations().iterator();
                    while (annotations.hasNext()) {
View Full Code Here

     * @return An array of annotation type names; The array could be empty if none are found.
     */
    public static String[] getCDIEnablingAnnotations(DeploymentContext context) {
        List<String> result = new ArrayList<String>();

        Types types = getTypes(context);
        if (types != null) {
            Iterator<Type> typesIter = types.getAllTypes().iterator();
            while (typesIter.hasNext()) {
                Type type = typesIter.next();
                if (!(type instanceof AnnotationType)) {
                    Iterator<AnnotationModel> annotations = type.getAnnotations().iterator();
                    while (annotations.hasNext()) {
View Full Code Here

     * @return A collection of class names; The collection could be empty if none are found.
     */
    public static Collection<String> getCDIAnnotatedClassNames(DeploymentContext context) {
        Set<String> result = new HashSet<String>();

        Types types = getTypes(context);
        if (types != null) {
            Iterator<Type> typesIter = types.getAllTypes().iterator();
            while (typesIter.hasNext()) {
                Type type = typesIter.next();
                if (!(type instanceof AnnotationType)) {
                    Iterator<AnnotationModel> annotations = type.getAnnotations().iterator();
                    while (annotations.hasNext()) {
View Full Code Here


    private static Types getTypes(DeploymentContext context) {
        String metadataKey = Types.class.getName();

        Types types = (Types) context.getTransientAppMetadata().get(metadataKey);
        while (types == null) {
            context = ((ExtendedDeploymentContext) context).getParentContext();
            if (context != null) {
                types = (Types) context.getTransientAppMetadata().get(metadataKey);
            } else {
View Full Code Here

TOP

Related Classes of org.glassfish.hk2.utilities.BuilderHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.