Ejemplo n.º 1
0
 private static Inject getInjectAnnotation(JParameter parameter) {
   Inject result = parameter.getAnnotation(Inject.class);
   if (result == null) {
     result = parameter.getEnclosingMethod().getAnnotation(Inject.class);
   }
   return result;
 }
Ejemplo n.º 2
0
 @SuppressWarnings("deprecation")
 private static String getParameterInjectionExpression(
     JParameter parameter, String iocContainerVariable, Map<String, IocConfig<?>> configurations) {
   JType parameterType = parameter.getType();
   if (parameterType.isClassOrInterface() != null) {
     String fieldTypeName = parameterType.getQualifiedSourceName();
     IocConfigImpl<?> iocConfig = (IocConfigImpl<?>) configurations.get(fieldTypeName);
     if (iocConfig != null) {
       Inject inject = getInjectAnnotation(parameter);
       if (inject.scope().equals(org.cruxframework.crux.core.client.ioc.Inject.Scope.DEFAULT)) {
         return iocContainerVariable
             + ".get"
             + fieldTypeName.replace('.', '_')
             + "("
             + Scope.class.getCanonicalName()
             + "."
             + iocConfig.getScope().name()
             + ", null)";
       }
       return iocContainerVariable
           + ".get"
           + fieldTypeName.replace('.', '_')
           + "("
           + Scope.class.getCanonicalName()
           + "."
           + getScopeName(inject.scope())
           + ", "
           + EscapeUtils.quote(inject.subscope())
           + ")";
     } else {
       return "GWT.create(" + fieldTypeName + ".class)";
     }
   } else {
     throw new IoCException(
         "Error injecting parameter ["
             + parameter.getName()
             + "] from method ["
             + parameter.getEnclosingMethod().getReadableDeclaration()
             + "]. Primitive fields can not be handled by ioc container.");
   }
 }