/** * @see com.ibm.etools.emf2xml.impl.Translator#convertValueToString(Object) */ public String convertValueToString(Object value, EObject owner) { if (value != null) return ((JavaClass) value).getQualifiedName(); return null; }
protected void adaptJavaClass(JavaClass javaClass) { if (javaClass != null) { javaClass.eAdapters().add(this); super.setTarget(javaClass); } }
/** * If the primary key is specified in the xml, answer whether it is the same as the derived primaryKeyAttribute */ public static boolean isValidPrimKeyField(ContainerManagedEntity cmp, JavaClass clas) { return cmp.getPrimaryKeyName().equals(clas.getJavaName()); }
/** * Get the method of this name and these parameters. It will look up the supertype hierarchy. * * This method is a duplicate of getMethodExtended(String, String[]). * For performance reasons, the code was duplicated instead of converting the * JavaParameter[] into a String[]. */ public static Method getMethodExtended(JavaClass clazz, String methodName, JavaParameter[] parameterTypes) { if (clazz.isInterface()) { // Check the current class first. If the method has been overriden, // don't want to return the parent's method instead of the child's. return getMethodInterfaceExtended(clazz, methodName, parameterTypes); } // Check the current class first. If the method has been overriden, // don't want to return the parent's method instead of the child's. Method method = null; List methods = null; do { methods = clazz.getMethods(); method = getMethod(methodName, parameterTypes, methods); if (method != null) { return method; } // else, search the parent clazz = clazz.getSupertype(); } while ((method == null) && (clazz != null)); return null; }
public static Method getMethodInterfaceExtended(JavaClass clazz, String methodName, JavaHelpers[] parameterTypes) { if (clazz == null) { return null; } // Check the current class first. If the method has been overriden, // don't want to return the parent's method instead of the child's. Method method = getMethod(methodName, parameterTypes, clazz.getMethods()); if (method != null) { return method; } // check parents List classesToCheck = clazz.getImplementsInterfaces(); Iterator clazzIterator = classesToCheck.iterator(); while (clazzIterator.hasNext()) { clazz = (JavaClass) clazzIterator.next(); method = getMethodInterfaceExtended(clazz, methodName, parameterTypes); if (method != null) { return method; } } return null; }
private IType getType(JavaClass clazz) { if (clazz == null) { return null; } IProject project = ProjectUtilities.getProject(clazz); IJavaProject javaProj = JemProjectUtilities.getJavaProject(project); return JDOMSearchHelper.findType(clazz.getJavaPackage().getName(), clazz.getName(), javaProj); }
/** * EJB 1.1 specification * Section: 9.4.7.2 */ public void validateClass(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException { super.validateClass(vc, bean, clazz); vc.terminateIfCancelled(); // The primary key class must be public if (!clazz.isPublic()) { IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2020, IEJBValidationContext.ERROR, bean, clazz, new String[] { clazz.getQualifiedName()}, this); vc.addMessage(message); } buildFieldNameList(vc, bean, clazz); // Doesn't make sense to check for cmp key attributes if it's not a valid prim key field. // primary key must map to at least one field on the bean ContainerManagedEntity cmp = (ContainerManagedEntity)bean; if(!ValidationRuleUtility.usesUnknownPrimaryKey(cmp)) { // primary key must map to at least one field on the bean // But if it's an unknown key, there's no point checking java.lang.Object List primKeyFields = cmp.getKeyAttributes(); if ((primKeyFields == null) || (primKeyFields.size() == 0)) { JavaClass primaryKey = cmp.getPrimaryKey(); // don't need to check MOFHelper.isValidType(primaryKey), because it's already been called in the validateDeploymentDescriptor method String beanName = (cmp.getName() == null) ? "null" : cmp.getName(); //$NON-NLS-1$ IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2829, IEJBValidationContext.ERROR, bean, primaryKey, new String[] { primaryKey.getName(), beanName }, this); vc.addMessage(message); } } }
public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) { return clazz.getName(); }
/** * @return */ private EClassifier getKeyFieldTypeFromKeyClass() { if (isKey()) { JavaClass key = getCMPEntity().getPrimaryKey(); if (key != null && key.getQualifiedName() != null && !key.getQualifiedName().startsWith("java.lang")) { //$NON-NLS-1$ Field field = key.getFieldExtended(getName()); if (field != null) return field.getEType(); } else return key; } return null; } public boolean isCMRField() {
String beanClassName = (bean.getEjbClass() == null) ? IEJBValidatorConstants.NULL_BEAN_CLASS : bean.getEjbClass().getJavaName(); String eClass = (e.getJavaClass() == null) ? ITypeConstants.CLASSNAME_JAVAX_EJB_SESSIONSYNCHRONIZATION : e.getJavaClass().getJavaName(); // Since only getType throws InvalidInputException, this cannot have been thrown because of the bean class String[] msgParm = { beanClassName, eClass }; IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2433, IEJBValidationContext.WARNING, bean, msgParm, this); String[] msgParm = { bean.getEjbClass().getQualifiedName(), e.getJavaClass().getQualifiedName()}; IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2907, IEJBValidationContext.WARNING, bean, msgParm, this); vc.addMessage(message);
protected String toDisplayString(JavaClass javaClass) { String className = javaClass.getQualifiedNameForReflection(); return (className != null) ? className : ""; //$NON-NLS-1$ }
Method[] allMethods = intf.listMethodExtended(); java.util.Vector resultVector = new java.util.Vector(allMethods.length); java.util.Hashtable methodNameTable = new java.util.Hashtable(); String interfaceName = m.getContainingJavaClass().getJavaName(); if (!interfaceName.equals("javax.ejb.EJBObject")) { //$NON-NLS-1$ Method synonym = (Method) methodNameTable.get(mKey); if (sClass.implementsInterface(mClass)) { resultVector.removeElement(synonym); methodNameTable.put(mKey, m);
public final void validate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationException { vc.subtask(IEJBValidatorConstants.STATUS_VALIDATING, new String[]{((JavaClass) target).getJavaName()}); if (ValidationRuleUtility.isUnnamedPackage(clazz.getJavaPackage())) { IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2041, IEJBValidationContext.INFO, bean, clazz, this); vc.addMessage(message); validate(vc, bean, clazz, clazz.listMethodExtended(), methodsExtendedList); vc.terminateIfCancelled(); validate(vc, bean, clazz, clazz.listFieldExtended(), fieldsExtendedList); vc.terminateIfCancelled();
String className = null; if(componentInterface != null) { className = componentInterface.getJavaName(); IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2403, IEJBValidationContext.WARNING, bean, clazz, method, new String[]{getComponentInterface(bean).getName()}, this); vc.addMessage(message);
w.write(exception.getQualifiedNameForReflection()); if (it.hasNext()) w.write(", "); incrementIndent(); newLine(w); String stubName = firstCharToLowerCase(javaClass.getName()); w.write("if ("); w.write(stubName);
protected void initializeForCompoundKey() { List keys = getKeyAttributes(); // clear key list keys.clear(); //ensure the key class is not null JavaClass keyClass = cmp.getPrimaryKey(); if (keyClass == null) return; keyClass.eAdapters().add(this); // reflect key fields into key attributes list List keyFields = keyClass.getFieldsExtended(); for (int i = 0; i < keyFields.size(); i++) { Field field = (Field) keyFields.get(i); if (field.getJavaVisibility() == JavaVisibilityKind.PUBLIC_LITERAL) { //only public fields CMPAttribute keyAttribute = cmp.getPersistentAttribute(field.getName()); if (keyAttribute != null) keys.add(keyAttribute); } } }
/** * @generated This field/method will be replaced during code generation */ public JavaClass getRemoteInterface() { if (remoteInterface != null && remoteInterface.eIsProxy()) { InternalEObject oldRemoteInterface = (InternalEObject)remoteInterface; remoteInterface = (JavaClass)eResolveProxy(oldRemoteInterface); if (remoteInterface != oldRemoteInterface) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, EjbPackage.ENTERPRISE_BEAN__REMOTE_INTERFACE, oldRemoteInterface, remoteInterface)); } } return remoteInterface; }
/** * @param aClass * @param methods * @return */ protected List excludeMethods(JavaClass aClass, List methods) { List currentMethods = aClass.getMethods(); List resultMethods = new ArrayList(); for (int i = 0; i < currentMethods.size(); i++) { if (!methods.contains(currentMethods.get(i))) resultMethods.add(currentMethods.get(i)); } return resultMethods; } /**
public final void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException { super.validate(vc, bean, clazz); // IWAD4251 = This class must be public. Read section 10.8.2 of the EJB 2.0 specification. if(!clazz.isPublic()) { IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2022, IEJBValidationContext.INFO, bean, clazz, this); vc.addMessage(message); } ContainerManagedEntity cmp = (ContainerManagedEntity)bean; if(!ValidationRuleUtility.usesUnknownPrimaryKey(cmp)) { // primary key must map to at least one field on the bean // But if it's an unknown key, there's no point checking java.lang.Object List primKeyFields = cmp.getKeyAttributes(); if ((primKeyFields == null) || (primKeyFields.size() == 0)) { JavaClass primaryKey = cmp.getPrimaryKey(); // don't need to check ValidationRuleUtility.isValidType(primaryKey), because it's already been called in the validateDeploymentDescriptor method String beanName = (cmp.getName() == null) ? "null" : cmp.getName(); //$NON-NLS-1$ IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2829, IEJBValidationContext.ERROR, cmp, primaryKey, new String[] { primaryKey.getName(), beanName }, this); vc.addMessage(message); } } }
if(!wrapper.isExistingType()) { Logger aLogger = getMsgLogger(); if(aLogger.isLoggingLevel(Level.FINEST)) { LogEntry entry = getLogEntry(); entry.setSourceID("ValidationRuleUtility.isValidType"); //$NON-NLS-1$ entry.setText("!wrapper.isExistingType(); type is " + wrapper.getJavaName()); //$NON-NLS-1$ aLogger.write(Level.FINEST, entry);