Examples of DescriptorImpl


Examples of org.glassfish.hk2.utilities.DescriptorImpl

                            try {
                                boolean readOne = false;

                                do {
                                    DescriptorImpl descriptorImpl = new DescriptorImpl();

                                    readOne = descriptorImpl.readObject(br);

                                    if (readOne) {
                                        descriptors.add(descriptorImpl);
                                    }
                                } while (readOne);
View Full Code Here

Examples of org.glassfish.hk2.utilities.DescriptorImpl

            if (activeDescriptors != null) {

                // use the copy constructor to create (nonactive) descriptor for serialization into the cache
                descriptors = new ArrayList<Descriptor>();
                for (Descriptor d : activeDescriptors) {
                    descriptors.add(new DescriptorImpl(d));
                }

                module.getModuleDefinition().getMetadata().addDescriptors(name, descriptors);

            }
        } else {
            activeDescriptors = new ArrayList<ActiveDescriptor>();

            DynamicConfiguration dcs = createDynamicConfiguration(serviceLocator);
            for (Descriptor descriptor : descriptors) {
               
                DescriptorImpl di = (descriptor instanceof DescriptorImpl) ? (DescriptorImpl) descriptor : new DescriptorImpl(descriptor) ;

                // set the hk2loader
                DescriptorImpl descriptorImpl = new OsgiPopulatorPostProcessor(osgiModuleImpl).process(serviceLocator, di);

                if (descriptorImpl != null) {
                    activeDescriptors.add(dcs.bind(descriptorImpl, false));
                }
            }
View Full Code Here

Examples of org.glassfish.hk2.utilities.DescriptorImpl

         * @see org.objectweb.asm.MethodVisitor#visitEnd()
         */
        @Override
        public void visitEnd() {
            for (GenerateMethodAnnotationData methodGenerated : allAnnotationDataToAdd) {
                DescriptorImpl di = new DescriptorImpl();
                di.setImplementation(methodGenerated.getImplementation());
                for (String contract : methodGenerated.getContracts()) {
                    di.addAdvertisedContract(contract);
                }
                di.setScope(methodGenerated.getScope());
                if (methodGenerated.getName() != null) {
                    di.setName(methodGenerated.getName());
                }
               
                di.addMetadata(METHOD_ACTUAL, actualType);
                di.addMetadata(METHOD_NAME, methodName);
                di.addMetadata(PARENT_CONFIGURED, parentConfigured);
               
                if (verbose) {
                    System.out.println("Generated Descriptor for GenerateServiceFromMethod annotation: " + di);
                }
               
View Full Code Here

Examples of org.glassfish.hk2.utilities.DescriptorImpl

                String with = decorateData.getWith();
               
                GenerateMethodAnnotationData gbad = classLevelGenerators.get(with);
               
                if (gbad != null) {
                    DescriptorImpl generatedDescriptor = new DescriptorImpl();
                    generatedDescriptor.setImplementation(gbad.getImplementation());
                   
                    for (String contract : gbad.getContracts()) {
                        generatedDescriptor.addAdvertisedContract(contract);
                    }
                   
                    if (gbad.getName() != null) {
                        generatedDescriptor.setName(gbad.getName());
                    }
                   
                    generatedDescriptor.addMetadata(METHOD_ACTUAL, implName);
                    generatedDescriptor.addMetadata(METHOD_NAME, decorateData.getMethodName());
                    generatedDescriptor.addMetadata(PARENT_CONFIGURED, decorateData.getTargetType());
                   
                    if (verbose) {
                        System.out.println("Generated Descriptor for class-level GenerateServiceFromMethod annotation: " +
                            generatedDescriptor);
                    };
                   
                    generatedDescriptors.add(generatedDescriptor);
                   
                    return;
                }
               
            }
           
            if (verbose) {
                System.out.println("Class " + implName + " is not annotated with @Service");
            }
            return;
        }
       
        DescriptorImpl generatedDescriptor = new DescriptorImpl();
        generatedDescriptor.setImplementation(implName);
        if (scopeClass == null) {
            // The default for classes with Service is Singleton
            generatedDescriptor.setScope(Singleton.class.getName());
        }
        else {
            generatedDescriptor.setScope(scopeClass);
        }
       
        if (providedContracts != null) {
            for (String providedContract : providedContracts) {
                generatedDescriptor.addAdvertisedContract(providedContract);
            }
           
        }
        else {
            generatedDescriptor.addAdvertisedContract(implName);
            for (String iFace : iFaces) {
                generatedDescriptor.addAdvertisedContract(iFace);
            }
        }
       
        for (String qualifier : qualifiers) {
            generatedDescriptor.addQualifier(qualifier);
        }
       
        if (baseName != null) {
            generatedDescriptor.setName(baseName.getName());
        }
       
        generatedDescriptor.setClassAnalysisName(classAnalyzer);
        if (metadataString != null) {
            Map<String, List<String>> serviceMetadata = new HashMap<String, List<String>>();
           
            ReflectionHelper.parseServiceMetadataString(metadataString, serviceMetadata);
           
            generatedDescriptor.addMetadata(serviceMetadata);
        }
       
        if (rank != null) {
            generatedDescriptor.setRanking(rank.intValue());
        }
       
        if (useProxy != null) {
            generatedDescriptor.setProxiable(useProxy);
        }
       
        generatedDescriptor.setDescriptorVisibility(visibility);
       
        if (!metadata.isEmpty()) {
            for (Map.Entry<String, List<String>> entry : metadata.entrySet()) {
                String key = entry.getKey();
                List<String> values = entry.getValue();
               
                for (String value : values) {
                    generatedDescriptor.addMetadata(key, value);
                }
            }
        }
       
        if (verbose) {
View Full Code Here

Examples of org.glassfish.hk2.utilities.DescriptorImpl

        if (!PROVIDE.equals(name)) return null;
        if (!desc.startsWith("()")) return null;
        if (factoryMethodFound) return null;
        factoryMethodFound = true;
       
        DescriptorImpl asAFactory = new DescriptorImpl();
        generatedDescriptors.add(asAFactory);
       
        asAFactory.setImplementation(implName);
        asAFactory.setDescriptorType(DescriptorType.PROVIDE_METHOD);
       
        String factoryType = desc.substring(2);
        if (factoryType.charAt(0) == '[') {
            // Array type, may not be of an object!
            asAFactory.addAdvertisedContract(factoryType)// Just the array of whatever type
        }
        else {
            if (factoryType.charAt(0) != 'L') {
                throw new AssertionError("Unable to handle provide descriptor " + desc);
            }
           
            int endIndex = factoryType.indexOf(';');
            if (endIndex < 0) {
                throw new AssertionError("Unable to find end of class return type in descriptor " + desc);
            }
           
            String trueFactoryClass = factoryType.substring(1, endIndex);
           
            // This might be parametererized, strip of the parameters
            trueFactoryClass = trueFactoryClass.replace('/', '.');
           
            Set<String> associatedContracts = utilities.getAssociatedContracts(
                    searchHere, trueFactoryClass);
           
            for (String contract : associatedContracts) {
                asAFactory.addAdvertisedContract(contract);
            }
        }
       
        return new MethodVisitorImpl(asAFactory);
    }
View Full Code Here

Examples of org.glassfish.hk2.utilities.DescriptorImpl

   
    private static DescriptorImpl createDescriptor(
            String typeName,
            HK2Loader cl,
            Map<String, List<String>> metadata) {
        DescriptorImpl retVal = new DescriptorImpl();
       
        retVal.setImplementation(typeName);
        retVal.addAdvertisedContract(typeName);
        retVal.setLoader(cl);
        retVal.setMetadata(metadata);
       
        return retVal;
    }
View Full Code Here

Examples of org.glassfish.hk2.utilities.DescriptorImpl

               
                BufferedReader reader = new BufferedReader(new InputStreamReader(urlStream));
               
                boolean goOn = true;
                while (goOn) {
                    DescriptorImpl bindMe = new DescriptorImpl();
               
                    goOn = bindMe.readObject(reader);
                    if (goOn == true) {
                        config.bind(bindMe);
                    }
                }
               
View Full Code Here

Examples of org.glassfish.hk2.utilities.DescriptorImpl

     */
    @Override
    public void visitEnd() {
        if (!isAService) return;
       
        DescriptorImpl di = new DescriptorImpl();
        di.setImplementation(implName);
        if (scopeClass == null) {
            // The default for classes with Service is Singelton
            di.setScope(Singleton.class.getName());
        }
        else {
            di.setScope(scopeClass.getName());
        }
       
        di.addAdvertisedContract(implName);
        for (String iFace : iFaces) {
            di.addAdvertisedContract(iFace);
        }
       
        for (String qualifier : qualifiers) {
            di.addQualifier(qualifier);
        }
       
        if (name != null) {
            di.setName(name);
        }
       
        if (verbose) {
            System.out.println("Binding service " + di);
        }
View Full Code Here

Examples of org.glassfish.hk2.utilities.DescriptorImpl

            contract = candidate;
        }
       
        final String fContract = contract;
        final String fName = descriptorImpl.getName();
        final DescriptorImpl fDescriptorImpl = descriptorImpl;
       
        if (serviceLocator.getBestDescriptor(new IndexedFilter() {

            @Override
            public boolean matches(Descriptor d) {
                return fDescriptorImpl.equals(d);
            }

            @Override
            public String getAdvertisedContract() {
                return fContract;
View Full Code Here

Examples of org.glassfish.hk2.utilities.DescriptorImpl

               
                BufferedReader reader = new BufferedReader(new InputStreamReader(urlStream));
               
                boolean goOn = true;
                while (goOn) {
                    DescriptorImpl bindMe = new DescriptorImpl();
               
                    goOn = bindMe.readObject(reader);
                    if (goOn == true) {
                        config.bind(bindMe);
                    }
                }
               
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.