Examples of InjectionPoint


Examples of com.google.inject.spi.InjectionPoint

   
    private String describeInjectionPoints(TypeLiteral<?> type) {
        StringBuilder sb = new StringBuilder();
       
        try {
            InjectionPoint ip = InjectionPoint.forConstructorOf(type);
            List<Dependency<?>> deps = ip.getDependencies();
            if (!deps.isEmpty()) {
                for (Dependency<?> dep : deps) {
                    sb.append("     dep : " + dep.getKey()).append("\n");
                }
            }
View Full Code Here

Examples of com.google.inject.spi.InjectionPoint

                }
               
                // If @Inject is present then instantiate using that constructor and manually inject
                // the dependencies.  Note that a null will be injected for excluded modules
                try {
                    InjectionPoint ip = InjectionPoint.forConstructorOf(type);
                    if (ip != null) {
                        Constructor<?> c = (Constructor<?>) ip.getMember();
                        c.setAccessible(true);
                        List<Dependency<?>> deps = ip.getDependencies();
                        if (!deps.isEmpty()) {
                            Object[] args = new Object[deps.size()];
                            for (Dependency<?> dep : deps) {
                                Class<?> type = dep.getKey().getTypeLiteral().getRawType();
                                if (Module.class.isAssignableFrom(type)) {
View Full Code Here

Examples of com.google.inject.spi.InjectionPoint

                return instance;
            }
           
            private T create() {
                // Look for an @Inject constructor or just create a new instance if not found
                InjectionPoint injectionPoint = InjectionPoint.forConstructorOf(type);
                final long startTime = System.nanoTime();
               
                for (LifecycleListener listener : listeners) {
                    listener.objectInjecting(TypeLiteral.get(type));
                }
                if (injectionPoint != null) {
                    List<Dependency<?>> deps = injectionPoint.getDependencies();
                    if (deps.size() > 0) {
                        Constructor<?> constructor = (Constructor<?>)injectionPoint.getMember();
                        // One thread for each dependency
                        ExecutorService executor = Executors.newCachedThreadPool(
                                new ThreadFactoryBuilder()
                                    .setDaemon(true)
                                    .setNameFormat("ConcurrentProviders-" + type.getSimpleName() + "-%d")
View Full Code Here

Examples of javax.enterprise.inject.spi.InjectionPoint

        @Override
        public Object redefineParameterValue(ParameterValue value) {
            Object result = value.getDefaultValue(creationalContext);

            InjectionPoint injectionPoint = value.getInjectionPoint();
            if (injectionPoint != null) {
                Annotated securingParameterAnnotatedType = injectionPoint.getAnnotated();
                Set<Annotation> securingParameterAnnotations = securingParameterAnnotatedType.getAnnotations();

                Set<Annotation> requiredBindingAnnotations = new HashSet<Annotation>();
                for (Annotation annotation : securingParameterAnnotations) {
                    if (annotation.annotationType().isAnnotationPresent(SecurityParameterBinding.class)) {
View Full Code Here

Examples of javax.enterprise.inject.spi.InjectionPoint

                                                                 BeanManager beanManager)
    {
        List<InjectionPoint> injectionPoints = new ArrayList<InjectionPoint>();
        for (AnnotatedParameter<X> parameter : method.getParameters())
        {
            InjectionPoint injectionPoint =
                    new ImmutableInjectionPoint(parameter, beanManager, declaringBean, false, false);

            injectionPoints.add(injectionPoint);
        }
        return injectionPoints;
View Full Code Here

Examples of javax.enterprise.inject.spi.InjectionPoint

    @Override
    public Object redefineParameterValue(ParameterValue value)
    {

        InjectionPoint injectionPoint = value.getInjectionPoint();
        if (injectionPoint != null)
        {
            if (value.getInjectionPoint().getAnnotated().getBaseType().equals(InvocationContext.class))
            {
                return invocation;
            }
            else if (value.getInjectionPoint().getAnnotated().isAnnotationPresent(SecuredReturn.class))
            {
                return result;
            }
            else
            {
                Annotated securingParameterAnnotatedType = injectionPoint.getAnnotated();
                Set<Annotation> securingParameterAnnotations = securingParameterAnnotatedType.getAnnotations();

                Set<Annotation> requiredBindingAnnotations = new HashSet<Annotation>();
                for (Annotation annotation : securingParameterAnnotations)
                {
View Full Code Here

Examples of javax.enterprise.inject.spi.InjectionPoint

   public void wireCrossContainerServices(@Observes AfterBeanDiscovery event, final BeanManager manager)
   {
      // needs to happen in the addon that is requesting the service
      for (final Entry<InjectionPoint, Class<?>> entry : requestedServices.entrySet())
      {
         final InjectionPoint injectionPoint = entry.getKey();
         final Annotated annotated = injectionPoint.getAnnotated();
         final Member member = injectionPoint.getMember();

         Class<?> beanClass = entry.getValue();
         Set<Type> typeClosure = annotated.getTypeClosure();
         Set<Type> beanTypeClosure = new LinkedHashSet<Type>();
         for (Type type : typeClosure)
View Full Code Here

Examples of javax.enterprise.inject.spi.InjectionPoint

    @Test
    @SpecAssertions({ @SpecAssertion(section = "2.3.1", id = "b"), @SpecAssertion(section = "11.1", id = "c") })
    public void testDefaultQualifierForInjectionPoint() {
        Bean<Order> order = getBeans(Order.class).iterator().next();
        assert order.getInjectionPoints().size() == 1;
        InjectionPoint injectionPoint = order.getInjectionPoints().iterator().next();
        assert injectionPoint.getQualifiers().contains(new DefaultLiteral());
    }
View Full Code Here

Examples of javax.enterprise.inject.spi.InjectionPoint

    @Test(expectedExceptions = InjectionException.class)
    @SpecAssertion(section = "11.3.9", id = "a")
    public void testValidateThrowsException() {
        DogHouse dogHouse = getInstanceByType(DogHouse.class);
        InjectionPoint injectionPoint = new InjectionPointDecorator(dogHouse.getDog().getInjectedMetadata());
        // Wrap the injection point to change the type to a more generalized class
        getCurrentManager().validate(injectionPoint);
    }
View Full Code Here

Examples of javax.enterprise.inject.spi.InjectionPoint

    @SpecAssertions({ @SpecAssertion(section = "11.3.22", id = "a") })
    public void testField() {
        AnnotatedType<?> type = getCurrentManager().createAnnotatedType(Library.class);
        assertEquals(type.getFields().size(), 1);
        AnnotatedField<?> field = type.getFields().iterator().next();
        InjectionPoint ip = getCurrentManager().createInjectionPoint(field);
        validateParameterizedType(ip.getType(), Book.class, String.class);
        annotationSetMatches(ip.getQualifiers(), Monograph.class, Fictional.class);
        assertNull(ip.getBean());
        assertEquals(field.getJavaMember(), ip.getMember());
        assertNotNull(ip.getAnnotated());
        assertFalse(ip.isDelegate());
        assertTrue(ip.isTransient());
    }
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.