Package com.google.inject

Examples of com.google.inject.Inject


    do
    {
      Field[] currentFields = current.getDeclaredFields();
      for (final Field field : currentFields)
      {
        Inject injectAnnotation = field.getAnnotation(Inject.class);
        if (!Modifier.isStatic(field.getModifiers()) && injectAnnotation != null)
        {
          try
          {
            Annotation bindingAnnotation = findBindingAnnotation(field.getAnnotations());
            Object proxy = LazyInitProxyFactory.createProxy(field.getType(),
                new GuiceProxyTargetLocator(field, bindingAnnotation,
                    injectAnnotation.optional()));

            if (!field.isAccessible())
            {
              field.setAccessible(true);
            }
            field.set(object, proxy);
          }
          catch (IllegalAccessException e)
          {
            throw new WicketRuntimeException("Error Guice-injecting field " +
                field.getName() + " in " + object, e);
          }
          catch (MoreThanOneBindingException e)
          {
            throw new RuntimeException(
                "Can't have more than one BindingAnnotation on field " +
                    field.getName() + " of class " +
                    object.getClass().getName());
          }
        }
      }
      Method[] currentMethods = current.getDeclaredMethods();
      for (final Method method : currentMethods)
      {
        Inject injectAnnotation = method.getAnnotation(Inject.class);
        if (!Modifier.isStatic(method.getModifiers()) && injectAnnotation != null)
        {
          Annotation[][] paramAnnotations = method.getParameterAnnotations();
          Class< ? >[] paramTypes = method.getParameterTypes();
          Type[] genericParamTypes = method.getGenericParameterTypes();
          Object[] args = new Object[paramTypes.length];
          for (int i = 0; i < paramTypes.length; i++)
          {
            Type paramType;
            if (genericParamTypes[i] instanceof ParameterizedType)
            {
              paramType = ((ParameterizedType)genericParamTypes[i]).getRawType();
            }
            else
            {
              paramType = paramTypes[i];
            }
            try
            {
              Annotation bindingAnnotation = findBindingAnnotation(paramAnnotations[i]);
              args[i] = LazyInitProxyFactory.createProxy(paramTypes[i],
                  new GuiceProxyTargetLocator(method, i, bindingAnnotation,
                      injectAnnotation.optional()));
            }
            catch (MoreThanOneBindingException e)
            {
              throw new RuntimeException(
                  "Can't have more than one BindingAnnotation on parameter " + i +
View Full Code Here


    do
    {
      Field[] currentFields = current.getDeclaredFields();
      for (final Field field : currentFields)
      {
        Inject injectAnnotation = field.getAnnotation(Inject.class);
        if (injectAnnotation != null)
        {
          actualDoInject = true;
          try
          {
            Annotation bindingAnnotation = findBindingAnnotation(field.getAnnotations());
            Object proxy = LazyInitProxyFactory.createProxy(field.getType(),
                new GuiceProxyTargetLocator(field, bindingAnnotation,
                    injectAnnotation.optional()));
            if (!field.isAccessible())
            {
              field.setAccessible(true);
            }
            field.set(object, proxy);
          }
          catch (IllegalAccessException e)
          {
            throw new WicketRuntimeException("Error Guice-injecting field " +
                field.getName() + " in " + object, e);
          }
          catch (MoreThanOneBindingException e)
          {
            throw new RuntimeException(
                "Can't have more than one BindingAnnotation on field " +
                    field.getName() + " of class " +
                    object.getClass().getName());
          }
        }
      }

      Method[] currentMethods = current.getDeclaredMethods();
      for (final Method method : currentMethods)
      {
        Inject injectAnnotation = method.getAnnotation(Inject.class);
        if (injectAnnotation != null)
        {
          actualDoInject = true;
          Annotation[][] paramAnnotations = method.getParameterAnnotations();
          Class< ? >[] paramTypes = method.getParameterTypes();
          Type[] genericParamTypes = method.getGenericParameterTypes();
          Object[] args = new Object[paramTypes.length];
          for (int i = 0; i < paramTypes.length; i++)
          {
            Type paramType;
            if (genericParamTypes[i] instanceof ParameterizedType)
            {
              paramType = ((ParameterizedType)genericParamTypes[i]).getRawType();
            }
            else
            {
              paramType = paramTypes[i];
            }
            try
            {
              Annotation bindingAnnotation = findBindingAnnotation(paramAnnotations[i]);
              args[i] = LazyInitProxyFactory.createProxy(paramTypes[i],
                  new GuiceProxyTargetLocator(method, i, bindingAnnotation,
                      injectAnnotation.optional()));
            }
            catch (MoreThanOneBindingException e)
            {
              throw new RuntimeException(
                  "Can't have more than one BindingAnnotation on parameter " + i +
View Full Code Here

  {
    Object target = null;

    if (supportsField(field))
    {
      Inject injectAnnotation = field.getAnnotation(Inject.class);
      if (!Modifier.isStatic(field.getModifiers()) && injectAnnotation != null)
      {
        try
        {
          Annotation bindingAnnotation = findBindingAnnotation(field.getAnnotations());
          final IProxyTargetLocator locator = new GuiceProxyTargetLocator(field,
              bindingAnnotation, injectAnnotation.optional());

          if (wrapInProxies)
          {
            target = LazyInitProxyFactory.createProxy(field.getType(), locator);
          }
View Full Code Here

    do
    {
      Field[] currentFields = current.getDeclaredFields();
      for (final Field field : currentFields)
      {
        Inject injectAnnotation = field.getAnnotation(Inject.class);
        if (injectAnnotation != null)
        {
          actualDoInject = true;
          try
          {
            Annotation bindingAnnotation = findBindingAnnotation(field.getAnnotations());
            Object proxy = LazyInitProxyFactory.createProxy(field.getType(),
                new GuiceProxyTargetLocator(field, bindingAnnotation,
                    injectAnnotation.optional()));
            if (!field.isAccessible())
            {
              field.setAccessible(true);
            }
            field.set(object, proxy);
          }
          catch (IllegalAccessException e)
          {
            throw new WicketRuntimeException("Error Guice-injecting field " +
                field.getName() + " in " + object, e);
          }
          catch (MoreThanOneBindingException e)
          {
            throw new RuntimeException(
                "Can't have more than one BindingAnnotation on field " +
                    field.getName() + " of class " +
                    object.getClass().getName());
          }
        }
      }

      Method[] currentMethods = current.getDeclaredMethods();
      for (final Method method : currentMethods)
      {
        Inject injectAnnotation = method.getAnnotation(Inject.class);
        if (injectAnnotation != null)
        {
          actualDoInject = true;
          Annotation[][] paramAnnotations = method.getParameterAnnotations();
          Class< ? >[] paramTypes = method.getParameterTypes();
          Type[] genericParamTypes = method.getGenericParameterTypes();
          Object[] args = new Object[paramTypes.length];
          for (int i = 0; i < paramTypes.length; i++)
          {
            Type paramType;
            if (genericParamTypes[i] instanceof ParameterizedType)
            {
              paramType = ((ParameterizedType)genericParamTypes[i]).getRawType();
            }
            else
            {
              paramType = paramTypes[i];
            }
            try
            {
              Annotation bindingAnnotation = findBindingAnnotation(paramAnnotations[i]);
              args[i] = LazyInitProxyFactory.createProxy(paramTypes[i],
                  new GuiceProxyTargetLocator(method, i, bindingAnnotation,
                      injectAnnotation.optional()));
            }
            catch (MoreThanOneBindingException e)
            {
              throw new RuntimeException(
                  "Can't have more than one BindingAnnotation on parameter " + i +
View Full Code Here

    do
    {
      Field[] currentFields = current.getDeclaredFields();
      for (final Field field : currentFields)
      {
        Inject injectAnnotation = field.getAnnotation(Inject.class);
        if (!Modifier.isStatic(field.getModifiers()) && injectAnnotation != null)
        {
          try
          {
            Annotation bindingAnnotation = findBindingAnnotation(field.getAnnotations());
            Object proxy = LazyInitProxyFactory.createProxy(field.getType(),
                new GuiceProxyTargetLocator(field, bindingAnnotation,
                    injectAnnotation.optional()));

            if (!field.isAccessible())
            {
              field.setAccessible(true);
            }
            field.set(object, proxy);
          }
          catch (IllegalAccessException e)
          {
            throw new WicketRuntimeException("Error Guice-injecting field " +
                field.getName() + " in " + object, e);
          }
          catch (MoreThanOneBindingException e)
          {
            throw new RuntimeException(
                "Can't have more than one BindingAnnotation on field " +
                    field.getName() + " of class " +
                    object.getClass().getName());
          }
        }
      }
      Method[] currentMethods = current.getDeclaredMethods();
      for (final Method method : currentMethods)
      {
        Inject injectAnnotation = method.getAnnotation(Inject.class);
        if (!Modifier.isStatic(method.getModifiers()) && injectAnnotation != null)
        {
          Annotation[][] paramAnnotations = method.getParameterAnnotations();
          Class< ? >[] paramTypes = method.getParameterTypes();
          Type[] genericParamTypes = method.getGenericParameterTypes();
          Object[] args = new Object[paramTypes.length];
          for (int i = 0; i < paramTypes.length; i++)
          {
            Type paramType;
            if (genericParamTypes[i] instanceof ParameterizedType)
            {
              paramType = ((ParameterizedType)genericParamTypes[i]).getRawType();
            }
            else
            {
              paramType = paramTypes[i];
            }
            try
            {
              Annotation bindingAnnotation = findBindingAnnotation(paramAnnotations[i]);
              args[i] = LazyInitProxyFactory.createProxy(paramTypes[i],
                  new GuiceProxyTargetLocator(method, i, bindingAnnotation,
                      injectAnnotation.optional()));
            }
            catch (MoreThanOneBindingException e)
            {
              throw new RuntimeException(
                  "Can't have more than one BindingAnnotation on parameter " + i +
View Full Code Here

  }

  InjectionPoint(TypeLiteral<?> type, Method method) {
    this.member = method;

    Inject inject = method.getAnnotation(Inject.class);
    this.optional = inject.optional();

    this.dependencies = forMember(method, type, method.getParameterAnnotations());
  }
View Full Code Here

  }

  InjectionPoint(TypeLiteral<?> type, Field field) {
    this.member = field;

    Inject inject = field.getAnnotation(Inject.class);
    this.optional = inject.optional();

    Annotation[] annotations = field.getAnnotations();

    Errors errors = new Errors(field);
    Key<?> key = null;
View Full Code Here

    Class<?> rawType = getRawType(type.getType());
    Errors errors = new Errors(rawType);

    Constructor<?> injectableConstructor = null;
    for (Constructor<?> constructor : rawType.getDeclaredConstructors()) {
      Inject inject = constructor.getAnnotation(Inject.class);
      if (inject != null) {
        if (inject.optional()) {
          errors.optionalConstructor(constructor);
        }

        if (injectableConstructor != null) {
          errors.tooManyConstructors(rawType);
View Full Code Here

    for (M member : factory.getMembers(getRawType(typeLiteral.getType()))) {
      if (isStatic(member) != statics) {
        continue;
      }

      Inject inject = member.getAnnotation(Inject.class);
      if (inject == null) {
        continue;
      }

      try {
        injectionPoints.add(factory.create(typeLiteral, member, errors));
      } catch (ConfigurationException ignorable) {
        if (!inject.optional()) {
          errors.merge(ignorable.getErrorMessages());
        }
      }
    }
  }
View Full Code Here

    do
    {
      Field[] currentFields = current.getDeclaredFields();
      for (final Field field : currentFields)
      {
        Inject injectAnnotation = field.getAnnotation(Inject.class);
        if (!Modifier.isStatic(field.getModifiers()) && injectAnnotation != null)
        {
          try
          {
            Annotation bindingAnnotation = findBindingAnnotation(field.getAnnotations());
            Object proxy = LazyInitProxyFactory.createProxy(field.getType(),
                new GuiceProxyTargetLocator(field, bindingAnnotation,
                    injectAnnotation.optional()));

            if (!field.isAccessible())
            {
              field.setAccessible(true);
            }
            field.set(object, proxy);
          }
          catch (IllegalAccessException e)
          {
            throw new WicketRuntimeException("Error Guice-injecting field " +
                field.getName() + " in " + object, e);
          }
          catch (MoreThanOneBindingException e)
          {
            throw new RuntimeException(
                "Can't have more than one BindingAnnotation on field " +
                    field.getName() + " of class " +
                    object.getClass().getName());
          }
        }
      }
      Method[] currentMethods = current.getDeclaredMethods();
      for (final Method method : currentMethods)
      {
        Inject injectAnnotation = method.getAnnotation(Inject.class);
        if (!Modifier.isStatic(method.getModifiers()) && injectAnnotation != null)
        {
          Annotation[][] paramAnnotations = method.getParameterAnnotations();
          Class< ? >[] paramTypes = method.getParameterTypes();
          Type[] genericParamTypes = method.getGenericParameterTypes();
          Object[] args = new Object[paramTypes.length];
          for (int i = 0; i < paramTypes.length; i++)
          {
            Type paramType;
            if (genericParamTypes[i] instanceof ParameterizedType)
            {
              paramType = ((ParameterizedType)genericParamTypes[i]).getRawType();
            }
            else
            {
              paramType = paramTypes[i];
            }
            try
            {
              Annotation bindingAnnotation = findBindingAnnotation(paramAnnotations[i]);
              args[i] = LazyInitProxyFactory.createProxy(paramTypes[i],
                  new GuiceProxyTargetLocator(method, i, bindingAnnotation,
                      injectAnnotation.optional()));
            }
            catch (MoreThanOneBindingException e)
            {
              throw new RuntimeException(
                  "Can't have more than one BindingAnnotation on parameter " + i +
View Full Code Here

TOP

Related Classes of com.google.inject.Inject

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.