private void processField(final DeploymentUnit deploymentUnit, final EJBResourceWrapper annotation, final FieldInfo fieldInfo, final EEModuleDescription eeModuleDescription) { final String fieldName = fieldInfo.name(); final String fieldType = fieldInfo.type().name().toString(); final InjectionTarget targetDescription = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, fieldType); final String localContextName = isEmpty(annotation.name()) ? fieldInfo.declaringClass().name().toString() + "/" + fieldInfo.name() : annotation.name(); final String beanInterfaceType = isEmpty(annotation.beanInterface()) || annotation.beanInterface().equals(Object.class.getName()) ? fieldType : annotation.beanInterface(); process(deploymentUnit, beanInterfaceType, annotation.beanName(), annotation.lookup(), fieldInfo.declaringClass(), targetDescription, localContextName, eeModuleDescription); }
fieldData = new HashMap<String, List<T>>(); for (TargetAnnotation instance : fieldAnnotations) { final String name = ((FieldInfo) instance.target()).name(); List<T> data = fieldData.get(name); if (data == null) {
FieldInfo f = (FieldInfo) target; String declaringClass = f.declaringClass().name().toString(); annotation = new AnnotationImpl(declaringClass, cl, null, f.name(), false, true, annotationClass);
protected void processFieldResource(final DeploymentPhaseContext phaseContext, final FieldInfo fieldInfo, final String name, final String type, final EEModuleClassDescription classDescription, final AnnotationInstance annotation, final EEModuleDescription eeModuleDescription, final Module module, final EEApplicationClasses applicationClasses, final PropertyReplacer replacer) throws DeploymentUnitProcessingException { final String fieldName = fieldInfo.name(); final String injectionType = isEmpty(type) || type.equals(Object.class.getName()) ? fieldInfo.type().name().toString() : type; final String localContextName = isEmpty(name) ? fieldInfo.declaringClass().name().toString() + "/" + fieldName : name; final InjectionTarget targetDescription = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, fieldInfo.type().name().toString()); process(phaseContext, classDescription, annotation, injectionType, localContextName, targetDescription, eeModuleDescription, module, applicationClasses, replacer); }
@Override public String getElementName() { return field.name(); }
public static String getBindingKey(FieldInfo field) { StringBuilder sb = new StringBuilder(); sb.append(getBindingKey(field.declaringClass())); sb.append('.'); sb.append(field.name()); sb.append(')'); sb.append(getGeneralTypeBindingKey(field.type())); return sb.toString(); }
/** * Populates the sets of transient field and method names. */ private void findTransientFieldAndMethodNames() { List<AnnotationInstance> transientMembers = classInfo.annotations().get( JPADotNames.TRANSIENT ); if ( transientMembers == null ) { return; } for ( AnnotationInstance transientMember : transientMembers ) { AnnotationTarget target = transientMember.target(); if ( target instanceof FieldInfo ) { transientFieldNames.add( ( (FieldInfo) target ).name() ); } else { transientMethodNames.add( ( (MethodInfo) target ).name() ); } } }
/** * Populates the sets of transient field and method names. */ private void findTransientFieldAndMethodNames() { List<AnnotationInstance> transientMembers = classInfo.annotations().get( JPADotNames.TRANSIENT ); if ( transientMembers == null ) { return; } for ( AnnotationInstance transientMember : transientMembers ) { AnnotationTarget target = transientMember.target(); if ( target instanceof FieldInfo ) { transientFieldNames.add( ( (FieldInfo) target ).name() ); } else { transientMethodNames.add( ( (MethodInfo) target ).name() ); } } }
/** * @param t1 can't be null * @param t2 can't be null */ public static boolean targetEquals(AnnotationTarget t1, AnnotationTarget t2) { if ( t1 == t2 ) { return true; } if ( t1 != null && t2 != null ) { if ( t1.getClass() == t2.getClass() ) { if ( t1.getClass() == ClassInfo.class ) { return ( (ClassInfo) t1 ).name().equals( ( (ClassInfo) t2 ).name() ); } else if ( t1.getClass() == MethodInfo.class ) { return ( (MethodInfo) t1 ).name().equals( ( (MethodInfo) t2 ).name() ); } else { return ( (FieldInfo) t1 ).name().equals( ( (FieldInfo) t2 ).name() ); } } } return false; }
/** * @param t1 can't be null * @param t2 can't be null */ public static boolean targetEquals(AnnotationTarget t1, AnnotationTarget t2) { if ( t1 == t2 ) { return true; } if ( t1 != null && t2 != null ) { if ( t1.getClass() == t2.getClass() ) { if ( t1.getClass() == ClassInfo.class ) { return ( (ClassInfo) t1 ).name().equals( ( (ClassInfo) t2 ).name() ); } else if ( t1.getClass() == MethodInfo.class ) { return ( (MethodInfo) t1 ).name().equals( ( (MethodInfo) t2 ).name() ); } else { return ( (FieldInfo) t1 ).name().equals( ( (FieldInfo) t2 ).name() ); } } } return false; }
private void processField(final DeploymentUnit deploymentUnit, final EJBResourceWrapper annotation, final FieldInfo fieldInfo, final EEModuleDescription eeModuleDescription) { final String fieldName = fieldInfo.name(); final String fieldType = fieldInfo.type().name().toString(); final InjectionTarget targetDescription = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, fieldType); final String localContextName = isEmpty(annotation.name()) ? fieldInfo.declaringClass().name().toString() + "/" + fieldInfo.name() : annotation.name(); final String beanInterfaceType = isEmpty(annotation.beanInterface()) || annotation.beanInterface().equals(Object.class.getName()) ? fieldType : annotation.beanInterface(); process(deploymentUnit, beanInterfaceType, annotation.beanName(), annotation.lookup(), fieldInfo.declaringClass(), targetDescription, localContextName, eeModuleDescription); }
public static Map<DotName, List<AnnotationInstance>> getMemberAnnotations(ClassInfo classInfo, String name) { if ( classInfo == null ) { throw new IllegalArgumentException( "classInfo cannot be null" ); } if ( name == null ) { throw new IllegalArgumentException( "name cannot be null" ); } Map<DotName, List<AnnotationInstance>> annotations = new HashMap<DotName, List<AnnotationInstance>>(); for ( List<AnnotationInstance> annotationList : classInfo.annotations().values() ) { for ( AnnotationInstance instance : annotationList ) { String targetName = null; if ( instance.target() instanceof FieldInfo ) { targetName = ( (FieldInfo) instance.target() ).name(); } else if ( instance.target() instanceof MethodInfo ) { targetName = ( (MethodInfo) instance.target() ).name(); } if ( targetName != null && name.equals( targetName ) ) { addAnnotationToMap( instance, annotations ); } } } return annotations; }
public static Map<DotName, List<AnnotationInstance>> getMemberAnnotations(ClassInfo classInfo, String name) { if ( classInfo == null ) { throw new IllegalArgumentException( "classInfo cannot be null" ); } if ( name == null ) { throw new IllegalArgumentException( "name cannot be null" ); } Map<DotName, List<AnnotationInstance>> annotations = new HashMap<DotName, List<AnnotationInstance>>(); for ( List<AnnotationInstance> annotationList : classInfo.annotations().values() ) { for ( AnnotationInstance instance : annotationList ) { String targetName = null; if ( instance.target() instanceof FieldInfo ) { targetName = ( (FieldInfo) instance.target() ).name(); } else if ( instance.target() instanceof MethodInfo ) { targetName = ( (MethodInfo) instance.target() ).name(); } if ( targetName != null && name.equals( targetName ) ) { addAnnotationToMap( instance, annotations ); } } } return annotations; }
private static void processFieldRef(final DeploymentUnit unit, final WSRefAnnotationWrapper annotation, final FieldInfo fieldInfo) throws DeploymentUnitProcessingException { final String fieldName = fieldInfo.name(); final String injectionType = isEmpty(annotation.type()) || annotation.type().equals(Object.class.getName()) ? fieldInfo.type().name().toString() : annotation.type(); final InjectionTarget injectionTarget = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, injectionType); final String bindingName = isEmpty(annotation.name()) ? fieldInfo.declaringClass().name().toString() + "/" + fieldInfo.name() : annotation.name(); processRef(unit, injectionType, annotation, fieldInfo.declaringClass(), injectionTarget, bindingName); }
private static void processFieldRef(final DeploymentUnit unit, final WSRefAnnotationWrapper annotation, final FieldInfo fieldInfo) throws DeploymentUnitProcessingException { final String fieldName = fieldInfo.name(); final String injectionType = isEmpty(annotation.type()) || annotation.type().equals(Object.class.getName()) ? fieldInfo.type().name().toString() : annotation.type(); final InjectionTarget injectionTarget = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, injectionType); final String bindingName = isEmpty(annotation.name()) ? fieldInfo.declaringClass().name().toString() + "/" + fieldInfo.name() : annotation.name(); processRef(unit, injectionType, annotation, fieldInfo.declaringClass(), injectionTarget, bindingName); }
private static void processFieldRef(final DeploymentUnit unit, final WSRefAnnotationWrapper annotation, final FieldInfo fieldInfo) throws DeploymentUnitProcessingException { final String fieldName = fieldInfo.name(); final String injectionType = isEmpty(annotation.type()) || annotation.type().equals(Object.class.getName()) ? fieldInfo.type().name().toString() : annotation.type(); final InjectionTarget injectionTarget = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, injectionType); final String bindingName = isEmpty(annotation.name()) ? fieldInfo.declaringClass().name().toString() + "/" + fieldInfo.name() : annotation.name(); processRef(unit, injectionType, annotation, fieldInfo.declaringClass(), injectionTarget, bindingName); }
protected void processFieldResource(final DeploymentPhaseContext phaseContext, final FieldInfo fieldInfo, final String name, final String type, final EEModuleClassDescription classDescription, final AnnotationInstance annotation, final EEModuleDescription eeModuleDescription, final Module module, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException { final String fieldName = fieldInfo.name(); final String injectionType = isEmpty(type) || type.equals(Object.class.getName()) ? fieldInfo.type().name().toString() : type; final String localContextName = isEmpty(name) ? fieldInfo.declaringClass().name().toString() + "/" + fieldName : name; final InjectionTarget targetDescription = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, fieldInfo.type().name().toString()); process(phaseContext, classDescription, annotation, injectionType, localContextName, targetDescription, eeModuleDescription, module, applicationClasses); }
protected void processFieldResource(final DeploymentPhaseContext phaseContext, final FieldInfo fieldInfo, final String name, final String type, final EEModuleClassDescription classDescription, final AnnotationInstance annotation, final EEModuleDescription eeModuleDescription, final Module module, final EEApplicationClasses applicationClasses, final PropertyReplacer replacer) throws DeploymentUnitProcessingException { final String fieldName = fieldInfo.name(); final String injectionType = isEmpty(type) || type.equals(Object.class.getName()) ? fieldInfo.type().name().toString() : type; final String localContextName = isEmpty(name) ? fieldInfo.declaringClass().name().toString() + "/" + fieldName : name; final InjectionTarget targetDescription = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, fieldInfo.type().name().toString()); process(phaseContext, classDescription, annotation, injectionType, localContextName, targetDescription, eeModuleDescription, module, applicationClasses, replacer); }
protected void processFieldResource(final DeploymentPhaseContext phaseContext, final FieldInfo fieldInfo, final String name, final String type, final EEModuleClassDescription classDescription, final AnnotationInstance annotation, final EEModuleDescription eeModuleDescription, final Module module, final EEApplicationClasses applicationClasses, final PropertyReplacer replacer) throws DeploymentUnitProcessingException { final String fieldName = fieldInfo.name(); final String injectionType = isEmpty(type) || type.equals(Object.class.getName()) ? fieldInfo.type().name().toString() : type; final String localContextName = isEmpty(name) ? fieldInfo.declaringClass().name().toString() + "/" + fieldName : name; final InjectionTarget targetDescription = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, fieldInfo.type().name().toString()); process(phaseContext, classDescription, annotation, injectionType, localContextName, targetDescription, eeModuleDescription, module, applicationClasses, replacer); }
private void processField(final DeploymentUnit deploymentUnit, final AnnotationInstance annotation, final FieldInfo fieldInfo, final EEModuleClassDescription eeModuleClassDescription) throws DeploymentUnitProcessingException { final String fieldName = fieldInfo.name(); final AnnotationValue declaredNameValue = annotation.value("name"); final String declaredName = declaredNameValue != null ? declaredNameValue.asString() : null; final String localContextName; if (declaredName == null || declaredName.isEmpty()) { localContextName = fieldInfo.declaringClass().name().toString() + "/" + fieldName; } else { localContextName = declaredName; } //final AnnotationValue declaredTypeValue = annotation.value("type"); final DotName declaredTypeDotName = fieldInfo.type().name(); final DotName injectionTypeDotName = declaredTypeDotName == null || declaredTypeDotName.toString().equals(Object.class.getName()) ? fieldInfo.type().name() : declaredTypeDotName; final String injectionType = injectionTypeDotName.toString(); final InjectionSource bindingSource = this.getBindingSource(deploymentUnit, annotation, injectionType, eeModuleClassDescription); if (bindingSource != null) { final BindingConfiguration bindingConfiguration = new BindingConfiguration(localContextName, bindingSource); eeModuleClassDescription.getBindingConfigurations().add(bindingConfiguration); // setup the injection target final InjectionTarget injectionTarget = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, fieldInfo.type().name().toString()); // source is always local ENC jndi final InjectionSource injectionSource = new LookupInjectionSource(localContextName); final ResourceInjectionConfiguration injectionConfiguration = new ResourceInjectionConfiguration(injectionTarget, injectionSource); eeModuleClassDescription.addResourceInjection(injectionConfiguration); } }