/** * For CMP 1.1 beans, the list is simply the fields, extended, * on the bean class * * @return java.util.List of {@link CMPFieldDescriptor} */ public static List getAvailableCMP11FieldDescriptors(JavaClass beanClass, CMPHelper.CMPFieldExistTester fieldTester) { if (beanClass == null) return Collections.EMPTY_LIST; List fields = beanClass.getFieldsExtended(); List result = new ArrayList(); for (int i = 0; i < fields.size(); i++) { Field aField = (Field) fields.get(i); if (!isPublic(aField) || aField.isStatic() || aField.isTransient() || (fieldTester != null && !fieldTester.isExisting(aField))) continue; String name = aField.getName(); String typeName = getTypeName(aField); if (typeName != null && name != null) result.add(createFieldDescriptor(name, typeName)); } return result; }
/** * 18.1.2 Programming restrictions *... * - An enterprise Bean must not use read/write static fields. Using read-only static fields is * allowed. Therefore, it is recommended that all static fields in the enterprise bean class be * declared as final. *... */ protected void validateStaticField(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field) throws InvalidInputException { if (field == null) { return; } // An enterprise Bean must not use read/write static fields. Using read-only static fields is // allowed. Therefore, it is recommended that all static fields in the enterprise bean class be // declared as final. if (field.isStatic() && !field.isFinal()) { IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2200, IEJBValidationContext.WARNING, bean, clazz, field, this); vc.addMessage(message); } }
/** * Used for the very narrow case of final static Strings */ protected void setInitializerIfPossible() { if (!(getTargetField().isStatic() && getTargetField().isFinal() && "java.lang.String".equals(((JavaHelpers) getTargetField().getEType()).getQualifiedName()))) //$NON-NLS-1$ return; String value = null; try { value = (String) getSourceField().get(null); } catch (IllegalAccessException ex) { return; } if (value == null) return; else value = "\"".concat(value).concat("\""); //$NON-NLS-2$//$NON-NLS-1$ Block aBlock = createBlock(getTargetField().getName(), value); getTargetField().setInitializer(aBlock); } /**