Package org.glassfish.hk2.api

Examples of org.glassfish.hk2.api.Injectee


   
    /**
     * Mallory cannot advertise the EvilService
     */
    public void tryToAdvertiseAService() {
        DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
        DynamicConfiguration config = dcs.createDynamicConfiguration();
       
        config.addActiveDescriptor(EvilService.class);
       
        config.commit()// This will throw a MultiException
    }
View Full Code Here


                return false;
            }
           
        };
       
        DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
        DynamicConfiguration config = dcs.createDynamicConfiguration();
       
        config.addUnbindFilter(unbindFilter);
       
        config.commit()// This will throw a MultiException
    }
View Full Code Here

     */
    public void tryToUnAdvertiseAService() {
        final Descriptor locatorService = locator.getBestDescriptor(BuilderHelper.createContractFilter(ServiceLocator.class.getName()));
       
        // This filter matches ServiceLocator itself!
        Filter unbindFilter = new Filter() {

            @Override
            public boolean matches(Descriptor d) {
                if (d.getServiceId().equals(locatorService.getServiceId())) {
                    if (d.getLocatorId().equals(locator.getLocatorId())) {
View Full Code Here

*/           
                AccessController.doPrivileged(new PrivilegedAction<List<ServiceHandle<? extends Object>>>() {
                    public List<ServiceHandle<? extends Object>> run() {
                       
                        List<ServiceHandle<? extends Object>> identities = (List<ServiceHandle<? extends Object>>)getBaseServiceLocator().getAllServices(
                           new Filter() {
       
                                @Override
                                public boolean matches(Descriptor d) {
                                   if (d == null) {
                                   return false;
View Full Code Here

                   
                });
            }
            final ClassLoader binderClassLoader = loader;
           
            defaultLoader = new HK2Loader() {
                @Override
                public Class<?> loadClass(String className) throws MultiException {
                    try {
                        return binderClassLoader.loadClass(className);
                    } catch (ClassNotFoundException e) {
View Full Code Here

        };
       
    }

    protected Class<?> loadClass(String type) throws ClassNotFoundException {
        HK2Loader loader = myself.getLoader();
       
        if (loader == null) {
            return getClass().getClassLoader().loadClass(type);
        }
       
        try {
            return loader.loadClass(type);
        }
        catch (MultiException me) {
            for (Throwable th : me.getErrors()) {
                if (th instanceof ClassNotFoundException) {
                    throw (ClassNotFoundException) th;
View Full Code Here

        }
       
        final String fContract = contract;
        final String fName = name;
       
        return new IndexedFilter() {

            @Override
            public boolean matches(Descriptor d) {
                if (qualifiers.isEmpty()) return true;
               
View Full Code Here

            List<Injectee> injecteeFields = Utilities.getFieldInjectees(field, null);

            validateSelfInjectees(null, injecteeFields, collector);
            collector.throwIfErrors();

            Injectee injectee = injecteeFields.get(0);

            Object fieldValue = resolver.resolve(injectee, null);

            try {
                ReflectionHelper.setField(field, injectMe, fieldValue);
            }
            catch (Throwable th) {
                throw new MultiException(th);
            }
        }

        for (Method method : methods) {
            List<Injectee> injectees = Utilities.getMethodInjectees(method, null);

            validateSelfInjectees(null, injectees, collector);
            collector.throwIfErrors();

            Object args[] = new Object[injectees.size()];

            for (Injectee injectee : injectees) {
                InjectionResolver<?> resolver = getInjectionResolver(locator, injectee);
                args[injectee.getPosition()] = resolver.resolve(injectee, null);
            }

            try {
                ReflectionHelper.invoke(injectMe, method, args, locator.getNeutralContextClassLoader());
            } catch (Throwable e) {
View Full Code Here

    private void fieldMe(Map<Injectee, Object> resolved, T t) throws Throwable {
        for (ResolutionInfo ri : myFields) {
            Field field = (Field) ri.baseElement;
            List<Injectee> injectees = ri.injectees;  // Should be only one injectee, itself!

            Injectee fieldInjectee = null;
            for (Injectee candidate : injectees) {
                fieldInjectee = candidate;
            }

            Object putMeIn = resolved.get(fieldInjectee);
View Full Code Here

    private void fieldMe(Map<Injectee, Object> resolved, T t) throws Throwable {
        for (ResolutionInfo ri : myFields) {
            Field field = (Field) ri.baseElement;
            List<Injectee> injectees = ri.injectees;  // Should be only one injectee, itself!

            Injectee fieldInjectee = null;
            for (Injectee candidate : injectees) {
                fieldInjectee = candidate;
            }

            Object putMeIn = resolved.get(fieldInjectee);
View Full Code Here

TOP

Related Classes of org.glassfish.hk2.api.Injectee

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.