Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model')
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ABMPHomeVRule.java57
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ABeanClassVRule.java506
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ACMPHomeVRule.java76
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AComponentVRule.java164
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AEntityBeanClassVRule.java44
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AEntityHomeVRule.java98
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AHomeVRule.java284
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AInterfaceTypeVRule.java150
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AKeyClassVRule.java79
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ASessionBeanClassVRule.java43
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ASessionHomeVRule.java24
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AStatelessHomeVRule.java35
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ATypeVRule.java643
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateBean.java673
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateEJB.java371
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateEntityBean.java582
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateEntityHome.java516
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateHome.java248
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateKeyClass.java132
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateRemote.java259
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidationRule.java123
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AbstractEJBValidationRuleFactory.java130
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AbstractEJBValidator.java320
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ApplicationClientMessageConstants.java37
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ApplicationClientValidator.java157
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPBeanClassVRule.java303
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPKeyClassVRule.java130
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPLocalComponentVRule.java114
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPLocalHomeVRule.java125
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPRemoteComponentVRule.java114
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPRemoteHomeVRule.java129
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPBeanClassVRule.java484
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPKeyClassVRule.java211
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPLocalComponentVRule.java113
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPLocalHomeVRule.java131
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPRemoteComponentVRule.java165
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPRemoteHomeVRule.java131
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ClassUtility.java304
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ConnectorMessageConstants.java31
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ConnectorValidator.java133
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/DuplicatesTable.java156
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EARValidationMessageResourceHandler.java83
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBExt20VRule.java248
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBJar11VRule.java588
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBJar20VRule.java879
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidationContext.java199
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidationRuleFactory.java373
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidator.java529
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidatorModelEnum.java29
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ERefValidationMessageResourceHandler.java37
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EarValidator.java959
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EnterpriseBean11VRule.java1067
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EnterpriseBean20VRule.java1258
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IClassVRule.java48
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IComponentType.java23
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBInterfaceType.java32
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBType.java38
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBValidationContext.java54
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBValidatorConstants.java35
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBValidatorMessageConstants.java114
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IFieldType.java24
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IHomeType.java23
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ILocalType.java21
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMessagePrefixEjb11Constants.java91
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMessagePrefixEjb20Constants.java206
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMethodAndFieldConstants.java99
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMethodType.java39
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IRemoteType.java21
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ITypeConstants.java64
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IValidationRule.java80
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IValidationRuleList.java63
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/InvalidInputException.java45
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/J2EEMessageConstants.java39
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/J2EEValidationResourceHandler.java499
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/J2EEValidator.java596
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/MessageDrivenBeanClassVRule.java291
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/MessageUtility.java358
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/MethodUtility.java2149
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/RoleHelper.java221
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionBeanClassVRule.java250
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionLocalComponentVRule.java110
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionLocalHomeVRule.java114
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionRemoteComponentVRule.java113
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionRemoteHomeVRule.java113
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionBeanClassVRule.java258
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionLocalComponentVRule.java109
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionLocalHomeVRule.java114
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionRemoteComponentVRule.java112
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionRemoteHomeVRule.java116
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPBean.java289
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPHome.java130
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPKey.java80
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPRemote.java64
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateCMPBean.java378
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateCMPKey.java259
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateCMPRemote.java63
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateSessionBean.java495
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateSessionHome.java252
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateSessionRemote.java64
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidationCancelledException.java26
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidationRuleUtility.java1627
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/WARMessageConstants.java72
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/WARValidationResourceHandler.java100
-rw-r--r--plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/WarValidator.java1420
104 files changed, 0 insertions, 26775 deletions
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ABMPHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ABMPHomeVRule.java
deleted file mode 100644
index 3862baa60..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ABMPHomeVRule.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-import java.util.List;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-public abstract class ABMPHomeVRule extends AEntityHomeVRule {
-
- public final void validateMatchingReturnTypeMatches(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method homeMethod, Method beanMethod, List[] methodsExtendedLists) {
- long methodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, homeMethod, methodsExtendedLists, this);
- if((methodType & FIND) != FIND) {
- super.validateMatchingReturnTypeMatches(vc, bean, clazz, homeMethod, beanMethod, methodsExtendedLists);
- }
- else {
- JavaHelpers homeRetType = homeMethod.getReturnType();
- JavaHelpers beanRetType = beanMethod.getReturnType();
- if (!ValidationRuleUtility.isAssignableFrom(homeRetType, beanRetType)) {
- // emit the error only if it's a multi-finder. Single-finders are supposed to have different return types on the home & bean class.
- boolean homeRetTypeIsRemote = ValidationRuleUtility.isAssignableFrom(homeRetType, bean.getRemoteInterface());
- boolean homeRetTypeIsLocal = ValidationRuleUtility.isAssignableFrom(homeRetType, bean.getLocalInterface());
- boolean beanRetTypeIsKey = ValidationRuleUtility.isAssignableFrom(beanRetType, ((Entity)bean).getPrimaryKey());
- if(!((homeRetTypeIsRemote || homeRetTypeIsLocal) && beanRetTypeIsKey)) {
- String retTypeName = null;
- if(beanRetTypeIsKey) {
- if((isRemote() & IEJBType.REMOTE) == IEJBType.REMOTE) {
- retTypeName = (bean.getRemoteInterface() == null) ? IEJBValidatorConstants.NULL_REMOTE : bean.getRemoteInterface().getJavaName();
- }
- else {
- retTypeName = (bean.getLocalInterface() == null) ? IEJBValidatorConstants.NULL_LOCAL : bean.getLocalInterface().getJavaName();
- }
- }
- else {
- retTypeName = (beanRetType == null) ? "?" : beanRetType.getJavaName(); //$NON-NLS-1$
- }
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2479, IEJBValidationContext.ERROR, bean, clazz, homeMethod, new String[] { retTypeName}, this);
- vc.addMessage(message);
- }
- }
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ABeanClassVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ABeanClassVRule.java
deleted file mode 100644
index c09dbaa9f..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ABeanClassVRule.java
+++ /dev/null
@@ -1,506 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * @version 1.0
- * @author
- */
-public abstract class ABeanClassVRule extends ATypeVRule implements IEJBType {
- protected final static long[] BASE_TYPES = new long[]{ITypeConstants.JAVA_LANG_OBJECT};
- protected final static int MESSAGE_REMOTE_EXCEPTION_SEVERITY = IEJBValidationContext.WARNING; // Deprecated use of RemoteException.
-
- public long[] getBaseTypes() {
- return BASE_TYPES;
- }
-
- public Object getTarget(Object parent, Object clazz) {
- if(parent == null) {
- return null;
- }
-
- return ((EnterpriseBean)parent).getEjbClass();
- }
-
- public long getDefaultMethodType() {
- return HELPER;
- }
-
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException {
- if(!followAbstractRules(clazz)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2014, IEJBValidationContext.WARNING, bean, clazz, this);
- vc.addMessage(message);
- }
-
- if(!followPublicRules(clazz)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2022, IEJBValidationContext.WARNING, bean, clazz, this);
- vc.addMessage(message);
- }
-
- if(!followFinalRules(clazz)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2015, IEJBValidationContext.WARNING, bean, clazz, this);
- vc.addMessage(message);
- }
-
- validateAppendixB(vc, bean, clazz);
- }
-
- public final static List getRemoteHomeMethodsExtended(List[] methodsExtendedList) {
- return methodsExtendedList[0];
- }
-
- public final static List getLocalHomeMethodsExtended(List[] methodsExtendedList) {
- return methodsExtendedList[1];
- }
-
- public final static List getRemoteComponentMethodsExtended(List[] methodsExtendedList) {
- return methodsExtendedList[2];
- }
-
- public final static List getLocalComponentMethodsExtended(List[] methodsExtendedList) {
- return methodsExtendedList[3];
- }
-
- public final static List getBeanClassMethodsExtended(List[] methodsExtendedList) {
- return methodsExtendedList[4];
- }
-
- public final List[] getMethodsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // A bean class needs the following classes' extended methods:
- // 1. remote home
- // 2. local home
- // 3. remote component
- // 4. local component
- // 5. bean class (when searching for a matching ejbPostCreate method).
- // If a particular bean doesn't use a remote view or local view,
- // then the corresponding entry in the array will be null.
- List[] result = new List[5];
- JavaClass remoteHome = bean.getHomeInterface();
- if(remoteHome != null) {
- result[0] = remoteHome.getMethodsExtended();
- }
- else {
- result[0] = null;
- }
-
- JavaClass localHome = bean.getLocalHomeInterface();
- if(localHome != null) {
- result[1] = localHome.getMethodsExtended();
- }
- else {
- result[1] = null;
- }
-
- JavaClass remoteComponent = bean.getRemoteInterface();
- if(remoteComponent != null) {
- result[2] = remoteComponent.getMethodsExtended();
- }
- else {
- result[2] = null;
- }
-
- JavaClass localComponent = bean.getLocalInterface();
- if(localComponent != null) {
- result[3] = localComponent.getMethodsExtended();
- }
- else {
- result[3] = null;
- }
-
- JavaClass beanClass = bean.getEjbClass();
- if(beanClass != null) {
- result[4] = beanClass.getMethodsExtended();
- }
- else {
- result[4] = null;
- }
-
- return result;
- }
-
- public final List[] getFieldsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // Never check that a bean class' field is defined on another class
- // of the bean.
- return null;
- }
-
- protected abstract boolean shouldBeFinal(JavaClass clazz);
- protected abstract boolean shouldBePublic(JavaClass clazz);
- protected abstract boolean shouldBeAbstract(JavaClass clazz);
- protected abstract boolean shouldValidateTransientField();
- protected abstract JavaHelpers getEjbCreateReturnType(EnterpriseBean bean, Method method) throws InvalidInputException;
- protected abstract String getEjbCreateReturnTypeName(EnterpriseBean bean, Method method) throws InvalidInputException;
- public abstract String getMatchingHomeMethodName(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedList);
-
- public String getMatchingEjbHomeMethodName(IEJBValidationContext vc, Method method) {
- // Section number stating this name convention?
- String methodName = method.getName();
- // Strip the "ejbHome" off, strip off the next character, and replace that character with a lowercase version of that character
- StringBuffer buffer = new StringBuffer(Character.toLowerCase(methodName.charAt(0)));
- buffer.append(method.getName().substring(8));
- return buffer.toString();
- }
-
- public String getMatchingEjbCreateMethodName(IEJBValidationContext vc, Method method) {
- StringBuffer buffer = new StringBuffer(IMethodAndFieldConstants.PREFIX_C);
- // Strip the "ejbC" off of "create" and replace with "c"
- buffer.append(method.getName().substring(4));
- return buffer.toString();
- }
-
- public String getMatchingEjbPostCreateMethodName(IEJBValidationContext vc, Method method) {
- StringBuffer buffer = new StringBuffer(IMethodAndFieldConstants.PREFIX_C);
- // Strip the "ejbPostC" off of "create" and replace with "c"
- buffer.append(method.getName().substring(8));
- return buffer.toString();
- }
-
-
-
- public String getMatchingEjbFindMethodName(IEJBValidationContext vc, Method method) {
- StringBuffer buffer = new StringBuffer(IMethodAndFieldConstants.PREFIX_F);
- // Strip the "ejbF" off of "ejbFind" and replace with "f"
- buffer.append(method.getName().substring(4));
- return buffer.toString();
- }
-
- public String getMatchingBusinessMethodName(IEJBValidationContext vc, Method method) {
- return method.getName();
- }
-
- /*
- * The given method is not supposed to have a matching method.
- */
- public String getNoMatchingMethodName(IEJBValidationContext vc, Method method) {
- return null; // not supposed to have a matching method
- }
-
- public final boolean followFinalRules(JavaClass clazz) {
- if(shouldBeFinal(clazz)) {
- return clazz.isFinal();
- }
- return !clazz.isFinal();
- }
-
- public final boolean followPublicRules(JavaClass clazz) {
- if(shouldBePublic(clazz)) {
- return clazz.isPublic();
- }
- return !clazz.isPublic();
- }
-
- public final boolean followAbstractRules(JavaClass clazz) {
- if(shouldBeAbstract(clazz)) {
- return clazz.isAbstract();
- }
- return !clazz.isAbstract();
- }
-
-
- public void validateEjbCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- if(!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2421, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(method.isFinal()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2422, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(method.isStatic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2423, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- JavaHelpers retType = getEjbCreateReturnType(bean, method);
- if((retType == null) || (!ValidationRuleUtility.isAssignableFrom(method.getReturnType(), retType))) {
- String retTypeName = (retType == null) ? getEjbCreateReturnTypeName(bean, method) : retType.getJavaName();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2424, IEJBValidationContext.WARNING, bean, clazz, method, new String[]{retTypeName}, this);
- vc.addMessage(message);
- }
-
- validateRMI_IIOPTypeRules(vc, bean, clazz, method, methodsExtendedLists, true);
-
- if(validateEjbCreateMethodExceptions()) {
- if(!followRemoteExceptionRules(bean, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2503_ejbCreate, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
- }
-
- public boolean validateEjbCreateMethodExceptions() {
- return true;
- }
-
- public void validateEjbPostCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException, InvalidInputException, ValidationException {
- if(!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2426, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(method.isFinal()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2427, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(method.isStatic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2428, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(!method.isVoid()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2505_ejbPostCreate, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(!followRemoteExceptionRules(bean, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2503_ejbPostCreate, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
-
- public final void validateEjbHomeMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- if(!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2431, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(method.isStatic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2439, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- validateRMI_IIOPTypeRules(vc, bean, clazz, method, methodsExtendedLists, true);
-
- if(!followRemoteExceptionRules(bean, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2503_ejbHome, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // "ejbHome" is 7 characters
- // method will follow the convention, "ejbHome" + Char.toUpper(0) + substring(1), so reverse that convention here
- StringBuffer buffer = new StringBuffer();
- buffer.append(Character.toLowerCase(method.getName().charAt(7))); // put the character back into lower-case
- buffer.append(method.getName().substring(8)); // substring starts at the character following "ejbHome" and the first character -- substring is 0 indexed
- String methodToMatchName = buffer.toString();
-
- Method matchingRemoteHomeMethod = ValidationRuleUtility.getMethod(method, methodToMatchName, getRemoteHomeMethodsExtended(methodsExtendedLists));
- if(matchingRemoteHomeMethod != null) {
- return;
- }
-
- Method matchingLocalHomeMethod = ValidationRuleUtility.getMethod(method, methodToMatchName, getLocalHomeMethodsExtended(methodsExtendedLists));
- if(matchingLocalHomeMethod != null) {
- return;
- }
-
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2430, IEJBValidationContext.INFO, bean, clazz, method, new String[]{methodToMatchName}, this);
- vc.addMessage(message);
- }
-
- public final void validateBusinessMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // IWAD4048 = Business methods must not start with "ejb". Read section 7.10.4 of the EJB 2.0 specification.
- // IWAD4201 = This method name must not start with "ejb". Read section 10.6.8 of the EJB 2.0 specification.
- // IWAD4317 = The method name must not start with "ejb". Read section 12.2.7 of the EJB 2.0 specification.
- if(method.getName().startsWith(IMethodAndFieldConstants.PREFIX_EJB)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2411, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4049 = This method must be public. Read section 7.10.4 of the EJB 2.0 specification.
- // IWAD4202 = This method must be public. Read section 10.6.8 of the EJB 2.0 specification.
- // IWAD4318 = The method must be public. Read section 12.2.7 of the EJB 2.0 specification.
- if(!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2441, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4050 = This method must not be final. Read section 7.10.4 of the EJB 2.0 specification.
- // IWAD4203 = This method must not be final. Read section 10.6.8 of the EJB 2.0 specification.
- // IWAD4319 = The method must not be final. Read section 12.2.7 of the EJB 2.0 specification.
- if(method.isFinal()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2442, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4051 = This method must not be static. Read section 7.10.4 of the EJB 2.0 specification.
- // IWAD4204 = This method must not be static. Read section 10.6.8 of the EJB 2.0 specification.
- // IWAD4320 = The method must not be static. Read section 12.2.7 of the EJB 2.0 specification.
- if(method.isStatic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2443, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4052 = {0} must be a legal RMI-IIOP type. Read section 7.10.4 of the EJB 2.0 specification.
- // IWAD4205 = {0} must be a legal RMI-IIOP type. Read section 10.6.8 of the EJB 2.0 specification.
- // IWAD4321 = {0} must be a legal type for RMI-IIOP. Read section 12.2.7 of the EJB 2.0 specification.
- validateRMI_IIOPTypeRules(vc, bean, clazz, method, methodsExtendedLists, true);
-
- // IWAD4053 = This method cannot throw java.rmi.RemoteException. Read section 7.10.4, 18.3.8, 18.6 of the EJB 2.0 specification.
- // IWAD4206 = This method must not throw java.rmi.RemoteException. Read section 10.6.8, 18.3.8, 18.6 of the EJB 2.0 specification.
- // IWAD4322 = This method must not throw java.rmi.RemoteException. Read section 12.2.7, 18.3.8, 18.6 of the EJB 2.0 specification.
- if(!followRemoteExceptionRules(bean, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2503_bus, getMessageRemoteExceptionSeverity(), bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- validateMatchingComponentMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
-
- public void validateEjbRemoveMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // IWAD4402 = This method must be public. Read section 15.7.5 of the EJB 2.0 specification.
- if(!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2492, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4403 = This method must not be final. Read section 15.7.5 of the EJB 2.0 specification.
- if(method.isFinal()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2493, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4404 = This method must not be static. Read section 15.7.5 of the EJB 2.0 specification.
- if(method.isStatic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2494, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4405 = This method must return void. Read section 15.7.5 of the EJB 2.0 specification.
- if(!method.isVoid()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2505_ejbRemove, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
-
- /*
- * @see IClassVRule#validate(IEJBValidationContext, JavaClass, Field)
- */
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field, List[] fieldExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // IWAD4024 = A transient field should not be the {0} type. Read section 7.4.1 of the EJB 2.0 specification.
- // IWAD4025 = Transient fields are discouraged. Read section 7.4.1 of the EJB 2.0 specification.
- // IWAD4115 = {0} must not be defined in this class. Read section 10.3.1 of the EJB 2.0 specification.
- // IWAD4259 = <cmp-field> field must be the {0} type. Read section 11.2.1 of the EJB 2.0 specification.
- // IWAD4260 = <cmr-field> field must be the {0} type. Read section 11.2.1 of the EJB 2.0 specification.
- if(shouldValidateTransientField()) {
- validateTransientField(vc, bean, clazz, field);
- }
- }
-
- public void validateTransientField(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // By default do nothing
- }
-
- public long getFieldType(EnterpriseBean bean, JavaClass clazz, Field field) {
- if(field == null) {
- return EXCLUDED_FIELD;
- }
- else if(field.getName().equals(IMethodAndFieldConstants.FIELDNAME_SERIALVERSIONUID)) {
- return SERIALVERSIONUID;
- }
- else {
- return OTHER_FIELD;
- }
- }
-
- public void validateMatchingMethodExceptions(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, JavaClass matchingClazz, Method matchingMethod) {
- // Every exception thrown on the bean class' method must be thrown on the component/home method
- /* Don't check for this here - let the home & component do it.
- Set exceptions = ValidationRuleUtility.getNotSubsetExceptions(bean, method, matchingMethod);
- Iterator eiterator = exceptions.iterator();
- while(eiterator.hasNext()) {
- }
- */
-
- // Every exception thrown by the component/home method should be thrown or there may be compile errors
- Set exceptions = ValidationRuleUtility.getNotSubsetSubtypeExceptions(bean, matchingMethod, method);
- Iterator eiterator = exceptions.iterator();
- while(eiterator.hasNext()) {
- JavaClass exception = (JavaClass)eiterator.next();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2456, IEJBValidationContext.WARNING, bean, clazz, method, new String[]{exception.getJavaName(), matchingClazz.getJavaName()}, this);
- vc.addMessage(message);
- }
- }
-
- public final void validateMatchingHomeMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- Method remoteMethod = ValidationRuleUtility.getMethod(method, getMatchingHomeMethodName(vc, bean, clazz, method, methodsExtendedLists), getRemoteHomeMethodsExtended(methodsExtendedLists));
- if(remoteMethod != null) {
- validateMatchingMethodExceptions(vc, bean, clazz, method, bean.getHomeInterface(), remoteMethod);
- }
-
- Method localMethod = ValidationRuleUtility.getMethod(method, getMatchingHomeMethodName(vc, bean, clazz, method, methodsExtendedLists), getLocalHomeMethodsExtended(methodsExtendedLists));
- if(localMethod != null) {
- validateMatchingMethodExceptions(vc, bean, clazz, method, bean.getLocalHomeInterface(), localMethod);
- }
- }
-
- public final void validateMatchingComponentMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- Method remoteMethod = ValidationRuleUtility.getMethod(method, method.getName(), getRemoteComponentMethodsExtended(methodsExtendedLists));
- if(remoteMethod != null) {
- validateMatchingMethodExceptions(vc, bean, clazz, method, bean.getRemoteInterface(), remoteMethod);
- }
-
- Method localMethod = ValidationRuleUtility.getMethod(method, method.getName(), getLocalComponentMethodsExtended(methodsExtendedLists));
- if(localMethod != null) {
- validateMatchingMethodExceptions(vc, bean, clazz, method, bean.getLocalInterface(), localMethod);
- }
- }
-
- protected void validateAppendixB(IEJBValidationContext vc, EnterpriseBean bean, JavaClass thisEjbObject) {
- // The Java inheritance structure must match the EJB inheritance structure.
- // e.g. if EJB B is a child of EJB A, then class B must be a child of class A.
- // B could be a grandchild (or great-grandchild or ...) of A.
- if(bean == null) {
- return;
- }
- EnterpriseBean supertype = getSuperType(bean);
- JavaClass parentEjbObject = null;
- if (supertype != null) {
- parentEjbObject = supertype.getEjbClass();
-
- // EJBObject a Xchild of parent EJBObject (X = child, grandchild, great-grandchild, etc.)
- try {
- ValidationRuleUtility.isValidType(thisEjbObject);
- ValidationRuleUtility.isValidType(parentEjbObject);
- if (!ValidationRuleUtility.isAssignableFrom(thisEjbObject, parentEjbObject)) {
- String[] msgParm = new String[] { thisEjbObject.getQualifiedName(), parentEjbObject.getQualifiedName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2103, IEJBValidationContext.ERROR, bean, thisEjbObject, msgParm, this);
- vc.addMessage(message);
- }
- }
- catch (InvalidInputException e) {
- String[] msgParm = { e.getJavaClass().getQualifiedName(), bean.getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2849, IEJBValidationContext.WARNING, bean, msgParm, this);
- vc.addMessage(message);
- }
- }
- }
-
- public final boolean followRemoteExceptionRules(EnterpriseBean bean, Method method) throws InvalidInputException, ValidationCancelledException {
- // must not throw RemoteException
- return ValidationRuleUtility.doesNotThrowRemoteException(bean, method);
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ACMPHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ACMPHomeVRule.java
deleted file mode 100644
index 573438dc4..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ACMPHomeVRule.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-import java.util.List;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- */
-public abstract class ACMPHomeVRule extends AEntityHomeVRule {
-
- public final void validateFindMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedList) throws ValidationCancelledException, InvalidInputException, ValidationException {
- super.validateFindMethod(vc, bean, clazz, method);
-
- // Check that this method is associated with a query element in ejb-jar.xml
- // findByPrimaryKey does not need a query element (10.5.6)
- long methodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedList, this);
- if((methodType & IMethodAndFieldConstants.FINDBYPRIMARYKEY) == IMethodAndFieldConstants.FINDBYPRIMARYKEY) {
- return;
- }
-
- ContainerManagedEntity cmp = (ContainerManagedEntity)bean;
- if(!ValidationRuleUtility.isAssociatedWithQuery(cmp, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2495, IEJBValidationContext.INFO, bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
-
- public boolean findMatchingMethod(long methodType) {
- if((methodType & FIND) == IMethodAndFieldConstants.FIND) {
- return false;
- }
- return super.findMatchingMethod(methodType);
- }
-
-
- /**
- * @see org.eclipse.wst.validation.internal.provisional.core.core.ejb.ejb20.rules.impl.AHomeVRule#returnsComponentInterfaceOrCollection(IEJBValidationContext, EnterpriseBean, JavaClass, Method)
- */
- protected boolean returnsComponentInterfaceOrCollection(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException, InvalidInputException {
- if(returnsComponentInterface(vc, bean, clazz, method)) {
- return true;
- }
-
- JavaHelpers returnParm = method.getReturnType();
- JavaHelpers javaUtilCollection = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_UTIL_COLLECTION, bean);
- if(ValidationRuleUtility.isAssignableFrom(returnParm, javaUtilCollection)) {
- return true;
- }
-
- return false;
- }
-
- public final void validateMatchingReturnTypeMatches(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method homeMethod, Method beanMethod, List[] methodsExtendedList) {
- long methodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, homeMethod, methodsExtendedList, this);
- if((methodType & FIND) != FIND) {
- super.validateMatchingReturnTypeMatches(vc, bean, clazz, homeMethod, beanMethod, methodsExtendedList);
- }
- // do not validate the return type of find methods because there should not be an implementation on the bean class
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AComponentVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AComponentVRule.java
deleted file mode 100644
index ba2aecead..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AComponentVRule.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * @version 1.0
- * @author
- */
-public abstract class AComponentVRule extends AInterfaceTypeVRule {
- public Object getTarget(Object parent, Object clazz) {
- if(parent == null) {
- return null;
- }
-
- if((isRemote() & REMOTE) == REMOTE) {
- return ((EnterpriseBean)parent).getRemoteInterface();
- }
- return ((EnterpriseBean)parent).getLocalInterface();
- }
-
- public long getDefaultMethodType() {
- return BUSINESS;
- }
-
- public long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException {
- if(!followRMI_IIOPInheritanceRules(bean, clazz)) {
- // IWAD4057 = {0} must follow RMI-IIOP rules for remote interfaces. Read section 7.10.5 of the EJB 2.0 specification.
- // IWAD4210 = {0} must follow RMI-IIOP rules for remote interfaces. Read section 10.6.9 of the EJB 2.0 specification.
- // IWAD4326 = {0} must follow RMI-IIOP rules for remote interfaces. Read section 12.2.8 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2468, IEJBValidationContext.INFO, bean, clazz, this);
- vc.addMessage(message);
- }
-
- validateAppendixB(vc, bean, clazz);
- }
-
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- super.validate(vc, bean, clazz, method, methodsExtendedLists); // check application exceptions
-
- if(isEJBInterfaceMethod(bean, method)) {
- // IWAD4021 = {0} is provided by the container. Read section 6.5 of the EJB 2.0 specification.
- // IWAD4110 = {0} is provided by the container. Read section 9.9 of the EJB 2.0 specification.
- // IWAD4112 = {0} is provided by the container. Read section 9.10 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2469, IEJBValidationContext.INFO, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- Method match = ValidationRuleUtility.getMethod(method, method.getName(), getBeanClassMethodsExtended(methodsExtendedLists));
- if(match == null) {
- // IWAD4058 = {0} must exist on {1}. Read section 7.10.5 of the EJB 2.0 specificiation.
- // IWAD4070 = {0} must exist on {1}. Read section 7.10.7 of the EJB 2.0 specification.
- // IWAD4327 = {0} must exist on {1}. Read section 12.2.8 of the EJB 2.0 specification.
- // IWAD4354 = {0} must exist on {1}. Read section 12.2.10 of the EJB 2.0 specification.
- // IWAD4211 = {0} must exist on {1}. Read section 10.6.9 of the EJB 2.0 specification.
- // IWAD4227 = {0} must exist on {1}. Read section 10.6.11 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2023, IEJBValidationContext.WARNING, bean, clazz, method, new String[]{method.getMethodElementSignature(), bean.getEjbClass().getJavaName()}, this);
- vc.addMessage(message);
- }
- else {
- if(!ValidationRuleUtility.isAssignableFrom(method.getReturnType(), match.getReturnType())) {
- // IWAD4212 = This method must return the same type as {0}. Read section 10.6.9 of the EJB 2.0 specification.
- // IWAD4228 = This method must return the same type as {0}. Read section 10.6.11 of the EJB 2.0 specification.
- // IWAD4328 = This method must return the same type as {0} on {1}. Read section 12.2.8 of the EJB 2.0 specification.
- // IWAD4355 = This method must return {0}. Read section 12.2.10 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2470, IEJBValidationContext.ERROR, bean, clazz, method, new String[]{match.getReturnType().getJavaName()}, this);
- vc.addMessage(message);
- }
-
- Set exceptions = ValidationRuleUtility.getNotSubsetExceptions(bean, match, method);
- Iterator eiterator = exceptions.iterator();
- while(eiterator.hasNext()) {
- JavaClass exception = (JavaClass)eiterator.next();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2471, IEJBValidationContext.WARNING, bean, clazz, method, new String[]{exception.getJavaName(), match.getMethodElementSignature()}, this);
- vc.addMessage(message);
- }
- }
-
- if(!followRemoteExceptionRules(bean, method)) {
- // IWAD4056 = This method must throw java.rmi.RemoteException. Read section 7.10.5 of the EJB 2.0 specification.
- // IWAD4069 = This method must not throw java.rmi.RemoteException. Read section 7.10.7, 18.3.8, 18.6 of the EJB 2.0 specification.
- // IWAD4325 = This method must throw java.rmi.RemoteException. Read section 12.2.8 of the EJB 2.0 specification.
- // IWAD4353 = This method must not throw java.rmi.RemoteException. Read section 12.2.10, 18.3.8, 18.6 of the EJB 2.0 specification.
- // IWAD4209 = This method must throw java.rmi.RemoteException. Read section 10.6.9 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2503_bus, getMessageRemoteExceptionSeverity(), bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4055 = {0} must be a legal type for RMI-IIOP. Read section 7.10.5 of the EJB 2.0 specification.
- // IWAD4208 = {0} must be a legal type for RMI-IIOP. Read section 10.6.9 of the EJB 2.0 specification.
- // IWAD4324 = {0} must be a legal type for RMI-IIOP. Read section 12.2.8 of the EJB 2.0 specification.
- validateRMI_IIOPTypeRules(vc, bean, clazz, method, methodsExtendedLists, true);
-
- JavaHelpers oe = getOverExposedLocalType(bean, clazz, method);
- if(oe != null) {
- // IWAD4059 = This method must not expose the {0} type. Read section 7.10.5 of the EJB 2.0 specification.
- // IWAD4107 = This method must not expose the {0} type. Read section 9.7.2 of the EJB 2.0 specification.
- // IWAD4330 = This method must not expose the {0} type. Read section 12.2.8 of the EJB 2.0 specification.
- // IWAD4128 = This method must not expose the {0} type. Read section 10.3.1, 10.3.10.1 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2472, IEJBValidationContext.INFO, bean, clazz, method, new String[]{oe.getQualifiedName()}, this);
- vc.addMessage(message);
- }
- }
-
- protected void validateAppendixB(IEJBValidationContext vc, EnterpriseBean bean, JavaClass thisComponent) {
- // The Java inheritance structure must match the EJB inheritance structure.
- // e.g. if EJB B is a child of EJB A, then class B must be a child of class A.
- // B could be a grandchild (or great-grandchild or ...) of A.
- if(bean == null) {
- return;
- }
- EnterpriseBean supertype = getSuperType(bean);
- JavaClass parentComponent = null;
- if (supertype != null) {
- parentComponent = getComponentInterface(supertype);
-
- if(parentComponent == null) {
- // child uses either local, or remote, but not both interfaces
- return;
- }
-
- // Component a Xchild of parent Component
- try {
- ValidationRuleUtility.isValidType(thisComponent);
- ValidationRuleUtility.isValidType(parentComponent);
- if (!ValidationRuleUtility.isAssignableFrom(thisComponent, parentComponent)) {
- String[] msgParm = new String[] { thisComponent.getQualifiedName(), parentComponent.getQualifiedName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2105, IEJBValidationContext.ERROR, bean, thisComponent, msgParm, this);
- vc.addMessage(message);
- }
- }
- catch (InvalidInputException e) {
- String[] msgParm = { e.getJavaClass().getQualifiedName(), bean.getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2849, IEJBValidationContext.WARNING, bean, msgParm, this);
- vc.addMessage(message);
- }
- }
-
-// validateAppendixB(vc, supertype, parentComponent);
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AEntityBeanClassVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AEntityBeanClassVRule.java
deleted file mode 100644
index 1f1219447..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AEntityBeanClassVRule.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.text.MessageFormat;
-import java.util.List;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- */
-public abstract class AEntityBeanClassVRule extends ABeanClassVRule {
- private static final String missingMethodTemplate = "{0}({1})"; //$NON-NLS-1$
-
- public void validateEjbCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedList) throws ValidationCancelledException, ValidationCancelledException, InvalidInputException, ValidationException {
- super.validateEjbCreateMethod(vc, bean, clazz, method, methodsExtendedList);
-
- validateMatchingEjbPostCreateMethod(vc, bean, clazz, method, methodsExtendedList);
- }
-
- public final void validateMatchingEjbPostCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- String matchingMethodName = IMethodAndFieldConstants.METHODNAME_EJBPOSTCREATE + method.getName().substring(9); // "ejbCreate" is 9 characters long, so strip off characters 0..8 inclusive
- Method ejbPostCreateMethod = ValidationRuleUtility.getMethod(method, matchingMethodName, getBeanClassMethodsExtended(methodsExtendedLists));
- if(ejbPostCreateMethod == null) {
- String missingMethod = MessageFormat.format(missingMethodTemplate, new String[]{matchingMethodName, ValidationRuleUtility.getParmsAsString(method)});
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2050_ejbPostCreate, IEJBValidationContext.ERROR, bean, clazz, method, new String[]{missingMethod}, this);
- vc.addMessage(message);
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AEntityHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AEntityHomeVRule.java
deleted file mode 100644
index 254ca2065..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AEntityHomeVRule.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaParameter;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-
-public abstract class AEntityHomeVRule extends AHomeVRule {
- /**
- * If the type of the method isn't listed in the KNOWN_METHODS, what type of method is it
- * considered to be?
- */
- public long getDefaultMethodType() {
- return HOME;
- }
-
- public final void validateFindByPrimaryKeyMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException, ValidationException {
- JavaClass key = ((Entity)bean).getPrimaryKey();
- JavaParameter[] parms = method.listParametersWithoutReturn();
- if((parms.length != 1) || (!ValidationRuleUtility.isAssignableFrom(key, parms[0].getJavaType()))) {
- String keyName = (key == null) ? IEJBValidatorConstants.NULL_PRIMARY_KEY : key.getJavaName();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2475, IEJBValidationContext.WARNING, bean, clazz, method, new String[]{keyName}, this);
- vc.addMessage(message);
- }
- }
-
- public void validateFindMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException, InvalidInputException, ValidationException {
- if(!ValidationRuleUtility.followsFinderExceptionRules(bean, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2477, IEJBValidationContext.INFO, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(!ValidationRuleUtility.followsObjectNotFoundExceptionRules(bean, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2478, IEJBValidationContext.INFO, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(method.getName().equals(IMethodAndFieldConstants.METHODNAME_FINDBYPRIMARYKEY)) {
- validateFindByPrimaryKeyMethod(vc, bean, clazz, method);
- if(!returnsComponentInterface(vc, bean, clazz, method)) {
- JavaClass componentInterface = getComponentInterface(bean);
- String className = null;
- if(componentInterface != null) {
- className = componentInterface.getJavaName();
- }
- else {
- if((isRemote() & IEJBType.REMOTE) == IEJBType.REMOTE) {
- className = IEJBValidatorConstants.NULL_REMOTE;
- }
- else {
- className = IEJBValidatorConstants.NULL_LOCAL;
- }
- }
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2479, IEJBValidationContext.ERROR, bean, clazz, method, new String[]{className}, this);
- vc.addMessage(message);
- }
- }
- else {
- if(!returnsComponentInterfaceOrCollection(vc, bean, clazz, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2403, IEJBValidationContext.WARNING, bean, clazz, method, new String[]{getComponentInterface(bean).getName()}, this);
- vc.addMessage(message);
- }
- }
- }
-
- public void validateHomeMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException, ValidationException {
- // IWAD4350 = The return type must match the return type of {0}. Read section 12.2.9 of the EJB 2.0 specification.
- // The above check is done in the "validate(vc, bean, clazz, method) method.
- if(method.getName().startsWith(IMethodAndFieldConstants.METHODNAME_CREATE)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2462, IEJBValidationContext.INFO, bean, clazz, method, this);
- vc.addMessage(message);
- }
- else if(method.getName().startsWith(IMethodAndFieldConstants.PREFIX_FIND)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2463, IEJBValidationContext.INFO, bean, clazz, method, this);
- vc.addMessage(message);
- }
- else if(method.getName().startsWith(IMethodAndFieldConstants.METHODNAME_REMOVE)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2464, IEJBValidationContext.INFO, bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AHomeVRule.java
deleted file mode 100644
index 09dfc454d..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AHomeVRule.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- * @version 1.0
- * @author
- */
-public abstract class AHomeVRule extends AInterfaceTypeVRule {
- public Object getTarget(Object parent, Object clazz) {
- if(parent == null) {
- return null;
- }
-
- if((isRemote() & REMOTE) == REMOTE) {
- return ((EnterpriseBean)parent).getHomeInterface();
- }
- return ((EnterpriseBean)parent).getLocalHomeInterface();
- }
-
- public void validateFindMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // By default, do nothing.
- // Let the entity rules override this method, and the session don't do anything
- // because validateMethodMustNotExist does what the sessions need.
- }
-
- public boolean followsCreateExceptionRules(EnterpriseBean bean, Method method) throws InvalidInputException, ValidationCancelledException {
- return ValidationRuleUtility.throwsCreateException(bean, method);
- }
-
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException {
- if(!ValidationRuleUtility.isLegalRMI_IIOPInheritance(clazz)) {
- // IWAD4334 = {0} must follow RMI-IIOP rules for remote interfaces. Read section 12.2.9 of the EJB 2.0 specification.
- // IWAD4217 = {0} must follow RMI-IIOP rules for remote interfaces. Read section 10.6.10 of the EJB 2.0 specification.
- // IWAD4062 = {0} must follow RMI-IIOP rules for remote interfaces. Read section 7.10.6 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2461, IEJBValidationContext.INFO, bean, clazz, this);
- vc.addMessage(message);
- }
-
- validateAppendixB(vc, bean, clazz);
- }
-
- public final void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- super.validate(vc, bean, clazz, method, methodsExtendedLists); // check application exceptions
-
- long methodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedLists, this);
- String nameOfMethodToFind = method.getName();
- boolean validateReturnTypeMatches = false;
- if((methodType & CREATE) == CREATE) {
- validateCreateMethod(vc, bean, clazz, method);
-
- StringBuffer buffer = new StringBuffer(IMethodAndFieldConstants.PREFIX_EJBC);
- // Strip the "c" off of "create" and replace with "ejbC"
- buffer.append(method.getName().substring(1));
- nameOfMethodToFind = buffer.toString();
- }
- else if((methodType & FIND) == FIND) {
- validateFindMethod(vc, bean, clazz, method);
- StringBuffer buffer = new StringBuffer(IMethodAndFieldConstants.PREFIX_EJBF);
- // Strip the "f" off of "find" and replace with "ejbF"
- buffer.append(method.getName().substring(1));
- nameOfMethodToFind = buffer.toString();
-
- validateReturnTypeMatches = true;
- }
- else if((methodType & HOME) == HOME) {
- // remove is a special method. See 9.5.3 for an example
-
- validateHomeMethod(vc, bean, clazz, method);
-
- // Section number stating this name convention?
- String methodName = method.getName();
- StringBuffer buffer = new StringBuffer(IMethodAndFieldConstants.PREFIX_EJBHOME);
- buffer.append(Character.toUpperCase(methodName.charAt(0)));
- buffer.append(method.getName().substring(1));
- nameOfMethodToFind = buffer.toString();
-
- validateReturnTypeMatches = true;
- }
- else {
- // Method shouldn't be here. ATypeVRule will catch.
- return;
- }
-
- if(!followRemoteExceptionRules(bean, method)) {
- IMethodType mType = MethodUtility.getUtility().getMethodType(bean, clazz, method, methodsExtendedLists, this);
- if(mType == null) {
- // should never happen...
- Logger logger = vc.getMsgLogger();
- if(logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("AHomeVRule - validate method which must not exist"); //$NON-NLS-1$
- entry.setText("Method type is null: " + clazz.getQualifiedName() + "::" + method.getName() ); //$NON-NLS-1$ //$NON-NLS-2$
- logger.write(Level.FINEST, entry);
- }
- }
- else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, mType.getMessageId_messageRemoteException(), getMessageRemoteExceptionSeverity(), bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
-
- validateRMI_IIOPTypeRules(vc, bean, clazz, method, methodsExtendedLists, ((methodType & FIND) != FIND)); // do not check that the return type of a find method is serializable. If it's Collection or Set it won't be serializable, and if it doesn't return Collection, Set, or the component interface then the return type will be flagged.
-
- JavaHelpers local = getOverExposedLocalType(bean, clazz, method);
- if(local != null) {
- // IWAD4023 = {0} cannot be an argument or result type. Read section 6.7.2 of the EJB 2.0 specification.
- // IWAD4225 = This method must not expose the {0} type. Read section 10.6.10 of the EJB 2.0 specification.
- // IWAD4351 = This method must not expose the {0} type. Read section 12.2.9 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2466, IEJBValidationContext.INFO, bean, clazz, method, new String[]{local.getQualifiedName()}, this);
- vc.addMessage(message);
- }
-
- if(findMatchingMethod(methodType)) {
- validateMatchingBeanMethod(vc, bean, clazz, method, nameOfMethodToFind, validateReturnTypeMatches, methodsExtendedLists);
- }
- }
-
- public boolean findMatchingMethod(long methodType) {
- return true;
- }
-
- public final void validateMatchingBeanMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, String nameOfMethodToFind, boolean validateReturnTypeMatches, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- Method match = ValidationRuleUtility.getMethod(method, nameOfMethodToFind, getBeanClassMethodsExtended(methodsExtendedLists));
- if(match == null) {
- IMethodType mType = MethodUtility.getUtility().getMethodType(bean, clazz, method, methodsExtendedLists, this);
- if(mType == null) {
- // oops
- Logger logger = vc.getMsgLogger();
- if(logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("AHomeVRule - validate method"); //$NON-NLS-1$
- entry.setText("Method type is null: " + bean.getName() + "::" + clazz.getJavaName() + "::" + method.getMethodElementSignature()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- logger.write(Level.FINEST, entry);
- }
- }
- else {
- JavaClass beanClass = bean.getEjbClass();
- String beanClassName = (beanClass == null) ? IEJBValidatorConstants.NULL_BEAN_CLASS : beanClass.getJavaName();
- IMessage message = MessageUtility.getUtility().getMessage(vc, mType.getMessageId_messageMissingMatching(), IEJBValidationContext.WARNING, bean, clazz, method, new String[]{nameOfMethodToFind, beanClassName}, this);
- vc.addMessage(message);
- }
- }
- else {
- if(validateReturnTypeMatches) {
- validateMatchingReturnTypeMatches(vc, bean, clazz, method, match, methodsExtendedLists);
- }
-
- Set exceptions = ValidationRuleUtility.getNotSubsetExceptions(bean, match, method);
- Iterator eiterator = exceptions.iterator();
- while(eiterator.hasNext()) {
- JavaClass exception = (JavaClass)eiterator.next();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2465, IEJBValidationContext.WARNING, bean, clazz, method, new String[]{exception.getJavaName(), match.getMethodElementSignature()}, this);
- vc.addMessage(message);
- }
- }
- }
-
- public void validateMatchingReturnTypeMatches(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method homeMethod, Method beanMethod, List[] methodsExtendedMethod) {
- if(!ValidationRuleUtility.isAssignableFrom(homeMethod.getReturnType(), beanMethod.getReturnType())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2402, IEJBValidationContext.ERROR, bean, clazz, homeMethod, new String[]{beanMethod.getReturnType().getJavaName()}, this);
- vc.addMessage(message);
- }
- }
-
- public void validateCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException, InvalidInputException, ValidationException {
- if(!followsCreateExceptionRules(bean, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2467, IEJBValidationContext.INFO, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(!returnsComponentInterface(vc, bean, clazz, method)) {
- JavaClass componentInterface = getComponentInterface(bean);
- String className = null;
- if(componentInterface != null) {
- className = componentInterface.getJavaName();
- }
- else {
- if((isRemote() & IEJBType.REMOTE) == IEJBType.REMOTE) {
- className = IEJBValidatorConstants.NULL_REMOTE;
- }
- else {
- className = IEJBValidatorConstants.NULL_LOCAL;
- }
- }
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2402, IEJBValidationContext.ERROR, bean, clazz, method, new String[]{className}, this);
- vc.addMessage(message);
- }
- }
-
- public void validateHomeMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException, ValidationException {
- // IWAD4350 = The return type must match the return type of {0}. Read section 12.2.9 of the EJB 2.0 specification.
- // The above check is done in the "validate(vc, bean, clazz, method) method.
- }
-
- protected boolean returnsComponentInterface(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException {
- JavaClass componentInterface = getComponentInterface(bean);
- return ValidationRuleUtility.isAssignableFrom(method.getReturnType(), componentInterface);
- }
-
- protected boolean returnsComponentInterfaceOrCollection(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException, InvalidInputException {
- if(returnsComponentInterface(vc, bean, clazz, method)) {
- return true;
- }
-
- JavaHelpers returnParm = method.getReturnType();
- JavaHelpers javaUtilEnumeration = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_UTIL_ENUMERATION, bean);
- if(ValidationRuleUtility.isAssignableFrom(returnParm, javaUtilEnumeration)) {
- return true;
- }
-
- JavaHelpers javaUtilCollection = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_UTIL_COLLECTION, bean);
- if(ValidationRuleUtility.isAssignableFrom(returnParm, javaUtilCollection)) {
- return true;
- }
-
- return false;
- }
-
- protected void validateAppendixB(IEJBValidationContext vc, EnterpriseBean bean, JavaClass thisHome) {
- // The Java inheritance structure must match the EJB inheritance structure.
- // e.g. if EJB B is a child of EJB A, then class B must be a child of class A.
- // B could be a grandchild (or great-grandchild or ...) of A.
-
- if(bean == null) {
- // bean has no supertype
- return;
- }
- EnterpriseBean supertype = getSuperType(bean);
- JavaClass parentHome = null;
- if (supertype != null) {
- // check this CMP's supertype
- parentHome = getHomeInterface(supertype);
-
- if(parentHome == null) {
- // child uses either local, or remote, but not both interfaces
- return;
- }
-
- // Home a Xchild of parent Home
- // In our EJB component inheritance structure, while it is legal for
- // a home to inherit from another home, (section B.2), it is not legal
- // for WSA component inheritance structure.
- try {
- ValidationRuleUtility.isValidType(thisHome);
- ValidationRuleUtility.isValidType(parentHome);
- if (ValidationRuleUtility.isAssignableFrom(thisHome, parentHome)) {
- String[] msgParm = new String[] { thisHome.getQualifiedName(), parentHome.getQualifiedName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2104, IEJBValidationContext.ERROR, bean, thisHome, msgParm, this);
- vc.addMessage(message);
- }
- }
- catch (InvalidInputException e) {
- String[] msgParm = { e.getJavaClass().getQualifiedName(), bean.getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2849, IEJBValidationContext.WARNING, bean, msgParm, this);
- vc.addMessage(message);
- }
- }
-
-// validateAppendixB(vc, supertype, parentHome);
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AInterfaceTypeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AInterfaceTypeVRule.java
deleted file mode 100644
index 3526bd066..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AInterfaceTypeVRule.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.JavaParameter;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/*
- * This class is a hack around the Java lack of support for multiple inheritance.
- * All if statements which object-oriented programming would normally replace
- * are contained in this class.
- */
-public abstract class AInterfaceTypeVRule extends ATypeVRule implements IEJBInterfaceType {
- public final static List getBeanClassMethodsExtended(List[] methodsExtendedList) {
- return methodsExtendedList[0];
- }
-
- public final List[] getMethodsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- // A home or component class needs the following classes' extended methods:
- // 1. bean class
- JavaClass beanClass = bean.getEjbClass();
- if(beanClass == null) {
- throw new InvalidInputException();
- }
- List[] result = new List[1];
- result[0] = beanClass.getMethodsExtended();
- return result;
- }
-
- public final List[] getFieldsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // Never check that a home or component's field is defined on another class
- // of the bean.
- return null;
- }
-
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field, List[] fieldsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- //Default
- }
-
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- validateApplicationExceptionRules(vc, bean, clazz, method);
- }
-
- public final boolean isEJBInterfaceMethod(EnterpriseBean bean, Method method) throws InvalidInputException {
- long[] superTypes = getSupertypes();
- for(int i=0; i<superTypes.length; i++) {
- if(ClassUtility.getUtility().isClassType(bean, method.getJavaClass(), superTypes[i])) {
- return true;
- }
- }
- return false;
- }
-
- public final JavaHelpers getOverExposedLocalType(EnterpriseBean bean, JavaClass clazz, Method method) {
- if((isRemote() & IEJBType.REMOTE) == IEJBType.REMOTE) {
- // need to check that the method doesn't expose any of the local types of the bean
- JavaParameter[] parms = method.listParametersWithoutReturn();
- if(parms != null) {
- for(int i=0; i<parms.length; i++) {
- JavaParameter parm = parms[i];
- if(ValidationRuleUtility.isLocalType(bean, parm.getJavaType())) {
- return parm.getJavaType();
- }
- }
- }
-
- // Now check the return type
- JavaHelpers parm = method.getReturnType();
- if(ValidationRuleUtility.isLocalType(bean, parm)) {
- return parm;
- }
-
- return null;
- }
- return null;
- }
-
- public long getFieldType(EnterpriseBean bean, JavaClass clazz, Field field) {
- if(field == null) {
- return EXCLUDED_FIELD;
- }
- else if(field.getName().equals(IMethodAndFieldConstants.FIELDNAME_SERIALVERSIONUID)) {
- return SERIALVERSIONUID;
- }
- else {
- return OTHER_FIELD;
- }
- }
-
- public void validateApplicationExceptionRules(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException {
- List exceptions = method.getJavaExceptions();
- if(exceptions.size() == 0) {
- return;
- }
-
- // IWAD4419 = {0} must be a subclass of java.lang.Exception. Read section 18.1.1, 18.2.1 of the EJB 2.0 specification.
- Iterator iterator = exceptions.iterator();
- try {
- JavaHelpers javaLangException = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_LANG_EXCEPTION, bean);
- JavaHelpers javaLangRuntimeException = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_LANG_RUNTIMEEXCEPTION, bean);
-
- while(iterator.hasNext()) {
- JavaClass exception = (JavaClass)iterator.next();
-
- if(!ValidationRuleUtility.isApplicationException(exception, bean)) {
- continue;
- }
-
- if(!ValidationRuleUtility.isAssignableFrom(exception, javaLangException)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2404, IEJBValidationContext.WARNING, bean, clazz, method, new String[]{exception.getName()}, this);
- vc.addMessage(message);
-
- // no point checking the rest
- continue;
- }
-
- // IWAD4420 = {0} must not be a subclass of java.lang.RuntimeException. Read section 18.1.1, 18.2.1 of the EJB 2.0 specification.
- if(ValidationRuleUtility.isAssignableFrom(exception, javaLangRuntimeException)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2416, IEJBValidationContext.WARNING, bean, clazz, method, new String[]{exception.getName()}, this);
- vc.addMessage(message);
- }
- }
- return;
- }
- catch(InvalidInputException exc) {
- // vc.addMessage("Cannot validate exceptions because the {0} type cannot be reflected. Check the classpath.");
- // Don't add any message other than the "cannot validate" message.
- return;
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AKeyClassVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AKeyClassVRule.java
deleted file mode 100644
index 958407488..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AKeyClassVRule.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.List;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * @version 1.0
- * @author
- */
-public abstract class AKeyClassVRule extends ATypeVRule {
- protected final static long[] BASE_TYPES = new long[]{ITypeConstants.JAVA_LANG_OBJECT};
-
- public long[] getBaseTypes() {
- return BASE_TYPES;
- }
-
- public final List[] getMethodsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // Never check that a key class' method is defined on another class
- // of the bean.
- return null;
- }
-
- public final List[] getFieldsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // Never check that a key class' field is defined on another class
- // of the bean.
- return null;
- }
-
- /*
- * @see IClassVRule#validate(IEJBValidationContext, EnterpriseBean, JavaClass)
- */
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // CHKJ2108 = {0} must be a legal Value Type in RMI-IIOP. Read section 9.8 of the EJB 2.0 specification.
- // CHKJ2241 = {0} must be a legal Value Type in RMI-IIOP. Read section 10.6.13 of the EJB 2.0 specification.
- // CHKJ2376 = {0} must be a legal Value Type in RMI-IIOP. Read section 12.2.12 of the EJB 2.0 specification.
- if(!ValidationRuleUtility.isLegalRMI_IIOPType(bean, clazz)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2019, IEJBValidationContext.INFO, bean, clazz, this);
- vc.addMessage(message);
- }
- }
-
- public long getFieldType(EnterpriseBean bean, JavaClass clazz, Field field) {
- if(field == null) {
- return EXCLUDED_FIELD;
- }
- else if(field.getName().equals(IMethodAndFieldConstants.FIELDNAME_SERIALVERSIONUID)) {
- return SERIALVERSIONUID;
- }
- else {
- return OTHER_FIELD;
- }
- }
-
- public long getDefaultMethodType() {
- return NO_METHODS;
- }
-
- public final boolean followRemoteExceptionRules(EnterpriseBean bean, Method method) throws InvalidInputException, ValidationCancelledException {
- // Doesn't matter if the key class throws RemoteException or not
- return true;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ASessionBeanClassVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ASessionBeanClassVRule.java
deleted file mode 100644
index e1b947510..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ASessionBeanClassVRule.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- */
-public abstract class ASessionBeanClassVRule extends ABeanClassVRule {
- public final void validateTransientField(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field) throws ValidationCancelledException, InvalidInputException, ValidationException {
- if(field.isTransient()) {
- // IWAD4025 = Transient fields are discouraged. Read section 7.4.1 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2453, IEJBValidationContext.INFO, bean, clazz, field, this);
- vc.addMessage(message);
-
- JavaHelpers javaxEjbSessionContext = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVAX_EJB_SESSIONCONTEXT, bean);
- JavaHelpers javaxTransactionUsertransaction = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVAX_TRANSACTION_USERTRANSACTION, bean);
- if(ValidationRuleUtility.isAssignableFrom(ValidationRuleUtility.getType(field), javaxEjbSessionContext) ||
- ValidationRuleUtility.isAssignableFrom(ValidationRuleUtility.getType(field), javaxTransactionUsertransaction) ||
- ValidationRuleUtility.isLocalType(bean, ValidationRuleUtility.getType(field)) ||
- ValidationRuleUtility.isJNDINamingContext(field))
- {
- // IWAD4024 = A transient field should not be the {0} type. Read section 7.4.1 of the EJB 2.0 specification.
- message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2452, IEJBValidationContext.WARNING, bean, clazz, field, this);
- vc.addMessage(message);
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ASessionHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ASessionHomeVRule.java
deleted file mode 100644
index 4959ef332..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ASessionHomeVRule.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-/**
- */
-public abstract class ASessionHomeVRule extends AHomeVRule {
- /**
- * If the type of the method isn't listed in the KNOWN_METHODS, what type of method is it
- * considered to be?
- */
- public long getDefaultMethodType() {
- // If it's not a create method, then it shouldn't be there.
- return EXCLUDED_METHOD;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AStatelessHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AStatelessHomeVRule.java
deleted file mode 100644
index 3bf8b84cc..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AStatelessHomeVRule.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * @version 1.0
- * @author
- */
-public abstract class AStatelessHomeVRule extends ASessionHomeVRule {
- public void validateCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // The create method must be a create() method.
- if((method.listParametersWithoutReturn().length != 0) || (!IMethodAndFieldConstants.METHODNAME_CREATE.equals(method.getName()))) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2476, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
- else {
- super.validateCreateMethod(vc, bean, clazz, method);
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ATypeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ATypeVRule.java
deleted file mode 100644
index 58ce95ac5..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ATypeVRule.java
+++ /dev/null
@@ -1,643 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import java.util.List;
-import java.util.logging.Level;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.JavaParameter;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * @version 1.0
- * @author
- */
-public abstract class ATypeVRule extends AValidationRule implements IClassVRule, IEJBType {
- private static final int NO_FIELDS = 0;
-
- private long _methodList = NO_METHODS;
- private long _fieldList = NO_FIELDS;
-
- public final void validate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationException {
- vc.subtask(IEJBValidatorConstants.STATUS_VALIDATING, new String[]{((JavaClass) target).getJavaName()});
-
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("EJB20Validator - validate"); //$NON-NLS-1$
- entry.setText(getClass().getName() + "::validate(" + targetParent + ", " + target); //$NON-NLS-1$ //$NON-NLS-2$
- logger.write(Level.FINEST, entry);
- }
-
- try {
- vc.terminateIfCancelled();
-
- EnterpriseBean bean = (EnterpriseBean) targetParent;
- JavaClass clazz = (JavaClass) target;
-
- try {
- //clean up old reflection error on the clazz that is getting validated
- vc.removeMessages(clazz);
- // Check that all of the types in the bean reflected correctly,
- // and that the types' parents reflected correctly too.
- ValidationRuleUtility.isValidTypeHierarchy(bean, clazz);
- } catch (InvalidInputException exc) {
- reflectionError(vc, bean, clazz);
- return;
- }
-
- if (ValidationRuleUtility.isUnnamedPackage(clazz.getJavaPackage())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2041, IEJBValidationContext.INFO, bean, clazz, this);
- vc.addMessage(message);
- }
-
- try {
- validate(vc, bean, clazz);
- vc.terminateIfCancelled();
-
- List[] methodsExtendedList = getMethodsExtended(vc, bean, clazz);
- validate(vc, bean, clazz, clazz.listMethodExtended(), methodsExtendedList);
- vc.terminateIfCancelled();
-
- List[] fieldsExtendedList = getFieldsExtended(vc, bean, clazz);
- validate(vc, bean, clazz, clazz.listFieldExtended(), fieldsExtendedList);
- vc.terminateIfCancelled();
-
- validateSupertypes(vc, bean, clazz);
- vc.terminateIfCancelled();
-
- validateMethodsWhichMustExist(vc, bean, clazz);
- vc.terminateIfCancelled();
- } catch (InvalidInputException exc) {
- reflectionError(vc, bean, clazz);
- return;
- }
- } catch (ValidationCancelledException exc) {
- // remove any existing messages since they may be faulty
- }
- }
-
- protected final void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field[] fields, List[] fieldsExtendedLists) throws ValidationException {
- try {
- vc.terminateIfCancelled();
-
- Field field = null;
- for (int i = 0; i < fields.length; i++) {
- vc.terminateIfCancelled();
- field = fields[i];
- if (field == null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINE)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("EJB20Validator - validate fields"); //$NON-NLS-1$
- entry.setText("A field is null on " + clazz.getQualifiedName()); //$NON-NLS-1$
- logger.write(Level.FINE, entry);
- }
- continue;
- }
- try {
- Logger logger = vc.getMsgLogger();
- if (logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("EJB20Validator - validate fields"); //$NON-NLS-1$
- entry.setText("Validating field " + field.getName() + "on clazz " + clazz + " and isValid returns " + isValid(bean, clazz, field)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- logger.write(Level.FINEST, entry);
- }
-
- if (isValid(bean, clazz, field)) {
- register(vc, bean, clazz, field, fieldsExtendedLists);
- validate(vc, bean, clazz, field, fieldsExtendedLists);
- }
- } catch (InvalidInputException e) {
- reflectionWarning(vc, bean, clazz, field, e);
- }
- }
- vc.terminateIfCancelled();
- } catch (ValidationCancelledException exc) {
- // remove any existing messages since they may be faulty
- }
-
- }
-
- protected final boolean isValid(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws InvalidInputException {
- if (isOwnedByBase(bean, method)) {
- return false;
- }
-
- return ((getMethodType(bean, clazz, method, methodsExtendedLists) & EXCLUDED_METHOD) != EXCLUDED_METHOD);
- }
-
- protected final boolean isOwnedByBase(EnterpriseBean bean, Field field) throws InvalidInputException {
- if (field == null) {
- return false;
- }
-
- long[] baseTypes = getBaseTypes();
- if (baseTypes == null) {
- // no parents
- return false;
- }
-
- for (int i = 0; i < baseTypes.length; i++) {
- if (ClassUtility.getUtility().isClassType(bean, field.getJavaClass(), baseTypes[i])) {
- return true;
- }
- }
- return false;
- }
-
- protected final boolean isOwnedByBase(EnterpriseBean bean, Method method) throws InvalidInputException {
- if (method == null) {
- return false;
- }
-
- long[] baseTypes = getBaseTypes();
- if (baseTypes == null) {
- // no parents
- return false;
- }
-
- for (int i = 0; i < baseTypes.length; i++) {
- if (ClassUtility.getUtility().isClassType(bean, method.getJavaClass(), baseTypes[i])) {
- return true;
- }
- }
- return false;
- }
-
- protected final boolean isValid(EnterpriseBean bean, JavaClass clazz, Field field) throws InvalidInputException {
- if (isOwnedByBase(bean, field)) {
- return false;
- }
-
- return ((getFieldType(bean, clazz, field) & EXCLUDED_FIELD) != EXCLUDED_FIELD);
- }
-
- protected final void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method[] methods, List[] methodsExtendedLists) throws ValidationException {
- try {
- vc.terminateIfCancelled();
-
- Method method = null;
- for (int i = 0; i < methods.length; i++) {
- vc.terminateIfCancelled();
- method = methods[i];
- if (method == null) {
- // No point adding a validation message, because the user can't do anything.
- // Log this condition.
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINE)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("EJB20Validator - validate methods"); //$NON-NLS-1$
- entry.setText("On " + clazz.getQualifiedName() + ", there is a null method."); //$NON-NLS-1$ //$NON-NLS-2$
- logger.write(Level.FINE, entry);
- }
- continue;
- }
- try {
- Logger logger = vc.getMsgLogger();
- if (logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("EJB20Validator - validate methods"); //$NON-NLS-1$
- entry.setText("Validating method " + method.getMethodElementSignature() + " on clazz " + clazz + " and isValid returns " + isValid(bean, clazz, method, methodsExtendedLists)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- logger.write(Level.FINEST, entry);
- }
-
- if (isValid(bean, clazz, method, methodsExtendedLists)) {
- register(vc, bean, clazz, method, methodsExtendedLists);
- if (isMethodAllowedToExist(bean, clazz, method, methodsExtendedLists)) {
- validate(vc, bean, clazz, method, methodsExtendedLists);
- } else {
- validateMethodWhichMustNotExist(vc, bean, clazz, method, methodsExtendedLists);
- }
- } else {
- if (!isOwnedByBase(bean, method)) {
- if ((MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedLists, this) & EXCLUDED_METHOD) == EXCLUDED_METHOD) {
- // unidentified method excluded
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2502, IEJBValidationContext.INFO, bean, clazz, method, new String[]{method.getName()}, this);
- vc.addMessage(message);
- }
- }
- }
- } catch (InvalidInputException e) {
- reflectionWarning(vc, bean, clazz, method, e);
- }
-
- }
- vc.terminateIfCancelled();
- } catch (ValidationCancelledException exc) {
- // remove any existing messages since they may be faulty
- }
-
- }
-
- public final void register(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field, List[] fieldsExtendedList) throws InvalidInputException, ValidationCancelledException, ValidationException {
- _fieldList = (_fieldList | getFieldType(bean, clazz, field));
- }
-
- private boolean isDefaultConstructor(long methodType) {
- return ((methodType & IMethodAndFieldConstants.CONSTRUCTOR_NOPARM) == IMethodAndFieldConstants.CONSTRUCTOR_NOPARM);
- }
-
- private boolean doesPublicDefaultConstructorExist() {
- if ((_methodList & IMethodAndFieldConstants.CONSTRUCTOR_NOPARM) == IMethodAndFieldConstants.CONSTRUCTOR_NOPARM) {
- return true;
- }
-
- return false;
- }
-
- private boolean isDefaultConstructorInsertedByCompiler() {
- // If the default constructor is not in the list, and if there are no constructors,
- // the Java compiler will insert a default constructor.
- if ((_methodList & IMethodAndFieldConstants.CONSTRUCTOR) == IMethodAndFieldConstants.CONSTRUCTOR) {
- // There is a constructor, so return false.
- return false;
- }
-
- return true;
- }
-
- protected final boolean isMethodAllowedToExist(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- long[] methods = getMethodsWhichMustNotExist();
- if (methods != null) {
- for (int i = 0; i < methods.length; i++) {
- long methodType = methods[i];
- long existingMethodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedLists, this);
- if ((existingMethodType & methodType) == methodType) {
- return false;
- }
- }
- }
- return true;
- }
-
- /*
- * @see IValidationRule#reset()
- */
- public void validateMethodsWhichMustExist(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException, ValidationCancelledException, ValidationException {
- long[] methods = getMethodsWhichMustExist();
- if (methods != null) {
- for (int i = 0; i < methods.length; i++) {
- long methodType = methods[i];
- boolean emitWarning = false;
- if (isDefaultConstructor(methodType)) {
- if (!doesPublicDefaultConstructorExist() && !isDefaultConstructorInsertedByCompiler()) {
- emitWarning = true;
- }
- } else {
- emitWarning = !exists(methodType);
- }
-
- if (emitWarning) {
- // IWAD4041 = This class must define a public constructor which takes no
- // parameters. Read section 7.10.1 of the EJB 2.0 specification.
- // IWAD4142 = {0} must exist. Read section 10.5.2 of the EJB 2.0 specification.
- // IWAD4173 = {0} must exist. Read section 10.6.2 of the EJB 2.0 specification.
- // IWAD4271 = {0} must exist. Read section 12.1.4.1 of the EJB 2.0
- // specification.
- // IWAD4290 = {0} must exist. Read section 12.2.2 of the EJB 2.0 specification.
- // IWAD4388 = {0} must exist. Read section 15.7.2 of the EJB 2.0 specification.
- IMethodType mType = MethodUtility.getUtility().getMethodType(methodType);
- if (mType == null) {
- // ummmm....oops. This case should never happen.
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("EJB20Validator - validate methods which must exist"); //$NON-NLS-1$
- entry.setText("Method type is null: " + methodType); //$NON-NLS-1$
- logger.write(Level.FINEST, entry);
- }
- continue;
- }
-
- IMessage message = MessageUtility.getUtility().getMessage(vc, mType.getMessageId_messageMissing(), IEJBValidationContext.WARNING, bean, clazz, new String[]{mType.getMethodName(bean, clazz, null)}, this);
- vc.addMessage(message);
- }
- }
- }
- }
-
- public final void validateMethodWhichMustNotExist(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws InvalidInputException, ValidationCancelledException, ValidationException {
- IMethodType mType = MethodUtility.getUtility().getMethodType(bean, clazz, method, methodsExtendedLists, this);
- if (mType == null) {
- // what happened?
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("EJB20Validator - validate method which must not exist"); //$NON-NLS-1$
- entry.setText("Method type is null: " + MethodUtility.getUtility().getMethodType(bean, clazz, method, methodsExtendedLists, this)); //$NON-NLS-1$
- logger.write(Level.FINEST, entry);
- }
- return;
- }
-
-
- IMessage message = MessageUtility.getUtility().getMessage(vc, mType.getMessageId_messageExists(), IEJBValidationContext.INFO, bean, clazz, method, new String[]{mType.getMethodName(bean, clazz, method)}, this);
- vc.addMessage(message);
- }
-
- public abstract long getFieldType(EnterpriseBean bean, JavaClass clazz, Field field);
-
- public abstract long[] getBaseTypes();
-
- public abstract int getMessageRemoteExceptionSeverity(); // is a missing (or present)
- // RemoteException a warning or an
- // error? See ILocalType and
- // IRemoteType.
-
- public final long getMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedList) {
- if (method == null) {
- return EXCLUDED_METHOD;
- }
- long id = MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedList, this);
- if ((id & CLINIT) == CLINIT) {
- return EXCLUDED_METHOD;
- }
- return id;
- }
-
- public final void register(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedList) throws InvalidInputException, ValidationCancelledException, ValidationException {
- _methodList = (_methodList | MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedList, this));
- }
-
- public final void validateSupertypes(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException, ValidationCancelledException, ValidationException {
- validateShouldBeSuperTypes(vc, bean, clazz);
- validateShouldNotBeSuperTypes(vc, bean, clazz);
- }
-
- /**
- * @param vc
- * @param bean
- * @param clazz
- * @throws InvalidInputException
- */
- protected void validateShouldNotBeSuperTypes(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- long[] types;
- // Test for types which can be supertypes, though it's either not recommended or should be
- // coded with caution
- types = getShouldNotBeSupertypes();
- if (types != null) {
- for (int i = 0; i < types.length; i++) {
- JavaHelpers superType = ClassUtility.getUtility().getSupertype(bean, types[i]);
- if (superType == null) {
- // no supertype
- continue;
- }
-
- if (ValidationRuleUtility.isAssignableFrom(clazz, superType)) {
- // IWAD4179 = Because this class implements {0}, "this" must not be passed as a
- // method argument or result. Read section 10.6.2 of the EJB 2.0 specification.
- // IWAD4292 = Because {0} implements {1}, "this" must not be passed as a method
- // argument or result. Read section 12.2.2 of the EJB 2.0 specification.
- // IWAD4043 = Because {0} implements {1}, "this" must not be passed as a method
- // argument or result. Read section 7.10.2 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2040, IEJBValidationContext.INFO, bean, clazz, this);
- vc.addMessage(message);
- }
- }
- }
- }
-
- /**
- * @param vc
- * @param bean
- * @param clazz
- * @throws InvalidInputException
- */
- protected void validateShouldBeSuperTypes(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- long[] types = getSupertypes();
- if (types != null) {
- for (int i = 0; i < types.length; i++) {
- JavaHelpers superType = ClassUtility.getUtility().getSupertype(bean, types[i]);
- if (superType == null) {
- // no supertype
- continue;
- }
-
- if (!ValidationRuleUtility.isAssignableFrom(clazz, superType)) {
- // IWAD4026 = This class must implement javax.ejb.SessionBean. Read section
- // 7.5.1, 7.10.2 of the EJB 2.0 specification.
- // IWAD4379 = This class must implement javax.ejb.MessageDrivenBean. Read
- // section 15.4.1, 15.7.2 of the EJB 2.0 specification.
- // IWAD4380 = This class must implement javax.jms.MessageListener. Read section
- // 15.4.1, 15.7.2 of the EJB 2.0 specification.
- // IWAD4170 = This class must implement java.ejb.EntityBean. Read section 10.6.2
- // of the EJB 2.0 specification.
- // IWAD4286 = This class must implement java.ejb.EntityBean. Read section 12.2.2
- // of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2017, IEJBValidationContext.ERROR, bean, clazz, new String[]{superType.getJavaName()}, this);
- vc.addMessage(message);
- }
- }
- }
- }
-
- public void reset() {
- super.reset();
- _methodList = NO_METHODS;
- _fieldList = NO_FIELDS;
- }
-
- protected final void reflectionError(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2907, IEJBValidationContext.ERROR, bean, clazz, new String[]{clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
-
- protected final void reflectionWarning(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field, InvalidInputException exc) {
- vc.removeMessages(field);
- vc.removeMessages(clazz, field.getName());
- IMessage message = getReflectionWarning(vc, exc, bean, clazz, field);
- vc.addMessage(message);
- }
-
- protected final void reflectionWarning(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, InvalidInputException exc) {
- vc.removeMessages(method);
- vc.removeMessages(clazz, method.getSignature());
- IMessage message = getReflectionWarning(vc, exc, bean, clazz, method);
- vc.addMessage(message);
- }
-
- protected final IMessage getReflectionWarning(IEJBValidationContext vc, InvalidInputException exc, EnterpriseBean bean, JavaClass clazz, EObject fieldOrMethod) {
- if (exc == null) {
- return null;
- }
-
- JavaClass badClazz = exc.getJavaClass();
- String typeName = (badClazz == null) ? "?" : badClazz.getQualifiedName(); //$NON-NLS-1$
- IMessage message = null;
-
- if (fieldOrMethod instanceof Field) {
- String name = ((Field) fieldOrMethod).getName();
- message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2433, IEJBValidationContext.WARNING, bean, clazz, (Field) fieldOrMethod, new String[]{name, typeName}, this);
- } else if (fieldOrMethod instanceof Method) {
- String name = ((Method) fieldOrMethod).getMethodElementSignature();
- message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2433, IEJBValidationContext.WARNING, bean, clazz, (Method) fieldOrMethod, new String[]{name, typeName}, this);
- } else {
- String name = ((XMIResource) fieldOrMethod.eResource()).getID(fieldOrMethod);
- message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2433, IEJBValidationContext.WARNING, bean, clazz, new String[]{name, typeName}, this);
- }
- if (badClazz == null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("getMessageId(IEJBValidationContext, InvalidInputException, boolean)"); //$NON-NLS-1$
- entry.setText("InvalidInputException thrown on unknown class"); //$NON-NLS-1$
- entry.setTargetException(exc);
- logger.write(Level.FINEST, entry);
- }
- }
-
- return message;
- }
-
-
- public final JavaClass getComponentInterface(EnterpriseBean bean) {
- if ((isRemote() & IEJBType.REMOTE) == IEJBType.REMOTE) {
- return bean.getRemoteInterface();
- }
- return bean.getLocalInterface();
- }
-
- public final boolean exists(long methodType) {
- return ((_methodList & methodType) == methodType);
- }
-
- public final JavaClass getHomeInterface(EnterpriseBean bean) {
- if ((isRemote() & IEJBType.REMOTE) == IEJBType.REMOTE) {
- return bean.getHomeInterface();
- }
- return bean.getLocalHomeInterface();
- }
-
- public boolean followRemoteExceptionRules(EnterpriseBean bean, Method method) throws InvalidInputException, ValidationCancelledException {
- if ((isRemote() & IEJBType.REMOTE) == IEJBType.REMOTE) {
- // must throw RemoteException or one of its parents (IOException or Exception)
- return ValidationRuleUtility.throwsRemoteExceptionOrParent(bean, method);
- } else if ((isRemote() & IEJBType.LOCAL) == IEJBType.LOCAL) {
- // must not throw RemoteException
- return ValidationRuleUtility.doesNotThrowRemoteException(bean, method);
- }
-
- return true;
- }
-
- public final void validateRMI_IIOPTypeRules(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedList, boolean checkReturnType) throws InvalidInputException {
- if ((isRemote() & IEJBType.REMOTE) == IEJBType.REMOTE) {
- JavaParameter[] parms = method.listParametersWithoutReturn();
-
- for (int i = 0; i < parms.length; i++) {
- JavaParameter parm = parms[i];
- if (!ValidationRuleUtility.isLegalRMI_IIOPType(bean, parm.getJavaType())) {
- IMethodType mt = MethodUtility.getUtility().getMethodType(bean, clazz, method, methodsExtendedList, this);
- if (mt == null) {
- // log
- } else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, mt.getMessageId_messageRMI_IIOPParm(), IEJBValidationContext.INFO, bean, clazz, method, new String[]{parm.getJavaType().getJavaName()}, this); // Can't
- // use
- // the
- // name
- // of
- // the
- // field,
- // because
- // when
- // it's
- // the
- // return
- // type
- // of
- // the
- // method,
- // it's
- // confusing
- // to
- // see
- // "result"
- // as
- // the
- // name
- // of
- // the
- // field.
- vc.addMessage(message);
- }
- }
- }
-
- if (checkReturnType) {
- if (!ValidationRuleUtility.isLegalRMI_IIOPType(bean, method.getReturnType())) {
- IMethodType mt = MethodUtility.getUtility().getMethodType(bean, clazz, method, methodsExtendedList, this);
- if (mt == null) {
- // log
- } else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, mt.getMessageId_messageRMI_IIOPParm(), IEJBValidationContext.INFO, bean, clazz, method, new String[]{method.getReturnType().getJavaName()}, this); // Can't
- // use
- // the
- // name
- // of
- // the
- // field,
- // because
- // when
- // it's
- // the
- // return
- // type
- // of
- // the
- // method,
- // it's
- // confusing
- // to
- // see
- // "result"
- // as
- // the
- // name
- // of
- // the
- // field.
- vc.addMessage(message);
- }
- }
- }
- } else {
- // don't need to check
- return;
- }
- }
-
- public final boolean followRMI_IIOPInheritanceRules(EnterpriseBean bean, JavaClass clazz) {
- if ((isRemote() & IEJBType.REMOTE) == IEJBType.REMOTE) {
- return ValidationRuleUtility.isLegalRMI_IIOPInheritance(clazz);
- }
- return true;
- }
-
- public void validateSerialVersionUID(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field) {
- /*
- * For now, do nothing. In future, check if the field is public & static?
- */
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateBean.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateBean.java
deleted file mode 100644
index 7a3a3adac..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateBean.java
+++ /dev/null
@@ -1,673 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * Performs validation common to session and entity beans.
- */
-public abstract class AValidateBean extends AValidateEJB {
- protected HashSet componentParents = null; // The JavaClass instances which are parents of this JavaClass instance, if this JavaClass instance is part of a component inheritance hierarchy.
-
- public AValidateBean() {
- componentParents = new HashSet();
- }
-
- public void reset() {
- super.reset();
- componentParents.clear();
- }
-
- protected void buildComponentParents(EnterpriseBean bean) {
- if (bean == null) {
- return;
- }
- EnterpriseBean supertype = getSuperType(bean);
- if (supertype == null) {
- return;
- }
-
- // check this CMP's supertype
- JavaClass thisEjbObject = bean.getEjbClass();
- JavaClass parentEjbObject = supertype.getEjbClass();
-
- // EJBObject a Xchild of parent EJBObject (X = child, grandchild, great-grandchild, etc.)
- if (ValidationRuleUtility.isAssignableFrom(thisEjbObject, parentEjbObject)) {
- componentParents.add(parentEjbObject);
- }
- buildComponentParents(supertype);
- }
-
- public final Object getTarget(Object parent, Object clazz) {
- if(parent == null) {
- return null;
- }
-
- return ((EnterpriseBean)parent).getEjbClass();
- }
-
- public final static List getRemoteHomeMethodsExtended(List[] methodsExtendedList) {
- return methodsExtendedList[0];
- }
-
- public final static List getRemoteComponentMethodsExtended(List[] methodsExtendedList) {
- return methodsExtendedList[1];
- }
-
- public final static List getBeanClassMethodsExtended(List[] methodsExtendedList) {
- return methodsExtendedList[2];
- }
-
- public final List[] getMethodsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // A bean class needs the following classes' extended methods:
- // 1. home
- // 2. remote
- // 3. bean class (when searching for a matching ejbPostCreate method).
- // If a particular bean doesn't use a remote view or local view,
- // then the corresponding entry in the array will be null.
- List[] result = new List[3];
- JavaClass remoteHome = bean.getHomeInterface();
- if(remoteHome != null) {
- result[0] = remoteHome.getMethodsExtended();
- }
- else {
- result[0] = null;
- }
-
- JavaClass remoteComponent = bean.getRemoteInterface();
- if(remoteComponent != null) {
- result[1] = remoteComponent.getMethodsExtended();
- }
- else {
- result[1] = null;
- }
-
- JavaClass beanClass = bean.getEjbClass();
- if(beanClass != null) {
- result[2] = beanClass.getMethodsExtended();
- }
- else {
- result[2] = null;
- }
-
- return result;
- }
-
- public final List[] getFieldsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // Never check that a bean class' field is defined on another class
- // of the bean.
- return null;
- }
-
-
-
- /**
- * For the check that the ejbCreate method has a matching create method on the home,
- * this method, given the bean method, returns the corresponding home method.
- *
- * 6.10.6 Session bean's home interface
- * The following are the requirements for the session bean's home interface:
- * - Each create method must be named "create", and it must match one of
- * the ejbCreate methods defined in the session bean class. The matching
- * ejbCreate method must have the same number and types of arguments.
- * (Note that the return type is different.)
- * - All the exceptions defined in the throws clause of an ejbCreate method
- * of the session bean class must be defined in the throws clause of the
- * matching create method of the home interface.
- *...
- *
- * 9.2.8 Entity bean's home interface
- * The following are the requirements for the entity bean's home interface:
- * - Each create method must be named "create", and it must match one of the
- * ejbCreate methods defined in the enterprise Bean class. The matching
- * ejbCreate method must have the same number and types of its arguments.
- * (Note that the return type is different.)
- * - All the exceptions defined in the throws clause of the matching ejbCreate
- * and ejbPostCreate methods of the enterprise Bean class must be included in
- * the throws clause of the matching create method of the home interface
- * (i.e the set of exceptions defined for the create method must be a superset
- * of the union of exceptions defined for the ejbCreate and ejbPostCreate methods)
- */
- public final Method getMatchingHomeCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- if (method == null) {
- return null;
- }
-
- if (bean == null) {
- return null;
- }
-
- JavaClass homeIntf = bean.getHomeInterface();
- ValidationRuleUtility.isValidTypeHierarchy(bean, homeIntf);
-
- // check only the current class, not the parents in this case.
- // This method is used in the component inheritance hierarchy tests.
- return ValidationRuleUtility.getMethod(method, IMethodAndFieldConstants.METHODNAME_CREATE, homeIntf.getMethods());
- }
-
- /**
- * For the check that the ejbCreate method has a matching create method on the home,
- * this method, given the bean method, returns the corresponding home method.
- *
- * 6.10.6 Session bean's home interface
- * The following are the requirements for the session bean's home interface:
- * - Each create method must be named "create", and it must match one of
- * the ejbCreate methods defined in the session bean class. The matching
- * ejbCreate method must have the same number and types of arguments.
- * (Note that the return type is different.)
- * - All the exceptions defined in the throws clause of an ejbCreate method
- * of the session bean class must be defined in the throws clause of the
- * matching create method of the home interface.
- *...
- *
- * 9.2.8 Entity bean's home interface
- * The following are the requirements for the entity bean's home interface:
- * - Each create method must be named "create", and it must match one of the
- * ejbCreate methods defined in the enterprise Bean class. The matching
- * ejbCreate method must have the same number and types of its arguments.
- * (Note that the return type is different.)
- * - All the exceptions defined in the throws clause of the matching ejbCreate
- * and ejbPostCreate methods of the enterprise Bean class must be included in
- * the throws clause of the matching create method of the home interface
- * (i.e the set of exceptions defined for the create method must be a superset
- * of the union of exceptions defined for the ejbCreate and ejbPostCreate methods)
- */
- public Method getMatchingHomeCreateMethodExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc. terminateIfCancelled();
- if (method == null) {
- return null;
- }
-
- if (bean == null) {
- return null;
- }
-
- JavaClass homeIntf = bean.getHomeInterface();
- ValidationRuleUtility.isValidTypeHierarchy(bean, homeIntf);
-
- return ValidationRuleUtility.getMethodExtended(homeIntf, method, IMethodAndFieldConstants.METHODNAME_CREATE);
- }
-
- /**
- * Return the name of the parent which the bean must implement.
- * For entity beans, it's javax.ejb.EntityBean.
- * For session beans, it's javax.ejb.SessionBean.
- */
- protected abstract String getParentName();
-
- /**
- * Returns true if the method passed in is a business method.
- *
- * Although the EJB 1.1 spec implies that all non-framework methods are business methods,
- * developers may create methods on the bean which are meant for internal use only. This
- * method (isBusinessMethod) separates the "internal helper" methods from the business
- * methods by checking if a corresponding method exists on the remote interface. If it
- * does, consider this a business method.
- */
- public boolean isBusinessMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- if (method == null) {
- return false;
- }
- String name = method.getName();
-
- if (isFrameworkMethod(name)) {
- return false;
- }
-
- if (method.isConstructor()) {
- return false;
- }
-
- // Check if there's a matching method on the remote interface.
- if (bean == null) {
- return false;
- }
-
- JavaClass remoteInterface = bean.getRemoteInterface();
- ValidationRuleUtility.isValidTypeHierarchy(bean, remoteInterface);
- Method remoteInterfaceMethod = ValidationRuleUtility.getMethodExtended(remoteInterface, name, method.listParametersWithoutReturn());
- if ((remoteInterfaceMethod == null) || (ValidationRuleUtility.isEJBObjectMethod(bean, remoteInterfaceMethod))) {
- // no matching method
- // filter out methods from javax.ejb.EJBObject
- return false;
- }
-
- return true;
- }
-
- /**
- * Return true if the method passed in is inherited from a parent in a
- * component inheritance hierarchy.
- */
- protected boolean isComponentInherited(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method meth) throws InvalidInputException {
- if (componentParents == null) {
- // Not part of a component inheritance hierarchy
- return false;
- }
-
- return (componentParents.contains(meth.getContainingJavaClass()));
- }
-
- public boolean isFrameworkMethod(String name) {
- if (name == null) {
- return false;
- }
- else if (name.equals(IMethodAndFieldConstants.METHODNAME_EJBACTIVATE)) {
- return true;
- }
- else if (name.equals(IMethodAndFieldConstants.METHODNAME_EJBPASSIVATE)) {
- return true;
- }
- else if (name.equals(IMethodAndFieldConstants.METHODNAME_EJBREMOVE)) {
- return true;
- }
- else if (name.startsWith(IMethodAndFieldConstants.PREFIX_EJBFIND)) {
- return true;
- }
- else if (name.equals(IMethodAndFieldConstants.METHODNAME_EJBCREATE)) {
- return true;
- }
- else if (name.equals(IMethodAndFieldConstants.METHODNAME_EJBPOSTCREATE)) {
- return true;
- }
- else if (name.equals(IMethodAndFieldConstants.METHODNAME_FINALIZE)) {
- return true;
- }
- return false;
-
- }
-
- /**
- * Return true if the field can, and should, be validated.
- * Filter out faulty fields (i.e., null), and fields which
- * belong to the base type, whatever that is. (e.g. java.lang.Object)
- */
- protected boolean isValid(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field, List[] fieldsExtendedList) throws InvalidInputException {
- if (super.isValid(vc, bean, clazz, field, fieldsExtendedList)) {
- // exclude root object methods
- if (ValidationRuleUtility.isJavaLangObjectField(bean, field)) {
- return false;
- }
- return true;
- }
- return false;
- }
-
- /**
- * Return true if the method can, and should, be validated.
- * Filter out faulty methods (i.e., null), and methods which
- * belong to the base type, whatever that is. (e.g. java.lang.Object)
- */
- protected final boolean isValid(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedList) throws InvalidInputException {
- if (super.isValid(vc, bean, clazz, method, methodsExtendedList)) {
- // exclude root object methods
- if (ValidationRuleUtility.isJavaLangObjectMethod(bean, method)) {
- return false;
- }
- else if (method.getName().equals(IMethodAndFieldConstants.METHODNAME_EJBCREATE)) {
- return isValidEjbCreateMethod(vc, bean, clazz, method, methodsExtendedList);
- }
- else if (method.getName().equals(IMethodAndFieldConstants.METHODNAME_EJBPOSTCREATE)) {
- return isValidEjbCreateMethod(vc, bean, clazz, method, methodsExtendedList);
- }
- else {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return true if the ejbCreate method passed in is not inherited
- * from a parent in a component inheritance hierarchy, or is inherited,
- * but is also defined on this bean's home interface.
- *
- * This method is used to exclude ejbCreate methods which are inherited
- * from a parent in a component inheritance hierarchy, and are not
- * exposed anywhere on this bean class instance itself. (i.e., inherited,
- * but never used.) Since we generate the code for these methods, we
- * should not flag them as warnings.
- */
- protected final boolean isValidEjbCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method meth, List[] methodsExtendedLists) throws InvalidInputException {
- boolean isValid = true;
- boolean isComp = isComponentInherited(vc, bean, clazz, meth);
- if (isComp) {
- Method homeMeth = getMatchingHomeCreateMethod(vc, bean, clazz, meth, methodsExtendedLists);
- if (homeMeth == null) {
- isValid = false;
- }
- }
-
- return isValid;
- }
-
- /**
- * 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.
- *...
- */
- public void primValidate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field) throws InvalidInputException {
- //super.primValidate(ejbMethod);
-
- vc.terminateIfCancelled();
-
- validateStaticField(vc, bean, clazz, field);
- }
-
- /**
- * 6.10.4 Business methods
- * The session bean class may define zero or more business methods whose signatures must follow these rules:
- * - The method names can be arbitrary, but they must not start with "ejb" to avoid conflicts with the callback methods used by the EJB architecture.
- *
- * 9.2.6 Business methods
- * - The entity bean class may define zero or more business methods whose signatures
- * must follow these rules:
- * - The method names can be arbitrary, but they must not start with 'ejb' to
- * avoid conflicts with the callback methods used by the EJB architecture.
- */
- public void validateBusinessMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- // The method names can be arbitrary, but they must not start with "ejb" to avoid conflicts with the callback methods used by the EJB architecture.
- if (method.getName().startsWith(IMethodAndFieldConstants.PREFIX_EJB)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2411, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // Section 6.10.5 (session), 9.2.7 (entity), declare that all exceptions declared
- // on the ejbCreate, ejbPostCreate methods must be defined in the throws clause of
- // the matching create of the remote interface.
-
- JavaClass remote = bean.getRemoteInterface();
- ValidationRuleUtility.isValidTypeHierarchy(bean, remote);
-
- Method remoteMethod = ValidationRuleUtility.getMethodExtended(remote, method, method.getName());
- if (remoteMethod == null) {
- // Then this method shouldn't have been called; unless the method exists on the remote, this bean method isn't a business method.
- return;
- }
-
- Set exceptions = ValidationRuleUtility.getNotSubsetExceptions(bean, method, remoteMethod);
- if (exceptions.size() > 0) {
- Iterator iterator = exceptions.iterator();
- while (iterator.hasNext()) {
- JavaClass exc = (JavaClass) iterator.next();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2432, IEJBValidationContext.ERROR, bean, clazz, method, new String[] { remote.getQualifiedName(), exc.getQualifiedName()}, this);
- vc.addMessage(message);
- }
- }
-
- validateMatchingMethodExceptions(vc, bean, clazz, method, bean.getRemoteInterface(), remoteMethod);
- }
-
- /**
- * 6.10.2 Session bean class
- * The following are the requirements for session bean class:
- * - The class must implement, directly or indirectly, the javax.ejb.SessionBean
- * interface.
- * - The class must be defined as public, must not be final, and must not
- * be abstract.
- * - The class may, but is not required to, implement the session bean's
- * remote interface [4] .
- * - If the class is a stateful session bean, it may optionally implement
- * the javax.ejb.SessionSynchronization interface.
- * - The session bean class may have superclasses and/or superinterfaces. If the
- * session bean has superclasses, then the business methods, the ejbCreate methods,
- * the methods of the SessionBean interface, and the methods of the optional
- * SessionSynchronization interface may be defined in the session bean class,
- * or in any of its superclasses.
- *
- *...
- * 9.2.2 Enterprise bean class
- * - The following are the requirements for an entity bean class:
- * - The class must implement, directly or indirectly, the javax.ejb.EntityBean interface.
- * - The class must be defined as public and must not be abstract.
- * - The class must not be defined as final.
- *...
- * - The class may, but is not required to, implement the entity bean's remote interface [9].
- * If the class implements the entity bean's remote interface, the class must provide no-op
- * implementations of the methods defined in the javax.ejb.EJBObject interface. The container
- * will never invoke these methods on the bean instances at runtime.
- * - A no-op implementation of these methods is required to avoid
- * defining the entity bean class as abstract.
- * - The entity bean class must implement the business methods, and the
- * ejbCreate, ejbPostCreate, and ejbFind<METHOD> methods as described
- * later in this section.
- * - The entity bean class may have superclasses and/or superinterfaces.
- * If the entity bean has superclasses, the business methods, the
- * ejbCreate and ejbPostCreate methods, the finder methods, and the
- * methods of the EntityBean interface may be implemented in the
- * enterprise bean class or in any of its superclasses.
- * - The entity bean class is allowed to implement other methods (for
- * example helper methods invoked internally by the business methods)
- * in addition to the methods required by the EJB specification.
- *...
- */
- public void validateClass(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- buildComponentParents(bean);
-
- // The class must implement, directly or indirectly, the javax.ejb.EntityBean (for entity beans),
- // or the javax.ejb.SessionBean (for session beans), interface.
- if (!ValidationRuleUtility.isAssignableFrom(clazz, ValidationRuleUtility.getType(getParentName(), bean))) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2013, IEJBValidationContext.ERROR, bean, clazz, new String[] {clazz.getQualifiedName(), getParentName()}, this);
- vc.addMessage(message);
- }
-
- // For both entity and session beans, the class must be public.
- if (!clazz.isPublic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2022, IEJBValidationContext.ERROR, bean, clazz, new String[] { clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
-
- // For both entity and session beans, the class must not be abstract.
- if (clazz.isAbstract()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2014, IEJBValidationContext.ERROR, bean, clazz, new String[] { clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
-
- // For both entity and session beans, the class must not be final.
- if (clazz.isFinal()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2015, IEJBValidationContext.ERROR, bean, clazz, new String[] { clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
-
- if (ValidationRuleUtility.isUnnamedPackage(clazz.getJavaPackage())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2041, IEJBValidationContext.INFO, bean, clazz, this);
- vc.addMessage(message);
- }
-
- validateAppendixB(vc, bean, clazz);
- }
-
- /**
- * 9.2.3 ejbCreate methods
- * - The entity bean class may define zero or more ejbCreate(...) methods whose signatures
- * must follow these rules:
- * - The method name must be ejbCreate.
- * - The method must be declared as public.
- * - The method must not be declared as final or static.
- * - The return type must be the entity bean's primary key type.
- * - The method argument and return value types must be legal types for RMI-IIOP.
- * - The throws clause may define arbitrary application specific exceptions,
- * including the javax.ejb.CreateException.
- * - Compatibility Note: EJB 1.0 allowed the ejbCreate method to throw the
- * java.rmi.RemoteException to indicate a non-application exception. This
- * practice is deprecated in EJB 1.1 -- an EJB 1.1 compliant enterprise bean
- * should throw the javax.ejb.EJBException or another java.lang.RuntimeException
- * to indicate non-application exceptions to the Container (see Section 12.2.2).
- * - The entity object created by the ejbCreate method must have a unique primary key.
- * This means that the primary key must be different from the primary keys of all
- * the existing entity objects within the same home. The ejbCreate method should
- * throw the DuplicateKeyException on an attempt to create an entity object with
- * a duplicate primary key. However, it is legal to reuse the primary key of a
- * previously removed entity object.
- *
- * 9.2.8 Entity bean's home interface
- * The following are the requirements for the entity bean's home interface:
- * - Each create method must be named "create", and it must match one of the
- * ejbCreate methods defined in the enterprise Bean class. The matching
- * ejbCreate method must have the same number and types of its arguments.
- * (Note that the return type is different.)
- * - All the exceptions defined in the throws clause of the matching ejbCreate
- * and ejbPostCreate methods of the enterprise Bean class must be included in
- * the throws clause of the matching create method of the home interface
- * (i.e the set of exceptions defined for the create method must be a superset
- * of the union of exceptions defined for the ejbCreate and ejbPostCreate methods)
- *...
- *
- * 9.4.2 ejbCreate, ejbPostCreate
- *...
- * - The ejbCreate(...) methods must be defined to return the primary key class type.
- * The implementation of the ejbCreate(...) methods should be coded to return a null.
- * The returned value is ignored by the Container.
- *...
- */
- public void validateEjbCreateMethod_homeDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- // The method which calls this method must have already tested that the method name is ejbCreate.
- if (method == null) {
- return;
- }
-
- Method createMethod = getMatchingHomeCreateMethodExtended(vc, bean, clazz, method);
- if (createMethod == null) {
- // Can't check the exceptions of a method which doesn't exist.
- return;
- }
-
- // Whether this is from a component inheritance or not, if the method exists on the
- // home, check that the method follows the spec.
-
- // Section 6.10.6 (session), 9.2.8 (entity), declare that all exceptions declared
- // on the ejbCreate, ejbPostCreate methods must be defined in the throws clause of
- // the matching create of the home interface.
- Set exceptions = ValidationRuleUtility.getNotSubsetExceptions(bean, method, createMethod);
- if (exceptions.size() > 0) {
- Iterator iterator = exceptions.iterator();
- while (iterator.hasNext()) {
- JavaClass exc = (JavaClass) iterator.next();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2420, IEJBValidationContext.ERROR, bean, clazz, method, new String[] { exc.getQualifiedName(), bean.getHomeInterface().getQualifiedName()}, this);
- vc.addMessage(message);
- }
- }
-
- }
-
- public void validateHelperMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) {
- //Default
- }
-
- public void validateNoRemoteException(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, String messagePrefix) throws InvalidInputException {
- // EJB 2.0 added "throws InvalidInputException" above
- if (method == null) {
- return;
- }
-
- if(!ValidationRuleUtility.doesNotThrowRemoteException(bean, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, messagePrefix, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- }
-
- /**
- * 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);
- }
- }
-
- public void validateMatchingMethodExceptions(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, JavaClass matchingClazz, Method matchingMethod) {
- // Every exception thrown on the bean class' method must be thrown on the component/home method
- /* Don't check for this here - let the home & component do it.
- Set exceptions = ValidationRuleUtility.getNotSubsetExceptions(bean, method, matchingMethod);
- Iterator eiterator = exceptions.iterator();
- while(eiterator.hasNext()) {
- }
- */
-
- // Every exception thrown by the component/home method should be thrown or there may be compile errors
- Set exceptions = ValidationRuleUtility.getNotSubsetSubtypeExceptions(bean, matchingMethod, method);
- Iterator eiterator = exceptions.iterator();
- while(eiterator.hasNext()) {
- JavaClass exception = (JavaClass)eiterator.next();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2456, IEJBValidationContext.WARNING, bean, clazz, method, new String[]{exception.getJavaName(), matchingClazz.getJavaName()}, this);
- vc.addMessage(message);
- }
- }
-
- protected void validateAppendixB(IEJBValidationContext vc, EnterpriseBean bean, JavaClass thisEjbObject) {
- // The Java inheritance structure must match the EJB inheritance structure.
- // e.g. if EJB B is a child of EJB A, then class B must be a child of class A.
- // B could be a grandchild (or great-grandchild or ...) of A.
- if(bean == null) {
- return;
- }
- EnterpriseBean supertype = getSuperType(bean);
- JavaClass parentEjbObject = null;
- if (supertype != null) {
- parentEjbObject = supertype.getEjbClass();
-
- // EJBObject a Xchild of parent EJBObject (X = child, grandchild, great-grandchild, etc.)
- try {
- ValidationRuleUtility.isValidType(thisEjbObject);
- ValidationRuleUtility.isValidType(parentEjbObject);
- if (!ValidationRuleUtility.isAssignableFrom(thisEjbObject, parentEjbObject)) {
- String[] msgParm = new String[] { thisEjbObject.getQualifiedName(), parentEjbObject.getQualifiedName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2103, IEJBValidationContext.ERROR, bean, thisEjbObject, msgParm, this);
- vc.addMessage(message);
- }
- }
- catch (InvalidInputException e) {
- String[] msgParm = { e.getJavaClass().getQualifiedName(), bean.getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2849, IEJBValidationContext.WARNING, bean, msgParm, this);
- vc.addMessage(message);
- }
- }
-
-// validateAppendixB(vc, supertype, parentEjbObject);
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateEJB.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateEJB.java
deleted file mode 100644
index b0eec60e1..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateEJB.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.logging.Level;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaParameter;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- * Insert the type's description here.
- * Creation date: (1/5/01 11:51:09 AM)
- * @author: Administrator
- */
-public abstract class AValidateEJB extends AValidationRule {
- private List roleMethodNames;
-
- public void reset() {
- super.reset();
- if(roleMethodNames != null) {
- roleMethodNames.clear();
- roleMethodNames = null; // in this case, clearing the list isn't enough, because it is legal to have zero role names. Must be null or we'll keep trying to reload the role names just because there are zero role names.
- }
- }
-
- /**
- * Insert the method's description here.
- * Creation date: (9/5/2001 12:36:39 PM)
- * @return java.util.List
- */
- protected List getRoleMethodNames(IEJBValidationContext vc, EnterpriseBean bean) {
- try {
- if (roleMethodNames == null && bean != null) {
- roleMethodNames = getRoleMethodNamesExtended(bean);
- }
- return roleMethodNames;
- }
- catch (Throwable exc) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINER)) {
- logger.write(Level.FINER, exc);
- }
- return Collections.EMPTY_LIST;
- }
- }
-
- protected boolean isEjbRelationshipRoleMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) {
- if (method == null)
- return false;
- List aRoleMethodNames = getRoleMethodNames(vc, bean);
- if(aRoleMethodNames != null && !aRoleMethodNames.isEmpty())
- return aRoleMethodNames.contains(method.getName());
- return false;
- }
-
- /**
- * Return true if the field can, and should, be validated.
- * Filter out faulty fields (i.e., null), and fields which
- * belong to the base type, whatever that is. (e.g. java.lang.Object)
- */
- protected boolean isValid(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field, List[] fieldsExtendedLists) throws InvalidInputException {
- // The following call checks if the type reflected properly
- ValidationRuleUtility.isValidType(ValidationRuleUtility.getType(field));
-
- if (field.getName().equals(IMethodAndFieldConstants.FIELDNAME_SERIALVERSIONUID)) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Return true if the method can, and should, be validated.
- * Filter out faulty methods (i.e., null), and methods which
- * belong to the base type, whatever that is. (e.g. java.lang.Object)
- */
- protected boolean isValid(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedList) throws InvalidInputException {
- if (method == null) {
- throw new InvalidInputException();
- }
- return true;
- }
-
- /**
- * This method actually does the validation. Since many of the classes do
- * not validate fields now, implement this method as a no-op so that the
- * classes compile.
- */
- public void primValidate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field) throws InvalidInputException {
- //Default
- }
-
- /**
- * This method actually does the validation.
- */
- public abstract void primValidate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException;
-
- /**
- * This method does the actual checking (if ejbMethod exists).
- */
- protected abstract void primValidateExistence(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException;
-
- protected abstract List[] getMethodsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz);
- protected abstract List[] getFieldsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz);
-
- protected final void reflectionError(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- vc.removeMessages(clazz);
-
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2907, IEJBValidationContext.ERROR, bean, clazz, new String[]{clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
-
- protected final void reflectionWarning(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field, InvalidInputException e) {
- // One of two cases where we care if the type is on this class or not (i.e., not leaving it up to MessageUtility)
- String[] msgParm = null;
- String javaClassName = (e.getJavaClass() == null) ? "?" : e.getJavaClass().getQualifiedName(); //$NON-NLS-1$
- if(ValidationRuleUtility.onClass(clazz, field)) {
- msgParm = new String[] {String.valueOf(field.getName()), String.valueOf(javaClassName)};
- }
- else {
- msgParm = new String[] {javaClassName}; // MessageUtility will substitute in the name of the field
- }
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2433, IEJBValidationContext.WARNING, bean, clazz, field, msgParm, this);
- vc.addMessage(message);
- }
-
- protected final void reflectionWarning(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, InvalidInputException e) {
- // One of two cases where we care if the type is on this class or not (i.e., not leaving it up to MessageUtility)
- String[] msgParm = null;
- String javaClassName = (e.getJavaClass() == null) ? "?" : e.getJavaClass().getQualifiedName(); //$NON-NLS-1$
- if(ValidationRuleUtility.onClass(clazz, method)) {
- msgParm = new String[] {method.getMethodElementSignature(), javaClassName};
- }
- else {
- msgParm = new String[] {javaClassName}; // MessageUtility will substitute in the name of the field
- }
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2433, IEJBValidationContext.WARNING, bean, clazz, method, msgParm, this);
- vc.addMessage(message);
- }
-
- public final void validate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationException {
- vc.terminateIfCancelled();
-
- EnterpriseBean bean = (EnterpriseBean)targetParent;
- JavaClass clazz = (JavaClass)target;
-
- try {
- // check if all of the types in the bean reflected properly
- ValidationRuleUtility.isValidTypeHierarchy(bean, clazz);
-
- vc.subtask(IEJBValidatorConstants.STATUS_VALIDATING, new String[]{clazz.getQualifiedName()});
- validateClass(vc, bean, clazz);
- validateMethods(vc, bean, clazz);
- validateFields(vc, bean, clazz);
- }
- catch(InvalidInputException e) {
- reflectionError(vc, bean, clazz);
- return;
- }
- catch(ValidationCancelledException e) {
- throw e;
- }
- }
-
- /**
- * This method should be called to avoid validating a Field more
- * than once. This is not used for checking the existence of a field.
- */
- public final void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field, List[] fieldsExtendedList) throws InvalidInputException {
- if (isValid(vc, bean, clazz, field, fieldsExtendedList)) {
- primValidate(vc, bean, clazz, field);
- }
- }
-
- /**
- * This method should be called to avoid validating a Method more
- * than once. This is not used for checking the existence of a method.
- */
- public final void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod, List[] methodsExtendedList) throws InvalidInputException {
- if (isValid(vc, bean, clazz, ejbMethod, methodsExtendedList)) {
- primValidate(vc, bean, clazz, ejbMethod);
- }
- }
- /**
- * Checks to see if @ejbMethod is one of the required methods.
- */
- protected final void validateExistence(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod, List[] methodsExtendedList) throws InvalidInputException {
- if (isValid(vc, bean, clazz, ejbMethod, methodsExtendedList)) {
- primValidateExistence(vc, bean, clazz, ejbMethod);
- }
- }
-
- public void validateClass(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- //Default
- }
-
- public final void validateFields(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException {
- vc.terminateIfCancelled();
-
- // Whenever looping over an entire list, always use an
- // iterator instead of a for loop, for performance reasons.
- // If the list is an instance of a linked list, for example,
- // the get(i) call can take a long time.
- List fields = clazz.getFieldsExtended();
- Iterator iterator = fields.iterator();
- Field field = null;
- List[] fieldsExtendedList = getFieldsExtended(vc, bean, clazz);
- while (iterator.hasNext()) {
- vc.terminateIfCancelled();
- field = (Field) iterator.next();
- if (field == null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("AValidateEJB.validateFields()"); //$NON-NLS-1$
- entry.setText("A field is null on " + clazz); //$NON-NLS-1$
- logger.write(Level.FINEST, entry);
- }
- continue;
- }
- try {
- validate(vc, bean, clazz, field, fieldsExtendedList);
- }
- catch (InvalidInputException e) {
- reflectionWarning(vc, bean, clazz, field, e);
- }
- }
- vc.terminateIfCancelled();
- }
-
- /**
- * Verifies that a given method is RMI legal.
- * This means that their argument and return values must be of valid types
- * for RMI/IIOP, and their throws clause must include the java.rmi.RemoteException.
- */
- public final void validateLegalRMIMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- validateLegalRMIMethodWithoutExceptions(vc, bean, clazz, method);
- validateLegalRMIMethodExceptions(vc, bean, clazz, method);
- }
-
- /**
- * Verifies that a given method is RMI legal.
- * This means that their argument and return values must be of valid types
- * for RMI/IIOP, and their throws clause must include the java.rmi.RemoteException.
- */
- public final void validateLegalRMIMethodArguments(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- if (method == null) {
- return;
- }
-
- JavaParameter[] args = method.listParametersWithoutReturn();
- for (int i = 0; i < args.length; i++) {
- vc.terminateIfCancelled();
-
- if (!ValidationRuleUtility.isLegalRMI_IIOPType(bean, args[i].getJavaType())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2413, IEJBValidationContext.INFO, bean, clazz, method, new String[]{args[i].getQualifiedName()}, this);
- vc.addMessage(message);
- }
- }
- }
-
- /**
- * Verifies that a given method is RMI legal.
- * This means that their argument and return values must be of valid types
- * for RMI/IIOP, and their throws clause must include the java.rmi.RemoteException.
- */
- public final void validateLegalRMIMethodExceptions(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- if (method == null) {
- return;
- }
-
- if (!ValidationRuleUtility.throwsRemoteExceptionOrParent(bean, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2414, IEJBValidationContext.ERROR, bean, clazz, method, new String[]{ITypeConstants.CLASSNAME_JAVA_RMI_REMOTEEXCEPTION}, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * Verifies that a given method is RMI legal, but doesn't check the exceptions.
- * This means that the method's argument and return values must be of valid types
- * for RMI/IIOP.
- */
- public final void validateLegalRMIMethodReturnType(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- if (method == null) {
- return;
- }
-
- if (!ValidationRuleUtility.isLegalRMI_IIOPType(bean, method.getReturnType())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2412, IEJBValidationContext.INFO, bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * Verifies that a given method is RMI legal, but doesn't check the exceptions.
- * This means that the method's argument and return values must be of valid types
- * for RMI/IIOP.
- */
- public final void validateLegalRMIMethodWithoutExceptions(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- validateLegalRMIMethodArguments(vc, bean, clazz, method);
- validateLegalRMIMethodReturnType(vc, bean, clazz, method);
- }
-
- /**
- * Final check to see if required methods were detected.
- */
- protected abstract void validateMethodExists(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException;
-
- public final void validateMethods(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException {
- vc.terminateIfCancelled();
-
- // Whenever looping over an entire list, always use an
- // iterator instead of a for loop, for performance reasons.
- // If the list is an instance of a linked list, for example,
- // the get(i) call can take a long time.
- Method[] ejbMethods = clazz.listMethodExtended();
- Method method = null;
- List[] methodsExtendedList = getMethodsExtended(vc, bean, clazz);
- for(int i=0; i<ejbMethods.length; i++) {
- vc.terminateIfCancelled();
- method = ejbMethods[i];
- if (method == null) {
- // No point adding a validation message, because the user can't do anything.
- // Log this condition.
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("AValidateEJB.validateMethods()"); //$NON-NLS-1$
- entry.setText("On " + clazz + ", there is a null method."); //$NON-NLS-1$ //$NON-NLS-2$
- logger.write(Level.FINEST, entry);
- }
- continue;
- }
- try {
- validateExistence(vc, bean, clazz, method, methodsExtendedList);
- validate(vc, bean, clazz, method, methodsExtendedList);
- }
- catch (InvalidInputException e) {
- reflectionWarning(vc, bean, clazz, method, e);
- }
- }
- validateMethodExists(vc, bean, clazz);
- vc.terminateIfCancelled();
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateEntityBean.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateEntityBean.java
deleted file mode 100644
index b6e4325a6..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateEntityBean.java
+++ /dev/null
@@ -1,582 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.JavaParameter;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * This class checks entity bean classes for errors or potential errors.
- * If any problems are found, an error, warning, or info marker is added to the task list.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- *
- * All 9.2.X sections describe BMP requirements.
- * If a CMP requirement is different than these, then the differences are
- * documented in 9.4.X sections.
- */
-public abstract class AValidateEntityBean extends AValidateBean {
- protected final static String JAVAX_EJB_ENTITYBEAN = "javax.ejb.EntityBean"; //$NON-NLS-1$
- protected final static String SETENTITYCONTEXT = "setEntityContext"; //$NON-NLS-1$
- protected final static String UNSETENTITYCONTEXT = "unsetEntityContext"; //$NON-NLS-1$
- protected final static String EJBLOAD = "ejbLoad"; //$NON-NLS-1$
- protected final static String EJBSTORE = "ejbStore"; //$NON-NLS-1$
- protected final static String JAVAX_EJB_ENTITYCONTEXT = "javax.ejb.EntityContext"; //$NON-NLS-1$
- private boolean hasValidConstructor = false;
- private boolean hasAConstructor = false;
- private boolean hasSetEntityContext = false;
- private boolean hasUnsetEntityContext = false;
- private boolean hasEjbActivate = false;
- private boolean hasEjbPassivate = false;
- private boolean hasEjbRemove = false;
- private boolean hasEjbLoad = false;
- private boolean hasEjbStore = false;
-
- /**
- * Given a bean's ejbFind method, return the matching find method from
- * the home, if it exists. If not, return null.
- */
- public Method getMatchingHomeFindMethodExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- if (method == null) {
- return null;
- }
-
- if (bean == null) {
- return null;
- }
-
- return ValidationRuleUtility.getMethodExtended(bean.getHomeInterface(), method, IMethodAndFieldConstants.PREFIX_FIND);
- }
- /**
- * getParentName method comment.
- */
- protected String getParentName() {
- return JAVAX_EJB_ENTITYBEAN;
- }
-
- public boolean isFrameworkMethod(String name) {
- if (name == null) {
- return false;
- }
-
- if (super.isFrameworkMethod(name)) {
- return true;
- }
- // check for entity-specific methods
- else if (name.equals(IMethodAndFieldConstants.METHODNAME_EJBLOAD)) {
- return true;
- }
- else if (name.equals(IMethodAndFieldConstants.METHODNAME_EJBSTORE)) {
- return true;
- }
- else if (name.equals(IMethodAndFieldConstants.METHODNAME_SETENTITYCONTEXT)) {
- return true;
- }
- else if (name.equals(IMethodAndFieldConstants.METHODNAME_UNSETENTITYCONTEXT)) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Checks that the methods in the entity bean class follow the EJB 1.1. specification,
- * and that there are no missing required methods.
- * Section: 9.2.2
- */
- public void primValidate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- //super.primValidate(ejbMethod);
-
- vc.terminateIfCancelled();
-
- String name = ejbMethod.getName();
- if (name.equals(IMethodAndFieldConstants.METHODNAME_EJBCREATE))
- validateEjbCreateMethod(vc, bean, clazz, ejbMethod);
- else if (name.equals(IMethodAndFieldConstants.METHODNAME_EJBPOSTCREATE))
- validateEjbPostCreateMethod(vc, bean, clazz, ejbMethod);
- else if (name.equals(IMethodAndFieldConstants.METHODNAME_FINALIZE))
- validateFinalize(vc, bean, clazz, ejbMethod);
- else if (name.startsWith(IMethodAndFieldConstants.PREFIX_EJBFIND))
- validateEjbFindMethod(vc, bean, clazz, ejbMethod);
- else if (isBusinessMethod(vc, bean, clazz, ejbMethod))
- validateBusinessMethod(vc, bean, clazz, ejbMethod);
- else
- validateHelperMethod(vc, bean, clazz, ejbMethod);
-
- vc.terminateIfCancelled();
- }
-
- /**
- * Checks to see if @ejbMethod is one of the required methods.
- */
- protected void primValidateExistence(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- //super.validateExistence(ejbMethod);
-
- vc.terminateIfCancelled();
-
- String name = ejbMethod.getName();
- if (!hasSetEntityContext && name.equals(IMethodAndFieldConstants.METHODNAME_SETENTITYCONTEXT)) {
- JavaParameter[] params = ejbMethod.listParametersWithoutReturn();
- if (params.length == 1) {
- if (ValidationRuleUtility.isAssignableFrom(params[0].getJavaType(), ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVAX_EJB_ENTITYCONTEXT, bean))) {
- hasSetEntityContext = true;
- }
- }
- }
- else if (!hasUnsetEntityContext && name.equals(IMethodAndFieldConstants.METHODNAME_UNSETENTITYCONTEXT)) {
- if (ejbMethod.listParametersWithoutReturn().length == 0) {
- hasUnsetEntityContext = true;
- }
- }
- else if (!hasEjbActivate && name.equals(IMethodAndFieldConstants.METHODNAME_EJBACTIVATE)) {
- if (ejbMethod.listParametersWithoutReturn().length == 0) {
- hasEjbActivate = true;
- }
- }
- else if (!hasEjbPassivate && name.equals(IMethodAndFieldConstants.METHODNAME_EJBPASSIVATE)) {
- if (ejbMethod.listParametersWithoutReturn().length == 0) {
- hasEjbPassivate = true;
- }
- }
- else if (!hasEjbRemove && name.equals(IMethodAndFieldConstants.METHODNAME_EJBREMOVE)) {
- if (ejbMethod.listParametersWithoutReturn().length == 0) {
- hasEjbRemove = true;
- }
- }
- else if (!hasEjbLoad && name.equals(IMethodAndFieldConstants.METHODNAME_EJBLOAD)) {
- if (ejbMethod.listParametersWithoutReturn().length == 0) {
- hasEjbLoad = true;
- }
- }
- else if (!hasEjbStore && name.equals(IMethodAndFieldConstants.METHODNAME_EJBSTORE)) {
- if (ejbMethod.listParametersWithoutReturn().length == 0) {
- hasEjbStore = true;
- }
- }
- else if (!hasValidConstructor && ejbMethod.isConstructor()) {
- hasAConstructor = true;
- if (ValidationRuleUtility.isPublic(ejbMethod) && (ejbMethod.listParametersWithoutReturn().length == 0)) {
- hasValidConstructor = true;
- }
- }
-
- vc.terminateIfCancelled();
-
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.6
- */
- public void validateBusinessMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- super.validateBusinessMethod(vc, bean, clazz, method); // make sure that name does not start with 'ejb'
-
- // The method must be declared as public.
- if (!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2408_bus, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // The method must not be declared as final or static.
- if (method.isStatic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2410_bus, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if (method.isFinal()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2409_bus, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // The method argument and return value types must be legal types for RMI-IIOP.
- validateLegalRMIMethodWithoutExceptions(vc, bean, clazz, method);
-
- // The throws clause may define arbitrary application specific exceptions.
- // Compatibility Note: EJB 1.0 allowed the business methods to throw the
- // java.rmi.RemoteException to indicate a non-application exception. This
- // practice is deprecated in EJB 1.1 -- an EJB 1.1 compliant enterprise bean
- // should throw the javax.ejb.EJBException or another java.lang.RuntimeException
- // to indicate non-application exceptions to the Container (see Section 12.2.2).
- validateBusinessMethodNoRemoteException(vc, bean, clazz, method);
- }
-
- protected void validateBusinessMethodNoRemoteException(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- // EJB 2.0 added "throws InvalidInputException" above
- validateNoRemoteException(vc, bean, clazz, method, IMessagePrefixEjb11Constants.CHKJ2400_bus);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.2
- */
- public void validateClass(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- // All of the above checks are performed by ValidateBean.
- super.validateClass(vc, bean, clazz);
-
- // Plus, check that at least one field exists on the bean.
- verifyFieldExists(vc, bean, clazz);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.3, 9.2.8 and 9.4.2
- */
- public void validateEjbCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- // The method which calls this method has already tested that the method name is ejbCreate.
- if (method == null)
- return;
-
- // The method must be declared as public.
- if (!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2408_ejbCreate, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // The method must not be declared as final or static.
- if (method.isStatic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2410_ejbCreate, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if (method.isFinal()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2409_ejbCreate, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // The method argument and return value types must be legal types for RMI-IIOP.
- // But if the bean uses java.lang.Object for a key, don't check if it's serializable.
- if(ValidationRuleUtility.usesUnknownPrimaryKey(bean)) {
- validateLegalRMIMethodArguments(vc, bean, clazz, method);
- }
- else {
- validateLegalRMIMethodWithoutExceptions(vc, bean, clazz, method);
- }
-
- // The return type must be the entity bean's primary key type; unless this is
- // a CMP, and an unkonwn primary key class is used. Read section 9.4.7.3.
- validateEjbCreateMethod_keyDep(vc, bean, clazz, method);
-
- // The throws clause may define arbitrary application specific exceptions,
- // including the javax.ejb.CreateException.
- // Compatibility Note: EJB 1.0 allowed the ejbPostCreate method to throw
- // the java.rmi.RemoteException to indicate a non-application exception.
- // This practice is deprecated in EJB 1.1 -- an EJB 1.1 compliant enterprise
- // bean should throw the javax.ejb.EJBException or another
- // java.lang.RuntimeException to indicate non-application exceptions to the
- // Container (see Section 12.2.2).
- validateNoRemoteException(vc, bean, clazz, method, IMessagePrefixEjb11Constants.CHKJ2400_ejbCreate);
-
- // Verify that there is a matching ejbPostCreate method for this ejbCreate method.
- Method ejbPostCreateMethod = ValidationRuleUtility.getMethodExtended(clazz, IMethodAndFieldConstants.METHODNAME_EJBPOSTCREATE, method.listParametersWithoutReturn());
- if (ejbPostCreateMethod == null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2002, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // Check for a matching create method on the home, and that the exceptions on
- // this method are a subset of the exceptions of the matching method on the home.
- validateEjbCreateMethod_homeDep(vc, bean, clazz, method);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.3, 9.2.8 and 9.4.2
- */
- public void validateEjbCreateMethod_keyDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- // The method which calls this method has already tested that the method name is ejbCreate.
- if (method == null)
- return;
-
- // Unknown primary key class (section 9.4.7.3) is also validated by this
- // check, because the primary key must be of type java.lang.Object, and
- // the ejbCreate must return java.lang.Object.
- JavaHelpers primaryKey = null;
- if(ValidationRuleUtility.usesUnknownPrimaryKey(bean)) {
- primaryKey = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_LANG_OBJECT, bean);
- }
- else {
- primaryKey = ((Entity) bean).getPrimaryKey();
- }
-
- // The return type must be the entity bean's primary key type.
- vc.terminateIfCancelled();
- JavaHelpers parmType = method.getReturnType();
-
- if (!ValidationRuleUtility.isAssignableFrom(parmType, primaryKey)) {
- // if the parameter type is java.lang.Object, could be section 9.4.7.3
- String keyName = (primaryKey == null) ? IEJBValidatorConstants.NULL_PRIMARY_KEY : primaryKey.getJavaName();
- String[] msgParm = {keyName};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2406, IEJBValidationContext.WARNING, bean, clazz, method, msgParm, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.5, 9.4.6 and 9.4.7.3
- */
- public void validateEjbFindMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- // This method is a no-op so that the dependency classes don't have to implement it.
- // (This method will never be called in a dependency class.)
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.5, 9.4.6 and 9.4.7.3
- */
- public void validateEjbFindMethod_homeDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- // All the exceptions defined in the throws clause of the matching ejbCreate
- // and ejbPostCreate methods of the enterprise Bean class must be included in
- // the throws clause of the matching create method of the home interface
- // (i.e the set of exceptions defined for the create method must be a superset
- // of the union of exceptions defined for the ejbCreate and ejbPostCreate methods)
- JavaClass home = bean.getHomeInterface();
- ValidationRuleUtility.isValidTypeHierarchy(bean, home);
-
- String methodName = IMethodAndFieldConstants.PREFIX_F + method.getName().substring(4); // e.g. if the home method is named findX, then the bean method will be named ejbFindX
- Method homeMethod = ValidationRuleUtility.getMethodExtended(home, method, methodName);
- if (homeMethod == null) {
- // Then this method shouldn't have been called; unless the method exists on the remote, this bean method isn't a business method.
- return;
- }
- Set exceptions = ValidationRuleUtility.getNotSubsetExceptions(bean, method, homeMethod);
- if (exceptions.size() > 0) {
- Iterator iterator = exceptions.iterator();
- while (iterator.hasNext()) {
- JavaClass exc = (JavaClass) iterator.next();
- String[] msgParm = { exc.getQualifiedName(), home.getQualifiedName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2420, IEJBValidationContext.ERROR, bean, clazz, method, msgParm, this);
- vc.addMessage(message);
- }
- }
- }
-
- /**
- * Checks that the ejbPostCreate method follows the EJB 1.1. specification.
- * Section: 9.2.4
- */
- public void validateEjbPostCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- // The method which calls this method has already tested that the method name is ejbPostCreate.
- if (method == null)
- return;
-
- // The method must be declared as public.
- if (!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2408_ejbPostCreate, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // The method must not be declared as final or static.
- if (method.isStatic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2410_ejbPostCreate, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if (method.isFinal()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2409_ejbPostCreate, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- vc.terminateIfCancelled();
-
- // The return type must be void.
- JavaHelpers parmType = method.getReturnType();
- String returnTypeName = ((parmType == null) ? "" : parmType.getQualifiedName()); //$NON-NLS-1$
- if (!returnTypeName.equals(ITypeConstants.VOID)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2418, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // The throws clause may define arbitrary application specific exceptions,
- // including the javax.ejb.CreateException.
- // Compatibility Note: EJB 1.0 allowed the ejbPostCreate method to throw
- // the java.rmi.RemoteException to indicate a non-application exception.
- // This practice is deprecated in EJB 1.1 -- an EJB 1.1 compliant enterprise
- // bean should throw the javax.ejb.EJBException or another
- // java.lang.RuntimeException to indicate non-application exceptions to the
- // Container (see Section 12.2.2).
- validateNoRemoteException(vc, bean, clazz, method, IMessagePrefixEjb11Constants.CHKJ2400_ejbPostCreate);
-
- // Verify that the ejbPostCreate method has a matching ejbCreate method.
- Method ejbCreateMethod = ValidationRuleUtility.getMethodExtended(clazz, IMethodAndFieldConstants.METHODNAME_EJBCREATE, method.listParametersWithoutReturn());
- if (ejbCreateMethod == null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2028, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- validateEjbPostCreateMethod_homeDep(vc, bean, clazz, method);
- }
-
- /**
- * Checks that the ejbPostCreate method follows the EJB 1.1. specification.
- * Section: 9.2.4
- */
- public void validateEjbPostCreateMethod_homeDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- // The method which calls this method has already tested that the method name is ejbPostCreate.
- if (method == null) {
- return;
- }
-
- JavaClass homeIntf = bean.getHomeInterface();
- ValidationRuleUtility.isValidTypeHierarchy(bean, homeIntf);
-
- Method createMethod = getMatchingHomeCreateMethodExtended(vc, bean, clazz, method);
- if (createMethod == null) {
- // If the ejbCreate method is inherited from a component parent, it is likely
- // that the corresponding create method does not exist on the home.
- // Since our tools generate the component inheritance code, suppress this warning.
-
- // ejbCreate methods which are inherited via component inheritance, but do not
- // have a method on their immediate home, are filtered out via the isValid(Method) method.
-
- // The validateEjbCreateMethod checks for a matching create method, but just in
- // case the ejbCreate method is missing, check for it here too.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2029, IEJBValidationContext.WARNING, bean, clazz, method, new String[] { homeIntf.getName()}, this);
- vc.addMessage(message);
-
- // Can't check the exceptions of a method which doesn't exist.
- return;
- }
-
- // Whether this is from a component inheritance or not, if the method exists on the
- // home, check that the method follows the spec.
-
- // Section 6.10.6 (session), 9.2.8 (entity), declare that all exceptions declared
- // on the ejbCreate, ejbPostCreate methods must be defined in the throws clause of
- // the matching create of the home interface.
- Set exceptions = ValidationRuleUtility.getNotSubsetExceptions(bean, method, createMethod);
- if (exceptions.size() > 0) {
- Iterator iterator = exceptions.iterator();
- while (iterator.hasNext()) {
- JavaClass exc = (JavaClass) iterator.next();
- String[] msgParm = { exc.getQualifiedName(), homeIntf.getQualifiedName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2420, IEJBValidationContext.ERROR, bean, clazz, method, msgParm, this);
- vc.addMessage(message);
- }
- }
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.2
- */
- protected void validateFinalize(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) {
- if (method == null) {
- return;
- }
-
- // If it's "finalize()", the ejb bean shouldn't have the method.
- if (method.listParametersWithoutReturn().length == 0) {
- // This is a warning, not an error, because EJB 1.0 allowed the finalize() method to be called. EJB 1.1 (section 6.10.2) specifically prohibits it.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2007, IEJBValidationContext.WARNING, bean, clazz, method, new String[] { clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.2
- */
- protected void validateMethodExists(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- final String[] modelObjectName = new String[] { clazz.getQualifiedName()};
- if (!hasValidConstructor && hasAConstructor) {
- // If a public constructor with no arguments does not exist explicitly,
- // Java will insert one as long as there are no constructors defined in the
- // class. If there is a constructor, Java does not insert a default constructor.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2006, IEJBValidationContext.ERROR, bean, clazz, modelObjectName, this);
- vc.addMessage(message);
- }
-
- if (!hasSetEntityContext) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2033, IEJBValidationContext.WARNING, bean, clazz, this);
- vc.addMessage(message);
- }
-
- if (!hasUnsetEntityContext) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2034, IEJBValidationContext.WARNING, bean, clazz, this);
- vc.addMessage(message);
- }
-
- if (!hasEjbActivate) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2035, IEJBValidationContext.WARNING, bean, clazz, this);
- vc.addMessage(message);
- }
-
- if (!hasEjbPassivate) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2036, IEJBValidationContext.WARNING, bean, clazz, this);
- vc.addMessage(message);
- }
-
- if (!hasEjbRemove) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2037, IEJBValidationContext.WARNING, bean, clazz, this);
- vc.addMessage(message);
- }
-
- if (!hasEjbLoad) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2038, IEJBValidationContext.WARNING, bean, clazz, this);
- vc.addMessage(message);
- }
-
- if (!hasEjbStore) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2039, IEJBValidationContext.WARNING, bean, clazz, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * Check that at least one field exists on the bean class.
- */
- public abstract void verifyFieldExists(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException;
-
- /*
- * @see IValidationRule#preValidate(IEJBValidationContext, Object, Object)
- */
- public void preValidate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException {
- super.preValidate(vc, targetParent, target);
- hasValidConstructor = false;
- hasAConstructor = false;
- hasSetEntityContext = false;
- hasUnsetEntityContext = false;
- hasEjbActivate = false;
- hasEjbPassivate = false;
- hasEjbRemove = false;
- hasEjbLoad = false;
- hasEjbStore = false;
-
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateEntityHome.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateEntityHome.java
deleted file mode 100644
index e5173bfea..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateEntityHome.java
+++ /dev/null
@@ -1,516 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashSet;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.JavaParameter;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * This class checks entity home classes for errors or potential errors.
- * If any problems are found, an error, warning, or info marker is added to the task list.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- * Section: 9.2.8
- */
-public abstract class AValidateEntityHome extends AValidateHome {
- private HashSet findByPKMethods = null;
-
- public AValidateEntityHome() {
- findByPKMethods = new HashSet();
- }
-
- public void reset() {
- super.reset();
- findByPKMethods.clear();
- }
-
- protected void incrementFindByPrimaryKeyCount(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) {
- if (method == null) {
- return;
- }
-
- // Need to track number of findByPrimaryKey methods for the
- // validateMethodExists() checks. Do not check only the current
- // class, or a findByPrimaryKey which is inherited from a parent interface
- // will not be detected.
- if (method.getName().equals(IMethodAndFieldConstants.METHODNAME_FINDBYPRIMARYKEY)) {
- findByPKMethods.add(method);
- }
- }
-
- /**
- * This method returns true if the given method returns the remote interface,
- * and false otherwise.
- */
- public boolean isSingleObjectFinder(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- if (method == null) {
- return false;
- }
-
- // The findByPrimaryKey method is always a single-object finder.
- JavaClass remoteIntf = bean.getRemoteInterface();
- ValidationRuleUtility.isValidTypeHierarchy(bean, remoteIntf);
-
- if (!ValidationRuleUtility.isAssignableFrom(method.getReturnType(), remoteIntf)) {
- return false;
- }
-
- // The method is a single-object finder.
- return true;
- }
-
- /**
- * This method checks that the entity home's methods comply with the EJB 1.1 specification.
- * Section: 9.2.8
- */
- public void primValidate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method hiMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- // super.primValidate(hiMethod);
-
- vc.terminateIfCancelled();
-
- String name = hiMethod.getName();
-
- // Each method defined in the home interface must be one of the following:
- // - A create method.
- // - A finder method.
- if (name.equals(IMethodAndFieldConstants.METHODNAME_CREATE))
- validateCreateMethod(vc, bean, clazz, hiMethod);
- else if (name.startsWith(IMethodAndFieldConstants.PREFIX_FIND))
- validateFindMethod(vc, bean, clazz, hiMethod);
- else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2005, IEJBValidationContext.ERROR, bean, clazz, hiMethod, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * Checks to see if @ejbMethod is one of the required methods.
- */
- protected void primValidateExistence(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- //super.validateExistence(ejbMethod);
-
- if (IMethodAndFieldConstants.METHODNAME_FINDBYPRIMARYKEY.equals(ejbMethod.getName()))
- incrementFindByPrimaryKeyCount(vc, bean, clazz, ejbMethod);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.8
- */
- public void validateClass(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- super.validateClass(vc, bean, clazz);
- // The superclass checks that the home extends javax.ejb.EJBHome,
- // and that the interface inheritance complies with RMI-IIOP rules.
- }
-
- /**
- * Checks that the create method on the entity home follows the EJB 1.1. specification.
- * Section: 9.2.8
- */
- public void validateCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- if (method == null) {
- return;
- }
-
- // Each create method must be named "create", and it must match one of the
- // ejbCreate methods defined in the enterprise Bean class. The matching
- // ejbCreate method must have the same number and types of its arguments.
- // (Note that the return type is different.)
- //
- // All the exceptions defined in the throws clause of the matching ejbCreate
- // and ejbPostCreate methods of the enterprise Bean class must be included in
- // the throws clause of the matching create method of the home interface
- // (i.e the set of exceptions defined for the create method must be a superset
- // of the union of exceptions defined for the ejbCreate and ejbPostCreate methods)
- validateCreateMethod_beanDep(vc, bean, clazz, method);
-
- vc.terminateIfCancelled();
-
- // The return type for a create method must be the entity bean's remote interface type.
- validateCreateMethod_remoteDep(vc, bean, clazz, method);
-
- // The throws clause of a create method must include the javax.ejb.CreateException.
- if (!ValidationRuleUtility.throwsCreateException(bean, method)) {
- String[] msgParm = { ITypeConstants.CLASSNAME_JAVAX_EJB_CREATEEXCEPTION };
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2414, IEJBValidationContext.ERROR, bean, clazz, method, msgParm, this);
- vc.addMessage(message);
- }
-
- // The methods defined in this interface must follow the rules for RMI-IIOP.
- // This means that their argument and return types must be of valid types for
- // RMI-IIOP, and that their throws clause must include the java.rmi.RemoteException.
- validateLegalRMIMethod(vc, bean, clazz, method);
-
- }
-
- /**
- * Checks that the create method on the entity home follows the EJB 1.1. specification.
- * Section: 9.2.8
- */
- public void validateCreateMethod_beanDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- if (method == null) {
- return;
- }
-
- // Each create method must be named "create", and it must match one of the
- // ejbCreate methods defined in the enterprise Bean class. The matching
- // ejbCreate method must have the same number and types of its arguments.
- // (Note that the return type is different.)
- super.validateCreateMethod_beanDep(vc, bean, clazz, method);
-
- //
- // All the exceptions defined in the throws clause of the matching ejbCreate
- // and ejbPostCreate methods of the enterprise Bean class must be included in
- // the throws clause of the matching create method of the home interface
- // (i.e the set of exceptions defined for the create method must be a superset
- // of the union of exceptions defined for the ejbCreate and ejbPostCreate methods)
- validateMatchingBeanPostCreateMethod(vc, bean, clazz, method);
- }
-
- /**
- * In addition to regular find rules, findByPrimaryKey needs to follow some other rules.
- * EJB 1.1 specification
- * Section: 9.2.8
- */
- public void validateFindByPrimaryKeyMethod_keyDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- if (method == null) {
- return;
- }
-
- boolean hasValidFBPKMethod = false;
- Entity entityBean = (Entity) bean; // bean is checked for null in AValidateEJB.validate() method, so don't need to check for it here.
- JavaClass keyClass = entityBean.getPrimaryKey();
-
- ValidationRuleUtility.isValidTypeHierarchy(bean, keyClass);
-
- vc.terminateIfCancelled();
-
- // The method must declare the primary key class as the method argument.
- // This check also validates case 9.4.7.3 (CMP unknown primary key class,
- // which must be declared as java.lang.Object.)
- JavaParameter[] parms = method.listParametersWithoutReturn();
- if (parms.length == 1) {
- JavaHelpers type = parms[0].getJavaType();
- if (ValidationRuleUtility.isAssignableFrom(type, keyClass)) {
- // check that it's a single-object finder
- if (isSingleObjectFinder(vc, bean, clazz, method)) {
- hasValidFBPKMethod = true;
- }
- }
- else {
- // check if it's java.lang.Object. If it is, this could be a case of 9.4.7.3.
- if (ValidationRuleUtility.isSameType(type, ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_LANG_OBJECT, entityBean))) {
- hasValidFBPKMethod = true;
- }
- }
- }
-
- if (!hasValidFBPKMethod) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2405, IEJBValidationContext.WARNING, bean, clazz, method, new String[] { keyClass.getQualifiedName()}, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * In addition to regular find rules, findByPrimaryKey needs to follow some other rules.
- * EJB 1.1 specification
- * Section: 9.2.8
- */
- public void validateFindByPrimaryKeyMethod_remoteDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- if (!isSingleObjectFinder(vc, bean, clazz, method)) {
- String remoteIntfName = bean.getRemoteInterface().getName(); // Can assume that remote interface isn't null, or isSingleObjectFinder would have thrown an InvalidInputException.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2403, IEJBValidationContext.WARNING, bean, clazz, method, new String[] { remoteIntfName }, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * Checks that the finder method on the entity home class follows the EJB 1.1 specification.
- * Section: 9.2.8
- */
- public void validateFindMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- if (method == null) {
- return;
- }
-
- // The return type for a find<METHOD> method must be the entity bean's remote
- // interface type (for a single-object finder), or a collection thereof (for a
- // multi-object finder).
- //
- // Whether or not the parameter is a type or an array of types, the following
- // call will return the base type. i.e., if it's an array of "MyClass",
- // the returnTypeName will be set to "MyClass", not an array type.
- validateFindMethod_remoteDep(vc, bean, clazz, method);
-
- // The throws clause of a finder method must include the javax.ejb.FinderException.
- if (!ValidationRuleUtility.throwsFinderException(bean, method)) {
- String[] msgParm = { ITypeConstants.CLASSNAME_JAVAX_EJB_FINDEREXCEPTION };
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2414, IEJBValidationContext.ERROR, bean, clazz, method, msgParm, this);
- vc.addMessage(message);
- }
-
- // The home interface must always include the findByPrimaryKey method, which is
- // always a single-object finder. The method must declare the primary key class
- // as the method argument.
- boolean validateRMIParameters = true; // should the parameters be validated to see if they follow RMI-IIOP rules?
- boolean validateRMIRetType = true; // should the return type be validated to see if it follows RMI-IIOP rules?
- if (method.getName().equals(IMethodAndFieldConstants.METHODNAME_FINDBYPRIMARYKEY)) {
- // - The home interface must always include the findByPrimaryKey method, which is
- // always a single-object finder. The method must declare the primary key class
- // as the method argument.
- //
- // The findByPrimaryKey method is always a single-object finder.
- // The call to validateFindByPrimaryKeyMethod_remoteDep is done in
- // validateFindMethod_remoteDep(method);
- //validateFindByPrimaryKeyMethod_remoteDep(method);
-
- // The method must declare the primary key class as the method argument.
- validateFindByPrimaryKeyMethod_keyDep(vc, bean, clazz, method);
-
- if(ValidationRuleUtility.usesUnknownPrimaryKey(bean)) {
- validateRMIParameters = false;
- }
- }
-
- // The methods defined in this interface must follow the rules for RMI-IIOP.
- // This means that their argument and return types must be of valid types for
- // RMI-IIOP, and that their throws clause must include the java.rmi.RemoteException.
- // However, the return type of "Enumeration" or "Collection" is exempted from this
- // check, because the spec states, in 9.1.8.2, that Enumeration or Collection must be returned
- // for multi-object finders.
- JavaHelpers retType = method.getReturnType();
- validateRMIRetType = !((ValidationRuleUtility.isAssignableFrom(retType, ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_UTIL_ENUMERATION, bean))) ||
- (ValidationRuleUtility.isAssignableFrom(retType, ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_UTIL_COLLECTION, bean))));
-
- if(validateRMIParameters) {
- validateLegalRMIMethodArguments(vc, bean, clazz, method);
- }
-
- if(validateRMIRetType) {
- validateLegalRMIMethodReturnType(vc, bean, clazz, method);
- }
-
- validateLegalRMIMethodExceptions(vc, bean, clazz, method);
- }
-
- /**
- * Checks that the finder method on the entity home class follows the EJB 1.1 specification.
- * Section: 9.2.8
- */
- public void validateFindMethod_remoteDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- if (method == null) {
- return;
- }
-
- // The return type for a find<METHOD> method must be the entity bean's remote
- // interface type (for a single-object finder), or a collection thereof (for a
- // multi-object finder).
- //
- // Whether or not the parameter is a type or an array of types, the following
- // call will return the base type. i.e., if it's an array of "MyClass",
- // the returnTypeName will be set to "MyClass", not an array type.
- JavaClass remoteIntf = bean.getRemoteInterface();
- ValidationRuleUtility.isValidTypeHierarchy(bean, remoteIntf);
-
- // Perform this check for all finders but the findByPrimaryKey method.
- // The findByPrimaryKey method must return the remote interface, because the method is
- // a single-object finder method; but other finders may return a Collection or Enumeration.
- if (!method.getName().equals(IMethodAndFieldConstants.METHODNAME_FINDBYPRIMARYKEY)) {
- JavaHelpers returnType = method.getReturnType();
-
- if (! (ValidationRuleUtility.isAssignableFromCollection(returnType, bean) ||
- ValidationRuleUtility.isAssignableFromEnumeration(returnType, bean) ||
- ValidationRuleUtility.isAssignableFrom(returnType, remoteIntf))) {
- String[] msgParm = { remoteIntf.getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2403, IEJBValidationContext.WARNING, bean, clazz, method, msgParm, this);
- vc.addMessage(message);
- }
- }
-
- // The home interface must always include the findByPrimaryKey method, which is
- // always a single-object finder. The method must declare the primary key class
- // as the method argument.
- if (method.getName().equals(IMethodAndFieldConstants.METHODNAME_FINDBYPRIMARYKEY)) {
- validateFindByPrimaryKeyMethod_remoteDep(vc, bean, clazz, method);
- }
- }
-
- public void validateMatchingBeanCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- super.validateMatchingBeanCreateMethod(vc, bean, clazz, method);
- JavaClass beanClass = bean.getEjbClass();
- Method ejbCreateMethod = ValidationRuleUtility.getMethodExtended(beanClass, method, IMethodAndFieldConstants.METHODNAME_EJBCREATE);
- if (ejbCreateMethod == null) {
- // already reported in super
- return;
- }
- }
-
- /**
- * Checks that the finder method on the entity home class follows the EJB 1.1 specification.
- * Section: 9.2.8
- */
- public void validateMatchingBeanFindMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method homeMethod) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- if (homeMethod == null) {
- return;
- }
-
- // Each finder method must be named "find<METHOD>" (e.g. findLargeAccounts), and it
- // must match one of the ejbFind<METHOD> methods defined in the entity bean class
- // (e.g. ejbFindLargeAccounts). The matching ejbFind<METHOD> method must have the
- // same number and types of arguments. (Note that the return type may be different.)
- String findMethodName = IMethodAndFieldConstants.PREFIX_EJBF + (homeMethod.getName()).substring(1); // e.g. if the home method is named findX, then the bean method will be named ejbFindX
-
- JavaClass beanClass = bean.getEjbClass();
- ValidationRuleUtility.isValidTypeHierarchy(bean, beanClass);
-
- Method beanMethod = ValidationRuleUtility.getMethodExtended(beanClass, homeMethod, findMethodName);
- if (beanMethod == null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2030, IEJBValidationContext.ERROR, bean, clazz, homeMethod, new String[] { beanClass.getName()}, this);
- vc.addMessage(message);
- return;
- }
-
- // Check if return types match
- vc.terminateIfCancelled();
- JavaHelpers homeRetType = homeMethod.getReturnType();
- JavaHelpers beanRetType = beanMethod.getReturnType();
- if (!ValidationRuleUtility.isAssignableFrom(homeRetType, beanRetType)) {
- // emit the error only if it's a multi-finder. Single-finders are supposed to have different return types on the home & bean class.
- boolean homeRetTypeIsRemote = ValidationRuleUtility.isAssignableFrom(homeRetType, bean.getRemoteInterface());
- boolean beanRetTypeIsKey = ValidationRuleUtility.isAssignableFrom(beanRetType, ((Entity)bean).getPrimaryKey());
- if(!(homeRetTypeIsRemote && beanRetTypeIsKey)) {
- JavaHelpers retType = (beanRetTypeIsKey) ? bean.getRemoteInterface() : beanRetType; // if the bean class returns a key, the home must return the remote; if the bean class returns a Coll/Enum, the home must return the same
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2415, IEJBValidationContext.ERROR, bean, clazz, homeMethod, new String[] { retType.getJavaName(), beanClass.getName()}, this);
- vc.addMessage(message);
- }
- }
-
- // All the exceptions defined in the throws clause of an ejbFind method of the
- // entity bean class must be included in the throws clause of the matching find
- // method of the home interface.
- /*
- // Don't check for the exceptions here - let the bean class do it. When the home
- // changes, a "dependent" validation of the bean's checks should be done automatically.
- // If it is checked in this method as well, there are duplicate messages on the task list.
- HashSet exceptions = getNotSubsetExceptions(homeMethod, beanMethod);
- if(exceptions.size() > 0) {
- Iterator iterator = exceptions.iterator();
- while(iterator.hasNext()) {
- JavaClass exc = (JavaClass)iterator.next();
- String[] msgParm = {exc.getQualifiedName()};
- addValidationMessage(IEJBValidationContext.ERROR, IMessagePrefixEjb11Constants.EJB_METHOD_THROW_NOTHI_EXCEP, msgParm, beanMethod, EJB_BEAN_GROUP);
- }
- }
- */
- }
-
- /**
- * Checks that the create method on the entity home has a matching ejbCreate and ejbPostCreate on the bean.
- * EJB 1.1 specification
- * Section: 9.2.8
- */
- public void validateMatchingBeanPostCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method homeMethod) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- if (homeMethod == null) {
- return;
- }
-
- // Each create method must be named "create", and it must match one of the
- // ejbCreate methods defined in the enterprise Bean class. The matching
- // ejbCreate method must have the same number and types of its arguments.
- // (Note that the return type is different.)
- JavaClass beanClass = bean.getEjbClass();
- ValidationRuleUtility.isValidTypeHierarchy(bean, beanClass);
-
- Method beanMethod = ValidationRuleUtility.getMethodExtended(beanClass, homeMethod, IMethodAndFieldConstants.METHODNAME_EJBPOSTCREATE);
- if (beanMethod == null) {
- // Let the bean class report this message. Otherwise, when the bean class reports it, this message looks like a duplicate.
- /*
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2031, IEJBValidationContext.WARNING, bean, clazz, homeMethod, new String[] { beanClass.getName()}, this);
- vc.addMessage(message);
- */
- return;
- }
-
- // All the exceptions defined in the throws clause of the matching ejbCreate
- // and ejbPostCreate methods of the enterprise Bean class must be included in
- // the throws clause of the matching create method of the home interface
- // (i.e the set of exceptions defined for the create method must be a superset
- // of the union of exceptions defined for the ejbCreate and ejbPostCreate methods)
- /*
- // Don't check for the exceptions here - let the bean class do it. When the home
- // changes, a "dependent" validation of the bean's checks should be done automatically.
- // If it is checked in this method as well, there are duplicate messages on the task list.
- HashSet exceptions = getNotSubsetExceptions(homeMethod, beanMethod);
- if(exceptions.size() > 0) {
- Iterator iterator = exceptions.iterator();
- while(iterator.hasNext()) {
- JavaClass exc = (JavaClass)iterator.next();
- String[] msgParm = {exc.getQualifiedName()};
- addValidationMessage(IEJBValidationContext.ERROR, IMessagePrefixEjb11Constants.EJB_METHOD_THROW_NOTHI_EXCEP, msgParm, beanMethod, EJB_BEAN_GROUP);
- }
- }
- */
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.8
- */
- protected void validateMethodExists(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- // - The home interface must always include the findByPrimaryKey method, which is
- // always a single-object finder. The method must declare the primary key class
- // as the method argument.
- if (findByPKMethods.size() == 0) {
- // must have one findByPrimaryKey method
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2011, IEJBValidationContext.ERROR, bean, clazz, new String[] { clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
- /*
- // Not sure if this check is useful or not, because it is legal for a child home to declare a findByPrimaryKey,
- // and also for a parent home to declare a findByPrimaryKey.
- else if ( findByPKMethods.size() > 1 ) {
- // if the home interface has multiple findByPrimaryKey methods (implied by 9.2.8)
- Iterator iterator = findByPKMethods.iterator();
- while(iterator.hasNext()) {
- addValidationMessage(IEJBValidationContext.WARNING, IMessagePrefixEjb11Constants.EJB_HAS_MULTIPLE_PK_METHODS, (Method)iterator.next());
- }
- }
- */
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateHome.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateHome.java
deleted file mode 100644
index df303bd4d..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateHome.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.List;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * This class checks home classes for errors or potential errors.
- * If any problems are found, an error, warning, or info marker is added to the task list.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- * Section: 6.8, 6.10.6 and 9.2.8
- */
-public abstract class AValidateHome extends AValidateEJB {
- public final Object getTarget(Object parent, Object clazz) {
- if(parent == null) {
- return null;
- }
-
- return ((EnterpriseBean)parent).getHomeInterface();
- }
-
- public final List[] getMethodsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // A home or component class needs the following classes' extended methods:
- // 1. bean class
- List[] result = new List[1];
- JavaClass beanClass = bean.getEjbClass();
- if(beanClass == null) {
- result[0] = null;
- }
- else {
- result[0] = beanClass.getMethodsExtended();
- }
- return result;
- }
-
- public final List[] getFieldsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // Never check that a home or component's field is defined on another class
- // of the bean.
- return null;
- }
-
- /**
- * For the check that the ejbCreate method has a matching create method on the home,
- * this method, given the bean method, returns the corresponding home method.
- * EJB 1.1 specification
- * Section: 6.10.6 and 9.2.8
- */
- public Method getMatchingBeanEjbCreateMethodExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
- if (method == null) {
- return null;
- }
-
- if (bean == null) {
- return null;
- }
-
- return ValidationRuleUtility.getMethodExtended(bean.getEjbClass(), method, IMethodAndFieldConstants.METHODNAME_EJBCREATE);
- }
-
- /**
- * Return true if the method can, and should, be validated.
- * Filter out faulty methods (i.e., null), and methods which
- * belong to the base type, whatever that is. (e.g. java.lang.Object)
- */
- protected boolean isValid(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedList) throws InvalidInputException {
- if (super.isValid(vc, bean, clazz, method, methodsExtendedList)) {
- // Exclude root remote interface methods
- if (ValidationRuleUtility.isEJBHomeMethod(bean, method)) {
- return false;
- }
- else if (ValidationRuleUtility.isClinitMethod(bean, method)) {
- return false;
- }
- else {
- return true;
- }
- }
- return false;
- }
-
- /**
- * EJB 1.1 specification
- * Section: 6.10.6 and 9.2.8
- */
- public void validateClass(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- // home interface must be an interface
- if (!clazz.isInterface()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2012, IEJBValidationContext.ERROR, bean, clazz, this);
- vc.addMessage(message);
- }
-
- // home interface must inherit javax.ejb.EJBHome.class
- if (!ValidationRuleUtility.isAssignableFrom(clazz, ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVAX_EJB_EJBHOME, bean))) {
- String[] msgParm = { ITypeConstants.CLASSNAME_JAVAX_EJB_EJBHOME };
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2017, IEJBValidationContext.ERROR, bean, clazz, msgParm, this);
- vc.addMessage(message);
- }
-
- if (ValidationRuleUtility.isUnnamedPackage(clazz.getJavaPackage())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2041, IEJBValidationContext.INFO, bean, clazz, this);
- vc.addMessage(message);
- }
-
- validateAppendixB(vc, bean, clazz);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 6.8 and 6.10.6
- */
- protected void validateCreateMethod_beanDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- if (method == null) {
- return;
- }
-
- // Each create method must be named "create", and it must match one of
- // the ejbCreate methods defined in the session bean class. The matching
- // ejbCreate method must have the same number and types of arguments.
- // (Note that the return type is different.)
- // All the exceptions defined in the throws clause of an ejbCreate method
- // of the session bean class must be defined in the throws clause of the
- // matching create method of the home interface.
- // The throws clause must include javax.ejb.CreateException.
- validateMatchingBeanCreateMethod(vc, bean, clazz, method);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 6.8, 6.10.6 and 9.2.8
- */
- protected void validateCreateMethod_remoteDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- if (method == null) {
- return;
- }
-
- JavaClass remoteIntf = bean.getRemoteInterface();
- ValidationRuleUtility.isValidTypeHierarchy(bean, remoteIntf);
-
- // The return type for a create method must be the remote interface type.
- if (!ValidationRuleUtility.isAssignableFrom(method.getReturnType(), remoteIntf)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2402, IEJBValidationContext.WARNING, bean, clazz, method, new String[] { remoteIntf.getName()}, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * EJB 1.1 specification
- * Section: 6.10.6 and 9.2.8
- */
- public void validateMatchingBeanCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- if (method == null) {
- return;
- }
-
- // Each create method must be named "create", and it must match one of the
- // ejbCreate methods defined in the enterprise Bean class. The matching
- // ejbCreate method must have the same number and types of its arguments.
- // (Note that the return type is different.)
- JavaClass beanClass = bean.getEjbClass();
- ValidationRuleUtility.isValidTypeHierarchy(bean, beanClass);
-
- Method ejbCreateMethod = ValidationRuleUtility.getMethodExtended(beanClass, method, IMethodAndFieldConstants.METHODNAME_EJBCREATE);
- if (ejbCreateMethod == null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2026, IEJBValidationContext.ERROR, bean, clazz, method, new String[] { beanClass.getName()}, this);
- vc.addMessage(message);
- return;
- }
-
- // Section 6.10.6 (session), 9.2.8 (entity), declare that all exceptions declared
- // on the ejbCreate, ejbPostCreate methods must be defined in the throws clause of
- // the matching create of the home interface.
- /*
- // Don't check for the exceptions here - let the bean class do it. When the home
- // changes, a "dependent" validation of the bean's checks should be done automatically.
- // If it is checked in this method as well, there are duplicate messages on the task list.
- HashSet exceptions = getNotSubsetExceptions(method, ejbCreateMethod);
- if(exceptions.size() > 0) {
- Iterator iterator = exceptions.iterator();
- while(iterator.hasNext()) {
- JavaClass exc = (JavaClass)iterator.next();
- String[] msgParm = {exc.getQualifiedName()};
- addValidationMessage(IEJBValidationContext.ERROR, IMessagePrefixEjb11Constants.EJB_METHOD_THROW_NOTHI_EXCEP, msgParm, ejbCreateMethod, EJB_HOME_GROUP); // since we're adding the message to the bean class, we need to mark it like the bean class would; i.e., a home-dependent message
- }
- }
- */
- }
-
- protected void validateAppendixB(IEJBValidationContext vc, EnterpriseBean bean, JavaClass thisHome) {
- // The Java inheritance structure must match the EJB inheritance structure.
- // e.g. if EJB B is a child of EJB A, then class B must be a child of class A.
- // B could be a grandchild (or great-grandchild or ...) of A.
-
- if(bean == null) {
- // bean has no supertype
- return;
- }
- EnterpriseBean supertype = getSuperType(bean);
- JavaClass parentHome = null;
- if (supertype != null) {
- // check this CMP's supertype
- parentHome = supertype.getHomeInterface();
-
- // Home a Xchild of parent Home
- // In our EJB component inheritance structure, while it is legal for
- // a home to inherit from another home, (section B.2), it is not legal
- // for WSA component inheritance structure.
- try {
- ValidationRuleUtility.isValidType(thisHome);
- ValidationRuleUtility.isValidType(parentHome);
- if (ValidationRuleUtility.isAssignableFrom(thisHome, parentHome)) {
- String[] msgParm = new String[] { thisHome.getQualifiedName(), parentHome.getQualifiedName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2104, IEJBValidationContext.ERROR, bean, thisHome, msgParm, this);
- vc.addMessage(message);
- }
- }
- catch (InvalidInputException e) {
- String[] msgParm = { e.getJavaClass().getQualifiedName(), bean.getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2849, IEJBValidationContext.WARNING, bean, msgParm, this);
- vc.addMessage(message);
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateKeyClass.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateKeyClass.java
deleted file mode 100644
index c2bbb70b8..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateKeyClass.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.List;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * This class checks entity key classes for errors or potential errors.
- * If any problems are found, an error, warning, or info marker is added to the task list.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- * Section 9.2.9
-*/
-public abstract class AValidateKeyClass extends AValidateEJB {
- public Object getTarget(Object parent, Object clazz) {
- if (parent == null) {
- return null;
- }
-
- return ((Entity) parent).getPrimaryKey();
- }
-
- public final List[] getMethodsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // Never check that a key class' method is defined on another class
- // of the bean.
- return null;
- }
-
- public final List[] getFieldsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // Never check that a key class' field is defined on another class
- // of the bean.
- return null;
- }
-
- /**
- * Return true if the method can, and should, be validated.
- * Filter out faulty methods (i.e., null), and methods which
- * belong to the base type, whatever that is. (e.g. java.lang.Object)
- */
- protected boolean isValid(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedList) throws InvalidInputException {
- if (super.isValid(vc, bean, clazz, method, methodsExtendedList)) {
- // exclude root object methods
- if (!ValidationRuleUtility.isJavaLangObjectMethod(bean, method)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.9
- */
- public void validateClass(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- validateLegalRMIType(vc, bean, clazz);
-
- if (ValidationRuleUtility.isUnnamedPackage(clazz.getJavaPackage())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2041, IEJBValidationContext.INFO, bean, clazz, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * Verifies that a given class is a legal Value Type in RMI-IIOP.
- *
- * Java Remote MethodInvocation
- * Specification
- *
- * Revision 1.7, Java 2 SDK, Standard Edition, v1.3.0, December 1999
- *
- * Section: 2.6
- */
- public final void validateLegalRMIType(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- ValidationRuleUtility.isValidType(clazz);
-
- if (!ValidationRuleUtility.isLegalRMI_IIOPType(bean, clazz)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2019, IEJBValidationContext.INFO, bean, clazz, new String[] { clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.9
- */
- public void validateMethodExists(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- // The class must provide suitable implementation of the hashCode() and
- // equals(Object other) methods to simplify the management of the primary keys
- // by client code.
- Method hashCodeMethod = ValidationRuleUtility.getMethodExtended(clazz, IMethodAndFieldConstants.METHODNAME_HASHCODE, new JavaHelpers[0]);
- if ((hashCodeMethod == null) || ValidationRuleUtility.isJavaLangObjectMethod(bean, hashCodeMethod)) {
- // EJB 1.0 did not require this method, so this is a warning instead of an error.
- String[] msgParm = { clazz.getQualifiedName(), IMethodAndFieldConstants.METHODSIGNATURE_HASHCODE};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2001, IEJBValidationContext.WARNING, bean, clazz, msgParm, this);
- vc.addMessage(message);
- }
-
- Method equalsMethod = ValidationRuleUtility.getMethodExtended(clazz, IMethodAndFieldConstants.METHODNAME_EQUALS, new JavaHelpers[]{ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_LANG_OBJECT, bean)});
- if ((equalsMethod == null) || (ValidationRuleUtility.isJavaLangObjectMethod(bean, equalsMethod))) {
- // EJB 1.0 did not require this method, so this is a warning instead of an error.
- String[] msgParm = { clazz.getQualifiedName(), IMethodAndFieldConstants.METHODSIGNATURE_EQUALS };
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2001, IEJBValidationContext.WARNING, bean, clazz, msgParm, this);
- vc.addMessage(message);
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateRemote.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateRemote.java
deleted file mode 100644
index d1f3bd3ee..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidateRemote.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.List;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * This class checks remote interface classes for errors or potential errors.
- * If any problems are found, an error, warning, or info marker is added to the task list.
- * The checks for a session remote interface and an entity remote interface are the same
- * in EJB 1.1.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- * Section: 6.10.5 and 9.2.7
- */
-public abstract class AValidateRemote extends AValidateEJB {
- public final Object getTarget(Object parent, Object clazz) {
- if(parent == null) {
- return null;
- }
-
- return ((EnterpriseBean)parent).getRemoteInterface();
- }
-
- public final List[] getMethodsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // A home or component class needs the following classes' extended methods:
- // 1. bean class
- List[] result = new List[1];
- JavaClass beanClass = bean.getEjbClass();
- if(beanClass == null) {
- result[0] = null;
- }
- else {
- result[0] = beanClass.getMethodsExtended();
- }
- return result;
- }
-
- public final List[] getFieldsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // Never check that a home or component's field is defined on another class
- // of the bean.
- return null;
- }
-
- /**
- * Return true if the method can, and should, be validated.
- * Filter out faulty methods (i.e., null), and methods which
- * belong to the base type, whatever that is. (e.g. java.lang.Object)
- */
- protected boolean isValid(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedList) throws InvalidInputException {
- if (super.isValid(vc, bean, clazz, method, methodsExtendedList)) {
- // Exclude root remote interface methods
- if (ValidationRuleUtility.isEJBObjectMethod(bean, method)) {
- return false;
- }
- else if (isEjbRelationshipRoleMethod(vc, bean, clazz, method)) {
- return false;
- }
- else if (ValidationRuleUtility.isClinitMethod(bean, method)) {
- return false;
- }
- else {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Check the remote interface's methods against the EJB 1.1 spec.
- * Section: 6.10.5 and 9.2.7
- */
- public void primValidate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method riMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- // super.validateExistence(riMethod);
-
- vc.terminateIfCancelled();
-
- // The methods defined in this interface must follow the rules for RMI/IIOP.
- validateLegalRMIMethod(vc, bean, clazz, riMethod);
-
- // For each method defined in the remote interface, there must be a matching
- // method in the session bean's class.
- validateMethod_beanDep(vc, bean, clazz, riMethod);
-
- }
-
- /**
- * Checks to see if @ejbMethod is one of the required methods.
- */
- protected void primValidateExistence(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- //super.validateExistence(ejbMethod);
-
- //There are no required methods.
- }
-
- /**
- * Check that the remote interface class definition follows the EJB 1.1 spec.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- * Section: 6.10.5 and 9.2.7
- */
- public void validateClass(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- // It must be an interface, not a class.
- if (!clazz.isInterface()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2012, IEJBValidationContext.ERROR, bean, clazz, this);
- vc.addMessage(message);
- }
-
- // The interface must extend the javax.ejb.EJBObject interface.
- JavaHelpers javaxEjbObject = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVAX_EJB_EJBOBJECT, bean);
- if (!ValidationRuleUtility.isAssignableFrom(clazz, javaxEjbObject)) {
- String[] msgParm = { ITypeConstants.CLASSNAME_JAVAX_EJB_EJBOBJECT };
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2017, IEJBValidationContext.ERROR, bean, clazz, msgParm, this);
- vc.addMessage(message);
- }
-
- if (ValidationRuleUtility.isUnnamedPackage(clazz.getJavaPackage())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2041, IEJBValidationContext.INFO, bean, clazz, this);
- vc.addMessage(message);
- }
-
- validateAppendixB(vc, bean, clazz);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 6.10.5 and 9.2.7
- */
- public void validateMatchingBeanMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method remoteMethod) throws InvalidInputException {
- vc.terminateIfCancelled();
- if (remoteMethod == null) {
- return;
- }
-
- JavaClass beanClass = bean.getEjbClass();
- ValidationRuleUtility.isValidTypeHierarchy(bean, beanClass);
-
- Method beanMethod = ValidationRuleUtility.getMethodExtended(beanClass, remoteMethod, remoteMethod.getName());
- if (beanMethod == null) {
- String[] msgParm = { beanClass.getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2023, IEJBValidationContext.ERROR, bean, clazz, remoteMethod, msgParm, this);
- vc.addMessage(message);
- return;
- }
-
- ValidationRuleUtility.isValidType(ValidationRuleUtility.getType(remoteMethod.getReturnType()));
-
- try {
- ValidationRuleUtility.isValidType(ValidationRuleUtility.getType(beanMethod.getReturnType()));
- }
- catch (InvalidInputException e) {
- // Let the validation of the bean class report the reflection warning.
- // Don't do any validation based on that method.
- return;
- }
-
- // Check if return types match
- vc.terminateIfCancelled();
- if (!ValidationRuleUtility.isAssignableFrom(remoteMethod.getReturnType(), beanMethod.getReturnType())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2415, IEJBValidationContext.ERROR, bean, clazz, remoteMethod, new String[] { beanMethod.getReturnType().getJavaName(), beanClass.getName()}, this);
- vc.addMessage(message);
- }
-
-
- // Section 6.10.5 (session), 9.2.7 (entity), declare that all exceptions declared
- // on the ejbCreate, ejbPostCreate methods must be defined in the throws clause of
- // the matching create of the remote interface.
- /*
- // Don't check for the exceptions here - let the bean class do it. When the remote
- // changes, a "dependent" validation of the bean's checks should be done automatically.
- // If it is checked in this method as well, there are duplicate messages on the task list.
- HashSet exceptions = getNotSubsetExceptions(remoteMethod, beanMethod);
- if(exceptions.size() > 0) {
- Iterator iterator = exceptions.iterator();
- while(iterator.hasNext()) {
- JavaClass exc = (JavaClass)iterator.next();
- String[] msgParm = {exc.getQualifiedName()};
- addValidationMessage(IEJBValidationContext.ERROR, IMessagePrefixEjb11Constants.EJB_METHOD_THROW_NOTRI_EXCEP, msgParm, beanMethod, EJB_BEAN_GROUP);
- }
- }
- */
- }
-
- /**
- * Check the remote interface's methods against the EJB 1.1 spec.
- * Section: 6.10.5 and 9.2.7
- */
- public void validateMethod_beanDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method riMethod) throws InvalidInputException {
- vc.terminateIfCancelled();
- // For each method defined in the remote interface, there must be a matching
- // method in the session bean's class.
- validateMatchingBeanMethod(vc, bean, clazz, riMethod);
- }
-
- /**
- * Final check to see if required methods were detected.
- */
- protected void validateMethodExists(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- //There are no required methods.
- }
-
- protected void validateAppendixB(IEJBValidationContext vc, EnterpriseBean bean, JavaClass thisRemote) {
- // The Java inheritance structure must match the EJB inheritance structure.
- // e.g. if EJB B is a child of EJB A, then class B must be a child of class A.
- // B could be a grandchild (or great-grandchild or ...) of A.
- if(bean == null) {
- return;
- }
- EnterpriseBean supertype = getSuperType(bean);
- JavaClass parentRemote = null;
- if (supertype != null) {
- parentRemote = supertype.getRemoteInterface();
-
- // Remote a Xchild of parent Remote
- try {
- ValidationRuleUtility.isValidType(thisRemote);
- ValidationRuleUtility.isValidType(parentRemote);
- if (!ValidationRuleUtility.isAssignableFrom(thisRemote, parentRemote)) {
- String[] msgParm = new String[] { thisRemote.getQualifiedName(), parentRemote.getQualifiedName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2105, IEJBValidationContext.ERROR, bean, thisRemote, msgParm, this);
- vc.addMessage(message);
- }
- }
- catch (InvalidInputException e) {
- String[] msgParm = { e.getJavaClass().getQualifiedName(), bean.getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2849, IEJBValidationContext.WARNING, bean, msgParm, this);
- vc.addMessage(message);
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidationRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidationRule.java
deleted file mode 100644
index 08d5d7b38..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AValidationRule.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.internal.EjbModuleExtensionHelper;
-import org.eclipse.jst.j2ee.internal.IEJBModelExtenderManager;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-
-
-/**
- * @version 1.0
- * @author
- */
-public abstract class AValidationRule implements IValidationRule {
-
- private Set _dependents = null;
-
- protected EjbModuleExtensionHelper modHelper = null;
-
- /*
- * @see IValidationRule#addDependent(IValidationRule)
- */
- public void addDependent(IValidationRule rule) {
- if (rule == null) { return; }
-
- if (_dependents == null) {
- _dependents = new HashSet();
- }
-
- _dependents.add(rule);
- }
-
- /*
- * @see IValidationRule#getDependents()
- */
- public Set getDependents() {
- return _dependents;
- }
-
- protected EjbModuleExtensionHelper getEjbExtensionHelper(Object context) {
- return IEJBModelExtenderManager.INSTANCE.getEJBModuleExtension(context);
- }
-
- /**
- * @param EnterpriseBean
- * @return EnterpriseBean return the super type of an EnterpriseBean by
- * loading the extnension plugin if extension plugin fails to load
- * return null
- */
- public final EnterpriseBean getSuperType(EnterpriseBean enterpriseBean) {
- EnterpriseBean superType = null;
- EjbModuleExtensionHelper aModHelper = getEjbExtensionHelper(enterpriseBean);
- if (aModHelper != null) superType = aModHelper.getSuperType(enterpriseBean);
- return superType;
- }
-
- /**
- * @param EnterpriseBean
- * @return String - super type file name return the super type file of an
- * EnterpriseBean by loading the extnension plugin if extension
- * plugin fails to load return null
- */
- public final String getEJBInheritanceFileName() {
- String superTypeFileName = null;
- // TODO MDE Revisit this after the drop
- EjbModuleExtensionHelper aModHelper = getEjbExtensionHelper(null);
- if (aModHelper != null) superTypeFileName = aModHelper.getEJBInheritanceFileName();
- return superTypeFileName;
- }
-
- /**
- * @param EnterpriseBean
- * @return List - extended role names return the extended role method name
- * of an EnterpriseBean by loading the extnension plugin if
- * extension plugin fails to load return null
- */
- public final List getRoleMethodNamesExtended(EnterpriseBean enterpriseBean) {
- List roleNameExtended = null;
- EjbModuleExtensionHelper aModHelper = getEjbExtensionHelper(enterpriseBean);
- if (aModHelper != null && enterpriseBean.isContainerManagedEntity())
- roleNameExtended = aModHelper.getRoleMethodNamesExtended((ContainerManagedEntity) enterpriseBean);
- return roleNameExtended;
- }
-
- /*
- * @see IValidationRule#preValidate(IEJBValidationContext, Object, Object)
- */
- public void preValidate(IEJBValidationContext vc, Object targetParent, Object target)
- throws ValidationCancelledException, ValidationException {
- // By default, allocate nothing.
- }
-
- /*
- * @see IValidationRule#postValidate(IEJBValidationContext, Object, Object)
- */
- public void postValidate(IEJBValidationContext vc, Object targetParent, Object target)
- throws ValidationCancelledException, ValidationException {
- // By default, assume that nothing was allocated in preValidate.
- }
-
- /*
- * @see IValidationRule#reset()
- */
- public void reset() {
- // By default, assume that nothing needs to be reset
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AbstractEJBValidationRuleFactory.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AbstractEJBValidationRuleFactory.java
deleted file mode 100644
index 47f92a055..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AbstractEJBValidationRuleFactory.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Abstract class for EJB Validation rules
- */
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.logging.Level;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-
-/**
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public abstract class AbstractEJBValidationRuleFactory {
-
- /**
- *
- */
- public AbstractEJBValidationRuleFactory() {
- //Default
- }
-
- protected HashMap _ruleList = null;
-
- public void release(IValidationRule rule) {
- if(rule == null) {
- return;
- }
-
- // Since we don't put a lock on the rule when it's checked out via getRule(Object),
- // there's nothing to do other than reset the rule to prepare it for reuse.
- rule.reset();
- }
-
- protected Iterator addDependentRuleToRuleList() {
- Iterator iterator = _ruleList.values().iterator();
- while(iterator.hasNext()) {
- IValidationRule rule = (IValidationRule)iterator.next();
- Object[] ids = rule.getDependsOn();
- if(ids == null) {
- continue;
- }
-
- for(int i=0; i<ids.length; i++) {
- IValidationRule dRule = (IValidationRule)_ruleList.get(ids[i]);
- if(dRule != null) {
- dRule.addDependent(rule);
- }
- }
- }
- return iterator;
- }
-
- protected void logAllDependentRules() {
- Iterator iterator;
- Logger logger = getMsgLogger();
- if (logger.isLoggingLevel(Level.FINEST)) {
- iterator = _ruleList.values().iterator();
- Iterator depIterator = null;
- while(iterator.hasNext()) {
- IValidationRule rule = (IValidationRule)iterator.next();
- Set dependents = rule.getDependents();
- StringBuffer buffer = new StringBuffer();
- buffer.append("list of dependents for rule:"); //$NON-NLS-1$
- buffer.append(rule.getClass().getName());
- buffer.append("\n"); //$NON-NLS-1$
- if(dependents != null) {
- depIterator = dependents.iterator();
- while(depIterator.hasNext()) {
- IValidationRule dRule = (IValidationRule)depIterator.next();
- buffer.append("\t"); //$NON-NLS-1$
- buffer.append(dRule.getClass().getName());
- buffer.append("\n"); //$NON-NLS-1$
- }
- }
- buffer.append("\n"); //$NON-NLS-1$
- logger.write(Level.FINEST, buffer.toString());
- }
- }
- }
-
- /**
- * @return
- */
- protected abstract Logger getMsgLogger();
-
- protected EJBJar getEJBJar(IEJBValidationContext vc) {
- return (EJBJar)vc.loadModel(EJBValidatorModelEnum.EJB_MODEL);
- }
-
- /**
- * This method will return the identified IValidationRule.
- * If the ruleid is not registered, or if there is a problem
- * instantiating the IValidationRule, then null will be returned.
- */
- public IValidationRule getRule(IEJBValidationContext vc, Object ruleId) {
- // To avoid loading a rule until it is needed, intialize
- // the list with a rule id as the key, and a String class name
- // as a value. When a rule is loaded, if the value is a String,
- // then the IValidationRule has not been instantiated. Create an
- // instance and store that in place of the String. If the value
- // is already an IValidationRule instance, return it.
-
- Object rule = _ruleList.get(ruleId);
- if(rule == null) {
- // No such ruleId registered.
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINE)) {
- logger.write(Level.FINE, "Cannot load rule from ruleId: " + ruleId); //$NON-NLS-1$
- }
- return null;
- }
-
- return (IValidationRule)rule;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AbstractEJBValidator.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AbstractEJBValidator.java
deleted file mode 100644
index 3b6f105ad..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/AbstractEJBValidator.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Nov 24, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.jst.j2ee.model.internal.validation;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-import java.util.logging.Level;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-/**
- * @author vijayb
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public abstract class AbstractEJBValidator extends J2EEValidator {
- protected Map _validated = null;
- /**
- *
- */
- public AbstractEJBValidator() {
- super();
- _validated = new HashMap();
- }
-
- protected void logMissingRule(IEJBValidationContext vc, Object ruleId) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, ruleId + " = null"); //$NON-NLS-1$
- }
- addInternalErrorMessage(vc);
- }
- protected void addInternalErrorMessage(IEJBValidationContext vc) {
- addInternalErrorMessage(vc, null);
- }
-
- protected void addInternalErrorMessage(IEJBValidationContext vc, Throwable exc) {
- IMessage mssg = vc.getMessage();
- mssg.setId(internalErrorMessage());
- vc.addMessage(mssg);
- if(exc != null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, exc);
- }
- }
- }
-
- protected Map removeOldMessages(IEJBValidationContext vc,Map targets) throws ValidationException {
- if(vc.getURIs() == null) {
- // Full validation
- vc.removeAllMessages(); // Remove messages from the EJBJar.
- vc.loadModel(removeOldMessagesString(), new Object[]{vc.getReporter(), null}); // Remove messages from any EJB client JAR files or Java Utility JAR files.
- return null;
- }
- preRemoveOldMessages(vc,targets); // Get the list of targets to be validated, and remove messages from all of them.
-
- // Remove the messages from all of the changed files and their dependents.
- vc.loadModel(removeOldMessagesString(), new Object[]{vc.getReporter(), targets});
- return targets;
- }
- /**
- * @param vc
- * @param delta
- * @param targets
- */
- protected void preRemoveOldMessages(IEJBValidationContext vc,Map targets) throws ValidationException {
- //Default
- }
- /**
- * @return
- */
- protected String removeOldMessagesString() {
- return null;
- }
- /**
- * @return
- */
- private String internalErrorMessage() {
- return null;
- }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.validation.internal.core.core.IValidator#validate(org.eclipse.wst.validation.internal.core.core.IHelper,
- * org.eclipse.wst.validation.internal.core.core.IReporter,
- * org.eclipse.wst.validation.internal.core.core.IFileDelta[])
- */
- public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
- //Default
- super.validate(helper, reporter);
- }
-
- public void run(IValidationRule rule, Object targetParent, Object target) throws ValidationException {
- if(isValidated(rule.getId(), targetParent, target)) {
- // Whether or not this is a full or incremental run, don't revalidate this target
- // if it has already been validated. (e.g. if a class is used by more than one bean,
- // and say one bean is stateless and one is stateful, and everything else about the
- // beans are identical, don't validate that class again.)
- return;
- }
-
- try {
- rule.preValidate(getValidationContext(), targetParent, target);
- rule.validate(getValidationContext(), targetParent, target);
- rule.postValidate(getValidationContext(), targetParent, target);
- }
- catch(ValidationCancelledException exc) {
- // Clean up the messages which are on the task list? Or is it nicer to leave them behind?
- }
- catch(ValidationException e) {
- throw e;
- }
- catch(Throwable exc) {
- addInternalErrorMessage(getValidationContext(), exc);
- }
- finally {
- setValidated(rule.getId(), targetParent, target);
- releaseRules(rule);
- }
- }
-
- /**
- * @param rule
- */
- protected abstract void releaseRules(IValidationRule rule);
-
- private IEJBValidationContext _vc = null;
-
- protected IEJBValidationContext getValidationContext() {
- return _vc;
- }
- protected void setValidationContext(IEJBValidationContext vc) {
- _vc = vc;
- }
-
- /**
- * This class is public only for the EJBHelper.
- */
- public class TargetObject {
- private Object _parent = null;
- private Object _target = null;
-
- public TargetObject() {
- //Default
- }
-
- public Object getTargetParent() {
- return _parent;
- }
-
- public Object getTarget() {
- return _target;
- }
-
- public void setTargetParent(Object tp) {
- _parent = tp;
- }
-
- public void setTarget(Object t) {
- _target = t;
- }
-
- public int hashCode() {
- int parent = (getTargetParent() == null) ? 0 : getTargetParent().hashCode();
- int target = (getTarget() == null) ? 0 : getTarget().hashCode();
- return parent + target;
- }
-
- public boolean equals(Object o) {
- if(o == null) {
- return false;
- }
-
- if(this == o) {
- return true;
- }
-
- if(!(o instanceof TargetObject)) {
- return false;
- }
-
- Object thisParent = this.getTargetParent();
- Object oParent = ((TargetObject)o).getTargetParent();
- Object thisTarget = this.getTarget();
- Object oTarget = ((TargetObject)o).getTarget();
-
- if((thisParent == null) && (oParent == null)) {
- // check target
- }
- else if((thisParent != null) && (oParent != null)) {
- if(thisParent.equals(oParent)) {
- // check target
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
-
- if((thisTarget == null) && (oTarget == null)) {
- return true;
- }
- else if((thisTarget != null) && (oTarget != null)) {
- return (thisTarget.equals(oTarget));
- }
- else {
- return false;
- }
- }
- }
-
-
- public void setValidated(Object key, Object targetParent, Object target) {
- Set done = null;
- if(_validated.containsKey(key)) {
- done = (Set)_validated.get(key);
- }
- else {
- done = new HashSet();
- }
-
- done.add(getTargetObjectPool().getTargetObject(targetParent, target));
- _validated.put(key, done);
- }
-
-
- protected class TargetObjectPool {
- private int _growSize = 0;
- private Vector _pool = null;
-
- public TargetObjectPool(int initialSize) {
- _growSize = initialSize;
- _pool = new Vector(initialSize, _growSize);
- grow();
- }
-
- private void grow() {
- for(int i=0; i<_growSize; i++) {
- _pool.add(new TargetObject());
- }
- }
-
- public TargetObject getTargetObject(Object targetParent, Object target) {
- if(_pool.size() <= 0) {
- grow();
- }
- TargetObject obj = (TargetObject)_pool.remove(0);
- obj.setTargetParent(targetParent);
- obj.setTarget(target);
- return obj;
- }
-
- public void release(TargetObject obj) {
- obj.setTargetParent(null);
- obj.setTarget(null);
- _pool.add(obj);
- }
- }
-
- protected abstract TargetObjectPool getTargetObjectPool();
-
- public boolean isValidated(Object key, Object targetParent, Object target) {
- if(!_validated.containsKey(key)) {
- return false;
- }
-
-
- Set done = (Set)_validated.get(key);
- TargetObject temp = getTargetObjectPool().getTargetObject(targetParent, target);
- try {
- if(done.contains(temp)) {
- return true;
- }
-
- return false;
- }
- finally {
- getTargetObjectPool().release(temp);
- }
- }
- public void cleanup(IReporter reporter) {
- Iterator iterator = _validated.keySet().iterator();
- while(iterator.hasNext()) {
- Set done = (Set)_validated.get(iterator.next());
- Iterator toIterator = done.iterator();
- while(toIterator.hasNext()) {
- TargetObject to = (TargetObject)toIterator.next();
- getTargetObjectPool().release(to);
- }
- done.clear();
- }
- _validated.clear();
- setValidationContext(null);
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ApplicationClientMessageConstants.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ApplicationClientMessageConstants.java
deleted file mode 100644
index 7e73b75a0..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ApplicationClientMessageConstants.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-
-
-
-/**
- * Insert the type's description here.
- * Creation date: (4/9/2001 11:49:47 AM)
- * @author: Administrator
- */
-public interface ApplicationClientMessageConstants extends org.eclipse.jst.j2ee.model.internal.validation.J2EEMessageConstants {
- public static final String APPCLIENT_MODEL_NAME = "APPLICATIONCLIENT_VALIDATION"; //$NON-NLS-1$
- public static final String INVALID_DD = "INVALID_DD"; //$NON-NLS-1$
- public static final String ERROR_EJB_REFS = "ERROR_EJB_REFS"; //$NON-NLS-1$
- public static final String APPLICATIONCLIENT_VALIDATOR_ID = "APPLICATIONCLIENT_VALIDATOR"; //$NON-NLS-1$
- public static final String ERROR_APPCLIENT_INVALID_APPCLIENT_FILE = "ERROR_APPLICATIONCLIENT_INVALID_APPCLIENT_FILE"; //$NON-NLS-1$
- public static final String MESSAGE_APPCLIENT_MISSING_URI = "MESSAGE_APPCLIENT_MISSING_URI"; //$NON-NLS-1$
- public static final String ERROR_APPCLIENT_VALIDATION_FAILED = "ERROR_APPCLIENT_VALIDATION_FAILED"; //$NON-NLS-1$
- public static final String APPCLIENT_DD_PARSE_LINECOL = "APPCLIENT_DD_PARSE_LINECOL"; //$NON-NLS-1$
- public static final String APPCLIENT_DD_PARSE_LINE = "APPCLIENT_DD_PARSE_LINE"; //$NON-NLS-1$
- public static final String APPCLIENT_DD_CANNOT_OPEN_DD = "APPCLIENT_DD_CANNOT_OPEN_DD"; //$NON-NLS-1$
- public static final String APPCLIENT_DD_PARSE_NOINFO = "APPCLIENT_DD_PARSE_NOINFO"; //$NON-NLS-1$
- public static final String APPCLIENT_DUP_RES_ENV_REF_ERROR_ = "APPCLIENT_DUP_RES_ENV_REF_ERROR_"; //$NON-NLS-1$
- public static final String APPCLIENT_DUP_EJB_REF_ERROR_ = "APPCLIENT_DUP_EJB_REF_ERROR_"; //$NON-NLS-1$
- public static final String APPCLIENT_MAIN_CLASS_ERROR_ = "APPCLIENT_MAIN_CLASS_ERROR_"; //$NON-NLS-1$
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ApplicationClientValidator.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ApplicationClientValidator.java
deleted file mode 100644
index d6a4f44e9..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ApplicationClientValidator.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.jst.j2ee.client.ApplicationClient;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ApplicationClientFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ValidateXmlCommand;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-
-
-
-/**
- * Validates the applicatin-client.xml
- */
-public class ApplicationClientValidator extends J2EEValidator implements ApplicationClientMessageConstants {
- protected ApplicationClientFile appClientFile;
- protected ApplicationClient appClientDD;
-
- /**
- * ApplicationClientValidator constructor comment.
- */
- public ApplicationClientValidator() {
- super();
- }// ApplicationClientValidator
-
- /**
- * <p>Answer the id of the resource bundle which is
- * used by the receiver.</p>
- */
- public String getBaseName() {
- return APLICATIONCLIENT_CATEGORY;
- }// getBaseName
-
- /**
- * XML Validator now handles validation of Deployment Descriptor
- *
- * @throws ValidationException
- */
- public void validate() throws ValidationException {
- validateMainClassInManifest();
- }// validate
-
- protected void validateMainClassInManifest() {
-
- if (appClientFile != null && appClientFile.getManifest() != null) {
- String mainClass = appClientFile.getManifest().getMainClass();
- if (mainClass == null || mainClass.length() == 0) {
- Object target = getManifestTarget();
- addError(getBaseName(), APPCLIENT_MAIN_CLASS_ERROR_, new String[0], target);
- }
- }
- }
-
- protected Object getManifestTarget() {
- return null;
- }
- /**
- * Does the validation.
- *
- * @throws ValidationException
- */
- public void validate(IValidationContext inHelper, IReporter inReporter)
- throws ValidationException {
-
- validateInJob(inHelper, inReporter);
- }// validate
- /**
- * Creates the validate xml command.
- *
- * @return Command
- */
- public Command createValidateXMLCommand() {
- Command cmd = new ValidateXmlCommand(appClientFile);
- return cmd;
- }// createValidateXMLCommand
-
- /**
- * Gets the appClientFile.
- *
- * @return ApplicationClientFile
- */
- public ApplicationClientFile getAppClientFile() {
- return appClientFile;
- }// getAppClientFile
-
- /**
- * Sets the appClientFile.
- *
- * @param ApplicatonClientFile appClientFile - The appClientFile to set
- */
- public void setAppClientFile(ApplicationClientFile appClientFile) {
- this.appClientFile = appClientFile;
- }// setAppClientFile
-
- /**
- * Gets the appClientDD.
- *
- * @return ApplicationClient
- */
- public ApplicationClient getAppClientDD() {
- return appClientDD;
- }// getAppClientDD
-
- /**
- * Sets the appClientDD.
- *
- * @param ApplicationClient appClientDD - The appClientDD to set
- */
- public void setAppClientDD(ApplicationClient appClientDD) {
- this.appClientDD = appClientDD;
- }// setAppClientDD
-
- public ISchedulingRule getSchedulingRule(IValidationContext helper) {
- return null;
- }
-
- public IStatus validateInJob(IValidationContext inHelper, IReporter inReporter)
- throws ValidationException {
-
- try {
- super.validateInJob(inHelper, inReporter);
- _reporter.removeAllMessages(this, null);
-
- setAppClientFile( (ApplicationClientFile) inHelper.loadModel(APPCLIENT_MODEL_NAME) );
- if ( appClientFile != null ) {
- setAppClientDD( appClientFile.getDeploymentDescriptor() );
- validate();
- } else {
- IMessage errorMsg = new Message(getBaseName(), IMessage.HIGH_SEVERITY, ERROR_APPCLIENT_INVALID_APPCLIENT_FILE);
- throw new ValidationException(errorMsg);
- }// if
- } catch (ValidationException ex) {
- throw ex;
- } catch (Exception e) {
- IMessage errorMsg = new Message(getBaseName(), IMessage.HIGH_SEVERITY, ERROR_APPCLIENT_VALIDATION_FAILED);
- throw new ValidationException(errorMsg, e);
- }// try
- return status;
- }
-}// ApplicationClientValidator
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPBeanClassVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPBeanClassVRule.java
deleted file mode 100644
index 58607c92d..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPBeanClassVRule.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class BMPBeanClassVRule extends AEntityBeanClassVRule implements IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_BMP_BEANCLASS;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_BMP_HOME, IValidationRuleList.EJB20_BMP_LOCALHOME, IValidationRuleList.EJB20_BMP_REMOTE, IValidationRuleList.EJB20_BMP_LOCAL, IValidationRuleList.EJB20_BMP_KEYCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".bb"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_ENTITYBEAN};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = new long[]{LOCAL_COMPONENT_INTERFACE, REMOTE_COMPONENT_INTERFACE};
-
- private final boolean SHOULD_BE_ABSTRACT = false;
- private final boolean SHOULD_BE_FINAL = false;
- private final boolean SHOULD_BE_PUBLIC = true;
- private final boolean SHOULD_VALIDATE_TRANSIENT_FIELD = false;
-
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{CONSTRUCTOR_NOPARM, EJBFINDBYPRIMARYKEY, SETENTITYCONTEXT, UNSETENTITYCONTEXT_NOPARM, EJBACTIVATE_NOPARM, EJBPASSIVATE_NOPARM, EJBREMOVE_NOPARM, EJBLOAD_NOPARM, EJBSTORE_NOPARM};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{FINALIZE_NOPARM};
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, CONSTRUCTOR_NOPARM, CONSTRUCTOR, EJBCREATE, EJBPOSTCREATE, EJBHOME, FINALIZE_NOPARM, EJBFINDBYPRIMARYKEY, EJBFIND, SETENTITYCONTEXT, UNSETENTITYCONTEXT_NOPARM, EJBACTIVATE_NOPARM, EJBPASSIVATE_NOPARM, EJBREMOVE_NOPARM, EJBLOAD_NOPARM, EJBSTORE_NOPARM, FINALIZE_NOPARM, BUSINESS};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2014, new String[]{CHKJ2014+EXT});
- MESSAGE_IDS.put(CHKJ2015, new String[]{CHKJ2015+EXT});
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2022, new String[]{CHKJ2022+EXT});
-
- MESSAGE_IDS.put(CHKJ2040, new String[]{CHKJ2040+EXT});
-
- MESSAGE_IDS.put(CHKJ2050_constr, new String[]{CHKJ2050_constr+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbCreate, new String[]{CHKJ2050_ejbCreate+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbFindByPrimaryKey, new String[]{CHKJ2050_ejbFindByPrimaryKey+EXT});
- MESSAGE_IDS.put(CHKJ2050_setEntityContext, new String[]{CHKJ2050_setEntityContext+EXT});
- MESSAGE_IDS.put(CHKJ2050_unsetEntityContext, new String[]{CHKJ2050_unsetEntityContext+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbActivate, new String[]{CHKJ2050_ejbActivate+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbPassivate, new String[]{CHKJ2050_ejbPassivate+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbRemove, new String[]{CHKJ2050_ejbRemove+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbLoad, new String[]{CHKJ2050_ejbLoad+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbStore, new String[]{CHKJ2050_ejbStore+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbSelect, new String[]{CHKJ2050_ejbSelect+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbFind, new String[]{CHKJ2050_ejbFind+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbPostCreate, new String[]{CHKJ2050_ejbPostCreate+EXT});
-
- MESSAGE_IDS.put(CHKJ2103, new String[]{CHKJ2103+SPEC});
-
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
- MESSAGE_IDS.put(CHKJ2407, new String[]{CHKJ2407+BEXT, CHKJ2407+MEXT});
-
- MESSAGE_IDS.put(CHKJ2411, new String[]{CHKJ2411+BEXT, CHKJ2411+MEXT});
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2421, new String[]{CHKJ2421+BEXT, CHKJ2421+MEXT});
- MESSAGE_IDS.put(CHKJ2422, new String[]{CHKJ2422+BEXT, CHKJ2422+MEXT});
- MESSAGE_IDS.put(CHKJ2423, new String[]{CHKJ2423+BEXT, CHKJ2423+MEXT});
- MESSAGE_IDS.put(CHKJ2424, new String[]{CHKJ2424+BEXT, CHKJ2424+MEXT});
- MESSAGE_IDS.put(CHKJ2426, new String[]{CHKJ2426+BEXT, CHKJ2426+MEXT});
- MESSAGE_IDS.put(CHKJ2427, new String[]{CHKJ2427+BEXT, CHKJ2427+MEXT});
- MESSAGE_IDS.put(CHKJ2428, new String[]{CHKJ2428+BEXT, CHKJ2428+MEXT});
-
- MESSAGE_IDS.put(CHKJ2430, new String[]{CHKJ2430+BEXT, CHKJ2430+MEXT});
- MESSAGE_IDS.put(CHKJ2431, new String[]{CHKJ2431+BEXT, CHKJ2431+MEXT});
- MESSAGE_IDS.put(CHKJ2439, new String[]{CHKJ2439+BEXT, CHKJ2439+MEXT});
-
- MESSAGE_IDS.put(CHKJ2441, new String[]{CHKJ2441+BEXT, CHKJ2441+MEXT});
- MESSAGE_IDS.put(CHKJ2442, new String[]{CHKJ2442+BEXT, CHKJ2442+MEXT});
- MESSAGE_IDS.put(CHKJ2443, new String[]{CHKJ2443+BEXT, CHKJ2443+MEXT});
-
- MESSAGE_IDS.put(CHKJ2456, new String[]{CHKJ2456+ON_BASE, CHKJ2456+ON_THIS}); // special case (shared by all types)
- MESSAGE_IDS.put(CHKJ2457, new String[]{CHKJ2457+BEXT, CHKJ2457+MEXT});
- MESSAGE_IDS.put(CHKJ2458, new String[]{CHKJ2458+BEXT, CHKJ2458+MEXT});
- MESSAGE_IDS.put(CHKJ2459, new String[]{CHKJ2459+BEXT, CHKJ2459+MEXT});
-
- MESSAGE_IDS.put(CHKJ2478, new String[]{CHKJ2478+BEXT, CHKJ2478+MEXT});
-
- MESSAGE_IDS.put(CHKJ2492, new String[]{CHKJ2492+BEXT, CHKJ2492+MEXT});
- MESSAGE_IDS.put(CHKJ2493, new String[]{CHKJ2493+BEXT, CHKJ2493+MEXT});
- MESSAGE_IDS.put(CHKJ2494, new String[]{CHKJ2494+BEXT, CHKJ2494+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_ejbCreate, new String[]{CHKJ2500_ejbCreate+BEXT, CHKJ2500_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2500_ejbFind, new String[]{CHKJ2500_ejbCreate+BEXT, CHKJ2500_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2500_business, new String[]{CHKJ2500_ejbCreate+BEXT, CHKJ2500_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2502_finalize, new String[]{CHKJ2502_finalize+BEXT, CHKJ2502_finalize+MEXT});
-
- MESSAGE_IDS.put(CHKJ2503_bus, new String[]{CHKJ2503_bus+BEXT, CHKJ2503_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2503_ejbCreate, new String[]{CHKJ2503_ejbCreate+BEXT, CHKJ2503_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2503_ejbPostCreate, new String[]{CHKJ2503_ejbPostCreate+BEXT, CHKJ2503_ejbPostCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2503_ejbHome, new String[]{CHKJ2503_ejbHome+BEXT, CHKJ2503_ejbHome+MEXT});
- MESSAGE_IDS.put(CHKJ2503_ejbFind, new String[]{CHKJ2503_ejbFind+BEXT, CHKJ2503_ejbFind+MEXT});
-
- MESSAGE_IDS.put(CHKJ2505_ejbRemove, new String[]{CHKJ2505_ejbRemove+BEXT, CHKJ2505_ejbRemove+MEXT});
- MESSAGE_IDS.put(CHKJ2505_ejbPostCreate, new String[]{CHKJ2505_ejbPostCreate+BEXT, CHKJ2505_ejbPostCreate+MEXT});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
- public final boolean shouldValidateTransientField() {
- return SHOULD_VALIDATE_TRANSIENT_FIELD;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
- public final boolean shouldBeAbstract(JavaClass clazz) {
- return SHOULD_BE_ABSTRACT;
- }
-
- public final boolean shouldBeFinal(JavaClass clazz) {
- return SHOULD_BE_FINAL;
- }
-
- public final boolean shouldBePublic(JavaClass clazz) {
- return SHOULD_BE_PUBLIC;
- }
- public final int isRemote() {
- return NEITHER;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-
- /*
- * @see ABeanClassVRule#followEjbCreateReturnTypeRules(Method)
- */
- public final JavaHelpers getEjbCreateReturnType(EnterpriseBean bean, Method method) {
- return ((Entity)bean).getPrimaryKey();
- }
-
- public final String getEjbCreateReturnTypeName(EnterpriseBean bean, Method method) {
- JavaHelpers retType = getEjbCreateReturnType(bean, method);
- if(retType == null) {
- return IEJBValidatorConstants.NULL_PRIMARY_KEY;
- }
- return retType.getJavaName();
- }
-
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- long methodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedLists, this);
-
- if((methodType & EJBCREATE) == EJBCREATE) {
- validateEjbCreateMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
- else if((methodType & EJBPOSTCREATE) == EJBPOSTCREATE) {
- validateEjbPostCreateMethod(vc, bean, clazz, method);
- }
- else if((methodType & EJBFIND) == EJBFIND) {
- validateEjbFindMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
- else if((methodType & EJBHOME) == EJBHOME) {
- validateEjbHomeMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
- else if((methodType & EJBREMOVE_NOPARM) == EJBREMOVE_NOPARM) {
- validateEjbRemoveMethod(vc, bean, clazz, method);
- }
- else if((methodType & BUSINESS) == BUSINESS) {
- validateBusinessMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
- else {
- // Method isn't supposed to be here. Let the validateMethodsWhichMustNotExist
- // take care of it.
- }
- }
-
- public final String getMatchingHomeMethodName(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- long methodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedLists, this);
-
- if((methodType & EJBCREATE) == EJBCREATE) {
- return getMatchingEjbCreateMethodName(vc, method);
- }
- else if((methodType & EJBPOSTCREATE) == EJBPOSTCREATE) {
- return getMatchingEjbPostCreateMethodName(vc, method);
- }
- else if((methodType & EJBFIND) == EJBFIND) {
- return getMatchingEjbFindMethodName(vc, method);
- }
- else if((methodType & EJBHOME) == EJBHOME) {
- return getMatchingEjbHomeMethodName(vc, method);
- }
- else if((methodType & EJBREMOVE_NOPARM) == EJBREMOVE_NOPARM) {
- return getNoMatchingMethodName(vc, method);
- }
- else if((methodType & BUSINESS) == BUSINESS) {
- return getMatchingBusinessMethodName(vc, method);
- }
- else {
- // Method isn't supposed to be here.
- return getNoMatchingMethodName(vc, method);
- }
- }
-
- public final void validateEjbFindMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // # ejbFind methods
- // IWAD4502 = This method must not exist on this class. Read section 10.5.5 of the EJB 2.0 specification.
- // IWAD4507 = The container provides the ejbFind method implementation. Read section 10.6.2 of the EJB 2.0 specification.
- // covered by the "must not exist" code?
-
- // IWAD4305 = This method must be public. Read section 12.2.5 of the EJB 2.0 specification.
- if(!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2457, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
-
- // IWAD4306 = This method must not be final. Read section 12.2.5 of the EJB 2.0 specification.
- if(method.isFinal()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2458, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4307 = This method must not be static. Read section 12.2.5 of the EJB 2.0 specification.
- if(method.isStatic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2459, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4308 = {0} must be a legal type for RMI-IIOP. Read section 12.2.5 of the EJB 2.0 specification.
- validateRMI_IIOPTypeRules(vc, bean, clazz, method, methodsExtendedLists, false); // do not check if the return type is serializable
-
- // IWAD4309 = This method must return {0} or a collection thereof. Read section 12.2.5 of the EJB 2.0 specification.
- // IWAD4312 = This method must return {0}. Read section 12.2.5 of the EJB 2.0 specification.
- JavaHelpers retType = ValidationRuleUtility.getType(method.getReturnType());
- JavaHelpers key = ((Entity)bean).getPrimaryKey();
- if(!(ValidationRuleUtility.isAssignableFromEnumeration(retType, bean) ||
- ValidationRuleUtility.isAssignableFromCollection(retType, bean) ||
- ValidationRuleUtility.isAssignableFrom(retType, key)
- )) {
- String keyName = (key == null) ? IEJBValidatorConstants.NULL_PRIMARY_KEY : key.getJavaName();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2407, IEJBValidationContext.WARNING, bean, clazz, method, new String[]{keyName}, this);
- vc.addMessage(message);
- }
-
- if(!ValidationRuleUtility.followsObjectNotFoundExceptionRules(bean, method)) {
- // IWAD4285 = This method must not throw javax.ejb.ObjectNotFoundException. Read section 12.1.8.4 of the EJB 2.0 specification.
- // IWAD4168 = This method must not throw ObjectNotFoundException. Read section 10.5.8.4 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2478, IEJBValidationContext.INFO, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4310 = This method must not throw java.rmi.RemoteException. Read section 12.2.5, 18.3.8, 18.6 of the EJB 2.0 specification.
- if(!followRemoteExceptionRules(bean, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2503_ejbFind, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPKeyClassVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPKeyClassVRule.java
deleted file mode 100644
index b091a8f04..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPKeyClassVRule.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class BMPKeyClassVRule extends AKeyClassVRule implements IEJBType, IRemoteType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_BMP_KEYCLASS;
- private static final Object[] DEPENDS_ON = null;
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".kb"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
-
- private final long[] SUPERTYPES = null;
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{HASHCODE_NOPARM, EQUALS};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = null;
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, HASHCODE_NOPARM, EQUALS, CONSTRUCTOR, CONSTRUCTOR_NOPARM};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2050_constr, new String[]{CHKJ2050_constr+EXT});
- MESSAGE_IDS.put(CHKJ2050_hashCode, new String[]{CHKJ2050_hashCode+EXT});
- MESSAGE_IDS.put(CHKJ2050_equals, new String[]{CHKJ2050_equals+EXT});
-
- MESSAGE_IDS.put(CHKJ2019, new String[]{CHKJ2019+EXT});
-
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- // Key methods are not checked for RemoteException, but to be consistent with the other VRules...
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-
- public Object getTarget(Object parent, Object clazz) {
- if(parent == null) {
- return null;
- }
-
- return ((Entity)parent).getPrimaryKey();
- }
-
- /*
- * @see IClassVRule#validate(IEJBValidationContext, EnterpriseBean, JavaClass, Method)
- */
- public final void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass parent, Method method, List[] methodExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // Do not perform any validation on the methods of this class (other than the
- // validation performed in AKeyClassVRule's check for the existence of hashCode()
- // and equals(Object)
- }
-
- /*
- * @see IClassVRule#validate(IEJBValidationContext, EnterpriseBean, JavaClass, Field)
- */
- public final void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field, List[] fieldExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // Do not perform any validation on the fields of the BMP key class
- long fieldType = MethodUtility.getUtility().getFieldTypeId(bean, clazz, field, this);
- if((fieldType & IMethodAndFieldConstants.SERIALVERSIONUID) == IMethodAndFieldConstants.SERIALVERSIONUID) {
- validateSerialVersionUID(vc, bean, clazz, field);
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPLocalComponentVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPLocalComponentVRule.java
deleted file mode 100644
index 65af05ef2..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPLocalComponentVRule.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class BMPLocalComponentVRule extends AComponentVRule implements IEJBType, ILocalType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_BMP_LOCAL;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_BMP_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".blc"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private static final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBLOCALOBJECT};
- private static final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private static final long[] METHODS_WHICH_MUST_EXIST = null;
- private static final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2023, new String[]{CHKJ2023+BEXT, CHKJ2023+MEXT});
-
- MESSAGE_IDS.put(CHKJ2105, new String[]{CHKJ2105+SPEC});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2468, new String[]{CHKJ2468+BEXT, CHKJ2468+MEXT});
- MESSAGE_IDS.put(CHKJ2469, new String[]{CHKJ2469+BEXT, CHKJ2469+MEXT});
-
- MESSAGE_IDS.put(CHKJ2470, new String[]{CHKJ2470+BEXT, CHKJ2470+MEXT});
- MESSAGE_IDS.put(CHKJ2471, new String[]{CHKJ2471+BEXT, CHKJ2471+MEXT});
- MESSAGE_IDS.put(CHKJ2472, new String[]{CHKJ2472+BEXT, CHKJ2472+MEXT});
-
- MESSAGE_IDS.put(CHKJ2503_bus, new String[]{CHKJ2503_bus+BEXT, CHKJ2503_bus+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
- /*
- * @see IValidationRule#getDependsOn()
- */
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- /*
- * @see IValidationRule#getId()
- */
- public final Object getId() {
- return ID;
- }
-
- /*
- * @see IValidationRule#getMessageIds()
- */
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPLocalHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPLocalHomeVRule.java
deleted file mode 100644
index c524194b9..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPLocalHomeVRule.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class BMPLocalHomeVRule extends ABMPHomeVRule implements ILocalType, IEJBType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_BMP_LOCALHOME;
- private static final Object[] DEPENDS_ON = new Object[] { IValidationRuleList.EJB20_BMP_BEANCLASS, IValidationRuleList.EJB20_BMP_KEYCLASS };
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".blh"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[] { JAVAX_EJB_EJBLOCALHOME };
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = new long[] { FINDBYPRIMARYKEY, FIND };
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = null;
-
- private final long[] KNOWN_METHOD_TYPES = new long[] {CLINIT, CREATE, FINDBYPRIMARYKEY, FIND, HOME };
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[] {CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2040, new String[]{CHKJ2040+EXT});
-
- MESSAGE_IDS.put(CHKJ2050_findByPrimaryKey, new String[] {CHKJ2050_findByPrimaryKey+EXT});
- MESSAGE_IDS.put(CHKJ2050_find, new String[]{CHKJ2050_find+EXT});
-
- MESSAGE_IDS.put(CHKJ2104, new String[]{CHKJ2104+SPEC});
- MESSAGE_IDS.put(CHKJ2402, new String[] { CHKJ2402+BEXT, CHKJ2402+MEXT });
- MESSAGE_IDS.put(CHKJ2403, new String[] { CHKJ2403+BEXT, CHKJ2403+MEXT });
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2461, new String[]{CHKJ2461+BEXT, CHKJ2461+MEXT});
- MESSAGE_IDS.put(CHKJ2462, new String[] { CHKJ2462+BEXT, CHKJ2462+MEXT });
- MESSAGE_IDS.put(CHKJ2463, new String[] { CHKJ2463+BEXT, CHKJ2463+MEXT });
- MESSAGE_IDS.put(CHKJ2464, new String[] { CHKJ2464+BEXT, CHKJ2464+MEXT });
- MESSAGE_IDS.put(CHKJ2465, new String[] { CHKJ2465+BEXT, CHKJ2465+MEXT });
- MESSAGE_IDS.put(CHKJ2466, new String[]{CHKJ2466+BEXT, CHKJ2466+MEXT});
- MESSAGE_IDS.put(CHKJ2467, new String[] { CHKJ2467+BEXT, CHKJ2467+MEXT });
-
- MESSAGE_IDS.put(CHKJ2475, new String[]{CHKJ2475+BEXT, CHKJ2475+MEXT});
- MESSAGE_IDS.put(CHKJ2477, new String[] { CHKJ2477+BEXT, CHKJ2477+MEXT });
- MESSAGE_IDS.put(CHKJ2478, new String[]{CHKJ2478+BEXT, CHKJ2478+MEXT});
- MESSAGE_IDS.put(CHKJ2479, new String[] { CHKJ2479+BEXT, CHKJ2479+MEXT });
-
- MESSAGE_IDS.put(CHKJ2500_create, new String[]{CHKJ2500_create+BEXT, CHKJ2500_create+MEXT});
- MESSAGE_IDS.put(CHKJ2500_find, new String[]{CHKJ2500_find+BEXT, CHKJ2500_find+MEXT});
- MESSAGE_IDS.put(CHKJ2500_home, new String[]{CHKJ2500_home+BEXT, CHKJ2500_home+MEXT});
- MESSAGE_IDS.put(CHKJ2503_create, new String[] { CHKJ2503_create+BEXT, CHKJ2503_create+MEXT });
- MESSAGE_IDS.put(CHKJ2503_find, new String[] { CHKJ2503_find+BEXT, CHKJ2503_find+MEXT });
- MESSAGE_IDS.put(CHKJ2503_home, new String[] { CHKJ2503_home+BEXT, CHKJ2503_home+MEXT });
- MESSAGE_IDS.put(CHKJ2504_create, new String[] { CHKJ2504_create+BEXT, CHKJ2504_create+MEXT });
- MESSAGE_IDS.put(CHKJ2504_find, new String[] { CHKJ2504_find+BEXT, CHKJ2504_find+MEXT });
- MESSAGE_IDS.put(CHKJ2504_home, new String[] { CHKJ2504_home+BEXT, CHKJ2504_home+MEXT });
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPRemoteComponentVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPRemoteComponentVRule.java
deleted file mode 100644
index 696716769..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPRemoteComponentVRule.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class BMPRemoteComponentVRule extends AComponentVRule implements IRemoteType, IComponentType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_BMP_REMOTE;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_BMP_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".brc"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBOBJECT};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = null;
- private static final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2023, new String[]{CHKJ2023+BEXT, CHKJ2023+MEXT});
-
- MESSAGE_IDS.put(CHKJ2105, new String[]{CHKJ2105+SPEC});
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2468, new String[]{CHKJ2468+BEXT, CHKJ2468+MEXT});
- MESSAGE_IDS.put(CHKJ2469, new String[]{CHKJ2469+BEXT, CHKJ2469+MEXT});
-
- MESSAGE_IDS.put(CHKJ2470, new String[]{CHKJ2470+BEXT, CHKJ2470+MEXT});
- MESSAGE_IDS.put(CHKJ2471, new String[]{CHKJ2471+BEXT, CHKJ2471+MEXT});
- MESSAGE_IDS.put(CHKJ2472, new String[]{CHKJ2472+BEXT, CHKJ2472+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_business, new String[]{CHKJ2500_business+BEXT, CHKJ2500_business+MEXT});
- MESSAGE_IDS.put(CHKJ2500_create, new String[]{CHKJ2500_create+BEXT, CHKJ2500_create+MEXT});
- MESSAGE_IDS.put(CHKJ2500_home, new String[]{CHKJ2500_home+BEXT, CHKJ2500_home+MEXT});
- MESSAGE_IDS.put(CHKJ2503_bus, new String[]{CHKJ2503_bus+BEXT, CHKJ2503_bus+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPRemoteHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPRemoteHomeVRule.java
deleted file mode 100644
index 1e3398752..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/BMPRemoteHomeVRule.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class BMPRemoteHomeVRule extends ABMPHomeVRule implements IRemoteType, IHomeType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_BMP_HOME;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_BMP_BEANCLASS, IValidationRuleList.EJB20_BMP_KEYCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".brh"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBHOME};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{FINDBYPRIMARYKEY, FIND};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = null;
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, CREATE, FINDBYPRIMARYKEY, FIND, HOME};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2040, new String[]{CHKJ2040+EXT});
-
- MESSAGE_IDS.put(CHKJ2050_findByPrimaryKey, new String[]{CHKJ2050_findByPrimaryKey+EXT});
- MESSAGE_IDS.put(CHKJ2050_find, new String[]{CHKJ2050_find+EXT});
-
- MESSAGE_IDS.put(CHKJ2104, new String[]{CHKJ2104+SPEC});
- MESSAGE_IDS.put(CHKJ2402, new String[]{CHKJ2402+BEXT, CHKJ2402+MEXT});
- MESSAGE_IDS.put(CHKJ2403, new String[]{CHKJ2403+BEXT, CHKJ2403+MEXT});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2461, new String[]{CHKJ2461+BEXT, CHKJ2461+MEXT});
- MESSAGE_IDS.put(CHKJ2462, new String[]{CHKJ2462+BEXT, CHKJ2462+MEXT});
- MESSAGE_IDS.put(CHKJ2463, new String[]{CHKJ2463+BEXT, CHKJ2463+MEXT});
- MESSAGE_IDS.put(CHKJ2464, new String[]{CHKJ2464+BEXT, CHKJ2464+MEXT});
- MESSAGE_IDS.put(CHKJ2465, new String[]{CHKJ2465+BEXT, CHKJ2465+MEXT});
- MESSAGE_IDS.put(CHKJ2466, new String[]{CHKJ2466+BEXT, CHKJ2466+MEXT});
- MESSAGE_IDS.put(CHKJ2467, new String[]{CHKJ2467+BEXT, CHKJ2467+MEXT});
-
- MESSAGE_IDS.put(CHKJ2475, new String[]{CHKJ2475+BEXT, CHKJ2475+MEXT});
- MESSAGE_IDS.put(CHKJ2477, new String[]{CHKJ2477+BEXT, CHKJ2477+MEXT});
- MESSAGE_IDS.put(CHKJ2478, new String[]{CHKJ2478+BEXT, CHKJ2478+MEXT});
- MESSAGE_IDS.put(CHKJ2479, new String[]{CHKJ2479+BEXT, CHKJ2479+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_create, new String[]{CHKJ2500_create+BEXT, CHKJ2500_create+MEXT});
- MESSAGE_IDS.put(CHKJ2500_find, new String[]{CHKJ2500_find+BEXT, CHKJ2500_find+MEXT});
- MESSAGE_IDS.put(CHKJ2500_home, new String[]{CHKJ2500_home+BEXT, CHKJ2500_home+MEXT});
- MESSAGE_IDS.put(CHKJ2503_create, new String[]{CHKJ2503_create+BEXT, CHKJ2503_create+MEXT});
- MESSAGE_IDS.put(CHKJ2503_find, new String[]{CHKJ2503_find+BEXT, CHKJ2503_find+MEXT});
- MESSAGE_IDS.put(CHKJ2503_home, new String[]{CHKJ2503_home+BEXT, CHKJ2503_home+MEXT});
- MESSAGE_IDS.put(CHKJ2504_create, new String[]{CHKJ2504_create+BEXT, CHKJ2504_create+MEXT});
- MESSAGE_IDS.put(CHKJ2504_find, new String[]{CHKJ2504_find+BEXT, CHKJ2504_find+MEXT});
- MESSAGE_IDS.put(CHKJ2504_home, new String[]{CHKJ2504_home+BEXT, CHKJ2504_home+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPBeanClassVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPBeanClassVRule.java
deleted file mode 100644
index 0bc8c646e..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPBeanClassVRule.java
+++ /dev/null
@@ -1,484 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.CMPAttribute;
-import org.eclipse.jst.j2ee.ejb.CMRField;
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.jst.j2ee.ejb.internal.impl.LocalModelledPersistentAttributeFilter;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class CMPBeanClassVRule extends AEntityBeanClassVRule implements IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_CMP_BEANCLASS;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_CMP_HOME, IValidationRuleList.EJB20_CMP_LOCALHOME, IValidationRuleList.EJB20_CMP_REMOTE, IValidationRuleList.EJB20_CMP_LOCAL, IValidationRuleList.EJB20_CMP_KEYCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".cb"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_ENTITYBEAN};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = new long[]{LOCAL_COMPONENT_INTERFACE, REMOTE_COMPONENT_INTERFACE};
-
- private final boolean SHOULD_BE_ABSTRACT = true;
- private final boolean SHOULD_BE_FINAL = false;
- private final boolean SHOULD_BE_PUBLIC = true;
- private final boolean SHOULD_VALIDATE_TRANSIENT_FIELD = false;
-
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{CONSTRUCTOR_NOPARM, SETENTITYCONTEXT, UNSETENTITYCONTEXT_NOPARM, EJBACTIVATE_NOPARM, EJBPASSIVATE_NOPARM, EJBREMOVE_NOPARM, EJBLOAD_NOPARM, EJBSTORE_NOPARM};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{EJBFIND, FINALIZE_NOPARM};
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, CONSTRUCTOR_NOPARM, CONSTRUCTOR, EJBCREATE, EJBPOSTCREATE, EJBHOME, FINALIZE_NOPARM, EJBFIND, ACCESSOR, EJBFINDBYPRIMARYKEY, SETENTITYCONTEXT, UNSETENTITYCONTEXT_NOPARM, EJBACTIVATE_NOPARM, EJBPASSIVATE_NOPARM, EJBREMOVE_NOPARM, EJBLOAD_NOPARM, EJBSTORE_NOPARM, EJBSELECT, FINALIZE_NOPARM, BUSINESS};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- // Add these checks in the code later
- MESSAGE_IDS.put(CHKJ2481, new String[]{CHKJ2481+BEXT, CHKJ2481+MEXT});
- MESSAGE_IDS.put(CHKJ2482, new String[]{CHKJ2482+BEXT, CHKJ2482+MEXT});
- MESSAGE_IDS.put(CHKJ2483, new String[]{CHKJ2483+BEXT, CHKJ2483+MEXT});
- MESSAGE_IDS.put(CHKJ2484, new String[]{CHKJ2484+BEXT, CHKJ2484+MEXT});
- MESSAGE_IDS.put(CHKJ2489, new String[]{CHKJ2489+BEXT, CHKJ2489+MEXT});
- MESSAGE_IDS.put(CHKJ2205, new String[]{CHKJ2205+BEXT, CHKJ2205+MEXT});
- MESSAGE_IDS.put(CHKJ2206, new String[]{CHKJ2206+BEXT, CHKJ2206+MEXT});
- // end add later
-
- MESSAGE_IDS.put(CHKJ2014, new String[]{CHKJ2014+EXT});
- MESSAGE_IDS.put(CHKJ2015, new String[]{CHKJ2015+EXT});
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2022, new String[]{CHKJ2022+EXT});
-
- MESSAGE_IDS.put(CHKJ2040, new String[]{CHKJ2040+EXT});
-
- MESSAGE_IDS.put(CHKJ2050_acc, new String[]{CHKJ2050_acc+EXT});
- MESSAGE_IDS.put(CHKJ2050_constr, new String[]{CHKJ2050_constr+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbCreate, new String[]{CHKJ2050_ejbCreate+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbFindByPrimaryKey, new String[]{CHKJ2050_ejbFindByPrimaryKey+EXT});
- MESSAGE_IDS.put(CHKJ2050_setEntityContext, new String[]{CHKJ2050_setEntityContext+EXT});
- MESSAGE_IDS.put(CHKJ2050_unsetEntityContext, new String[]{CHKJ2050_unsetEntityContext+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbActivate, new String[]{CHKJ2050_ejbActivate+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbPassivate, new String[]{CHKJ2050_ejbPassivate+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbRemove, new String[]{CHKJ2050_ejbRemove+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbLoad, new String[]{CHKJ2050_ejbLoad+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbStore, new String[]{CHKJ2050_ejbStore+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbSelect, new String[]{CHKJ2050_ejbSelect+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbFind, new String[]{CHKJ2050_ejbFind+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbPostCreate, new String[]{CHKJ2050_ejbPostCreate+EXT});
-
- MESSAGE_IDS.put(CHKJ2103, new String[]{CHKJ2103+SPEC});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2411, new String[]{CHKJ2411+BEXT, CHKJ2411+MEXT});
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2421, new String[]{CHKJ2421+BEXT, CHKJ2421+MEXT});
- MESSAGE_IDS.put(CHKJ2422, new String[]{CHKJ2422+BEXT, CHKJ2422+MEXT});
- MESSAGE_IDS.put(CHKJ2423, new String[]{CHKJ2423+BEXT, CHKJ2423+MEXT});
- MESSAGE_IDS.put(CHKJ2424, new String[]{CHKJ2424+BEXT, CHKJ2424+MEXT});
- MESSAGE_IDS.put(CHKJ2426, new String[]{CHKJ2426+BEXT, CHKJ2426+MEXT});
- MESSAGE_IDS.put(CHKJ2427, new String[]{CHKJ2427+BEXT, CHKJ2427+MEXT});
- MESSAGE_IDS.put(CHKJ2428, new String[]{CHKJ2428+BEXT, CHKJ2428+MEXT});
- MESSAGE_IDS.put(CHKJ2430, new String[]{CHKJ2430+BEXT, CHKJ2430+MEXT});
- MESSAGE_IDS.put(CHKJ2431, new String[]{CHKJ2431+BEXT, CHKJ2431+MEXT});
- MESSAGE_IDS.put(CHKJ2439, new String[]{CHKJ2439+BEXT, CHKJ2439+MEXT});
-
- MESSAGE_IDS.put(CHKJ2441, new String[]{CHKJ2441+BEXT, CHKJ2441+MEXT});
- MESSAGE_IDS.put(CHKJ2442, new String[]{CHKJ2442+BEXT, CHKJ2442+MEXT});
- MESSAGE_IDS.put(CHKJ2443, new String[]{CHKJ2443+BEXT, CHKJ2443+MEXT});
- MESSAGE_IDS.put(CHKJ2449, new String[]{CHKJ2449+BEXT, CHKJ2449+MEXT});
-
- MESSAGE_IDS.put(CHKJ2450, new String[]{CHKJ2450+BEXT, CHKJ2450+MEXT});
- MESSAGE_IDS.put(CHKJ2454, new String[]{CHKJ2454+BEXT, CHKJ2454+MEXT});
- MESSAGE_IDS.put(CHKJ2456, new String[]{CHKJ2456+ON_BASE, CHKJ2456+ON_THIS}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2478, new String[]{CHKJ2478+BEXT, CHKJ2478+MEXT});
-
- MESSAGE_IDS.put(CHKJ2480, new String[]{CHKJ2480+BEXT, CHKJ2480+MEXT});
- MESSAGE_IDS.put(CHKJ2485, new String[]{CHKJ2485+BEXT, CHKJ2485+MEXT});
- MESSAGE_IDS.put(CHKJ2486, new String[]{CHKJ2486+BEXT, CHKJ2486+MEXT});
- MESSAGE_IDS.put(CHKJ2487, new String[]{CHKJ2487+BEXT, CHKJ2487+MEXT});
- MESSAGE_IDS.put(CHKJ2488, new String[]{CHKJ2488+BEXT, CHKJ2488+MEXT});
-
- MESSAGE_IDS.put(CHKJ2492, new String[]{CHKJ2492+BEXT, CHKJ2492+MEXT});
- MESSAGE_IDS.put(CHKJ2493, new String[]{CHKJ2493+BEXT, CHKJ2493+MEXT});
- MESSAGE_IDS.put(CHKJ2494, new String[]{CHKJ2494+BEXT, CHKJ2494+MEXT});
- MESSAGE_IDS.put(CHKJ2496, new String[]{CHKJ2496+BEXT, CHKJ2496+MEXT});
- MESSAGE_IDS.put(CHKJ2497, new String[]{CHKJ2497+BEXT, CHKJ2497+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_ejbCreate, new String[]{CHKJ2500_ejbCreate+BEXT, CHKJ2500_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2500_ejbFind, new String[]{CHKJ2500_ejbCreate+BEXT, CHKJ2500_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2500_business, new String[]{CHKJ2500_ejbCreate+BEXT, CHKJ2500_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2500_ejbHome, new String[]{CHKJ2500_ejbHome+BEXT, CHKJ2500_ejbHome+MEXT});
- MESSAGE_IDS.put(CHKJ2502_finalize, new String[]{CHKJ2502_finalize+BEXT, CHKJ2502_finalize+MEXT});
- MESSAGE_IDS.put(CHKJ2502_ejbFind, new String[]{CHKJ2502_ejbFind+BEXT, CHKJ2502_ejbFind+MEXT});
-
- MESSAGE_IDS.put(CHKJ2503_bus, new String[]{CHKJ2503_bus+BEXT, CHKJ2503_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2503_ejbCreate, new String[]{CHKJ2503_ejbCreate+BEXT, CHKJ2503_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2503_ejbPostCreate, new String[]{CHKJ2503_ejbPostCreate+BEXT, CHKJ2503_ejbPostCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2503_ejbHome, new String[]{CHKJ2503_ejbHome+BEXT, CHKJ2503_ejbHome+MEXT});
-
- MESSAGE_IDS.put(CHKJ2505_ejbPostCreate, new String[]{CHKJ2505_ejbPostCreate+BEXT, CHKJ2505_ejbPostCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2505_ejbRemove, new String[]{CHKJ2505_ejbRemove+BEXT, CHKJ2505_ejbRemove+MEXT});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final boolean shouldValidateTransientField() {
- return SHOULD_VALIDATE_TRANSIENT_FIELD;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final boolean shouldBeAbstract(JavaClass clazz) {
- return SHOULD_BE_ABSTRACT;
- }
-
- public final boolean shouldBeFinal(JavaClass clazz) {
- return SHOULD_BE_FINAL;
- }
-
- public final boolean shouldBePublic(JavaClass clazz) {
- return SHOULD_BE_PUBLIC;
- }
-
- public final int isRemote() {
- return NEITHER;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final JavaHelpers getEjbCreateReturnType(EnterpriseBean bean, Method method) {
- ContainerManagedEntity cmp = (ContainerManagedEntity)bean;
- if(ValidationRuleUtility.usesUnknownPrimaryKey(cmp)) {
- try {
- return ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_LANG_OBJECT, cmp);
- }
- catch(InvalidInputException e) {
- // problems....
- // let this fall through to the default (getPrimaryKey())
- }
- }
- return ((Entity)bean).getPrimaryKey();
- }
-
- public final String getEjbCreateReturnTypeName(EnterpriseBean bean, Method method) {
- JavaHelpers retType = getEjbCreateReturnType(bean, method);
- if(retType == null) {
- return IEJBValidatorConstants.NULL_PRIMARY_KEY;
- }
- return retType.getJavaName();
- }
-
- public final void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException {
- super.validate(vc, bean, clazz);
-
- ContainerManagedEntity cmp = (ContainerManagedEntity)bean;
-
- // 10.3.1, container-managed persistent fields and container-managed relationship
- // fields must *not* be defined in the entity bean class.
- List cmrFields = cmp.getCMRFields();
- Iterator iterator = cmrFields.iterator();
- while(iterator.hasNext()) {
- CMRField cmrField = (CMRField)iterator.next();
- if((cmrField != null) && (!cmrField.isDerived())) {
- validateCmrField(vc, cmp, clazz, cmrField);
- }
- }
-
- List cmpFields = cmp.getFilteredFeatures(LocalModelledPersistentAttributeFilter.singleton());
- if(cmpFields != null && !cmpFields.isEmpty()) {
- iterator = cmpFields.iterator();
- while(iterator.hasNext()) {
- CMPAttribute cmpField = (CMPAttribute)iterator.next();
- if((cmpField != null) && (!cmpField.isDerived())) {
- validateCmpField(vc, cmp, clazz, cmpField);
- }
- }
- }
- }
-
- public void validateEjbCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedList) throws ValidationCancelledException, InvalidInputException, ValidationException {
- super.validateEjbCreateMethod(vc, bean, clazz, method, methodsExtendedList);
-
- if(!ValidationRuleUtility.throwsCreateException(bean, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2497, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
-
- public final void validateEjbSelectMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass parent, Method method) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // # ejbSelect<METHOD> checks
- // IWAD4154 = {0} must exist. Read section 10.5.2 of the EJB 2.0 specification.
- // IWAD4502 = This method must not exist on this class. Read section 10.5.5 of the EJB 2.0 specification.
- // IWAD4197 = An ejbSelect method must exist. Read section 10.6.7 of the EJB 2.0 specification.
-
- JavaHelpers returnType = method.getReturnType();
- JavaHelpers javaUtilCollection = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_UTIL_COLLECTION, bean);
- if(!ValidationRuleUtility.isAssignableFrom(returnType, bean.getLocalInterface()) &&
- !ValidationRuleUtility.isAssignableFrom(returnType, javaUtilCollection) ) {
- // IWAD4160 = Type {0} cannot be returned by a select method. Read section 10.5.7 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2486, IEJBValidationContext.INFO, bean, parent, method, this);
- vc.addMessage(message);
- }
-
- if(!ValidationRuleUtility.isPublic(method)) {
- // IWAD4198 = This method must be public. Read section 10.6.7 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2487, IEJBValidationContext.INFO, bean, parent, method, this);
- vc.addMessage(message);
- }
-
- if(!method.isAbstract()) {
- // IWAD4199 = This method must be abstract. Read section 10.6.7 of the EJB 2.0 specification.
- // IWAD4158 = {0} must be abstract. Read section 10.5.7 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2485, IEJBValidationContext.INFO, bean, parent, method, this);
- vc.addMessage(message);
- }
-
- if(!ValidationRuleUtility.throwsFinderException(bean, method)) {
- // IWAD4200 = This method must throw javax.ejb.FinderException. Read section 10.6.7 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2488, IEJBValidationContext.INFO, bean, parent, method, this);
- vc.addMessage(message);
- }
-
- if(!ValidationRuleUtility.followsObjectNotFoundExceptionRules(bean, method)) {
- // IWAD4285 = This method must not throw javax.ejb.ObjectNotFoundException. Read section 12.1.8.4 of the EJB 2.0 specification.
- // IWAD4168 = This method must not throw ObjectNotFoundException. Read section 10.5.8.4 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2478, IEJBValidationContext.INFO, bean, parent, method, this);
- vc.addMessage(message);
- }
-
- // Check method is associated with a query element in ejb-jar.xml.
- ContainerManagedEntity cmp = (ContainerManagedEntity)bean;
- if(!ValidationRuleUtility.isAssociatedWithQuery(cmp, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2496, IEJBValidationContext.INFO, bean, parent, method, this);
- vc.addMessage(message);
- }
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-
- public void validateCmpField(IEJBValidationContext vc, ContainerManagedEntity cmp, JavaClass clazz, CMPAttribute attrib) throws ValidationCancelledException, InvalidInputException, ValidationException {
- String fieldName = attrib.getName();
- if((fieldName == null) || (fieldName.equals(""))) { //$NON-NLS-1$
- // let the EJBJarVRule report this
- return;
- }
-
- if(!Character.isLowerCase(fieldName.charAt(0))) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2480, IEJBValidationContext.INFO, cmp, clazz, attrib.getField(), this);
- vc.addMessage(message);
- }
-
- // Section 10.8.3
- if(!ValidationRuleUtility.isUnknownPrimaryKey(attrib)) {
- JavaClass ejbClass = cmp.getEjbClass();
- Method getMethod = ValidationRuleUtility.getMethodExtended(ejbClass, attrib.getGetterName(), new JavaHelpers[0], attrib.getType());
- if(getMethod == null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2050_acc, IEJBValidationContext.ERROR, cmp, clazz, new String[]{attrib.getGetterName()}, this);
- vc.addMessage(message);
- }
- else {
- validateCMPAccessorMethod(vc, cmp, clazz, getMethod, attrib);
- }
-
- JavaHelpers[] setMethodParms = new JavaHelpers[]{attrib.getType()};
- Method setMethod = ValidationRuleUtility.getMethodExtended(ejbClass, attrib.getSetterName(), setMethodParms);
- if(setMethod == null) {
- String setterName = attrib.getSetterName() + "(" + ValidationRuleUtility.getParmsAsString(setMethodParms) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2050_acc, IEJBValidationContext.ERROR, cmp, clazz, new String[]{setterName}, this);
- vc.addMessage(message);
- }
- else {
- validateCMPAccessorMethod(vc, cmp, clazz, setMethod, attrib);
- }
- }
-
- Field field = attrib.getField();
- if ((field != null) && (clazz.getFieldExtended(attrib.getName()) != null)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2454, IEJBValidationContext.WARNING, cmp, clazz, field, new String[]{attrib.getName()}, this);
- vc.addMessage(message);
- }
-
- }
-
- public void validateCmrField(IEJBValidationContext vc, ContainerManagedEntity cmp, JavaClass clazz, CMRField cmrField) throws ValidationCancelledException, InvalidInputException, ValidationException {
- String fieldName = cmrField.getName();
- if((fieldName == null) || (fieldName.equals(""))) { //$NON-NLS-1$
- // let the EJBJarVRule report this
- return;
- }
-
- if(!Character.isLowerCase(fieldName.charAt(0))) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2480, IEJBValidationContext.INFO, cmp, clazz, cmrField.getField(), this);
- vc.addMessage(message);
- }
-
- JavaClass ejbClass = cmp.getEjbClass();
- JavaHelpers localType = ValidationRuleUtility.getCMRFieldType(vc, cmp, clazz, cmrField);
- if(localType == null) {
- // user made a mistake in ejb-jar.xml by trying to create a relation
- // to a CMP which doesn't have a local interface.
- // Don't report an error here; let the DD validation report the error.
- return;
- }
- Method getMethod = ValidationRuleUtility.getMethodExtended(ejbClass, cmrField.getGetterName(), new JavaHelpers[0], localType);
- if(getMethod == null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2050_acc, IEJBValidationContext.ERROR, cmp, clazz, new String[]{cmrField.getGetterName()}, this);
- vc.addMessage(message);
- }
- else {
- validateCMRAccessorMethod(vc, cmp, clazz, getMethod, cmrField);
- }
-
- JavaHelpers[] setMethodParms = new JavaHelpers[]{localType};
- Method setMethod = ValidationRuleUtility.getMethodExtended(ejbClass, cmrField.getSetterName(), setMethodParms);
- if(setMethod == null) {
- String setterName = cmrField.getSetterName() + "(" + ValidationRuleUtility.getParmsAsString(setMethodParms) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2050_acc, IEJBValidationContext.ERROR, cmp, clazz, new String[]{setterName}, this);
- vc.addMessage(message);
- }
- else {
- validateCMRAccessorMethod(vc, cmp, clazz, setMethod, cmrField);
- }
-
- Field field = cmrField.getField();
- if ((field != null) && (clazz.getFieldExtended(cmrField.getName()) != null)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2454, IEJBValidationContext.WARNING, cmp, clazz, field, new String[]{cmrField.getName()}, this);
- vc.addMessage(message);
- }
- }
-
- protected void validateCMRAccessorMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, CMRField field) throws ValidationCancelledException, InvalidInputException, ValidationException {
- if(!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2449, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(!method.isAbstract()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2450, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
-
- protected void validateCMPAccessorMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, CMPAttribute field) throws ValidationCancelledException, InvalidInputException, ValidationException {
- if(!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2449, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(!method.isAbstract()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2450, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
-
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- long methodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedLists, this);
-
- if((methodType & EJBCREATE) == EJBCREATE) {
- validateEjbCreateMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
- else if((methodType & EJBPOSTCREATE) == EJBPOSTCREATE) {
- validateEjbPostCreateMethod(vc, bean, clazz, method);
- }
- else if((methodType & EJBHOME) == EJBHOME) {
- validateEjbHomeMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
- else if((methodType & EJBREMOVE_NOPARM) == EJBREMOVE_NOPARM) {
- validateEjbRemoveMethod(vc, bean, clazz, method);
- }
- else if((methodType & ACCESSOR) == ACCESSOR) {
- // This has already been validated in the validate(vc, bean, clazz) method
- }
- else if((methodType & BUSINESS) == BUSINESS) {
- validateBusinessMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
- else {
- // Method isn't supposed to be here. Let the validateMethodsWhichMustNotExist
- // take care of it.
- }
- }
-
- public String getMatchingHomeMethodName(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedList) {
- long methodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedList, this);
-
- if((methodType & EJBCREATE) == EJBCREATE) {
- return getMatchingEjbCreateMethodName(vc, method);
- }
- else if((methodType & EJBPOSTCREATE) == EJBPOSTCREATE) {
- return getMatchingEjbPostCreateMethodName(vc, method);
- }
- else if((methodType & EJBHOME) == EJBHOME) {
- return getMatchingEjbHomeMethodName(vc, method);
- }
- else if((methodType & EJBREMOVE_NOPARM) == EJBREMOVE_NOPARM) {
- return getNoMatchingMethodName(vc, method);
- }
- else if((methodType & ACCESSOR) == ACCESSOR) {
- // This has already been validated in the validate(vc, bean, clazz) method
- return getNoMatchingMethodName(vc, method);
- }
- else if((methodType & BUSINESS) == BUSINESS) {
- return getMatchingBusinessMethodName(vc, method);
- }
- else {
- // Method isn't supposed to be here.
- return getNoMatchingMethodName(vc, method);
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPKeyClassVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPKeyClassVRule.java
deleted file mode 100644
index dceab8b06..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPKeyClassVRule.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.CMPAttribute;
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class CMPKeyClassVRule extends AKeyClassVRule implements IEJBType, IRemoteType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_CMP_KEYCLASS;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_CMP_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".kc"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE + SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS + SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = null;
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{HASHCODE_NOPARM, EQUALS, CONSTRUCTOR_NOPARM};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = null;
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, HASHCODE_NOPARM, EQUALS, CONSTRUCTOR_NOPARM, CONSTRUCTOR};
-
- private Set _keyFields = null;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2050_constr, new String[]{CHKJ2050_constr+EXT});
- MESSAGE_IDS.put(CHKJ2050_hashCode, new String[]{CHKJ2050_hashCode+EXT});
- MESSAGE_IDS.put(CHKJ2050_equals, new String[]{CHKJ2050_equals+EXT});
- MESSAGE_IDS.put(CHKJ2022, new String[]{CHKJ2022+EXT});
-
- MESSAGE_IDS.put(CHKJ2019, new String[]{CHKJ2019+EXT});
-
- MESSAGE_IDS.put(CHKJ2205, new String[]{CHKJ2205+BEXT, CHKJ2205+MEXT});
- MESSAGE_IDS.put(CHKJ2206, new String[]{CHKJ2206+BEXT, CHKJ2206+MEXT});
-
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2829, new String[]{CHKJ2829+SPEC});
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- // Key methods are not checked for RemoteException, but to be consistent with the other VRules...
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public Object getTarget(Object parent, Object clazz) {
- if(parent == null) {
- return null;
- }
-
- ContainerManagedEntity cmp = (ContainerManagedEntity)parent;
- if(ValidationRuleUtility.isPrimitivePrimaryKey(cmp)) {
- return null; // do not validate a primitive primary key
- }
-
- return cmp.getPrimaryKey();
- }
-
-
- /*
- * @see IClassVRule#validate(IEJBValidationContext, EnterpriseBean, JavaClass, Method)
- */
- public final void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // Nothing to do.
- }
-
- 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);
- }
- }
- }
-
- private Set getKeyFields(ContainerManagedEntity cmp) {
- if(_keyFields == null) {
- // Know that the traversal of the fields and methods is done sequentially.
- // i.e., that a class is validated according to one bean at at time.
- // Thus, we can cache the key field information to speed up subsequent calls.
- List fields = cmp.getKeyAttributes();
- Iterator iterator = fields.iterator();
- _keyFields = new HashSet();
- while(iterator.hasNext()) {
- CMPAttribute attrib = (CMPAttribute)iterator.next();
- _keyFields.add(attrib.getName());
- }
- }
- return _keyFields;
- }
-
- /*
- * @see IClassVRule#validate(IEJBValidationContext, EnterpriseBean, JavaClass, Field)
- */
- public final void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field, List[] fieldExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- long fieldType = MethodUtility.getUtility().getFieldTypeId(bean, clazz, field, this);
- if((fieldType & IMethodAndFieldConstants.SERIALVERSIONUID) == IMethodAndFieldConstants.SERIALVERSIONUID) {
- validateSerialVersionUID(vc, bean, clazz, field);
- }
- else {
- // IWAD4253 = This field must be public. Read section 10.8.1 of the EJB 2.0 specification.
- if(!ValidationRuleUtility.isPublic(field)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2205, IEJBValidationContext.WARNING, bean, clazz, field, this);
- vc.addMessage(message);
- }
-
- Set keyFields = getKeyFields((ContainerManagedEntity)bean);
- if(!keyFields.contains(field.getName())) {
- // IWAD4254 = This field is not a <cmp-field>. Read section 10.8.1 of the EJB 2.0 specification.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2206, IEJBValidationContext.WARNING, bean, clazz, field, this);
- vc.addMessage(message);
- }
- }
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-
- /*
- * @see IValidationRule#reset()
- */
- public void reset() {
- super.reset();
- if(_keyFields != null) {
- _keyFields.clear();
- _keyFields = null; // in this case, clearing the Set isn't enough.
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPLocalComponentVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPLocalComponentVRule.java
deleted file mode 100644
index 7dcace187..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPLocalComponentVRule.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class CMPLocalComponentVRule extends AComponentVRule implements IComponentType, ILocalType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_CMP_LOCAL;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_CMP_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".clc"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBLOCALOBJECT};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = null;
- private static final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{EJBSELECT};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, EJBSELECT}; // Must know EJBSELECT to check that it's not exposed on this interface
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2023, new String[]{CHKJ2023+BEXT, CHKJ2023+MEXT});
-
- MESSAGE_IDS.put(CHKJ2105, new String[]{CHKJ2105+SPEC});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2468, new String[]{CHKJ2468+BEXT, CHKJ2468+MEXT});
- MESSAGE_IDS.put(CHKJ2469, new String[]{CHKJ2469+BEXT, CHKJ2469+MEXT});
-
- MESSAGE_IDS.put(CHKJ2470, new String[]{CHKJ2470+BEXT, CHKJ2470+MEXT});
- MESSAGE_IDS.put(CHKJ2471, new String[]{CHKJ2471+BEXT, CHKJ2471+MEXT});
- MESSAGE_IDS.put(CHKJ2472, new String[]{CHKJ2472+BEXT, CHKJ2472+MEXT});
- MESSAGE_IDS.put(CHKJ2474, new String[]{CHKJ2474+BEXT, CHKJ2474+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_create, new String[]{CHKJ2500_create+BEXT, CHKJ2500_create+MEXT});
- MESSAGE_IDS.put(CHKJ2500_home, new String[]{CHKJ2500_home+BEXT, CHKJ2500_home+MEXT});
- MESSAGE_IDS.put(CHKJ2502_ejbSelect, new String[]{CHKJ2502_ejbSelect+BEXT, CHKJ2502_ejbSelect+MEXT});
- MESSAGE_IDS.put(CHKJ2503_bus, new String[]{CHKJ2503_bus+BEXT, CHKJ2503_bus+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPLocalHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPLocalHomeVRule.java
deleted file mode 100644
index 79aee23ac..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPLocalHomeVRule.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class CMPLocalHomeVRule extends ACMPHomeVRule implements ILocalType, IHomeType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_CMP_LOCALHOME;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_CMP_BEANCLASS, IValidationRuleList.EJB20_CMP_KEYCLASS, IValidationRuleList.EJB20_EJBEXT};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".clh"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBLOCALHOME};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{FINDBYPRIMARYKEY, FIND};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{EJBSELECT};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, CREATE, FINDBYPRIMARYKEY, FIND, HOME, EJBSELECT}; // Must know EJBSELECT to check that it's not exposed on this interface
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2040, new String[]{CHKJ2040+EXT});
-
- MESSAGE_IDS.put(CHKJ2050_findByPrimaryKey, new String[]{CHKJ2050_findByPrimaryKey+EXT});
- MESSAGE_IDS.put(CHKJ2050_find, new String[]{CHKJ2050_find+EXT});
-
- MESSAGE_IDS.put(CHKJ2104, new String[]{CHKJ2104+SPEC});
- MESSAGE_IDS.put(CHKJ2402, new String[]{CHKJ2402+BEXT, CHKJ2402+MEXT});
- MESSAGE_IDS.put(CHKJ2403, new String[]{CHKJ2403+BEXT, CHKJ2403+MEXT});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2461, new String[]{CHKJ2461+BEXT, CHKJ2461+MEXT});
- MESSAGE_IDS.put(CHKJ2462, new String[]{CHKJ2462+BEXT, CHKJ2462+MEXT});
- MESSAGE_IDS.put(CHKJ2463, new String[]{CHKJ2463+BEXT, CHKJ2463+MEXT});
- MESSAGE_IDS.put(CHKJ2464, new String[]{CHKJ2464+BEXT, CHKJ2464+MEXT});
- MESSAGE_IDS.put(CHKJ2465, new String[]{CHKJ2465+BEXT, CHKJ2465+MEXT});
- MESSAGE_IDS.put(CHKJ2466, new String[]{CHKJ2466+BEXT, CHKJ2466+MEXT});
- MESSAGE_IDS.put(CHKJ2467, new String[]{CHKJ2467+BEXT, CHKJ2467+MEXT});
-
- MESSAGE_IDS.put(CHKJ2475, new String[]{CHKJ2475+BEXT, CHKJ2475+MEXT});
- MESSAGE_IDS.put(CHKJ2477, new String[]{CHKJ2477+BEXT, CHKJ2477+MEXT});
- MESSAGE_IDS.put(CHKJ2478, new String[]{CHKJ2478+BEXT, CHKJ2478+MEXT});
- MESSAGE_IDS.put(CHKJ2479, new String[]{CHKJ2479+BEXT, CHKJ2479+MEXT});
-
- MESSAGE_IDS.put(CHKJ2495, new String[]{CHKJ2495+BEXT, CHKJ2495+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_home, new String[]{CHKJ2500_home+BEXT, CHKJ2500_home+MEXT});
- MESSAGE_IDS.put(CHKJ2500_create, new String[]{CHKJ2500_create+BEXT, CHKJ2500_create+MEXT});
- MESSAGE_IDS.put(CHKJ2500_find, new String[]{CHKJ2500_find+BEXT, CHKJ2500_find+MEXT});
- MESSAGE_IDS.put(CHKJ2502_ejbSelect, new String[]{CHKJ2502_ejbSelect+BEXT, CHKJ2502_ejbSelect+MEXT});
- MESSAGE_IDS.put(CHKJ2503_create, new String[]{CHKJ2503_create+BEXT, CHKJ2503_create+MEXT});
- MESSAGE_IDS.put(CHKJ2503_find, new String[]{CHKJ2503_find+BEXT, CHKJ2503_find+MEXT});
- MESSAGE_IDS.put(CHKJ2503_home, new String[]{CHKJ2503_home+BEXT, CHKJ2503_home+MEXT});
- MESSAGE_IDS.put(CHKJ2504_create, new String[]{CHKJ2504_create+BEXT, CHKJ2504_create+MEXT});
- MESSAGE_IDS.put(CHKJ2504_find, new String[]{CHKJ2504_find+BEXT, CHKJ2504_find+MEXT});
- MESSAGE_IDS.put(CHKJ2504_home, new String[]{CHKJ2504_home+BEXT, CHKJ2504_home+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPRemoteComponentVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPRemoteComponentVRule.java
deleted file mode 100644
index 87155b480..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPRemoteComponentVRule.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.CMRField;
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class CMPRemoteComponentVRule extends AComponentVRule implements IRemoteType, IComponentType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_CMP_REMOTE;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_CMP_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".crc"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBOBJECT};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = null;
- private static final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{EJBSELECT};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, EJBSELECT}; // Must know EJBSELECT to check that it's not exposed on this interface
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2023, new String[]{CHKJ2023+BEXT, CHKJ2023+MEXT});
-
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2105, new String[]{CHKJ2105+SPEC});
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2468, new String[]{CHKJ2468+BEXT, CHKJ2468+MEXT});
- MESSAGE_IDS.put(CHKJ2469, new String[]{CHKJ2469+BEXT, CHKJ2469+MEXT});
-
- MESSAGE_IDS.put(CHKJ2470, new String[]{CHKJ2470+BEXT, CHKJ2470+MEXT});
- MESSAGE_IDS.put(CHKJ2471, new String[]{CHKJ2471+BEXT, CHKJ2471+MEXT});
- MESSAGE_IDS.put(CHKJ2472, new String[]{CHKJ2472+BEXT, CHKJ2472+MEXT});
- MESSAGE_IDS.put(CHKJ2473, new String[]{CHKJ2473+BEXT, CHKJ2473+MEXT});
- MESSAGE_IDS.put(CHKJ2474, new String[]{CHKJ2474+BEXT, CHKJ2474+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_business, new String[]{CHKJ2500_business+BEXT, CHKJ2500_business+MEXT});
- MESSAGE_IDS.put(CHKJ2500_create, new String[]{CHKJ2500_create+BEXT, CHKJ2500_create+MEXT});
- MESSAGE_IDS.put(CHKJ2500_home, new String[]{CHKJ2500_home+BEXT, CHKJ2500_home+MEXT});
- MESSAGE_IDS.put(CHKJ2502_ejbSelect, new String[]{CHKJ2502_ejbSelect+BEXT, CHKJ2502_ejbSelect+MEXT});
- MESSAGE_IDS.put(CHKJ2503_bus, new String[]{CHKJ2503_bus+BEXT, CHKJ2503_bus+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException {
- super.validate(vc, bean, clazz);
-
- ContainerManagedEntity cmp = (ContainerManagedEntity)bean;
-
- // 10.3.1, container-managed persistent fields and container-managed relationship
- // fields must *not* be defined in the entity bean class.
- List cmrFields = cmp.getCMRFields();
- Iterator iterator = cmrFields.iterator();
- while(iterator.hasNext()) {
- CMRField cmrField = (CMRField)iterator.next();
- if((cmrField != null) && (!cmrField.isDerived())) {
-
- JavaHelpers localType = ValidationRuleUtility.getCMRFieldType(vc, cmp, clazz, cmrField);
- if(localType == null) {
- // user made a mistake in ejb-jar.xml by trying to create a relation
- // to a CMP which doesn't have a local interface.
- // Don't report an error here; let the DD validation report the error.
- continue;
- }
-
- // Cannot expose get/set methods of CMR fields on the remote home or interface
- Method remoteGetMethod = ValidationRuleUtility.getMethodExtended(clazz, cmrField.getGetterName(), new JavaHelpers[0], localType);
- if(remoteGetMethod != null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2473, IEJBValidationContext.WARNING, cmp, clazz, remoteGetMethod, new String[]{cmrField.getGetterName()}, this);
- vc.addMessage(message);
- }
-
- JavaHelpers[] setMethodParms = new JavaHelpers[]{localType};
- Method remoteSetMethod = ValidationRuleUtility.getMethodExtended(clazz, cmrField.getSetterName(), setMethodParms);
- if(remoteSetMethod != null) {
- String setterName = cmrField.getSetterName() + "(" + ValidationRuleUtility.getParmsAsString(setMethodParms) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2473, IEJBValidationContext.WARNING, cmp, clazz, remoteSetMethod, new String[]{setterName}, this);
- vc.addMessage(message);
- }
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPRemoteHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPRemoteHomeVRule.java
deleted file mode 100644
index f40ec25d1..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/CMPRemoteHomeVRule.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class CMPRemoteHomeVRule extends ACMPHomeVRule implements IRemoteType, IHomeType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_CMP_HOME;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_CMP_BEANCLASS, IValidationRuleList.EJB20_CMP_KEYCLASS, IValidationRuleList.EJB20_EJBEXT};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".crh"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBHOME};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{FINDBYPRIMARYKEY, FIND};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{EJBSELECT};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, CREATE, FINDBYPRIMARYKEY, FIND, HOME, EJBSELECT}; // Must know EJBSELECT to check that it's not exposed on this interface
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2040, new String[]{CHKJ2040+EXT});
-
- MESSAGE_IDS.put(CHKJ2050_findByPrimaryKey, new String[]{CHKJ2050_findByPrimaryKey+EXT});
- MESSAGE_IDS.put(CHKJ2050_find, new String[]{CHKJ2050_find+EXT});
-
- MESSAGE_IDS.put(CHKJ2104, new String[]{CHKJ2104+SPEC});
- MESSAGE_IDS.put(CHKJ2402, new String[]{CHKJ2402+BEXT, CHKJ2402+MEXT});
- MESSAGE_IDS.put(CHKJ2403, new String[]{CHKJ2403+BEXT, CHKJ2403+MEXT});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2461, new String[]{CHKJ2461+BEXT, CHKJ2461+MEXT});
- MESSAGE_IDS.put(CHKJ2462, new String[]{CHKJ2462+BEXT, CHKJ2462+MEXT});
- MESSAGE_IDS.put(CHKJ2463, new String[]{CHKJ2463+BEXT, CHKJ2463+MEXT});
- MESSAGE_IDS.put(CHKJ2464, new String[]{CHKJ2464+BEXT, CHKJ2464+MEXT});
- MESSAGE_IDS.put(CHKJ2465, new String[]{CHKJ2465+BEXT, CHKJ2465+MEXT});
- MESSAGE_IDS.put(CHKJ2466, new String[]{CHKJ2466+BEXT, CHKJ2466+MEXT});
- MESSAGE_IDS.put(CHKJ2467, new String[]{CHKJ2467+BEXT, CHKJ2467+MEXT});
-
- MESSAGE_IDS.put(CHKJ2475, new String[]{CHKJ2475+BEXT, CHKJ2475+MEXT});
- MESSAGE_IDS.put(CHKJ2477, new String[]{CHKJ2477+BEXT, CHKJ2477+MEXT});
- MESSAGE_IDS.put(CHKJ2478, new String[]{CHKJ2478+BEXT, CHKJ2478+MEXT});
- MESSAGE_IDS.put(CHKJ2479, new String[]{CHKJ2479+BEXT, CHKJ2479+MEXT});
-
- MESSAGE_IDS.put(CHKJ2495, new String[]{CHKJ2495+BEXT, CHKJ2495+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_home, new String[]{CHKJ2500_home+BEXT, CHKJ2500_home+MEXT});
- MESSAGE_IDS.put(CHKJ2500_create, new String[]{CHKJ2500_create+BEXT, CHKJ2500_create+MEXT});
- MESSAGE_IDS.put(CHKJ2500_find, new String[]{CHKJ2500_find+BEXT, CHKJ2500_find+MEXT});
- MESSAGE_IDS.put(CHKJ2502_ejbSelect, new String[]{CHKJ2502_ejbSelect+BEXT, CHKJ2502_ejbSelect+MEXT});
- MESSAGE_IDS.put(CHKJ2503_create, new String[]{CHKJ2503_create+BEXT, CHKJ2503_create+MEXT});
- MESSAGE_IDS.put(CHKJ2503_find, new String[]{CHKJ2503_find+BEXT, CHKJ2503_find+MEXT});
- MESSAGE_IDS.put(CHKJ2503_home, new String[]{CHKJ2503_home+BEXT, CHKJ2503_home+MEXT});
- MESSAGE_IDS.put(CHKJ2504_create, new String[]{CHKJ2504_create+BEXT, CHKJ2504_create+MEXT});
- MESSAGE_IDS.put(CHKJ2504_find, new String[]{CHKJ2504_find+BEXT, CHKJ2504_find+MEXT});
- MESSAGE_IDS.put(CHKJ2504_home, new String[]{CHKJ2504_home+BEXT, CHKJ2504_home+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ClassUtility.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ClassUtility.java
deleted file mode 100644
index 976d51c25..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ClassUtility.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import java.util.Arrays;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-
-
-public final class ClassUtility {
- public static long supertype_counter = 0x1; // used by IMethodAndFieldConstants.java
- private long[] _classTypeIndex;
- private AClassType[] _classNames;
-
- private abstract class AClassType {
- public abstract String getName(EnterpriseBean bean) throws InvalidInputException;
- public abstract long getId();
-
- public JavaHelpers getClass(EnterpriseBean bean) throws InvalidInputException {
- return ValidationRuleUtility.getType(getName(bean), bean);
- }
-
- /**
- * Is this class type equal to the clazz parameter.
- */
- public boolean equals(EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- if(clazz == null) {
- return false;
- }
-
- JavaHelpers thisClass = getClass(bean);
- if(thisClass == null) {
- return false;
- }
-
- return clazz.equals(thisClass);
- }
- }
-
- private static ClassUtility _inst = null;
-
- private ClassUtility() {
- buildTypeList();
- }
-
- public static ClassUtility getUtility() {
- if(_inst == null) {
- _inst = new ClassUtility();
- }
- return _inst;
- }
-
- /**
- * Return true if the clazz is the same as the class, identified by the "type"
- * parameter, in the bean.
- */
- public boolean isClassType(EnterpriseBean bean, JavaClass clazz, long type) throws InvalidInputException {
- AClassType ct = getClassType(type);
- if(ct == null) {
- // Unknown type
- return false;
- }
-
- return ct.equals(bean, clazz);
- }
-
- public String getClassName(EnterpriseBean bean, long type) throws InvalidInputException {
- AClassType ct = getClassType(type);
- if(ct == null) {
- return null;
- }
-
- return ct.getName(bean);
- }
-
- public AClassType getClassType(long type) {
- int index = Arrays.binarySearch(_classTypeIndex, type);
- if(index > _classNames.length) {
- return null;
- }
-
- if(index < 0) {
- return null;
- }
-
- if(_classNames[index].getId() != type) {
- return null;
- }
-
- return _classNames[index];
- }
-
- public JavaHelpers getSupertype(EnterpriseBean bean, long type) throws InvalidInputException {
- AClassType ct = getClassType(type);
- if(ct == null) {
- // No supertype
- return null;
- }
-
- return ct.getClass(bean);
- }
-
- private void buildTypeList() {
- int typeCount = 12; // This is the number of identifiable classes in ITypeConstants
- _classTypeIndex = new long[typeCount];
- _classNames = new AClassType[typeCount];
- int count = 0;
-
- // The index of the type in the long[] is equal to the
- // index of the IMethodType in the IMethodType[]. By using
- // this technique instead of a HashMap, we don't need to
- // create an Integer every time we need to locate the
- // IMethodType.
- _classTypeIndex[count] = ITypeConstants.LOCAL_COMPONENT_INTERFACE;
- _classNames[count++] = new AClassType() {
- public String getName(EnterpriseBean bean) {
- JavaHelpers clazz = getClass(bean);
- if(clazz == null) {
- return null;
- }
- return clazz.getQualifiedName();
- }
-
- public long getId() {
- return ITypeConstants.LOCAL_COMPONENT_INTERFACE;
- }
-
- public JavaHelpers getClass(EnterpriseBean bean) {
- if(bean == null) {
- return null;
- }
-
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_LocalInterface())) {
- JavaClass result = bean.getLocalInterface();
- try {
- ValidationRuleUtility.isValidTypeHierarchy(bean, result);
- }
- catch(InvalidInputException e) {
- return null;
- }
- return result;
- }
-
- return null;
- }
- };
-
- _classTypeIndex[count] = ITypeConstants.REMOTE_COMPONENT_INTERFACE;
- _classNames[count++] = new AClassType() {
- public String getName(EnterpriseBean bean) {
- JavaHelpers clazz = getClass(bean);
- if(clazz == null) {
- return null;
- }
- return clazz.getQualifiedName();
- }
-
- public long getId() {
- return ITypeConstants.REMOTE_COMPONENT_INTERFACE;
- }
-
- public JavaHelpers getClass(EnterpriseBean bean) {
- if(bean == null) {
- return null;
- }
-
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_RemoteInterface())) {
- JavaClass result = bean.getRemoteInterface();
- try {
- ValidationRuleUtility.isValidTypeHierarchy(bean, result);
- }
- catch(InvalidInputException e) {
- return null;
- }
- return result;
- }
-
- return null;
- }
- };
-
- _classTypeIndex[count] = ITypeConstants.JAVAX_EJB_ENTITYBEAN;
- _classNames[count++] = new AClassType() {
- public String getName(EnterpriseBean bean) {
- return ITypeConstants.CLASSNAME_JAVAX_EJB_ENTITYBEAN;
- }
-
- public long getId() {
- return ITypeConstants.JAVAX_EJB_ENTITYBEAN;
- }
- };
-
- _classTypeIndex[count] = ITypeConstants.JAVAX_EJB_EJBLOCALHOME;
- _classNames[count++] = new AClassType() {
- public String getName(EnterpriseBean bean) {
- return ITypeConstants.CLASSNAME_JAVAX_EJB_EJBLOCALHOME;
- }
-
- public long getId() {
- return ITypeConstants.JAVAX_EJB_EJBLOCALHOME;
- }
- };
-
- _classTypeIndex[count] = ITypeConstants.JAVAX_EJB_EJBLOCALOBJECT;
- _classNames[count++] = new AClassType() {
- public String getName(EnterpriseBean bean) {
- return ITypeConstants.CLASSNAME_JAVAX_EJB_EJBLOCALOBJECT;
- }
-
- public long getId() {
- return ITypeConstants.JAVAX_EJB_EJBLOCALOBJECT;
- }
- };
-
- _classTypeIndex[count] = ITypeConstants.JAVAX_EJB_EJBHOME;
- _classNames[count++] = new AClassType() {
- public String getName(EnterpriseBean bean) {
- return ITypeConstants.CLASSNAME_JAVAX_EJB_EJBHOME;
- }
-
- public long getId() {
- return ITypeConstants.JAVAX_EJB_EJBHOME;
- }
- };
-
- _classTypeIndex[count] = ITypeConstants.JAVAX_EJB_EJBOBJECT;
- _classNames[count++] = new AClassType() {
- public String getName(EnterpriseBean bean) {
- return ITypeConstants.CLASSNAME_JAVAX_EJB_EJBOBJECT;
- }
-
- public long getId() {
- return ITypeConstants.JAVAX_EJB_EJBOBJECT;
- }
- };
-
- _classTypeIndex[count] = ITypeConstants.JAVA_LANG_OBJECT;
- _classNames[count++] = new AClassType() {
- public String getName(EnterpriseBean bean) {
- return ITypeConstants.CLASSNAME_JAVA_LANG_OBJECT;
- }
-
- public long getId() {
- return ITypeConstants.JAVA_LANG_OBJECT;
- }
- };
-
- _classTypeIndex[count] = ITypeConstants.JAVAX_EJB_MESSAGEDRIVENBEAN;
- _classNames[count++] = new AClassType() {
- public String getName(EnterpriseBean bean) {
- return ITypeConstants.CLASSNAME_JAVAX_EJB_MESSAGEDRIVENBEAN;
- }
-
- public long getId() {
- return ITypeConstants.JAVAX_EJB_MESSAGEDRIVENBEAN;
- }
- };
-
- _classTypeIndex[count] = ITypeConstants.JAVAX_JMS_MESSAGELISTENER;
- _classNames[count++] = new AClassType() {
- public String getName(EnterpriseBean bean) {
- return ITypeConstants.CLASSNAME_JAVAX_JMS_MESSAGELISTENER;
- }
-
- public long getId() {
- return ITypeConstants.JAVAX_JMS_MESSAGELISTENER;
- }
- };
-
- _classTypeIndex[count] = ITypeConstants.JAVAX_EJB_SESSIONBEAN;
- _classNames[count++] = new AClassType() {
- public String getName(EnterpriseBean bean) {
- return ITypeConstants.CLASSNAME_JAVAX_EJB_SESSIONBEAN;
- }
-
- public long getId() {
- return ITypeConstants.JAVAX_EJB_SESSIONBEAN;
- }
- };
-
- _classTypeIndex[count] = ITypeConstants.JAVAX_EJB_SESSIONSYNCHRONIZATION;
- _classNames[count++] = new AClassType() {
- public String getName(EnterpriseBean bean) {
- return ITypeConstants.CLASSNAME_JAVAX_EJB_SESSIONSYNCHRONIZATION;
- }
-
- public long getId() {
- return ITypeConstants.JAVAX_EJB_SESSIONSYNCHRONIZATION;
- }
- };
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ConnectorMessageConstants.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ConnectorMessageConstants.java
deleted file mode 100644
index 890d48215..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ConnectorMessageConstants.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Jan 22, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-/**
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-public interface ConnectorMessageConstants extends J2EEMessageConstants {
- public static final String DOCTYPE_1_3 = "1.0"; //$NON-NLS-1$
- public static final String DOCTYPE_1_4 = "1.5"; //$NON-NLS-1$
- public static final String CONNECTOR_MODEL_NAME = "CONNECTOR_VALIDATION"; //$NON-NLS-1$
- public static final String CONNECTOR_INVALID_DOC_TYPE_ERROR_ = "CONNECTOR_INVALID_DOC_TYPE_ERROR_"; //$NON-NLS-1$
- public static final String ERROR_INVALID_CONNECTOR_FILE = "ERROR_INVALID_CONNECTOR_FILE"; //$NON-NLS-1$
- public static final String ERROR_CONNECTOR_VALIDATION_FAILED = "ERROR_CONNECTOR_VALIDATION_FAILED"; //$NON-NLS-1$
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ConnectorValidator.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ConnectorValidator.java
deleted file mode 100644
index 9f424079d..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ConnectorValidator.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Jan 22, 2004
- *
- * To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.RARFile;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.jca.Connector;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-
-
-/**
- * To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-public class ConnectorValidator extends J2EEValidator implements ConnectorMessageConstants {
- protected RARFile rarFile;
- protected Connector connectorDD;
- /**
- *
- */
- public ConnectorValidator() {
- super();
- }
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.model.validation.J2EEValidator#getBaseName()
- */
- public String getBaseName() {
- return "rarvalidation"; //$NON-NLS-1$
- }
- /**
- * @return Returns the connectorDD.
- */
- protected Connector getConnectorDD() {
- return connectorDD;
- }
-
- /**
- * @param connectorDD The connectorDD to set.
- */
- protected void setConnectorDD(Connector connectorDD) {
- this.connectorDD = connectorDD;
- }
-
- /**
- * @return Returns the rarFile.
- */
- protected RARFile getRarFile() {
- return rarFile;
- }
-
- /**
- * @param rarFile The rarFile to set.
- */
- protected void setRarFile(RARFile rarFile) {
- this.rarFile = rarFile;
- }
-
- /**
- * Does the validation.
- *
- * @throws ValidationException
- */
- public void validate(IValidationContext inHelper, IReporter inReporter) throws ValidationException {
- validateInJob(inHelper, inReporter);
- }
-
- protected void validateJ2EE14DocType() {
-
- if ( getConnectorDD().getVersionID() < J2EEVersionConstants.JCA_1_5_ID) {
- String[] params = new String[3];
- params[0] = DOCTYPE_1_4;
- //params[1] = helper.getProject().getName();
- params[2] = DOCTYPE_1_3;
- addError(getBaseName(), CONNECTOR_INVALID_DOC_TYPE_ERROR_, params);
- } else if (getConnectorDD().getVersionID() != J2EEVersionConstants.JCA_1_0_ID) {
- String[] params = new String[3];
- params[0] = DOCTYPE_1_3;
- //params[1] = helper.getProject().getName();
- params[2] = DOCTYPE_1_4;
- addError(getBaseName(), CONNECTOR_INVALID_DOC_TYPE_ERROR_, params);
- }// if
- }// validateDocTypeVsNature
-
- public ISchedulingRule getSchedulingRule(IValidationContext helper) {
- return null;
- }
-
- public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws ValidationException{
-
- super.validateInJob(helper, reporter);
-
- // First remove all previous msg. for this project
- _reporter.removeAllMessages(this, null); // Note the WarHelper will return web.xml with a null object as well
-
- try {
- setRarFile((RARFile) helper.loadModel(CONNECTOR_MODEL_NAME));
- if (rarFile != null) {
- setConnectorDD( rarFile.getDeploymentDescriptor() );
- //validateJ2EE14DocType();
- } else {
- IMessage errorMsg = new Message(getBaseName(), IMessage.HIGH_SEVERITY, ERROR_INVALID_CONNECTOR_FILE);
- throw new ValidationException(errorMsg);
- }
-
- } catch (ValidationException ex) {
- throw ex;
- } catch (Exception e) {
- IMessage errorMsg = new Message(getBaseName(), IMessage.HIGH_SEVERITY, ERROR_CONNECTOR_VALIDATION_FAILED);
- throw new ValidationException(errorMsg, e);
- }
- return status;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/DuplicatesTable.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/DuplicatesTable.java
deleted file mode 100644
index cb1c63878..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/DuplicatesTable.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * In some places in the code, it is necessary to find out if there
- * are duplicates in a list, and if there are, to register a validation
- * message against the duplicates. This class is used to make finding
- * the duplicates easier.
- */
-public class DuplicatesTable extends java.util.HashMap {
- /**
- *
- */
- private static final long serialVersionUID = -3189901849555229718L;
- protected static final Boolean UNIQUE = Boolean.FALSE;
- protected static final Boolean DUPLICATE = Boolean.TRUE;
- protected Map _duplicates = null;
-
- /**
- * Add an object to this table; if the object is a duplicate, it will be
- * marked to a duplicate instead of being added twice to the table.
- */
- public void add(Object o) {
- // Build up hashtable to check for duplicate elements.
- Object key = get(o);
- if (key == null) {
- put(o, UNIQUE);
- }
- else {
- saveDuplicate(o);
- put(o, DUPLICATE);
- }
- }
-
- protected void saveDuplicate(Object o) {
- // The given object has been marked a duplicate.
- // Given that the HashMap can store only one object with the key,
- // duplicates are overwritten. This method stores the duplicates
- // elsewhere in a List.
- if (_duplicates == null) {
- _duplicates = new HashMap();
- }
-
- List dupList = (List) _duplicates.get(o);
- if (dupList == null) {
- dupList = new ArrayList();
- }
-
- dupList.add(o);
- _duplicates.put(o, dupList);
- }
-
- /**
- * If there are duplicates in this table, return true; else, return false.
- */
- public boolean containsDuplicates() {
- return containsValue(DUPLICATE);
- }
-
- /**
- * If there are unique elements in this table, return true; else, return false.
- */
- public boolean containsUniques() {
- return containsValue(UNIQUE);
- }
-
- /**
- * If there are duplicates in this table, return a set of the duplicates.
- * Otherwise, return an empty set.
- */
- public List getDuplicates() {
- if (!containsDuplicates()) {
- return Collections.EMPTY_LIST;
- }
-
- // Else, get the duplicate elements from the list
- return getElements(DUPLICATE);
- }
-
- /**
- * If there are duplicates in this table, return a list of the duplicates.
- * Otherwise, return an empty list.
- */
- private List getElements(Boolean type) {
- if (type == null) {
- return Collections.EMPTY_LIST;
- }
-
- // Else, get the duplicate elements from the list
- Set keys = keySet();
- if (keys == null) {
- return Collections.EMPTY_LIST;
- }
-
- List elements = new ArrayList();
- Iterator iterator = keys.iterator();
- while (iterator.hasNext()) {
- Object key = iterator.next();
- Object value = get(key);
- if (value == type) {
- elements.add(key);
- }
- }
-
- if (type == DUPLICATE) {
- // Also add the elements from the "duplicates" list.
- if (_duplicates != null) {
- iterator = _duplicates.values().iterator();
- while (iterator.hasNext()) {
- List dupList = (List) iterator.next();
- elements.addAll(dupList);
- }
- }
- }
-
- return elements;
- }
-
- /**
- * If there are unique elements in this table, return a set of the unique elements.
- * Otherwise, return an empty set.
- */
- public List getUniques() {
- if (!containsUniques()) {
- return Collections.EMPTY_LIST;
- }
-
- // Else, get the unique elements from the list
- return getElements(UNIQUE);
- }
-
- public void clear() {
- super.clear();
- if(_duplicates != null) {
- _duplicates.clear();
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EARValidationMessageResourceHandler.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EARValidationMessageResourceHandler.java
deleted file mode 100644
index 4c914f36a..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EARValidationMessageResourceHandler.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import org.eclipse.osgi.util.NLS;
-
-public class EARValidationMessageResourceHandler extends NLS {
-
- private static final String BUNDLE_NAME = "earvalidation";//$NON-NLS-1$
-
- private EARValidationMessageResourceHandler() {
- // Do not instantiate
- }
-
-
- public static String ERROR_EAR_VALIDATION_FAILED;
- public static String ERROR_EAR_INVALID_EAR_FILE;
- public static String ERROR_EAR_DUPLICATE_ROLES;
- public static String MESSAGE_EAR_NO_MODULE_URI;
- public static String MESSAGE_EAR_MISSING_URI;
- public static String EAR_DD_PARSE_LINECOL;
- public static String EAR_DD_PARSE_LINE;
- public static String EAR_DD_PARSE_NOINFO;
- public static String EAR_DD_CANNOT_OPEN_DD;
- public static String URI_CONTAINS_SPACES_ERROR_;
- public static String MESSAGE_EAR_DUPLICATE_URI_ERROR_;
- public static String MESSAGE_EAR_DUPICATE_ROOTCONTEXT_ERROR_;
- public static String MESSAGE_EMPTY_ALT_DD_ERROR_;
- public static String DUPLICATE_UTILJAR_FOR_PROJECT_NAME_ERROR_;
- public static String DUPLICATE_MODULE_FOR_PROJECT_NAME_ERROR_;
- public static String MESSAGE_UTIL_URI_NAME_COLLISION_ERROR_;
- public static String MESSAGE_UTIL_PROJECT_NAME_COLLISION_ERROR_;
- public static String ERROR_READING_MANIFEST_ERROR_;
- public static String MANIFEST_LINE_END_ERROR_;
- public static String MANIFEST_LINE_EXCEEDS_LENGTH_ERROR_;
- public static String INVALID_URI_FOR_MODULE_ERROR_;
- public static String EAR_INVALID_DOC_TYPE_ERROR_;
- public static String MODULE_DD_PARSE_LINECOL_ERROR_;
- public static String MODULE_DD_PARSE_LINE_ERROR_;
- public static String MODULE_DD_PARSE_NOINFO_ERROR_;
- public static String EJB_BEAN_EJB_LINK_INTEFACE_MISMATCH_ERROR_;
- public static String WARNING_METAFOLDER_MISSING;
- public static String WARNING_FILE_MISSING;
- public static String MESSAGE_INVALID_ALT_DD_WARN_;
- public static String INVALID_MANIFEST_CLASSPATH_ONE_WARN_;
- public static String INVALID_MANIFEST_CLASSPATH_TWO_WARN_;
- public static String INVALID_MANIFEST_CLASSPATH_DEPENDENCY_WARN_;
- public static String PROJECT_IS_CLOSED_WARN_;
- public static String PROJECT_DOES_NOT_EXIST_WARN_;
- public static String MISSING_WEBNATURE_FORMODULE_WARN_;
- public static String DEPRECATED_ABSPATHS_WARN_;
- public static String INVALID_CONTEXTROOT_WEBMODULE_WARN_;
- public static String MISSING_CLIENTNATURE_FORMODULE_WARN_;
- public static String MISSING_EJBNATURE_FORMODULE_WARN_;
- public static String MISSING_PROJECT_FORMODULE_WARN_;
- public static String INVALID_CASE_FOR_MANIFEST_ERROR_;
- public static String URI_ALREADY_EXISTS_IN_EAR_WARN_;
- public static String MISSING_MODULE_EXTENSION_ERROR_;
- public static String PROJECT_SERVER_TARGET_DOES_NOT_MATCH_EAR;
- public static String NO_SERVER_TARGET_MODULE_IN_EAR_WITH_SERVER_TARGET;
- public static String NO_SERVER_TARGET_ON_EAR_WITH_MODULE_SERVER_TARGETS;
- public static String INVALID_EAR_SERVER_TARGET_FOR_14_SPEC_LEVEL;
- public static String INVALID_MODULE_SERVER_TARGET_FOR_14_SPEC_LEVEL;
- public static String MESSAGE_INCOMPATIBLE_SPEC_WARNING_;
- public static String MESSAGE_INCOMPATIBLE_13_SPEC_WARNING_;
- public static String MESSAGE_INCOMPATIBLE_14_SPEC_WARNING_;
- public static String EAR_VALIDATION_INTERNAL_ERROR_UI_;
-
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, EARValidationMessageResourceHandler.class);
- }
-
- /**
- * String message;
- ...
- // no args
- message = EARValidationMessageResourceHandler.key_one;
- ...
- // bind one arg
- message = NLS.bind(EARValidationMessageResourceHandler.key_two, "example usage"); //$NON-NLS-1$
-
- */
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBExt20VRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBExt20VRule.java
deleted file mode 100644
index 5c2ea98da..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBExt20VRule.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.jst.j2ee.ejb.MessageDriven;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- * Validate the WebSphere-specific implementation of non-spec features, such
- * as component inheritance.
- */
-public class EJBExt20VRule extends AValidationRule implements IMessagePrefixEjb20Constants {
- private static final Map MESSAGE_IDS;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_STATELESS_SESSION_BEANCLASS, IValidationRuleList.EJB20_STATELESS_SESSION_REMOTE, IValidationRuleList.EJB20_STATELESS_SESSION_HOME, IValidationRuleList.EJB20_STATELESS_SESSION_LOCAL, IValidationRuleList.EJB20_STATELESS_SESSION_LOCALHOME, IValidationRuleList.EJB20_STATEFUL_SESSION_BEANCLASS, IValidationRuleList.EJB20_STATEFUL_SESSION_REMOTE, IValidationRuleList.EJB20_STATEFUL_SESSION_HOME, IValidationRuleList.EJB20_STATEFUL_SESSION_LOCAL, IValidationRuleList.EJB20_STATEFUL_SESSION_LOCALHOME, IValidationRuleList.EJB20_CMP_BEANCLASS, IValidationRuleList.EJB20_CMP_REMOTE, IValidationRuleList.EJB20_CMP_HOME, IValidationRuleList.EJB20_CMP_LOCAL, IValidationRuleList.EJB20_CMP_LOCALHOME, IValidationRuleList.EJB20_CMP_KEYCLASS, IValidationRuleList.EJB20_BMP_BEANCLASS, IValidationRuleList.EJB20_BMP_REMOTE, IValidationRuleList.EJB20_BMP_HOME, IValidationRuleList.EJB20_BMP_LOCAL, IValidationRuleList.EJB20_BMP_LOCALHOME, IValidationRuleList.EJB20_BMP_KEYCLASS, IValidationRuleList.EJB20_MESSAGE_BEANCLASS, IValidationRuleList.EJB20_EJBJAR};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2106, new String[]{CHKJ2106+SPEC});
- MESSAGE_IDS.put(CHKJ2849, new String[]{CHKJ2849+SPEC});
- MESSAGE_IDS.put(CHKJ2852, new String[]{CHKJ2852});
- }
-
- public Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public Object getId() {
- return IValidationRuleList.EJB20_EJBEXT;
- }
-
- public Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public Object getTarget(Object parent, Object clazz) {
- return null;
- }
-
- /**
- * If the bean components (home interface, remote interface, bean class, and primary
- * key) can all be found and reflected, return true. Let the DDValidator
- * report the error message against the bean if one of these types doesn't reflect.
- */
- public boolean areBeanComponentsReflected(EnterpriseBean bean) {
- // Don't need to check if the bean is null, because this method will
- // not be called if it is.
- try {
- ValidationRuleUtility.isValidTypeHierarchy(bean, bean.getEjbClass());
- }
- catch (InvalidInputException exc) {
- return false;
- }
-
- if(bean instanceof MessageDriven) {
- // don't need to check the rest
- return true;
- }
-
- try {
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_HomeInterface())) {
- ValidationRuleUtility.isValidTypeHierarchy(bean, bean.getHomeInterface());
- }
- }
- catch (InvalidInputException exc) {
- return false;
- }
-
- try {
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_RemoteInterface())) {
- ValidationRuleUtility.isValidTypeHierarchy(bean, bean.getRemoteInterface());
- }
- }
- catch (InvalidInputException exc) {
- return false;
- }
-
- try {
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_LocalHomeInterface())) {
- ValidationRuleUtility.isValidTypeHierarchy(bean, bean.getLocalHomeInterface());
- }
- }
- catch (InvalidInputException exc) {
- return false;
- }
-
- try {
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_LocalInterface())) {
- ValidationRuleUtility.isValidTypeHierarchy(bean, bean.getLocalInterface());
- }
- }
- catch (InvalidInputException exc) {
- return false;
- }
-
- if (bean.isEntity()) {
- JavaClass primaryKey = ((Entity) bean).getPrimaryKey();
- try {
- if(((Entity)bean).eIsSet(EjbPackage.eINSTANCE.getEntity_PrimaryKey())) {
- ValidationRuleUtility.isValidTypeHierarchy(bean, primaryKey);
- }
- }
- catch (InvalidInputException exc) {
- return false;
- }
- }
-
- return true;
- }
-
- public void validate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException {
- Logger logger = vc.getMsgLogger();
- if(logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("EJB20Validator - validate"); //$NON-NLS-1$
- entry.setText(getClass().getName() + "::validate(" + targetParent + ", " + target); //$NON-NLS-1$ //$NON-NLS-2$
- logger.write(Level.FINEST, entry);
- }
-
- EJBJar ejbJar = null;
- if(targetParent == null) {
- ejbJar = (EJBJar)target;
- validate(vc, ejbJar);
- }
- else {
- // running as a dependent
- ejbJar = (EJBJar)vc.loadModel(EJBValidatorModelEnum.EJB_MODEL);
- EnterpriseBean bean = (EnterpriseBean)targetParent;
- validate(vc, ejbJar, bean);
- }
- }
-
- /*
- * @see IValidationRule#validate(IEJBValidationContext, Object, Object)
- */
- public void validate(IEJBValidationContext vc, EJBJar ejbJar) throws ValidationCancelledException, ValidationException {
- List enterpriseBeans = ejbJar.getEnterpriseBeans();
- Iterator iterator = enterpriseBeans.iterator();
- EnterpriseBean bean = null;
- while(iterator.hasNext()) {
- bean = (EnterpriseBean)iterator.next();
- if(bean == null) {
- // If bean isn't valid, don't perform any of the other
- // validation checks on it. Let DDValidator output the error message.
- continue;
- }
- validate(vc, ejbJar, bean);
- }
- }
-
- public void validate(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) throws ValidationCancelledException, ValidationException {
- try {
- // Check if the class exists, etc.
- if(!areBeanComponentsReflected(bean)) {
- // Something didn't reflect properly, so don't continue with the
- // rest of the checks. Some metadata will be nonsense.
- return;
- }
-
- // Component inheritance is now checked in each VRule instead of here.
- // This was necessary for incremental validation; if one class changed
- // in the bean, and the bean was a member of component inheritance, then
- // messages were added multiple times onto the classes which had not changed.
- // In order to avoid multiple messages, only the component inheritance of
- // the class which changed should be revalidated when the class changes.
- validateAppendixB(vc, ejbJar, bean); // validate the key class since that message is registered against ejb-jar.xml
- }
- catch(ValidationCancelledException e) {
- throw e;
- }
- /* unreachable catch block
- catch(ValidationException exc) {
- // If there's a problem, proceed with the next bean.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorConstants.CHKJ2852, IEJBValidationContext.WARNING, bean, new String[]{ArchiveConstants.EJBJAR_EXTENSIONS_SHORT_NAME, beanName}, this);
- vc.addMessage(message);
- if(logger.isLoggingLevel(Level.FINER)) {
- logger.write(Level.FINER, exc);
- }
- }
- */
- catch(Throwable exc) {
- // If there's a problem, proceed with the next bean.
- String superTypeName = getEJBInheritanceFileName();
- if(superTypeName == null)
- superTypeName = "unknown super type"; //$NON-NLS-1$
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2852, IEJBValidationContext.WARNING, bean, new String[]{superTypeName, bean.getName()}, this);
- vc.addMessage(message);
- Logger logger = vc.getMsgLogger();
- if(logger != null && logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, exc);
- }
- }
- }
-
- protected void validateAppendixB(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- // The Java inheritance structure must match the EJB inheritance structure.
- // e.g. if EJB B is a child of EJB A, then class B must be a child of class A.
- // B could be a grandchild (or great-grandchild or ...) of A.
- if(bean == null) {
- return;
- }
- if(!bean.isEntity()) {
- return;
- }
- JavaClass thisKey = ((Entity)bean).getPrimaryKey();
- EnterpriseBean supertype = getSuperType(bean);
- JavaClass parentKey = null;
- if (supertype != null) {
- // check this CMP's supertype
- // Key a Xchild of parent Key
- // In WSA EJB component inheritance, the root EJB must define the key.
- // The key is the same for all child EJBs.
- if (supertype instanceof Entity) {
- parentKey = ((Entity) supertype).getPrimaryKey();
-
- if ((thisKey == null) || (parentKey == null) || !thisKey.equals(parentKey)) {
- String[] msgParm = new String[] { bean.getName(), parentKey.getQualifiedName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2106, IEJBValidationContext.ERROR, bean, msgParm, this);
- vc.addMessage(message);
- }
- }
- }
-
-// validateAppendixB(vc, supertype, parentKey);
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBJar11VRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBJar11VRule.java
deleted file mode 100644
index a5f564dee..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBJar11VRule.java
+++ /dev/null
@@ -1,588 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-
-import org.eclipse.jem.java.Method;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.common.CommonPackage;
-import org.eclipse.jst.j2ee.common.SecurityRole;
-import org.eclipse.jst.j2ee.ejb.AssemblyDescriptor;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.MethodElement;
-import org.eclipse.jst.j2ee.ejb.MethodPermission;
-import org.eclipse.jst.j2ee.ejb.MethodTransaction;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- * This class checks ejb-jar.xml for errors or potential errors.
- * If any problems are found, an error, warning, or info marker is added to the task list.
- *
- * 15.2.5.3 Declaration of security roles referenced from the bean's code
- * The Bean Provider is responsible for declaring in the security-role-ref elements of the deploy-ment
- * descriptor all the security role names used in the enterprise bean code. Declaring the security roles
- * references in the code allows the Application Assembler or Deployer to link the names of the security
- * roles used in the code to the security roles defined for an assembled application through the secu-rity-
- * role elements.
- * The Bean Provider must declare each security role referenced in the code using the secu-rity-
- * role-ref element as follows:
- * Declare the name of the security role using the role-name element. The name must be the
- * security role name that is used as a parameter to the isCallerInRole(String role-Name)
- * method.
- * Optional: Provide a description of the security role in the description element.
- * A security role reference, including the name defined by the role-name element, is scoped to the ses-sion
- * or entity bean element whose declaration contains the security-role-ref element.
- * The following example illustrates how an enterprise bean's references to security roles are declared in
- * the deployment descriptor.
- * ...
- * <enterprise-beans>
- * ...
- * <entity>
- * <ejb-name>AardvarkPayroll</ejb-name>
- * <ejb-class>com.aardvark.payroll.PayrollBean</ejb-class>
- * ...
- * <security-role-ref>
- * <description>
- * This security role should be assigned to the
- * employees of the payroll department who are
- * allowed to update employees' salaries.
- * </description>
- * <role-name>payroll</role-name>
- * </security-role-ref>
- * ...
- * </entity>
- * ...
- * </enterprise-beans>
- * ...
- *
- * The deployment descriptor above indicates that the enterprise bean AardvarkPayroll makes the
- * security check using isCallerInRole("payroll") in its business method.
- *
- *
- * 15.3.3 Linking security role references to security roles
- * If the Application Assembler defines the security-role elements in the deployment descriptor, he
- * or she is also responsible for linking all the security role references declared in the secu-rity-
- * role-ref elements to the security roles defined in the security-role elements.
- * The Application Assembler links each security role reference to a security role using the role-link
- * element. The value of the role-link element must be the name of one of the security roles defined in
- * a security-role element.
- * A role-link element must be used even if the value of role-name is the same as the value of the
- * role-link reference.
- * The following deployment descriptor example shows how to link the security role reference named
- * payroll to the security role named payroll-department.
- * ...
- * <enterprise-beans>
- * ...
- * <entity>
- * <ejb-name>AardvarkPayroll</ejb-name>
- * <ejb-class>com.aardvark.payroll.PayrollBean</ejb-class>
- * ...
- * <security-role-ref>
- * <description>
- * This role should be assigned to the
- * employees of the payroll department.
- * Members of this role have access to
- * anyone's payroll record.
- *
- * The role has been linked to the
- * payroll-department role.
- * </description>
- * <role-name>payroll</role-name>
- * <role-link>payroll-department</role-link>
- * </security-role-ref>
- * ...
- * </entity>
- * ...
- * </enterprise-beans>
- * ...
- */
-public class EJBJar11VRule extends AValidationRule implements IMessagePrefixEjb11Constants {
- private DuplicatesTable _ejbName = null;
- private static final Object ID = IValidationRuleList.EJB11_EJBJAR;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB11_SESSION_BEANCLASS, IValidationRuleList.EJB11_SESSION_REMOTE, IValidationRuleList.EJB11_SESSION_HOME, IValidationRuleList.EJB11_CMP_BEANCLASS, IValidationRuleList.EJB11_CMP_REMOTE, IValidationRuleList.EJB11_CMP_HOME, IValidationRuleList.EJB11_CMP_KEYCLASS, IValidationRuleList.EJB11_BMP_BEANCLASS, IValidationRuleList.EJB11_BMP_REMOTE, IValidationRuleList.EJB11_BMP_HOME, IValidationRuleList.EJB11_BMP_KEYCLASS, IValidationRuleList.EJB11_EJBEXT};
-
- private static final Map MESSAGE_IDS;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2814, new String[]{CHKJ2814 + SPEC});
-
- MESSAGE_IDS.put(CHKJ2825, new String[]{CHKJ2825 + SPEC});
- MESSAGE_IDS.put(CHKJ2826, new String[]{CHKJ2826 + SPEC});
-
- MESSAGE_IDS.put(CHKJ2842, new String[]{CHKJ2842 + SPEC});
- MESSAGE_IDS.put(CHKJ2843, new String[]{CHKJ2843 + SPEC});
- MESSAGE_IDS.put(CHKJ2844, new String[]{CHKJ2844 + SPEC});
- MESSAGE_IDS.put(CHKJ2845, new String[]{CHKJ2845 + SPEC});
- MESSAGE_IDS.put(CHKJ2846, new String[]{CHKJ2846 + SPEC});
- MESSAGE_IDS.put(CHKJ2847, new String[]{CHKJ2847 + SPEC});
-
- MESSAGE_IDS.put(CHKJ2850, new String[]{CHKJ2850 + SPEC});
- MESSAGE_IDS.put(CHKJ2852, new String[]{CHKJ2852});
-
- MESSAGE_IDS.put(CHKJ2875, new String[]{CHKJ2875 + SPEC});
-
- MESSAGE_IDS.put(CHKJ2895, new String[]{CHKJ2895 + SPEC});
- }
-
- public EJBJar11VRule() {
- _ejbName = new DuplicatesTable();
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public Object getTarget(Object parent, Object target) {
- return null;
- }
-
- /**
- * 15.3.1 Security roles
- * The Application Assembler can define one or more security roles in
- * the deployment descriptor. The Application Assembler then assigns
- * groups of methods of the enterprise beans' home and remote interfaces
- * to the security roles to define the security view of the application.
- * Because the Application Assembler does not, in general, know the
- * security environment of the operational environment, the security
- * roles are meant to be logical roles (or actors), each representing
- * a type of user that should have the same access rights to the
- * application. The Deployer then assigns user groups and/or user
- * accounts defined in the operational environment to the security roles
- * defined by the Application Assembler.
- * Defining the security roles in the deployment descriptor is optional [17]
- * for the Application Assembler. Their omission in the deployment
- * descriptor means that the Application Assembler chose not to pass any
- * security deployment related instructions to the Deployer in the
- * deployment descriptor. The Application Assembler is responsible for
- * the following:
- * - Define each security role using a security-role element.
- * - Use the role-name element to define the name of the security role.
- * - Optionally, use the description element to provide a description of
- * a security role.
- * The security roles defined by the security-role elements are scoped to
- * the ejb-jar file level, and apply to all the enterprise beans in the
- * ejb-jar file.
- * [17] If the Application Assembler does not define security roles in the
- * deployment descriptor, the Deployer will have to define security
- * roles at deployment time.
- *...
- */
- protected void validateAssemblyDescriptorElement(IEJBValidationContext vc, EJBJar ejbJar) {
- vc.terminateIfCancelled();
-
- // Validate the security roles, if they're defined in the assembly-descriptor.
- if (ejbJar == null) {
- // nothing to validate
- return;
- }
-
- /**
- * Need to build up a list of duplicate role names, but the validation message
- * needs to be registered against the duplicate SecurityRole instance.
- * (Without the instance, we cannot get line numbers.)
- *
- * This class wrappers the SecurityRol instance so that the wrapper's
- * implemention of equals compares the names, but the validation message will
- * still be able to get the ref from the duplicate name.
- */
- class RoleWrapper {
- private SecurityRole _role = null;
-
- public RoleWrapper(SecurityRole role) {
- _role = role;
- }
-
- public boolean equals(Object o) {
- if (o instanceof RoleWrapper) {
- RoleWrapper other = (RoleWrapper) o;
- return _role.getRoleName().equals(other.getRole().getRoleName());
- }
- return false;
- }
-
- public SecurityRole getRole() {
- return _role;
- }
- }
-
- AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
- if (assemblyDescriptor == null) {
- // nothing to validate
- return;
- }
-
- List roles = assemblyDescriptor.getSecurityRoles();
- if (roles != null) {
- DuplicatesTable roleNames = new DuplicatesTable();
- SecurityRole role = null;
- Iterator roleIt = roles.iterator();
- while (roleIt.hasNext()) {
- vc.terminateIfCancelled();
- // Check that the role-name element has been set
- role = (SecurityRole) roleIt.next();
- if (role == null) {
- // role-name not set
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2825, IEJBValidationContext.WARNING, ejbJar, this);
- vc.addMessage(message);
- }
- else if ((!role.eIsSet(CommonPackage.eINSTANCE.getSecurityRole_RoleName())) || (role.getRoleName().equals(""))) { //$NON-NLS-1$
- // role-name not set
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2825, IEJBValidationContext.WARNING, role, this);
- vc.addMessage(message);
- }
- else {
- // Build up hashtable to check for duplicate role-names.
- roleNames.add(new RoleWrapper(role));
- }
- }
-
- // Check that there are no duplicate role-names. (15.3.1)
- if (roleNames.containsDuplicates()) {
- List duplicates = roleNames.getDuplicates();
- Iterator iterator = duplicates.iterator();
- while (iterator.hasNext()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2826, IEJBValidationContext.WARNING, ((RoleWrapper) iterator.next()).getRole(), this);
- vc.addMessage(message);
- }
- }
- roleNames.clear();
- }
-
- List methTrans = assemblyDescriptor.getMethodTransactions();
- MethodTransaction mt = null;
- Iterator iterator = methTrans.iterator();
- while (iterator.hasNext()) {
- vc.terminateIfCancelled();
-
- try {
- mt = (MethodTransaction) iterator.next();
- }
- catch (Throwable exc) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINER)) {
- logger.write(Level.FINER, exc);
- }
- mt = null;
- }
-
- if (mt == null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("DDValidator.validateAssemblyDescriptorElement"); //$NON-NLS-1$
- entry.setText("mt is null"); //$NON-NLS-1$
- logger.write(Level.FINEST, entry);
- }
- continue;
- }
-
- boolean hasValidMethod = validateMethodElements(vc, ejbJar, mt.getMethodElements());
- if (!hasValidMethod) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2847, IEJBValidationContext.WARNING, mt, this);
- vc.addMessage(message);
- }
- }
-
- List methodPermissions = assemblyDescriptor.getMethodPermissions();
- iterator = methodPermissions.iterator();
- while (iterator.hasNext()) {
- MethodPermission mp = (MethodPermission) iterator.next();
-
- boolean hasValidMethod = validateMethodElements(vc, ejbJar, mp.getMethodElements());
- if (!hasValidMethod) {
- // 15.3.2, p. 229, a <method-permission> must have at least one method listed (and that method must be found)
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2846, IEJBValidationContext.WARNING, mp, this);
- vc.addMessage(message);
- }
-
- // at least one security-role must be defined
- List mproles = mp.getRoles();
- if ((mproles == null) || (mproles.size() == 0)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2845, IEJBValidationContext.WARNING, mp, this);
- vc.addMessage(message);
- }
- }
- }
-
- /**
- * This validateDeploymentDescriptor is called if the EJBJar could load, which means
- * that the syntax of the JAR is (mostly) correct.
- *
- * EJB spec 1.1, section C.4, "Added the requirement for the Bean Provider to specify whether the
- * enterprise bean uses a bean-managed or container-managed transaction."
- */
- public void validate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationException {
- EJBJar ejbJar = (EJBJar) target;
- List enterpriseBeans = ejbJar.getEnterpriseBeans();
- Iterator iterator = enterpriseBeans.iterator();
- EnterpriseBean bean = null;
- String beanName = null;
- while (iterator.hasNext()) {
- try {
- bean = (EnterpriseBean) iterator.next();
- register(vc, ejbJar, bean);
-
- Object id = IValidationRuleList.EJB11_ENTERPRISEBEAN;
- IValidationRule vRule = EJBValidationRuleFactory.getFactory().getRule(vc, id);
- if (vRule == null) {
- // This has already been logged by the AbstractEJBValidationRuleFactory, so just
- // need to add "Cannot validate" to the task list.
- continue;
- }
- try {
- vRule.preValidate(vc, ejbJar, bean);
- vRule.validate(vc, ejbJar, bean);
- vRule.postValidate(vc, ejbJar, bean);
- }
- catch (ValidationCancelledException exc) {
- // Clean up the messages which are on the task list? Or is it nicer to leave them behind?
- }
- catch(ValidationException e) {
- throw e;
- }
- catch (Throwable exc) {
- addInternalErrorMessage(vc, exc);
- }
- finally {
- EJBValidationRuleFactory.getFactory().release(vRule);
- }
- }
- catch(ValidationCancelledException e) {
- throw e;
- }
- catch (ValidationException e) {
- throw e;
- }
- catch (Throwable exc) {
- // If there's a problem, proceed with the next bean.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2852, IEJBValidationContext.WARNING, bean, new String[] { J2EEConstants.EJBJAR_DD_SHORT_NAME, beanName }, this);
- vc.addMessage(message);
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, exc);
- }
- }
- }
-
- // Since the assembly descriptor is not specific to a bean, validate it once, after all bean processing is complete.
- validateAssemblyDescriptorElement(vc, ejbJar);
- validateUniqueEjbNames(vc, ejbJar);
- validateClientJAR(vc, ejbJar);
- }
-
- public void reset() {
- super.reset();
- _ejbName.clear();
- }
-
- protected void register(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- // To check if every bean name is unique, need to build a list
- _ejbName.add(new EjbNameWrapper(bean));
- }
-
- private void addInternalErrorMessage(IEJBValidationContext vc, Throwable exc) {
- IMessage mssg = vc.getMessage();
- mssg.setId(IEJBValidatorMessageConstants.CHKJ2900);
- vc.addMessage(mssg);
-
- if(exc != null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, exc);
- }
- }
- }
-
- public void validateUniqueEjbNames(IEJBValidationContext vc, EJBJar ejbJar) {
- List names = _ejbName.getDuplicates();
- if(names.size() == 0) {
- return;
- }
-
- Iterator iterator = names.iterator();
- while(iterator.hasNext()) {
- EjbNameWrapper wrapper = (EjbNameWrapper)iterator.next();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2895, IEJBValidationContext.WARNING, wrapper.getBean(), new String[]{wrapper.getBean().getName()}, this);
- vc.addMessage(message);
- }
- }
-
- protected void validateClientJAR(IEJBValidationContext vc, EJBJar ejbJar) {
- String clientJARName = ejbJar.getEjbClientJar();
- if(clientJARName == null) {
- // No client JAR specified; everything's okay.
- return;
- }
-
- Boolean exists = (Boolean)vc.loadModel(EJBValidatorModelEnum.EJB_CLIENTJAR, new Object[]{clientJARName});
- if(exists == null) {
- // Helper doesn't support load model. WAS?
- // Can't perform this check, so just return.
- return;
- }
-
- if(!exists.booleanValue()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2875, IEJBValidationContext.ERROR, ejbJar, new String[]{clientJARName}, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * Both section 11.4.1 and 15.3.2 need the <method> element. Also refer
- * to 16.5 for syntax.
- *
- * Return true if at least one of the methods referenced by this list of
- * MethodElement can be found.
- */
- protected boolean validateMethodElements(IEJBValidationContext vc, EJBJar ejbJar, List elements) {
- if ((elements == null) || (elements.size() == 0)) {
- return false;
- }
-
- boolean hasValidMethod = false;
- Iterator iterator = elements.iterator();
- while (iterator.hasNext()) {
- vc.terminateIfCancelled();
- MethodElement element = (MethodElement) iterator.next();
-
- EnterpriseBean bean = element.getEnterpriseBean();
- if (bean == null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2814, IEJBValidationContext.WARNING, element, this);
- vc.addMessage(message);
- continue;
- }
-
- if (element.getName() != null) {
- // Do not attempt to access the methods on the home or remote interface if there'
- // been a problem locating or reflecting those types
- boolean reflected = true;
- try {
- ValidationRuleUtility.isValidType(bean.getHomeInterface());
- }
- catch (InvalidInputException e) {
- reflected = false;
- String className = (e.getJavaClass() == null) ? IEJBValidatorConstants.NULL_HOME : e.getJavaClass().getQualifiedName();
- String[] msgParm = { className };
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2850, IEJBValidationContext.WARNING, bean, msgParm, this);
- vc.addMessage(message);
- }
- try {
- ValidationRuleUtility.isValidType(bean.getRemoteInterface());
- }
- catch (InvalidInputException e) {
- reflected = false;
- String className = (e.getJavaClass() == null) ? IEJBValidatorConstants.NULL_REMOTE : e.getJavaClass().getQualifiedName();
- String[] msgParm = { className };
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2850, IEJBValidationContext.WARNING, bean, msgParm, this);
- vc.addMessage(message);
- }
-
- if(reflected) {
- // The "element.getMethods()" has a null pointer exception when it attempts to retrieve the methods from the home/remote interface,
- // if either of the interfaces don't exist.
- String name = element.getName();
-
- Method[] methods = element.getMethods(); // get all methods which will be retrieved for the given method-permission
- boolean hasMethods = ((methods != null) && (methods.length > 0));
-
- if (!hasMethods) {
- // warning
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2843, IEJBValidationContext.WARNING, element, new String[] { bean.getName()}, this);
- vc.addMessage(message);
- }
- else {
- hasValidMethod = true; // a <method-permission> must have at least one method (15.3.2, p.229)
- if (name.equals("*")) { //$NON-NLS-1$
- List params = element.getMethodParams();
- if ((params != null) && (params.size() > 0)) {
- // warning
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2842, IEJBValidationContext.WARNING, element, this);
- vc.addMessage(message);
- }
- }
- }
- }
- }
- else {
- // error
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2844, IEJBValidationContext.WARNING, element, this);
- vc.addMessage(message);
- }
- }
-
- return hasValidMethod;
- }
-
- /**
- * Need to build up a list of duplicate EJB names, but the validation message
- * needs to be registered against the duplicate EnterpriseBean instance.
- * (Without the instance, we cannot get line numbers.)
- *
- * This class wrappers the EnterpriseBean instance so that the wrapper's
- * implemention of equals compares the names, but the validation message will
- * still be able to get the ref from the duplicate name.
- */
- class EjbNameWrapper {
- private EnterpriseBean _bean = null;
-
- public EjbNameWrapper(EnterpriseBean bean) {
- _bean = bean;
- }
-
- public boolean equals(Object o) {
- if (o instanceof EjbNameWrapper) {
- EjbNameWrapper other = (EjbNameWrapper)o;
- if((_bean.getName() == null) && (other.getBean().getName() == null)) {
- return true;
- }
- else if(_bean.getName() == null) {
- return false;
- }
- else if(other.getBean().getName() == null) {
- return false;
- }
- return _bean.getName().equals(other.getBean().getName());
- }
- return false;
- }
-
- public int hashCode() {
- if((getBean() != null) && (getBean().getName() != null)) {
- return getBean().getName().hashCode();
- }
- return super.hashCode();
- }
-
- public EnterpriseBean getBean() {
- return _bean;
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBJar20VRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBJar20VRule.java
deleted file mode 100644
index 1d8726b85..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBJar20VRule.java
+++ /dev/null
@@ -1,879 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-
-import org.eclipse.jem.java.Method;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.common.CommonPackage;
-import org.eclipse.jst.j2ee.common.SecurityRole;
-import org.eclipse.jst.j2ee.ejb.AssemblyDescriptor;
-import org.eclipse.jst.j2ee.ejb.CMRField;
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-import org.eclipse.jst.j2ee.ejb.EJBRelation;
-import org.eclipse.jst.j2ee.ejb.EJBRelationshipRole;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.jst.j2ee.ejb.MethodElement;
-import org.eclipse.jst.j2ee.ejb.MethodPermission;
-import org.eclipse.jst.j2ee.ejb.MethodTransaction;
-import org.eclipse.jst.j2ee.ejb.MultiplicityKind;
-import org.eclipse.jst.j2ee.ejb.Relationships;
-import org.eclipse.jst.j2ee.ejb.RoleSource;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- * @version 1.0
- * @author
- */
-public class EJBJar20VRule extends AValidationRule implements IMessagePrefixEjb20Constants {
- private static final Map MESSAGE_IDS;
- private DuplicatesTable _ejbName = null;
- private DuplicatesTable _asName = null;
- private DuplicatesTable _relationshipName = null;
- private DuplicatesTable _relationshipRoleName = null;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_STATELESS_SESSION_BEANCLASS, IValidationRuleList.EJB20_STATELESS_SESSION_REMOTE, IValidationRuleList.EJB20_STATELESS_SESSION_HOME, IValidationRuleList.EJB20_STATELESS_SESSION_LOCAL, IValidationRuleList.EJB20_STATELESS_SESSION_LOCALHOME, IValidationRuleList.EJB20_STATEFUL_SESSION_BEANCLASS, IValidationRuleList.EJB20_STATEFUL_SESSION_REMOTE, IValidationRuleList.EJB20_STATEFUL_SESSION_HOME, IValidationRuleList.EJB20_STATEFUL_SESSION_LOCAL, IValidationRuleList.EJB20_STATEFUL_SESSION_LOCALHOME, IValidationRuleList.EJB20_CMP_BEANCLASS, IValidationRuleList.EJB20_CMP_REMOTE, IValidationRuleList.EJB20_CMP_HOME, IValidationRuleList.EJB20_CMP_LOCAL, IValidationRuleList.EJB20_CMP_LOCALHOME, IValidationRuleList.EJB20_CMP_KEYCLASS, IValidationRuleList.EJB20_BMP_BEANCLASS, IValidationRuleList.EJB20_BMP_REMOTE, IValidationRuleList.EJB20_BMP_HOME, IValidationRuleList.EJB20_BMP_LOCAL, IValidationRuleList.EJB20_BMP_LOCALHOME, IValidationRuleList.EJB20_BMP_KEYCLASS, IValidationRuleList.EJB20_MESSAGE_BEANCLASS, IValidationRuleList.EJB20_EJBEXT};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2800_NAMED, new String[]{CHKJ2800_NAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2800_UNNAMED, new String[]{CHKJ2800_UNNAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2802_NAMED, new String[]{CHKJ2802_NAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2802_UNNAMED, new String[]{CHKJ2802_UNNAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2803_NAMED, new String[]{CHKJ2803_NAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2803_UNNAMED, new String[]{CHKJ2803_UNNAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2804_NAMED, new String[]{CHKJ2804_NAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2804_UNNAMED, new String[]{CHKJ2804_UNNAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2805_NAMED, new String[]{CHKJ2805_NAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2805_UNNAMED, new String[]{CHKJ2805_UNNAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2806, new String[]{CHKJ2806+SPEC});
- MESSAGE_IDS.put(CHKJ2807, new String[]{CHKJ2807+SPEC});
- MESSAGE_IDS.put(CHKJ2808, new String[]{CHKJ2808+SPEC});
- MESSAGE_IDS.put(CHKJ2809, new String[]{CHKJ2809+SPEC});
- MESSAGE_IDS.put(CHKJ2810_NAMED, new String[]{CHKJ2810_NAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2810_UNNAMED, new String[]{CHKJ2810_UNNAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2811_NAMED, new String[]{CHKJ2811_NAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2814, new String[]{CHKJ2814+SPEC});
- MESSAGE_IDS.put(CHKJ2816, new String[]{CHKJ2816+SPEC});
- MESSAGE_IDS.put(CHKJ2817, new String[]{CHKJ2817+SPEC});
- MESSAGE_IDS.put(CHKJ2818, new String[]{CHKJ2818+SPEC});
- MESSAGE_IDS.put(CHKJ2820, new String[]{CHKJ2820+SPEC});
- MESSAGE_IDS.put(CHKJ2821, new String[]{CHKJ2821+SPEC});
- MESSAGE_IDS.put(CHKJ2822, new String[]{CHKJ2822+SPEC});
- MESSAGE_IDS.put(CHKJ2823, new String[]{CHKJ2823+SPEC});
- MESSAGE_IDS.put(CHKJ2824, new String[]{CHKJ2824+SPEC});
- MESSAGE_IDS.put(CHKJ2825, new String[]{CHKJ2825+SPEC});
- MESSAGE_IDS.put(CHKJ2826, new String[]{CHKJ2826+SPEC});
- MESSAGE_IDS.put(CHKJ2827, new String[]{CHKJ2827+SPEC});
- MESSAGE_IDS.put(CHKJ2828, new String[]{CHKJ2828+SPEC});
- MESSAGE_IDS.put(CHKJ2829, new String[]{CHKJ2829+SPEC});
- MESSAGE_IDS.put(CHKJ2830, new String[]{CHKJ2830+SPEC});
- MESSAGE_IDS.put(CHKJ2831, new String[]{CHKJ2831+SPEC});
- MESSAGE_IDS.put(CHKJ2832, new String[]{CHKJ2832+SPEC});
- MESSAGE_IDS.put(CHKJ2833, new String[]{CHKJ2833+SPEC});
- MESSAGE_IDS.put(CHKJ2834, new String[]{CHKJ2834+SPEC});
- MESSAGE_IDS.put(CHKJ2835, new String[]{CHKJ2835+SPEC});
- MESSAGE_IDS.put(CHKJ2836, new String[]{CHKJ2836+SPEC});
- MESSAGE_IDS.put(CHKJ2837, new String[]{CHKJ2837+SPEC});
- MESSAGE_IDS.put(CHKJ2838, new String[]{CHKJ2838+SPEC});
- MESSAGE_IDS.put(CHKJ2839, new String[]{CHKJ2839+SPEC});
- MESSAGE_IDS.put(CHKJ2841, new String[]{CHKJ2841+SPEC});
- MESSAGE_IDS.put(CHKJ2842, new String[]{CHKJ2842+SPEC});
- MESSAGE_IDS.put(CHKJ2843, new String[]{CHKJ2843+SPEC});
- MESSAGE_IDS.put(CHKJ2844, new String[]{CHKJ2844+SPEC});
- MESSAGE_IDS.put(CHKJ2845, new String[]{CHKJ2845+SPEC});
- MESSAGE_IDS.put(CHKJ2846, new String[]{CHKJ2846+SPEC});
- MESSAGE_IDS.put(CHKJ2847, new String[]{CHKJ2847+SPEC});
- MESSAGE_IDS.put(CHKJ2848, new String[]{CHKJ2848+SPEC});
- MESSAGE_IDS.put(CHKJ2850, new String[]{CHKJ2850+SPEC});
- MESSAGE_IDS.put(CHKJ2854, new String[]{CHKJ2854+SPEC});
- MESSAGE_IDS.put(CHKJ2855, new String[]{CHKJ2855+SPEC});
- MESSAGE_IDS.put(CHKJ2856, new String[]{CHKJ2856+SPEC});
- MESSAGE_IDS.put(CHKJ2857, new String[]{CHKJ2857+SPEC});
- MESSAGE_IDS.put(CHKJ2858, new String[]{CHKJ2858+SPEC});
- MESSAGE_IDS.put(CHKJ2859, new String[]{CHKJ2859+SPEC});
- MESSAGE_IDS.put(CHKJ2860, new String[]{CHKJ2860+SPEC});
- MESSAGE_IDS.put(CHKJ2866, new String[]{CHKJ2866+SPEC});
- MESSAGE_IDS.put(CHKJ2867, new String[]{CHKJ2867+SPEC});
- MESSAGE_IDS.put(CHKJ2868, new String[]{CHKJ2868+SPEC});
- MESSAGE_IDS.put(CHKJ2869, new String[]{CHKJ2869+SPEC});
- MESSAGE_IDS.put(CHKJ2871, new String[]{CHKJ2871+SPEC});
- MESSAGE_IDS.put(CHKJ2872, new String[]{CHKJ2872+SPEC});
- MESSAGE_IDS.put(CHKJ2873, new String[]{CHKJ2873+SPEC});
- MESSAGE_IDS.put(CHKJ2874, new String[]{CHKJ2874+SPEC});
- MESSAGE_IDS.put(CHKJ2875, new String[]{CHKJ2875 + SPEC});
- MESSAGE_IDS.put(CHKJ2895, new String[]{CHKJ2895+SPEC});
- MESSAGE_IDS.put(CHKJ2852, new String[]{CHKJ2852});
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public EJBJar20VRule() {
- _ejbName = new DuplicatesTable();
- _asName = new DuplicatesTable();
- _relationshipName = new DuplicatesTable();
- _relationshipRoleName = new DuplicatesTable();
- }
-
- public Object[] getDependsOn() {
- // EJBJar doesn't depend on anything else
- return DEPENDS_ON;
- }
-
- public Object getId() {
- return IValidationRuleList.EJB20_EJBJAR;
- }
-
- public Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public Object getTarget(Object parent, Object clazz) {
- // Since this rule doesn't depend on another rule, this
- // method (which is called on a dependent rule) will never
- // be called.
- return null;
- }
-
- /*
- * @see IValidationRule#reset()
- */
- public void reset() {
- super.reset();
- _ejbName.clear();
- _asName.clear();
- _relationshipName.clear();
- _relationshipRoleName.clear();
- }
-
- protected void addInternalErrorMessage(IEJBValidationContext vc, Throwable exc) {
- IMessage mssg = vc.getMessage();
- mssg.setId(IEJBValidatorMessageConstants.CHKJ2900);
- vc.addMessage(mssg);
-
- if(exc != null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, exc);
- }
- }
- }
-
- protected void logMissingRule(IEJBValidationContext vc, Object ruleId) {
- log(vc, ruleId + " = null"); //$NON-NLS-1$
- addInternalErrorMessage(vc, null);
- }
-
- protected void log(IEJBValidationContext vc, String message) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, message);
- }
- }
-
- /*
- * @see IValidationRule#validate(IEJBValidationContext, Object, Object)
- */
- public void validate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException {
- Logger logger = vc.getMsgLogger();
- if(logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("EJBJar20VRule - validate"); //$NON-NLS-1$
- entry.setText(getClass().getName() + "::validate(" + targetParent + ", " + target); //$NON-NLS-1$ //$NON-NLS-2$
- logger.write(Level.FINEST, entry);
- }
-
- EJBJar ejbJar = (EJBJar) target;
- List beans = ejbJar.getEnterpriseBeans();
- Iterator iterator = beans.iterator();
- EnterpriseBean bean = null;
- while (iterator.hasNext()) {
- try {
- bean = (EnterpriseBean) iterator.next();
-
- register(vc, ejbJar, bean);
-
- Object id = null;
- switch(bean.getVersionID()) {
- case J2EEVersionConstants.EJB_1_0_ID:
- case J2EEVersionConstants.EJB_1_1_ID:
- id = IValidationRuleList.EJB11_ENTERPRISEBEAN;
- break;
- case J2EEVersionConstants.EJB_2_0_ID:
- case J2EEVersionConstants.EJB_2_1_ID:
- id = IValidationRuleList.EJB20_ENTERPRISEBEAN;
- break;
- default:
- // What version is it then?
- if(bean instanceof ContainerManagedEntity) {
- validateCMPVersionElement(vc, ejbJar, (ContainerManagedEntity)bean);
- }
- else {
- // log
- log(vc, "!bean.isVersion1_X() && !bean.isVersion2_X()"); //$NON-NLS-1$
- }
- continue;
- }
-
- IValidationRule vRule = EJBValidationRuleFactory.getFactory().getRule(vc, id);
- if(vRule == null) {
- logMissingRule(vc, id);
- continue;
- }
- try {
- vRule.preValidate(vc, ejbJar, bean);
- vRule.validate(vc, ejbJar, bean);
- vRule.postValidate(vc, ejbJar, bean);
- }
- catch(ValidationCancelledException exc) {
- // Clean up the messages which are on the task list? Or is it nicer to leave them behind?
- throw exc;
- }
- catch(ValidationException e) {
- throw e;
- }
- catch(Throwable exc) {
- addInternalErrorMessage(vc, exc);
- }
- finally {
- EJBValidationRuleFactory.getFactory().release(vRule);
- }
-
- }
- catch(ValidationCancelledException e) {
- throw e;
- }
- catch(ValidationException exc) {
- // something goes wrong, just proceed with the next bean
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2852, IEJBValidationContext.WARNING, bean, new String[]{J2EEConstants.EJBJAR_DD_SHORT_NAME, bean.getName()}, this);
- vc.addMessage(message);
- if (logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, exc);
- }
- }
- catch (Throwable exc) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2852, IEJBValidationContext.WARNING, bean, new String[]{J2EEConstants.EJBJAR_DD_SHORT_NAME, bean.getName()}, this);
- vc.addMessage(message);
- if (logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, exc);
- }
- }
- }
-
- // Since the assembly descriptor is not specific to a bean, validate it once, after all bean processing is complete.
- validateAssemblyDescriptorElement(vc, ejbJar);
- //TODO The Datasource validation will be done by the extensions
- validateUniqueEjbNames(vc, ejbJar);
- validateUniqueAbstractSchemaNames(vc, ejbJar);
- validateRelationships(vc, ejbJar);
- validateClientJAR(vc, ejbJar);
- }
-
- protected void register(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- // To check if every bean name is unique, need to build a list
- _ejbName.add(new EjbNameWrapper(bean));
-
- if((bean instanceof ContainerManagedEntity) && bean.getVersionID() >= J2EEVersionConstants.EJB_2_0_ID) {
- // To check if every bean name is unique, need to build a list
- _asName.add(new ASNameWrapper((ContainerManagedEntity)bean));
- }
- }
-
- protected void validateCMPVersionElement(IEJBValidationContext vc, EJBJar ejbJar, ContainerManagedEntity cmp) {
- if(cmp.eIsSet(EjbPackage.eINSTANCE.getContainerManagedEntity_Version())) {
- String version = cmp.getVersion();
- if(! (ContainerManagedEntity.VERSION_1_X.equals(version) || ContainerManagedEntity.VERSION_2_X.equals(version))) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2872, IEJBValidationContext.ERROR, cmp, this);
- vc.addMessage(message);
- }
- }
- }
-
-
-
- protected void validateAssemblyDescriptorElement(IEJBValidationContext vc, EJBJar ejbJar) {
- vc.terminateIfCancelled();
-
- // Validate the security roles, if they're defined in the assembly-descriptor.
- if (ejbJar == null) {
- // nothing to validate
- return;
- }
-
- /**
- * Need to build up a list of duplicate role names, but the validation message
- * needs to be registered against the duplicate SecurityRole instance.
- * (Without the instance, we cannot get line numbers.)
- *
- * This class wrappers the SecurityRol instance so that the wrapper's
- * implemention of equals compares the names, but the validation message will
- * still be able to get the ref from the duplicate name.
- */
- class RoleWrapper {
- private SecurityRole _role = null;
-
- public RoleWrapper(SecurityRole role) {
- _role = role;
- }
-
- public boolean equals(Object o) {
- if (o instanceof RoleWrapper) {
- RoleWrapper other = (RoleWrapper) o;
- return _role.getRoleName().equals(other.getRole().getRoleName());
- }
- return false;
- }
-
- public SecurityRole getRole() {
- return _role;
- }
- }
-
- AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
- if (assemblyDescriptor == null) {
- // nothing to validate
- return;
- }
-
- List roles = assemblyDescriptor.getSecurityRoles();
- if (roles != null) {
- DuplicatesTable roleNames = new DuplicatesTable();
- SecurityRole role = null;
- Iterator roleIt = roles.iterator();
- while (roleIt.hasNext()) {
- vc.terminateIfCancelled();
- // Check that the role-name element has been set
- role = (SecurityRole) roleIt.next();
- if ((role == null) || (!role.eIsSet(CommonPackage.eINSTANCE.getSecurityRole_RoleName())) || (role.getRoleName().equals(""))) { //$NON-NLS-1$
- // role-name not set
- if(role == null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2825, IEJBValidationContext.WARNING, role, this);
- vc.addMessage(message);
- }
- else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2825, IEJBValidationContext.WARNING, assemblyDescriptor, this);
- vc.addMessage(message);
- }
- }
- else {
- // Build up hashtable to check for duplicate role-names.
- roleNames.add(new RoleWrapper(role));
- }
- }
-
- // Check that there are no duplicate role-names. (15.3.1)
- if (roleNames.containsDuplicates()) {
- List duplicates = roleNames.getDuplicates();
- Iterator iterator = duplicates.iterator();
- while (iterator.hasNext()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2826, IEJBValidationContext.WARNING, ((RoleWrapper) iterator.next()).getRole(), this);
- vc.addMessage(message);
- }
- }
- roleNames.clear();
- }
-
- List methTrans = assemblyDescriptor.getMethodTransactions();
- MethodTransaction mt = null;
- Iterator iterator = methTrans.iterator();
- while (iterator.hasNext()) {
- vc.terminateIfCancelled();
-
- try {
- mt = (MethodTransaction) iterator.next();
- }
- catch (Throwable exc) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINER)) {
- logger.write(Level.FINER, exc);
- }
- mt = null;
- }
-
- if (mt == null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("EJBJar20VRule.validateAssemblyDescriptorElement"); //$NON-NLS-1$
- entry.setText("mt is null"); //$NON-NLS-1$
- logger.write(Level.FINEST, entry);
- }
- continue;
- }
-
- boolean hasValidMethod = validateMethodElements(vc, ejbJar, mt.getMethodElements());
- if (!hasValidMethod) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2847, IEJBValidationContext.WARNING, mt, this);
- vc.addMessage(message);
- }
- }
-
- List methodPermissions = assemblyDescriptor.getMethodPermissions();
- iterator = methodPermissions.iterator();
- while (iterator.hasNext()) {
- MethodPermission mp = (MethodPermission) iterator.next();
-
- boolean hasValidMethod = validateMethodElements(vc, ejbJar, mp.getMethodElements());
- if (!hasValidMethod) {
- // 15.3.2, p. 229, a <method-permission> must have at least one method listed (and that method must be found)
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2846, IEJBValidationContext.WARNING, mp, this);
- vc.addMessage(message);
- }
-
- // at least one security-role must be defined
- List mproles = mp.getRoles();
- if (((mproles == null) || (mproles.size() == 0)) && (!mp.isSetUnchecked())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2845, IEJBValidationContext.WARNING, mp, this);
- vc.addMessage(message);
- }
- }
- }
-
- protected void validateUniqueAbstractSchemaNames(IEJBValidationContext vc, EJBJar ejbJar) {
- List names = _asName.getDuplicates();
- if(names.size() == 0) {
- return;
- }
-
- Iterator iterator = names.iterator();
- while(iterator.hasNext()) {
- ASNameWrapper wrapper = (ASNameWrapper)iterator.next();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2854, IEJBValidationContext.ERROR, wrapper.getBean(), new String[]{wrapper.getBean().getAbstractSchemaName()}, this);
- vc.addMessage(message);
- }
- }
-
- protected void validateUniqueEjbNames(IEJBValidationContext vc, EJBJar ejbJar) {
- List names = _ejbName.getDuplicates();
- if(names.size() == 0) {
- return;
- }
-
- Iterator iterator = names.iterator();
- while(iterator.hasNext()) {
- EjbNameWrapper wrapper = (EjbNameWrapper)iterator.next();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2895, IEJBValidationContext.WARNING, wrapper.getBean(), new String[]{wrapper.getBean().getName()}, this);
- vc.addMessage(message);
- }
- }
-
- protected void validateRelationships(IEJBValidationContext vc, EJBJar ejbJar) {
- Relationships relationships = ejbJar.getRelationshipList();
- if(relationships == null) {
- return;
- }
-
- List ejbRelationList = relationships.getEjbRelations();
- Iterator iterator = ejbRelationList.iterator();
- while(iterator.hasNext()) {
- EJBRelation relation = (EJBRelation)iterator.next();
-
- _relationshipName.add(new EJBRelationNameWrapper(relation));
-
- boolean atLeastOneCmrFieldExists = false;
- List roles = relation.getRelationshipRoles();
- Iterator roleIterator = roles.iterator();
- while(roleIterator.hasNext()) {
- EJBRelationshipRole role = (EJBRelationshipRole)roleIterator.next();
-
- _relationshipRoleName.add(new EJBRelationshipRoleNameWrapper(role));
-
- boolean validMultiplicity = role.isSetMultiplicity();
- if(!validMultiplicity) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2818, IEJBValidationContext.INFO, role, this);
- vc.addMessage(message);
- }
-
- // 10.3.4.2
- // The cascade-delete element can only be specified for an ejb-relationship-role
- // element contained in an ejb-relation element if the *other* ejb-relationship-role
- // element in the same ejb-relation element specifies a multiplicity of One.
- EJBRelationshipRole oppositeRole = role.getOpposite();
- if(role.isSetCascadeDelete()) {
- boolean isOtherMultiplicityOne = ((oppositeRole.isSetMultiplicity()) && (oppositeRole.getMultiplicity().getValue() == MultiplicityKind.ONE));
- if(!isOtherMultiplicityOne) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2848, IEJBValidationContext.INFO, role, this);
- vc.addMessage(message);
- }
- }
-
- CMRField cmrField = role.getCmrField();
- if(cmrField != null) {
- atLeastOneCmrFieldExists = true;
- if(cmrField.eIsSet(EjbPackage.eINSTANCE.getCMRField_CollectionType())) {
- String cmrFieldType = cmrField.getCollectionTypeName();
- if((!ITypeConstants.CLASSNAME_JAVA_UTIL_COLLECTION.equals(cmrFieldType)) &&
- (!ITypeConstants.CLASSNAME_JAVA_UTIL_SET.equals(cmrFieldType))) {
- // CHKJ2868: The value of the <cmr-field-type> element must be either "java.util.Collection" or "java.util.Set" (EJB 2.0: 10.3.13, 22.5).
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2868, IEJBValidationContext.INFO, role, this);
- vc.addMessage(message);
- }
- }
- }
-
- RoleSource sourceRoleSource = role.getSource();
- if(sourceRoleSource == null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2821, IEJBValidationContext.INFO, role, new String[]{role.getName()}, this);
- vc.addMessage(message);
- continue;
- }
-
- Entity sourceEntity = sourceRoleSource.getEntityBean();
- if(sourceEntity == null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2821, IEJBValidationContext.INFO, role, new String[]{role.getName()}, this);
- vc.addMessage(message);
- }
- else if(sourceEntity.isContainerManagedEntity()) {
- // CHKJ2866: <cmr-field> {0} must be defined on {1} (EJB 2.0: 22.5).
- if(cmrField != null) {
- ContainerManagedEntity cmp = (ContainerManagedEntity)sourceEntity;
- List cmrFields = cmp.getCMRFields();
- boolean found_cmrField = false;
- if((cmrFields != null) && (cmrFields.size() > 0)) {
- found_cmrField = cmrFields.contains(cmrField);
- }
-
- if(!found_cmrField) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2866, IEJBValidationContext.INFO, role, new String[]{cmrField.getName(), sourceEntity.getName()}, this);
- vc.addMessage(message);
- }
- }
- }
- else {
- // CHKJ2871: <ejb-name> {0} must refer to a CMP bean (EJB 2.0: 10.3.2, 10.3.13).
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2871, IEJBValidationContext.INFO, role, new String[]{sourceEntity.getName()}, this);
- vc.addMessage(message);
- }
-
- if( oppositeRole == null )
- continue;
- RoleSource oppositeRoleSource = oppositeRole.getSource();
- if(oppositeRoleSource == null) {
- // Do not emit an error message - when we iterate to the role where
- // this is the source, this error will be detected.
- continue;
- }
-
- Entity targetEntity = oppositeRoleSource.getEntityBean();
- if(targetEntity == null) {
- // Do not emit an error message - when we iterate to the role where
- // this is the source, this error will be detected.
- }
- else if(targetEntity.getLocalInterface() == null) {
- // Does the target of this role have a local interface?
- // CHKJ2867: This bean can have only unidirectional relationships to other beans (EJB 2.0: 10.3.2).
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2867, IEJBValidationContext.INFO, oppositeRole, this);
- vc.addMessage(message);
- }
- }
-
- // Verify unique role names within the <ejb-relation>
- validateUniqueRelationshipRoleNames(vc, ejbJar);
- _relationshipRoleName.clear();
-
- if(!atLeastOneCmrFieldExists) {
- // CHKJ2869I: At least one <ejb-relationship-role> must define a <cmr-field> (EJB 2.0: 10.3.2, 10.3.13, 22.5).
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2869, IEJBValidationContext.INFO, relation, this);
- vc.addMessage(message);
- }
- }
-
- validateUniqueRelationNames(vc, ejbJar);
- }
-
- protected void validateUniqueRelationNames(IEJBValidationContext vc, EJBJar ejbJar) {
- List names = _relationshipName.getDuplicates();
- if(names.size() == 0) {
- return;
- }
-
- Iterator iterator = names.iterator();
- while(iterator.hasNext()) {
- EJBRelationNameWrapper wrapper = (EJBRelationNameWrapper)iterator.next();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2816, IEJBValidationContext.INFO, wrapper.getRelation(), new String[]{wrapper.getRelation().getName()}, this);
- vc.addMessage(message);
- }
- }
-
- protected void validateUniqueRelationshipRoleNames(IEJBValidationContext vc, EJBJar ejbJar) {
- List names = _relationshipRoleName.getDuplicates();
- if(names.size() == 0) {
- return;
- }
-
- Iterator iterator = names.iterator();
- while(iterator.hasNext()) {
- EJBRelationshipRoleNameWrapper wrapper = (EJBRelationshipRoleNameWrapper)iterator.next();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2817, IEJBValidationContext.INFO, wrapper.getRelationshipRole(), new String[]{wrapper.getRelationshipRole().getName()}, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * Both section 11.4.1 and 15.3.2 need the <method> element. Also refer
- * to 16.5 for syntax.
- *
- * Return true if at least one of the methods referenced by this list of
- * MethodElement can be found.
- */
- protected boolean validateMethodElements(IEJBValidationContext vc, EJBJar ejbJar, List elements) {
- if ((elements == null) || (elements.size() == 0)) {
- return false;
- }
-
- boolean hasValidMethod = false;
- Iterator iterator = elements.iterator();
- while (iterator.hasNext()) {
- vc.terminateIfCancelled();
- MethodElement element = (MethodElement) iterator.next();
-
- EnterpriseBean bean = element.getEnterpriseBean();
- if (bean == null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2814, IEJBValidationContext.WARNING, element, this);
- vc.addMessage(message);
- continue;
- }
-
- if (element.getName() != null) {
- String name = element.getName();
-
- Method[] methods = element.getMethods(); // get all methods which will be retrieved for the given method-permission
- boolean hasMethods = ((methods != null) && (methods.length > 0));
-
- if (!hasMethods) {
- // warning
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2843, IEJBValidationContext.WARNING, element, new String[] { bean.getName()}, this);
- vc.addMessage(message);
- }
- else {
- hasValidMethod = true; // a <method-permission> must have at least one method (15.3.2, p.229)
- if (name.equals("*")) { //$NON-NLS-1$
- List params = element.getMethodParams();
- if ((params != null) && (params.size() > 0)) {
- // warning
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2842, IEJBValidationContext.WARNING, element, this);
- vc.addMessage(message);
- }
- }
- }
- }
- else {
- // error
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2844, IEJBValidationContext.WARNING, element, this);
- vc.addMessage(message);
- }
- }
-
- return hasValidMethod;
- }
-
- protected void validateClientJAR(IEJBValidationContext vc, EJBJar ejbJar) {
- String clientJARName = ejbJar.getEjbClientJar();
- if(clientJARName == null) {
- // No client JAR specified; everything's okay.
- return;
- }
-
- Boolean exists = (Boolean)vc.loadModel(EJBValidatorModelEnum.EJB_CLIENTJAR, new Object[]{clientJARName});
- if(exists == null) {
- // Helper doesn't support load model. WAS?
- // Can't perform this check, so just return.
- return;
- }
-
- if(!exists.booleanValue()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2875, IEJBValidationContext.ERROR, ejbJar, new String[]{clientJARName}, this);
- vc.addMessage(message);
- }
- }
-
- class ASNameWrapper {
- private ContainerManagedEntity _bean = null;
-
- public ASNameWrapper(ContainerManagedEntity bean) {
- _bean = bean;
- }
-
- public boolean equals(Object o) {
- if (o instanceof ASNameWrapper) {
- ASNameWrapper other = (ASNameWrapper)o;
- if((_bean.getAbstractSchemaName() == null) && (other.getBean().getAbstractSchemaName() == null)) {
- return true;
- }
- else if(_bean.getAbstractSchemaName() == null) {
- return false;
- }
- else if(other.getBean().getAbstractSchemaName() == null) {
- return false;
- }
- return _bean.getAbstractSchemaName().equals(other.getBean().getAbstractSchemaName());
- }
- return false;
- }
-
- public int hashCode() {
- if((getBean() != null) && (getBean().getAbstractSchemaName() != null)) {
- return getBean().getAbstractSchemaName().hashCode();
- }
- return super.hashCode();
- }
-
- public ContainerManagedEntity getBean() {
- return _bean;
- }
- }
-
- /**
- * Need to build up a list of duplicate EJB names, but the validation message
- * needs to be registered against the duplicate EnterpriseBean instance.
- * (Without the instance, we cannot get line numbers.)
- *
- * This class wrappers the EnterpriseBean instance so that the wrapper's
- * implemention of equals compares the names, but the validation message will
- * still be able to get the ref from the duplicate name.
- */
- class EjbNameWrapper {
- private EnterpriseBean _bean = null;
-
- public EjbNameWrapper(EnterpriseBean bean) {
- _bean = bean;
- }
-
- public boolean equals(Object o) {
- if (o instanceof EjbNameWrapper) {
- EjbNameWrapper other = (EjbNameWrapper)o;
- if((_bean.getName() == null) && (other.getBean().getName() == null)) {
- return true;
- }
- else if(_bean.getName() == null) {
- return false;
- }
- else if(other.getBean().getName() == null) {
- return false;
- }
- return _bean.getName().equals(other.getBean().getName());
- }
- return false;
- }
-
- public int hashCode() {
- if((getBean() != null) && (getBean().getName() != null)) {
- return getBean().getName().hashCode();
- }
- return super.hashCode();
- }
-
- public EnterpriseBean getBean() {
- return _bean;
- }
- }
-
- /**
- * Need to build up a list of duplicate relation names, but the validation message
- * needs to be registered against the duplicate EnterpriseBean instance.
- * (Without the instance, we cannot get line numbers.)
- *
- * This class wrappers the EnterpriseBean instance so that the wrapper's
- * implemention of equals compares the names, but the validation message will
- * still be able to get the ref from the duplicate name.
- */
- class EJBRelationNameWrapper {
- private EJBRelation _relation = null;
-
- public EJBRelationNameWrapper(EJBRelation rel) {
- _relation = rel;
- }
-
- public boolean equals(Object o) {
- if (o instanceof EJBRelationNameWrapper) {
- EJBRelationNameWrapper other = (EJBRelationNameWrapper)o;
- if((_relation.getName() == null) && (other.getRelation().getName() == null)) {
- return true;
- }
- else if(_relation.getName() == null) {
- return false;
- }
- else if(other.getRelation().getName() == null) {
- return false;
- }
- return _relation.getName().equals(other.getRelation().getName());
- }
- return false;
- }
-
- public int hashCode() {
- if((getRelation() != null) && (getRelation().getName() != null)) {
- return getRelation().getName().hashCode();
- }
- return super.hashCode();
- }
-
- public EJBRelation getRelation() {
- return _relation;
- }
- }
-
- /**
- * Need to build up a list of duplicate relation names, but the validation message
- * needs to be registered against the duplicate EnterpriseBean instance.
- * (Without the instance, we cannot get line numbers.)
- *
- * This class wrappers the EnterpriseBean instance so that the wrapper's
- * implemention of equals compares the names, but the validation message will
- * still be able to get the ref from the duplicate name.
- */
- class EJBRelationshipRoleNameWrapper {
- private EJBRelationshipRole _relationshipRole = null;
-
- public EJBRelationshipRoleNameWrapper(EJBRelationshipRole role) {
- _relationshipRole = role;
- }
-
- public boolean equals(Object o) {
- if (o instanceof EJBRelationshipRoleNameWrapper) {
- EJBRelationshipRoleNameWrapper other = (EJBRelationshipRoleNameWrapper)o;
- if((_relationshipRole.getRoleName() == null) && (other.getRelationshipRole().getRoleName() == null)) {
- return true;
- }
- else if(_relationshipRole.getRoleName() == null) {
- return false;
- }
- else if(other.getRelationshipRole().getRoleName() == null) {
- return false;
- }
- return _relationshipRole.getRoleName().equals(other.getRelationshipRole().getRoleName());
- }
- return false;
- }
-
- public int hashCode() {
- if((getRelationshipRole() != null) && (getRelationshipRole().getRoleName() != null)) {
- return getRelationshipRole().getRoleName().hashCode();
- }
- return super.hashCode();
- }
-
- public EJBRelationshipRole getRelationshipRole() {
- return _relationshipRole;
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidationContext.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidationContext.java
deleted file mode 100644
index 4f8ccdf10..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidationContext.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.core.MessageFilter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/**
- * @version 1.0
- * @author
- */
-public class EJBValidationContext implements IEJBValidationContext {
- private IValidator _validator = null;
- private IValidationContext _helper = null;
- private IReporter _reporter = null;
- private LogEntry logEntry = null;
-// private IMessage _message = null;
-
- public EJBValidationContext(IValidator v, IValidationContext h, IReporter r) {
- setValidator(v);
- setHelper(h);
- setReporter(r);
- }
-
- public IValidator getValidator() {
- return _validator;
- }
-
- public void setValidator(IValidator v) {
- _validator = v;
- }
-
- public IValidationContext getHelper() {
- return _helper;
- }
-
- public void setHelper(IValidationContext h) {
- _helper = h;
- }
-
- public IReporter getReporter() {
- return _reporter;
- }
-
- public void setReporter(IReporter r) {
- _reporter = r;
- }
-
- /*
- * Returns an empty Message which can be reused.
- */
- public IMessage getMessage() {
- IMessage message = new Message();
- message.setBundleName(IEJBValidatorConstants.BUNDLE_NAME);
- return message;
- /*
- if(_message == null) {
- _message = new Message();
- }
-
- reset(_message);
- _message.setBundleName(IEJBValidatorConstants.BUNDLE_NAME);
-
- return _message;
- */
- }
-
- /**
- * If, for performance reasons, an IMessage is reused instead of creating
- * a new one each time, this method resets the internal fields to the default.
- *
- * This method should really be on the IMessage implementation itself, but
- * this'll do for now.
- */
- protected void reset(IMessage message) {
- message.setId(null);
- message.setParams(null);
- message.setSeverity(MessageFilter.ANY_SEVERITY);
- message.setTargetObject(null);
- message.setBundleName(null);
- message.setGroupName(null);
- message.setLineNo(IMessage.LINENO_UNSET);
- message.setOffset(IMessage.OFFSET_UNSET);
- message.setLength(IMessage.OFFSET_UNSET);
- }
-
-
-
- public Logger getMsgLogger() {
- return Logger.getLogger(IEJBValidatorConstants.J2EE_CORE_PLUGIN);
- }
-
- public LogEntry getLogEntry() {
- if(logEntry == null)
- logEntry = new LogEntry(IEJBValidatorConstants.BUNDLE_NAME);
- return logEntry;
- }
-
- public Object loadModel(String symbolicName) {
- return getHelper().loadModel(symbolicName);
- }
-
- public Object loadModel(String symbolicName, Object[] parms) {
- return getHelper().loadModel(symbolicName, parms);
- }
-
- public void removeAllMessages() {
- getReporter().removeAllMessages(getValidator());
- }
-
- public void removeMessages(Object target) {
- getReporter().removeAllMessages(getValidator(), target);
- }
-
- public void removeMessages(Object target, String groupIdentifier) {
- getReporter().removeMessageSubset(getValidator(), target, groupIdentifier);
- }
-
- public void addMessage(IMessage message) {
- if(message == null) {
- return;
- }
- getReporter().addMessage(getValidator(), message);
- }
-
- public void addMessage(int severity, String messageId) {
- IMessage message = new Message(IEJBValidatorConstants.BUNDLE_NAME,severity,messageId);
- getReporter().addMessage(getValidator(), message);
- }
-
- public void addMessage(int severity, String messageId, String[] parms) {
- IMessage message = new Message(IEJBValidatorConstants.BUNDLE_NAME,severity,messageId,parms);
- getReporter().addMessage(getValidator(), message);
- }
-
- public void addMessage(int severity, String messageId, Object target) {
- IMessage message = new Message(IEJBValidatorConstants.BUNDLE_NAME,severity,messageId,null,target);
- getReporter().addMessage(getValidator(), message);
- }
-
- public void addMessage(int severity, String messageId, String[] parms, Object target) {
- IMessage message = new Message(IEJBValidatorConstants.BUNDLE_NAME,severity,messageId,parms,target);
- getReporter().addMessage(getValidator(), message);
- }
-
- public void addMessage(int severity, String messageId, Object target, String groupName) {
- /**
- * 11/28/05 Commenting the following line to get rid of Warning message
- * Quite possibly the getRoporter().addMessage needs to be used.
- *
- */
-
- //IMessage message = new Message(IEJBValidatorConstants.BUNDLE_NAME,severity,messageId,null,target,groupName);
- }
-
- public void addMessage(int severity, String messageId, String[] parms, Object target, String groupName) {
- IMessage message = new Message(IEJBValidatorConstants.BUNDLE_NAME,severity,messageId,parms,target,groupName);
- getReporter().addMessage(getValidator(), message);
- }
-
- public void terminateIfCancelled() throws ValidationCancelledException {
- if(getReporter().isCancelled()) {
- throw new ValidationCancelledException();
- }
- }
-
- public void subtask(String messageId) {
- subtask(messageId, null);
- }
-
- public void subtask(String messageId, String[] parms) {
- if((messageId == null) || (messageId.equals(""))) { //$NON-NLS-1$
- return;
- }
- IMessage message = getMessage();
- message.setId(messageId);
- message.setParams(parms);
- getReporter().displaySubtask(getValidator(), message);
- }
-
- public String[] getURIs() {
- return null;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidationRuleFactory.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidationRuleFactory.java
deleted file mode 100644
index 610ab0322..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidationRuleFactory.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.logging.Level;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-
-/**
- * Core EJB Validation rules
- */
-public class EJBValidationRuleFactory extends AbstractEJBValidationRuleFactory {
- private static EJBValidationRuleFactory _inst = null;
- private Logger logger = null;
-
- public EJBValidationRuleFactory() {
- createRuleList();
- }
-
- public static EJBValidationRuleFactory getFactory() {
- if(_inst == null) {
- _inst = new EJBValidationRuleFactory();
- }
- return _inst;
- }
- protected Logger getMsgLogger(){
- if(logger == null)
- logger = Logger.getLogger(IEJBValidatorConstants.J2EE_CORE_PLUGIN);
- return logger;
- }
- private void createRuleList() {
- _ruleList = new HashMap();
-
- _ruleList.put(IValidationRuleList.EJB11_EJBJAR, new org.eclipse.jst.j2ee.model.internal.validation.EJBJar11VRule());
- _ruleList.put(IValidationRuleList.EJB20_EJBJAR, new org.eclipse.jst.j2ee.model.internal.validation.EJBJar20VRule());
-
- _ruleList.put(IValidationRuleList.EJB11_ENTERPRISEBEAN, new org.eclipse.jst.j2ee.model.internal.validation.EnterpriseBean11VRule());
- _ruleList.put(IValidationRuleList.EJB20_ENTERPRISEBEAN, new org.eclipse.jst.j2ee.model.internal.validation.EnterpriseBean20VRule());
-
- _ruleList.put(IValidationRuleList.EJB11_SESSION_BEANCLASS, new org.eclipse.jst.j2ee.model.internal.validation.ValidateSessionBean());
- _ruleList.put(IValidationRuleList.EJB11_SESSION_REMOTE, new org.eclipse.jst.j2ee.model.internal.validation.ValidateSessionRemote());
- _ruleList.put(IValidationRuleList.EJB11_SESSION_HOME, new org.eclipse.jst.j2ee.model.internal.validation.ValidateSessionHome());
-
- _ruleList.put(IValidationRuleList.EJB20_STATELESS_SESSION_BEANCLASS, new org.eclipse.jst.j2ee.model.internal.validation.StatelessSessionBeanClassVRule());
- _ruleList.put(IValidationRuleList.EJB20_STATELESS_SESSION_REMOTE, new org.eclipse.jst.j2ee.model.internal.validation.StatelessSessionRemoteComponentVRule());
- _ruleList.put(IValidationRuleList.EJB20_STATELESS_SESSION_HOME, new org.eclipse.jst.j2ee.model.internal.validation.StatelessSessionRemoteHomeVRule());
- _ruleList.put(IValidationRuleList.EJB20_STATELESS_SESSION_LOCAL, new org.eclipse.jst.j2ee.model.internal.validation.StatelessSessionLocalComponentVRule());
- _ruleList.put(IValidationRuleList.EJB20_STATELESS_SESSION_LOCALHOME, new org.eclipse.jst.j2ee.model.internal.validation.StatelessSessionLocalHomeVRule());
-
- _ruleList.put(IValidationRuleList.EJB20_STATEFUL_SESSION_BEANCLASS, new org.eclipse.jst.j2ee.model.internal.validation.StatefulSessionBeanClassVRule());
- _ruleList.put(IValidationRuleList.EJB20_STATEFUL_SESSION_REMOTE, new org.eclipse.jst.j2ee.model.internal.validation.StatefulSessionRemoteComponentVRule());
- _ruleList.put(IValidationRuleList.EJB20_STATEFUL_SESSION_HOME, new org.eclipse.jst.j2ee.model.internal.validation.StatefulSessionRemoteHomeVRule());
- _ruleList.put(IValidationRuleList.EJB20_STATEFUL_SESSION_LOCAL, new org.eclipse.jst.j2ee.model.internal.validation.StatefulSessionLocalComponentVRule());
- _ruleList.put(IValidationRuleList.EJB20_STATEFUL_SESSION_LOCALHOME, new org.eclipse.jst.j2ee.model.internal.validation.StatefulSessionLocalHomeVRule());
-
- _ruleList.put(IValidationRuleList.EJB11_CMP_BEANCLASS, new org.eclipse.jst.j2ee.model.internal.validation.ValidateCMPBean());
- _ruleList.put(IValidationRuleList.EJB11_CMP_REMOTE, new org.eclipse.jst.j2ee.model.internal.validation.ValidateCMPRemote());
- _ruleList.put(IValidationRuleList.EJB11_CMP_KEYCLASS, new org.eclipse.jst.j2ee.model.internal.validation.ValidateCMPKey());
-
- _ruleList.put(IValidationRuleList.EJB20_CMP_BEANCLASS, new org.eclipse.jst.j2ee.model.internal.validation.CMPBeanClassVRule());
- _ruleList.put(IValidationRuleList.EJB20_CMP_REMOTE, new org.eclipse.jst.j2ee.model.internal.validation.CMPRemoteComponentVRule());
- _ruleList.put(IValidationRuleList.EJB20_CMP_HOME, new org.eclipse.jst.j2ee.model.internal.validation.CMPRemoteHomeVRule());
- _ruleList.put(IValidationRuleList.EJB20_CMP_LOCAL, new org.eclipse.jst.j2ee.model.internal.validation.CMPLocalComponentVRule());
- _ruleList.put(IValidationRuleList.EJB20_CMP_LOCALHOME, new org.eclipse.jst.j2ee.model.internal.validation.CMPLocalHomeVRule());
- _ruleList.put(IValidationRuleList.EJB20_CMP_KEYCLASS, new org.eclipse.jst.j2ee.model.internal.validation.CMPKeyClassVRule());
-
- _ruleList.put(IValidationRuleList.EJB11_BMP_BEANCLASS, new org.eclipse.jst.j2ee.model.internal.validation.ValidateBMPBean());
- _ruleList.put(IValidationRuleList.EJB11_BMP_REMOTE, new org.eclipse.jst.j2ee.model.internal.validation.ValidateBMPRemote());
- _ruleList.put(IValidationRuleList.EJB11_BMP_HOME, new org.eclipse.jst.j2ee.model.internal.validation.ValidateBMPHome());
- _ruleList.put(IValidationRuleList.EJB11_BMP_KEYCLASS, new org.eclipse.jst.j2ee.model.internal.validation.ValidateBMPKey());
-
- _ruleList.put(IValidationRuleList.EJB20_BMP_BEANCLASS, new org.eclipse.jst.j2ee.model.internal.validation.BMPBeanClassVRule());
- _ruleList.put(IValidationRuleList.EJB20_BMP_REMOTE, new org.eclipse.jst.j2ee.model.internal.validation.BMPRemoteComponentVRule());
- _ruleList.put(IValidationRuleList.EJB20_BMP_HOME, new org.eclipse.jst.j2ee.model.internal.validation.BMPRemoteHomeVRule());
- _ruleList.put(IValidationRuleList.EJB20_BMP_LOCAL, new org.eclipse.jst.j2ee.model.internal.validation.BMPLocalComponentVRule());
- _ruleList.put(IValidationRuleList.EJB20_BMP_LOCALHOME, new org.eclipse.jst.j2ee.model.internal.validation.BMPLocalHomeVRule());
- _ruleList.put(IValidationRuleList.EJB20_BMP_KEYCLASS, new org.eclipse.jst.j2ee.model.internal.validation.BMPKeyClassVRule());
-
- _ruleList.put(IValidationRuleList.EJB20_MESSAGE_BEANCLASS, new org.eclipse.jst.j2ee.model.internal.validation.MessageDrivenBeanClassVRule());
-
- addDependentRuleToRuleList();
- logAllDependentRules();
- }
-
- /**
- * If the IFileDelta represents a static load model (i.e., the file name is always the same),
- * then return the Integer which loads that model. Otherwise return null.
- */
- public Object getRuleId(IEJBValidationContext vc, String fileName) {
- if(fileName == null) {
- Logger aLogger = vc.getMsgLogger();
- if (aLogger != null && aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule from fileName: " + fileName); //$NON-NLS-1$
- }
- return null;
- }
-
- EJBJar ejbJar = getEJBJar(vc);
-
- if(fileName.endsWith(J2EEConstants.EJBJAR_DD_SHORT_NAME)) {
- if(ejbJar.getVersionID() == J2EEVersionConstants.EJB_1_1_ID) {
- return IValidationRuleList.EJB11_EJBJAR;
- }
- return IValidationRuleList.EJB20_EJBJAR;
- }
- return null; // must be a JavaClass
- }
-
- /**
- * If the IFileDelta represents a dynamic load model (i.e., the file name can be changed by the
- * user), then return the Integer which loads that model. Return null if no such model exists.
- */
- public final Object getRuleId(IEJBValidationContext vc, JavaClass clazz, EnterpriseBean bean) {
- // Return the rule id which will validate the JavaClass as the
- // type which it is used as by the EnterpriseBean.
- if((clazz == null) || (bean == null)) {
- Logger aLogger = vc.getMsgLogger();
- if (aLogger != null && aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule because either bean (" + bean + ") or class (" + clazz + ") is null"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- return null;
- }
-
- boolean isStatelessSession = (bean.isSession() && ValidationRuleUtility.isStateless(bean));
- boolean isStatefulSession = (bean.isSession() && ValidationRuleUtility.isStateful(bean));
-
- if(bean.getVersionID() >= J2EEVersionConstants.EJB_2_0_ID) {
- if(clazz.equals(bean.getEjbClass())) {
- if(isStatelessSession) {
- return IValidationRuleList.EJB20_STATELESS_SESSION_BEANCLASS;
- }
- else if(isStatefulSession) {
- return IValidationRuleList.EJB20_STATEFUL_SESSION_BEANCLASS;
- }
- else if(bean.isContainerManagedEntity()) {
- return IValidationRuleList.EJB20_CMP_BEANCLASS;
- }
- else if(bean.isBeanManagedEntity()) {
- return IValidationRuleList.EJB20_BMP_BEANCLASS;
- }
- else if(bean.isMessageDriven()) {
- return IValidationRuleList.EJB20_MESSAGE_BEANCLASS;
- }
- else {
- Logger aLogger = vc.getMsgLogger();
- if (aLogger != null && aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule: bean.isVersion2_X() && clazz.equals(bean.getEjbClass()"); //$NON-NLS-1$
- }
-
- return null;
- }
- }
- else if(clazz.equals(bean.getRemoteInterface())) {
- if(isStatelessSession) {
- return IValidationRuleList.EJB20_STATELESS_SESSION_REMOTE;
- }
- else if(isStatefulSession) {
- return IValidationRuleList.EJB20_STATEFUL_SESSION_REMOTE;
- }
- else if(bean.isContainerManagedEntity()) {
- return IValidationRuleList.EJB20_CMP_REMOTE;
- }
- else if(bean.isBeanManagedEntity()) {
- return IValidationRuleList.EJB20_BMP_REMOTE;
- }
- else {
- Logger aLogger = vc.getMsgLogger();
- if (aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule: bean.isVersion2_X() && clazz.equals(bean.getRemoteInterface()"); //$NON-NLS-1$
- }
- return null;
- }
- }
- else if(clazz.equals(bean.getHomeInterface())) {
- if(isStatelessSession) {
- return IValidationRuleList.EJB20_STATELESS_SESSION_HOME;
- }
- else if(isStatefulSession) {
- return IValidationRuleList.EJB20_STATEFUL_SESSION_HOME;
- }
- else if(bean.isContainerManagedEntity()) {
- return IValidationRuleList.EJB20_CMP_HOME;
- }
- else if(bean.isBeanManagedEntity()) {
- return IValidationRuleList.EJB20_BMP_HOME;
- }
- else {
- Logger aLogger = vc.getMsgLogger();
- if (aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule: bean.isVersion2_X() && clazz.equals(bean.getHomeInterface()"); //$NON-NLS-1$
- }
- return null;
- }
- }
- else if(clazz.equals(bean.getLocalHomeInterface())) {
- if(isStatelessSession) {
- return IValidationRuleList.EJB20_STATELESS_SESSION_LOCALHOME;
- }
- else if(isStatefulSession) {
- return IValidationRuleList.EJB20_STATEFUL_SESSION_LOCALHOME;
- }
- else if(bean.isContainerManagedEntity()) {
- return IValidationRuleList.EJB20_CMP_LOCALHOME;
- }
- else if(bean.isBeanManagedEntity()) {
- return IValidationRuleList.EJB20_BMP_LOCALHOME;
- }
- else {
- Logger aLogger = vc.getMsgLogger();
- if (aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule: bean.isVersion2_X() && clazz.equals(bean.getLocalHomeInterface()"); //$NON-NLS-1$
- }
- return null;
- }
- }
- else if(clazz.equals(bean.getLocalInterface())) {
- if(isStatelessSession) {
- return IValidationRuleList.EJB20_STATELESS_SESSION_LOCAL;
- }
- else if(isStatefulSession) {
- return IValidationRuleList.EJB20_STATEFUL_SESSION_LOCAL;
- }
- else if(bean.isContainerManagedEntity()) {
- return IValidationRuleList.EJB20_CMP_LOCAL;
- }
- else if(bean.isBeanManagedEntity()) {
- return IValidationRuleList.EJB20_BMP_LOCAL;
- }
- else {
- Logger aLogger = vc.getMsgLogger();
- if (aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule: bean.isVersion2_X() && clazz.equals(bean.getLocalInterface()"); //$NON-NLS-1$
- }
- return null;
- }
- }
- else if(bean instanceof Entity) {
- if(clazz.equals(((Entity)bean).getPrimaryKey())) {
- if(bean.isContainerManagedEntity()) {
- ContainerManagedEntity cmp = (ContainerManagedEntity)bean;
- // If it's a primitive primary key, it's exempt from these checks.
- if(ValidationRuleUtility.isPrimitivePrimaryKey(cmp)) {
- return null;
- }
- else if(ValidationRuleUtility.usesUnknownPrimaryKey(cmp)) {
- return null;
- }
- return IValidationRuleList.EJB20_CMP_KEYCLASS;
- }
- else if(bean.isBeanManagedEntity()) {
- return IValidationRuleList.EJB20_BMP_KEYCLASS;
- }
- else {
- Logger aLogger = vc.getMsgLogger();
- if (aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule: bean.isVersion2_X() && clazz.equals(((Entity)bean).getPrimaryKey()"); //$NON-NLS-1$
- }
- return null;
- }
- }
- }
-
- Logger aLogger = vc.getMsgLogger();
- if (aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule: bean.isVersion2_X()"); //$NON-NLS-1$
- }
- return null;
- }
- else if(bean.getVersionID() <= J2EEVersionConstants.EJB_1_1_ID) {
- if(clazz.equals(bean.getEjbClass())) {
- if(bean.isSession()) {
- return IValidationRuleList.EJB11_SESSION_BEANCLASS;
- }
- else if(bean.isContainerManagedEntity()) {
- return IValidationRuleList.EJB11_CMP_BEANCLASS;
- }
- else if(bean.isBeanManagedEntity()) {
- return IValidationRuleList.EJB11_BMP_BEANCLASS;
- }
- else {
- Logger aLogger = vc.getMsgLogger();
- if (aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule: bean.isVersion1_X() && clazz.equals(bean.getEjbClass()"); //$NON-NLS-1$
- }
- return null;
- }
- }
- else if(clazz.equals(bean.getRemoteInterface())) {
- if(bean.isSession()) {
- return IValidationRuleList.EJB11_SESSION_REMOTE;
- }
- else if(bean.isContainerManagedEntity()) {
- return IValidationRuleList.EJB11_CMP_REMOTE;
- }
- else if(bean.isBeanManagedEntity()) {
- return IValidationRuleList.EJB11_BMP_REMOTE;
- }
- else {
- Logger aLogger = vc.getMsgLogger();
- if (aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule: bean.isVersion1_X() && clazz.equals(bean.getRemoteInterface()"); //$NON-NLS-1$
- }
- return null;
- }
- }
- else if(clazz.equals(bean.getHomeInterface())) {
- if(bean.isSession()) {
- return IValidationRuleList.EJB11_SESSION_HOME;
- }
- else if(bean.isContainerManagedEntity()) {
- return IValidationRuleList.EJB11_CMP_HOME;
- }
- else if(bean.isBeanManagedEntity()) {
- return IValidationRuleList.EJB11_BMP_HOME;
- }
- else {
- Logger aLogger = vc.getMsgLogger();
- if (aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule: bean.isVersion1_X() && clazz.equals(bean.getHomeInterface()"); //$NON-NLS-1$
- }
- return null;
- }
- }
- else if(bean instanceof Entity) {
- if(clazz.equals(((Entity)bean).getPrimaryKey())) {
- if(bean.isContainerManagedEntity()) {
- ContainerManagedEntity cmp = (ContainerManagedEntity)bean;
- // If it's a primitive primary key, it's exempt from these checks.
- if(ValidationRuleUtility.isPrimitivePrimaryKey(cmp)) {
- return null;
- }
- else if(ValidationRuleUtility.usesUnknownPrimaryKey(cmp)) {
- return null;
- }
- return IValidationRuleList.EJB11_CMP_KEYCLASS;
- }
- else if(bean.isBeanManagedEntity()) {
- return IValidationRuleList.EJB11_BMP_KEYCLASS;
- }
- else {
- Logger aLogger = vc.getMsgLogger();
- if (aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule: bean.isVersion1_X() && clazz.equals(((Entity)bean).getPrimaryKey()"); //$NON-NLS-1$
- }
- return null;
- }
- }
- }
- }
-
- Logger aLogger = vc.getMsgLogger();
- if (aLogger.isLoggingLevel(Level.FINE)) {
- aLogger.write(Level.FINE, "Cannot load rule: !bean.isVersion1_X() && !bean.isVersion2_X()"); //$NON-NLS-1$
- }
- return null;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidator.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidator.java
deleted file mode 100644
index 13726a4d4..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidator.java
+++ /dev/null
@@ -1,529 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.operations.WorkbenchReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-
-/**
- * @version 1.0
- * @author
- */
-public class EJBValidator extends AbstractEJBValidator {
- private static EJBValidator _inst = null;
- private static TargetObjectPool _targetObjectPoolSingleton = null;
- private LogEntry logEntry = null;
-
-
- public EJBValidator() {
- _inst = this;
- }
-
- public static EJBValidator getValidator() {
- return _inst;
- }
-
- private LogEntry getLogEntry(){
- if(logEntry == null)
- logEntry = new LogEntry(IEJBValidatorConstants.BUNDLE_NAME);
- return logEntry;
- }
-
- public String getBaseName() {
- return "ejbvalidator"; //$NON-NLS-1$
- }
-
- public void commonValidate(IValidationContext helper, IReporter reporter) throws ValidationException {
- long start = System.currentTimeMillis();
- Logger logger = Logger.getLogger(IEJBValidatorConstants.J2EE_CORE_PLUGIN);
- if (logger != null && logger.isLoggingLevel(Level.FINER)) {
- long end = System.currentTimeMillis();
- LogEntry entry = getLogEntry();
- entry.setSourceID("EJBValidator::validate"); //$NON-NLS-1$
- entry.setText("validate took " + (end - start) + " milliseconds."); //$NON-NLS-1$ //$NON-NLS-2$
- logger.write(Level.FINER, entry);
- }
- try {
- EJBValidationContext vc = new EJBValidationContext(this, helper, reporter);
- setValidationContext(vc);
- if (isFullValidate(vc)) {
- fullValidate(vc);
- } else {
- incrementalValidate(vc);
- }
- if (logger != null && logger.isLoggingLevel(Level.FINER)) {
- long end = System.currentTimeMillis();
- LogEntry entry = getLogEntry();
- entry.setSourceID("EJBValidator::validate"); //$NON-NLS-1$
- entry.setText("validate took " + (end - start) + " milliseconds."); //$NON-NLS-1$ //$NON-NLS-2$
- logger.write(Level.FINER, entry);
- }
- } finally {
-
- }
- }
-
-
- public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
- commonValidate(helper, reporter);
- }
- /*
- * @see IValidator#validate(IValidationContext, IReporter, IFileDelta[])
- */
- public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws ValidationException {
- commonValidate(helper, reporter);
- return status;
- }
-
- public boolean isFullValidate(IEJBValidationContext vc) {
- String[] fileURIs = vc.getURIs();
- if(fileURIs == null) {
- return true;
- }
- if(fileURIs.length == 0) {
- return true;
- }
-
- for(int i=0; i<fileURIs.length; i++) {
- String uri = fileURIs[i];
- if(uri.endsWith(J2EEConstants.EJBJAR_DD_SHORT_NAME)) {
- return true;
- }
- }
-
- return false;
- }
-
- public void runDependents(IEJBValidationContext vc, IValidationRule rule, Object targetParent, Object target) throws ValidationException {
- // If a class is being run only because it depends on a rule which has changed,
- // i.e., it's a dependent, then we don't want to run its dependents because the
- // class itself hasn't changed.
- Set dependents = rule.getDependents();
- if(dependents == null) {
- return;
- }
-
- Iterator iterator = dependents.iterator();
- while(iterator.hasNext()) {
- try {
- IValidationRule dRule = (IValidationRule)iterator.next();
- Object dRuleTarget = dRule.getTarget(targetParent, target);
- if(dRuleTarget != null) {
- run(dRule, targetParent, dRuleTarget); // false=not full validation
- }
- }
- catch(ValidationCancelledException e) {
- throw e;
- }
- catch(ValidationException e) {
- throw e;
- }
- catch(Throwable exc) {
- addInternalErrorMessage(getValidationContext(), exc);
- }
- finally {
- EJBValidationRuleFactory.getFactory().release(rule);
- }
- }
- }
-
- protected String internalErrorMessage() {
- return IEJBValidatorMessageConstants.CHKJ2900;
- }
-
-
-
- protected void logMissingRule(IEJBValidationContext vc, Object ruleId) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, ruleId + " = null"); //$NON-NLS-1$
- }
- addInternalErrorMessage(vc);
- }
-
- protected void preRemoveOldMessages(IEJBValidationContext vc, Map targets) throws ValidationException {
- List validatedClasses = new ArrayList();
-
- try {
- String[] uris = vc.getURIs();
- for(int i=0; i<uris.length; i++) {
- String uriInst = uris[i];
- if((uriInst == null) || (uriInst.length() == 0)) {
- continue;
- }
-
- Object id = EJBValidationRuleFactory.getFactory().getRuleId(vc, uriInst);
- if(id == null) {
- Object[] clazzAndBean = (Object[])vc.loadModel(uriInst, null); // Don't need a second parameter, but can't cast a RefObject to an Object[], so use the second load method.
- if(clazzAndBean == null) {
- // Log, add "Cannot validate" to task list, and return.
- logMissingRule(vc, id);
- continue;
- }
-
- // In the clazzAndBean object array, the first entry is the JavaClass,
- // and the rest of the entries are the EnterpriseBean instances which
- // use the JavaClass.
- JavaClass clazz = (JavaClass)clazzAndBean[0];
- List beans = (List)clazzAndBean[1];
-
- // The validatedClass set keeps track of JavaClasses
- // that have changed, and this set is used to determine
- // whose children need to be found and validated.
- // Validation is performed after all of the changed files
- // are validated so that all of the children of all of
- // the changed files can be searched for at once. Searching
- // once on a group produces performance savings because
- // the type hierarchy method takes a non-trivial amount
- // of time when there's a large group of deltas.
- validatedClasses.add(clazz);
-
- if((beans == null) || (beans.size() == 0)) {
- // The JavaClass itself is not part of an enterprise bean, but one of its children may be.
- }
- else {
- Iterator iterator = beans.iterator();
- while(iterator.hasNext()) {
- EnterpriseBean bean = (EnterpriseBean)iterator.next();
- id = EJBValidationRuleFactory.getFactory().getRuleId(vc, clazz, bean);
-
- IValidationRule clazzRule = EJBValidationRuleFactory.getFactory().getRule(vc, id);
- if(clazzRule == null) {
- // This has already been logged by the AbstractEJBValidationRuleFactory (if it's
- // an error - this is expected if the key is a primitive primary key).
- continue;
- }
-
- setValidated(clazzRule.getId(), bean, clazz);
- }
- }
-
- }
- else {
- EJBJar ejbJar = (EJBJar)vc.loadModel(EJBValidatorModelEnum.EJB_MODEL);
- if(ejbJar == null) {
- // Log, add "Cannot validate" to task list, and return.
- continue;
- }
-
- IValidationRule ejbExtRule = EJBValidationRuleFactory.getFactory().getRule(vc, id);
- if(ejbExtRule == null) {
- // This has already been logged by the AbstractEJBValidationRuleFactory, so just
- // need to add "Cannot validate" to the task list.
- continue;
- }
-
- setValidated(ejbExtRule.getId(), null, ejbJar);
- }
- } // end for
-
- // Always validate ejb-jar.xml, because a change to one of the files it references
- // may mean that it needs to be revalidated.
- EJBJar ejbJar = (EJBJar)vc.loadModel(EJBValidatorModelEnum.EJB_MODEL);
- if(ejbJar != null) {
- Object id = EJBValidationRuleFactory.getFactory().getRuleId(vc, J2EEConstants.EJBJAR_DD_SHORT_NAME);
- if(id == null) {
- // Log, add "Cannot validate" to task list, and return.
- logMissingRule(vc, id);
- }
- else {
- IValidationRule ejbJarRule = EJBValidationRuleFactory.getFactory().getRule(vc, id);
- if(ejbJarRule == null) {
- logMissingRule(vc, id);
- }
- setValidated(ejbJarRule.getId(), null, ejbJar);
- }
- }
-
- if(validatedClasses.size() > 0) {
- // Check the children of the changed classes.
- // This check must be done before the dependents, because
- // the dependents of the children classes must be checked
- // as well.
-
- // Class never validated before, so check its children
- for (int vC = 0; vC<validatedClasses.size(); vC++) {
- List beans = (List)vc.loadModel(EJBValidatorModelEnum.EJB, new Object[]{validatedClasses.get(vC)});
- if((beans == null) || (beans.size() == 0)) {
- // The class is not a member of an enterprise bean.
- continue;
- }
- Set rootValidatedClass = new HashSet();
- rootValidatedClass.add(validatedClasses.get(vC));
- JavaClass[] children = (JavaClass[])vc.loadModel(EJBValidatorModelEnum.CHILDREN, new Object[]{vc.getReporter(), rootValidatedClass});
- if((children != null) && (children.length > 0)) {
- Iterator bciterator = null;
- Object id = null;
- for(int c=0; c<children.length; c++) {
- JavaClass child = children[c];
- beans = (List)vc.loadModel(EJBValidatorModelEnum.EJB, new Object[]{child});
- // The child is not a member of an enterprise bean.
- if((beans == null) || (beans.size() == 0))
- continue;
- bciterator = beans.iterator();
- while(bciterator.hasNext()) {
- EnterpriseBean bean = (EnterpriseBean)bciterator.next();
- id = EJBValidationRuleFactory.getFactory().getRuleId(vc, child, bean);
- IValidationRule clazzRule = EJBValidationRuleFactory.getFactory().getRule(vc, id);
- // This has already been logged by the AbstractEJBValidationRuleFactory, so just need to add "Cannot validate" to the task list.
- if(clazzRule == null)
- continue;
- setValidated(clazzRule.getId(), bean, child);
- }
- }
- }
- }
- validatedClasses.clear(); // Don't need this cache any more; free the memory.
- }
-
- // Now, validate the dependents.
- targets.putAll(_validated);
- Iterator iterator = targets.keySet().iterator();
- while(iterator.hasNext()) {
- Object id = iterator.next();
- IValidationRule rule = EJBValidationRuleFactory.getFactory().getRule(vc, id);
- if(rule == null) {
- continue;
- }
-
- Set contexts = (Set)targets.get(id);
- if(contexts == null) {
- continue;
- }
-
- Iterator cIterator = contexts.iterator();
- while(cIterator.hasNext()) {
- TargetObject to = (TargetObject)cIterator.next();
- Object targetParent = to.getTargetParent();
- Object target = to.getTarget();
- Set dependents = rule.getDependents();
- if(dependents == null) {
- continue;
- }
-
- Iterator dIterator = dependents.iterator();
- while(dIterator.hasNext()) {
- try {
- IValidationRule dRule = (IValidationRule)dIterator.next();
- Object dRuleTarget = dRule.getTarget(targetParent, target);
- if(dRuleTarget != null) {
- setValidated(dRule.getId(), targetParent, dRuleTarget);
- }
- }
- catch(ValidationCancelledException e) {
- throw e;
- }
- catch(Throwable exc) {
- addInternalErrorMessage(getValidationContext(), exc);
- }
- finally {
- EJBValidationRuleFactory.getFactory().release(rule);
- }
- }
- }
- }
- }
- finally {
- // No matter what, clear the temporary caches.
- targets.clear();
- validatedClasses.clear();
-
- // Now put the "validated" results in "done", because they weren't
- // really validated; it was just a tracking mechanism.
- targets.putAll(_validated);
- _validated.clear(); // Clear the "validated" cache because the targets weren't really validated; they were just tracked.
- }
- }
-
- protected String removeOldMessagesString() {
- return EJBValidatorModelEnum.REMOVE_OLD_MESSAGES;
- }
-
- public void fullValidate(IEJBValidationContext vc) throws ValidationException {
- removeOldMessages(vc,null); // null == no IFileDelta, null = don't track targets
-
-
- EJBJar ejbJar = (EJBJar)vc.loadModel(EJBValidatorModelEnum.EJB_MODEL);
- if(ejbJar == null) {
- // Log, add "Cannot validate" to task list, and return.
- // EJBProjectResources will already have logged the problem.
-
- IMessage mssg = vc.getMessage();
- mssg.setId(IEJBValidatorMessageConstants.CHKJ2905);
- vc.addMessage(mssg);
- return;
- }
-
- Object id = EJBValidationRuleFactory.getFactory().getRuleId(vc, J2EEConstants.EJBJAR_DD_SHORT_NAME);
- if(id == null) {
- // Log, add "Cannot validate" to task list, and return.
- logMissingRule(vc, J2EEConstants.EJBJAR_DD_SHORT_NAME);
- return;
- }
- IValidationRule ejbJarRule = EJBValidationRuleFactory.getFactory().getRule(vc, id);
- if(ejbJarRule == null) {
- logMissingRule(vc, id);
- return;
- }
- run(ejbJarRule, null, ejbJar); // true= full validation
-
- List beans = ejbJar.getEnterpriseBeans();
- Iterator iterator = beans.iterator();
- id = null;
-
- while(iterator.hasNext()) {
- EnterpriseBean bean = (EnterpriseBean)iterator.next();
- JavaClass[] classes = getJavaClass(bean);
- for(int i=0; i<classes.length; i++) {
- JavaClass clazz = classes[i];
- id = EJBValidationRuleFactory.getFactory().getRuleId(vc, clazz, bean);
-
- IValidationRule clazzRule = EJBValidationRuleFactory.getFactory().getRule(vc, id);
- if(clazzRule == null) {
- // This has already been logged by the AbstractEJBValidationRuleFactory (if it's
- // an error - this is expected if the key is a primitive primary key).
- continue;
- }
-
- run(clazzRule, bean, clazz); // true = full validation
- }
- }
- }
-
- protected JavaClass[] getJavaClass(EnterpriseBean bean) {
- int count = 0;
- JavaClass[] classes = new JavaClass[6];
-
- JavaClass ejbClass = bean.getEjbClass();
- if((ejbClass != null) && (ejbClass.isExistingType())) {
- classes[count++] = ejbClass;
- }
-
- JavaClass remoteClass = bean.getRemoteInterface();
- if((remoteClass != null) && (remoteClass.isExistingType())) {
- classes[count++] = remoteClass;
- }
-
- JavaClass localClass = bean.getLocalInterface();
- if((localClass != null) && (localClass.isExistingType())) {
- classes[count++] = localClass;
- }
-
- JavaClass homeClass = bean.getHomeInterface();
- if((homeClass != null) && (homeClass.isExistingType())) {
- classes[count++] = homeClass;
- }
-
- JavaClass localHomeClass = bean.getLocalHomeInterface();
- if((localHomeClass != null) && (localHomeClass.isExistingType())) {
- classes[count++] = localHomeClass;
- }
-
- if(bean instanceof Entity) {
- JavaClass key = ((Entity)bean).getPrimaryKey();
- if((key != null) && (key.isExistingType())) {
- classes[count++] = key;
- }
- }
-
- if(count == 6) {
- return classes;
- }
-
- JavaClass[] result = new JavaClass[count];
- System.arraycopy(classes, 0, result, 0, count);
- return result;
- }
-
- public void incrementalValidate(IEJBValidationContext vc) throws ValidationException {
- Map targets = new HashMap();
- try {
- removeOldMessages(vc,targets);
-
- Iterator iterator = targets.keySet().iterator();
- while(iterator.hasNext()) {
- Object id = iterator.next();
- IValidationRule rule = EJBValidationRuleFactory.getFactory().getRule(vc, id);
- if(rule == null) {
- continue;
- }
-
- Set contexts = (Set)targets.get(id);
- if(contexts == null) {
- continue;
- }
-
- Iterator cIterator = contexts.iterator();
- while(cIterator.hasNext()) {
- TargetObject to = (TargetObject)cIterator.next();
- run(rule, to.getTargetParent(), to.getTarget());
- }
- }
- }
- finally {
- targets.clear();
- targets = null;
- }
- }
-
- protected TargetObjectPool getTargetObjectPool() {
- if(_targetObjectPoolSingleton == null) {
- _targetObjectPoolSingleton = new TargetObjectPool(100);
- }
- return _targetObjectPoolSingleton;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.model.validation.AbstractEJBValidator#releaseRules(org.eclipse.jst.j2ee.internal.model.validation.ejb.IValidationRule)
- */
- protected void releaseRules(IValidationRule rule) {
- EJBValidationRuleFactory.getFactory().release(rule);
-
- }
-
- public ISchedulingRule getSchedulingRule(IValidationContext helper) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void cleanup(IReporter reporter){
- if( reporter instanceof WorkbenchReporter ){
- WorkbenchReporter wbReporter = (WorkbenchReporter)reporter;
- IProject project = wbReporter.getProject();
- HashMap helperMap = ValidationRuleUtility.getHelperMap(project);
- helperMap.clear();
- ValidationRuleUtility.projectHelperMap.remove( helperMap );
- helperMap = null;
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidatorModelEnum.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidatorModelEnum.java
deleted file mode 100644
index 68824609b..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EJBValidatorModelEnum.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-/**
- * This interface contains the symbolic names of the models which the
- * EJBValidator needs, and the IValidationContext that is used in the EJBValidator's
- * validate method must support these symbolic names.
- */
-public interface EJBValidatorModelEnum {
- public final static String EJB_MODEL = "EJB_MODEL"; // return an EJBJar object //$NON-NLS-1$
- public final static String EJB_FILE = "EJB_FILE"; // return a ModuleFile object (either EJBJarFile or EARFile) //$NON-NLS-1$
- public final static String EJB = "EJB"; // Given a JavaClass instance, return a java.util.List of EnterpriseBean instances that use that JavaClass as part of the bean. //$NON-NLS-1$
- public final static String CHILDREN = "children"; // Given a JavaClass instance, return a JavaClass[] of the JavaClasses that inherit or extend the instance. //$NON-NLS-1$
- //The EJB_BINDING symbols is WAS specific and need to be moved to WAS Ext layer
- public final static String EJB_BINDING = "EJB_BINDING"; // return the EJBJarBinding for the EJBJar //$NON-NLS-1$
- public final static String EJB_CLIENTJAR = "EJB_CLIENTJAR"; // If the EJB uses a client JAR, given the name of the JAR, this method returns a Boolean.TRUE if the client JAR can be found and loaded successfully. If it can't be found and loaded, return Boolean.FALSE. //$NON-NLS-1$
- public final static String REMOVE_OLD_MESSAGES = "REMOVE_OLD_MESSAGES"; // Remove all Messages registered against the given Objects in the array. //$NON-NLS-1$
-}
-
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ERefValidationMessageResourceHandler.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ERefValidationMessageResourceHandler.java
deleted file mode 100644
index b94e081b6..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ERefValidationMessageResourceHandler.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import org.eclipse.osgi.util.NLS;
-
-public class ERefValidationMessageResourceHandler extends NLS {
-
- private static final String BUNDLE_NAME = "erefvalidation";//$NON-NLS-1$
-
- private ERefValidationMessageResourceHandler() {
- // Do not instantiate
- }
-
- public static String ERROR_EAR_MISSING_EREFNAME;
- public static String ERROR_EAR_INVALID_EREFTYPE;
- public static String ERROR_EAR_MISSING_EREFTYPE;
- public static String ERROR_EAR_MISSING_EREFHOME;
- public static String ERROR_EAR_MISSING_EREFREMOTE;
- public static String ERROR_EAR_MISSING_EJB_ROLE;
- public static String ERROR_EAR_DUPLICATE_RESREF;
- public static String UNRESOLVED_EJB_REF_WARN_;
- public static String ERROR_EAR_DUPLICATE_SERVICEREF;
- public static String ERROR_EAR_DUPLICATE_SECURITYROLEREF;
- public static String ERROR_EAR_DUPLICATE_EJBREF;
- public static String ERROR_EAR_DUPLICATE_RESENVREF;
- public static String ERROR_EAR_DUPLICATE_MESSSAGEDESTINATIONREF;
- public static String ERROR_EAR_MISSING_MESSSAGEDESTINATION;
- public static String ERROR_UNRESOLVED_MDB_MISSING_MESSAGE_DESTINATION;
- public static String ERROR_EAR_MISSING_EMPTY_MESSSAGEDESTINATION;
-
-
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, ERefValidationMessageResourceHandler.class);
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EarValidator.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EarValidator.java
deleted file mode 100644
index b3feee877..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EarValidator.java
+++ /dev/null
@@ -1,959 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.application.Application;
-import org.eclipse.jst.j2ee.application.Module;
-import org.eclipse.jst.j2ee.application.WebModule;
-import org.eclipse.jst.j2ee.client.ApplicationClient;
-import org.eclipse.jst.j2ee.client.internal.impl.ApplicationClientImpl;
-import org.eclipse.jst.j2ee.common.EJBLocalRef;
-import org.eclipse.jst.j2ee.common.EjbRef;
-import org.eclipse.jst.j2ee.common.MessageDestination;
-import org.eclipse.jst.j2ee.common.MessageDestinationRef;
-import org.eclipse.jst.j2ee.common.ResourceEnvRef;
-import org.eclipse.jst.j2ee.common.ResourceRef;
-import org.eclipse.jst.j2ee.common.SecurityRole;
-import org.eclipse.jst.j2ee.common.SecurityRoleRef;
-import org.eclipse.jst.j2ee.common.internal.impl.EjbRefImpl;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ModuleRef;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.ValidateXmlCommand;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.ArchiveWrappedException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.NoModuleFileException;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.exception.ResourceLoadException;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.MessageDriven;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.internal.common.XMLResource;
-import org.eclipse.jst.j2ee.webapplication.WebApp;
-import org.eclipse.jst.j2ee.webservice.wsclient.ServiceRef;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.operations.LocalizedMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-
-
-/**
- * Insert the type's description here.
- * Creation date: (12/6/2000 11:08:55 AM)
- * @author: Administrator
- */
-public class EarValidator extends J2EEValidator {
- public static final String RES_REF_GROUP_NAME = "RES_REF_GROUP_NAME"; //$NON-NLS-1$
- public static final String RES_ENV_REF_GROUP_NAME = "RES_ENV_REF_GROUP_NAME"; //$NON-NLS-1$
- public static final String SERVICE_REF_GROUP_NAME = "SERVICE_REF_GROUP_NAME"; //$NON-NLS-1$
- public static final String EJB_REF_GROUP_NAME = "EJB_REF_GROUP_NAME"; //$NON-NLS-1$
- public static final String SEC_ROLE_REF_GROUP_NAME = "SEC_ROLE_REF_GROUP_NAME"; //$NON-NLS-1$
- public static final String MESSAGE_REF_GROUP_NAME = "MESSAGE_REF_GROUP_NAME"; //$NON-NLS-1$
- public static final String MESSAGE_DESTINATION_REF_GROUP_NAME = "MESSAGE_DESTINATION_REF_GROUP_NAME"; //$NON-NLS-1$
- public static final String MESSAGE_DESTINATION_MDB_REF_GROUP_NAME = "MESSAGE_DESTINATION_MDB_REF_GROUP_NAME"; //$NON-NLS-1$
-
- protected EARFile earFile;
- protected Application appDD;
-
- /**
- * RelationshipMapValidator constructor comment.
- */
- public EarValidator() {
- super();
- }// EarValidator
-
- /**
- * Creates the validateXML command.
- *
- * @return Command
- */
- public Command createValidateXMLCommand() {
- Command cmd = new ValidateXmlCommand(earFile);
- return cmd;
- }// createValidateXMLCommand
-
- /**
- * <p>Answer the id of the resource bundle which is
- * used by the receiver.</p>
- *
- * @return String
- */
- public String getBaseName() {
- return EAR_CATEGORY;
- }// getBaseName
-
- /**
- * XML Validation now handles validation of Deployment Descriptor
- *
- * @throws ValidationException
- */
- public void validate() throws ValidationException {
- validateModules(appDD.getModules());
- validateSecurity();
- validateRefs();
- validateWebContexts();
- validateSpecLevel();
- validateMessageDestinations();
- }// validate
-
- /**
- * Does the validation
- */
- public void validate(IValidationContext inHelper, IReporter inReporter) throws ValidationException {
- validateInJob( inHelper, inReporter );
- }
-
- public IStatus validateInJob( IValidationContext inHelper, IReporter inReporter ) throws ValidationException {
-
- inReporter.removeAllMessages(this);
- super.validateInJob(inHelper, inReporter );
- try {
- earFile = (EARFile) _helper.loadModel(J2EEConstants.EAR_MODEL_NAME);
- if (earFile != null) {
- appDD = earFile.getDeploymentDescriptor();
- if (appDD != null && appDD.eResource() != null && appDD.eResource().isLoaded())
- validate();
- else {
- String msg = NLS.bind(EARValidationMessageResourceHandler.EAR_DD_CANNOT_OPEN_DD, new String[] { getResourceName()});
- IMessage errorMsg = new LocalizedMessage(IMessage.HIGH_SEVERITY, msg);
- status = WTPCommonPlugin.createErrorStatus(errorMsg.getText());
- throw new ValidationException(errorMsg);
- }
- } else {
- String msg = NLS.bind(EARValidationMessageResourceHandler.ERROR_EAR_INVALID_EAR_FILE, new String[] { getResourceName()});
- IMessage errorMsg = new LocalizedMessage(IMessage.HIGH_SEVERITY, msg);
- throw new ValidationException(errorMsg);
- } // if
- } catch (ValidationException ex) {
- throw ex;
- } catch (Exception e) {
- String[] param = new String[1];
- if (earFile != null)
- param[0] = earFile.getName();
- Logger.getLogger().logError(e);
- String msg = NLS.bind(EARValidationMessageResourceHandler.EAR_VALIDATION_INTERNAL_ERROR_UI_, param );
- IMessage errorMsg = new LocalizedMessage(IMessage.HIGH_SEVERITY, msg );
- throw new ValidationException(errorMsg, e);
- } // try
- return status;
- } // validate
-
-
- /**
- * Gets the resource name
- *
- * @return String
- */
- protected String getResourceName() {
- return earFile.getURI();
- }// getResourceName
-
- /**
- * validate for duplicates in EAR Roles
- *
- * @param EList earRoleList - List of ear roles.
- */
- public void validateEarRoles(EList earRoleList) {
- Set s = new HashSet(earRoleList.size());
- for (int i = 0; i < earRoleList.size(); i++) {
- SecurityRole securityRole = (SecurityRole) earRoleList.get(i);
- if (!(s.add(securityRole.getRoleName()))) {
- String roleName = securityRole.getRoleName();
- String[] params = new String[1];
- params[0] = roleName;
- String msg = NLS.bind(EARValidationMessageResourceHandler.ERROR_EAR_DUPLICATE_ROLES, params);
- addLocalizedWarning( msg, appDD );
- }// if
- }// for
- }// validateEarRoles
-
- /**
- * validateRefs(WebApp) - validate EJB references
- *
- * @param EjbRef eref - An ejb ref.
- * @param Sting uri - The uri of the module.
- */
- public void validateEJBRefMandatoryElements(List ejbRefs, String uri) {
- for(int i = 0; i < ejbRefs.size(); i++) {
- EjbRef eref = (EjbRef) ejbRefs.get(i);
- String refName = eref.getName();
- String[] params = new String[2];
- params[0] = refName;
- params[1] = uri;
-
- if ((eref.getName().trim() == null) || (eref.getName().trim().length() == 0)) {
- addWarning(EREF_CATEGORY, ERROR_EAR_MISSING_EREFNAME, params);
- }// if
- if (eref.isSetType())
- {if(eref.getType() == null )
- addWarning(EREF_CATEGORY, ERROR_EAR_INVALID_EREFTYPE, params);}
- else
- addWarning(EREF_CATEGORY, ERROR_EAR_MISSING_EREFTYPE, params);
- // if
- if ((eref.getHome() == null) || (eref.getHome().trim().length() == 0)) {
- addWarning(EREF_CATEGORY, ERROR_EAR_MISSING_EREFHOME, params);
- }// if
- if ((eref.getRemote() == null) || (eref.getRemote().trim().length() == 0)) {
- addWarning(EREF_CATEGORY, ERROR_EAR_MISSING_EREFREMOTE, params);
- }
- }
- }
-
- /**
- * Compare the ejb interfaces to check if they are similar.
- *
- * @param EjbRef eref - The ejb reference.
- * @param EnterpriseBean ejb - The enterprise bean
- */
- public boolean isSimilarEJBInterface(EjbRef eref, EnterpriseBean ejb) {
-
- if( eref.isLocal() ) {
- if( ejb.getLocalHomeInterfaceName() == null ||
- ejb.getLocalInterfaceName() == null ||
- ((EJBLocalRef)eref).getLocalHome() == null ||
- ((EJBLocalRef)eref).getLocal() == null ) {
- return false;
- }// if
-
- boolean isHomeLocalOk = ejb.getLocalHomeInterfaceName().equals(((EJBLocalRef)eref).getLocalHome());
- boolean isRemoteLocalOk = ejb.getLocalInterfaceName().equals(((EJBLocalRef)eref).getLocal());
- return isHomeLocalOk && isRemoteLocalOk;
- }// if
-
- if( ejb.getHomeInterfaceName() == null ||
- ejb.getRemoteInterfaceName() == null ||
- eref.getHome() == null ||
- eref.getRemote() == null ) {
- return false;
- }// if
-
- boolean isHomeOk = ejb.getHomeInterfaceName().equals( eref.getHome() );
- boolean isRemoteOk = ejb.getRemoteInterfaceName().equals( eref.getRemote() );
-
- return isHomeOk && isRemoteOk;
- }// isSimilarEJBInterface
-
- /**
- * validate for duplicates in EAR Roles
- *
- * @param List ejbRefs - List of ejb refs.
- * @param String uri - The uri of the module.
- */
- public void validateEJBRefs(List ejbRefs, String uri) {
- for (int i = 0; i < ejbRefs.size(); i++) {
- EjbRef eref = (EjbRef) ejbRefs.get(i);
- if( eref != null && eref.getLink() != null && eref.getLink().length() > 0) {
- EnterpriseBean ejb = earFile.getEnterpiseBeanFromRef( eref, uri );
- if( ejb == null ) {
- String[] params = new String[3];
- params[0] = eref.getName();
- params[1] = uri;
- params[2] = earFile.getName();
- String msg = NLS.bind(ERefValidationMessageResourceHandler.UNRESOLVED_EJB_REF_WARN_, params);
- addLocalizedWarning(msg, null);
- } else {
- if( !isSimilarEJBInterface( eref, ejb ) ) {
- String[] params = new String[3];
- params[0] = ejb.getName();
- params[1] = eref.getName();
- params[2] = uri;
- String msg = NLS.bind(EARValidationMessageResourceHandler.EJB_BEAN_EJB_LINK_INTEFACE_MISMATCH_ERROR_, params);
- addLocalizedError( msg, appDD);
- }
- }
- }
- }
- }
-
- /**
- * validate the existance of the EJB Roles in the EAR Roles and duplicates ib EJB Roles
- *
- * @param EList earRoleList - List of ear roles.
- * @param EList ejbRoles - List of ejb roles.
- */
- public void validateEJBRolesWithEARRoles(EList earRoleList, EList ejbRoles) {
- for (int i = 0; i < ejbRoles.size(); i++) {
- if (!(earRoleList.contains(ejbRoles.get(i)))) {
- String[] params = new String[1];
- params[0] = ((SecurityRole) (ejbRoles.get(i))).getRoleName();
- addWarning(EREF_CATEGORY, ERROR_EAR_MISSING_EJB_ROLE, params);
- }// if
- }// for
- }// validateEJBRolesWithEARRoles
-
- /**
- * For each module, make sure its archive exists
- *(a very expensive, but more meaningful test would be to also make sure they can be loaded)
- *
- * @param EList modulesList - List of modules
- */
- public void validateModules(EList modulesList) {
-// String errorString = ""; //$NON-NLS-1$
- IMessage msg = new LocalizedMessage(IMessage.NORMAL_SEVERITY, "Validating Modules");
- _reporter.displaySubtask( this, msg );
-
-
- HashSet duplicateURI = new HashSet();
-
- for (int i = 0; i < modulesList.size(); i++) {
- Module m = (Module) modulesList.get(i);
- String filename = m.getUri();
- if ((filename == null) || (filename.length() == 0)) {
- addLocalizedError(EARValidationMessageResourceHandler.MESSAGE_EAR_NO_MODULE_URI, null);
- } else {
- //check if the URI has any spaces
- if( filename.indexOf( " " ) != -1) { //$NON-NLS-1$
- String[] params = new String[1];
- params[0] = filename;
- String msg1 = NLS.bind(EARValidationMessageResourceHandler.URI_CONTAINS_SPACES_ERROR_, params);
- addLocalizedError(msg1, appDD);
- }// if
- }// if
- String altDD = m.getAltDD();
- if (altDD != null)
- altDD = altDD.trim();
- validateAltDD(m, altDD);
- String key = altDD == null ? filename + altDD : filename;
- if (!duplicateURI.add(key)) {
- String[] params = new String[2];
- params[0] = m.getUri();
- params[1] = earFile.getName();
- String tmp = NLS.bind(EARValidationMessageResourceHandler.MESSAGE_EAR_DUPLICATE_URI_ERROR_, params);
- addLocalizedError(tmp, appDD);
- }// if
-
- }// for
-
- }// validateModules
-
- /**
- * Validate the alt dd
- *
- * @param Module m - A module.
- * @param String altDD - An altDD
- */
- protected void validateAltDD(Module m, String altDD) {
- //isDuplicate will test if it is a file or a loaded resource
- if ("".equals(altDD)) { //$NON-NLS-1$
- String[] params = new String[2];
- params[0] = m.getUri();
- params[1] = earFile.getName();
- String tmp = NLS.bind(EARValidationMessageResourceHandler.MESSAGE_EMPTY_ALT_DD_ERROR_, params);
- addLocalizedError(tmp, appDD);
- } else if (altDD != null && !earFile.isDuplicate(altDD)) {
- String[] params = new String[3];
- params[0] = m.getUri();
- params[1] = altDD;
- params[2] = earFile.getName();
- String tmp = NLS.bind(EARValidationMessageResourceHandler.MESSAGE_INVALID_ALT_DD_WARN_, params);
- addLocalizedWarning(tmp, appDD);
- }// if
- }// validateAltDD
-
- /**
- * validate EJB and resource references
- */
- public void validateRefs() {
-
- IMessage msg = new LocalizedMessage(IMessage.NORMAL_SEVERITY, "Validating Refs");
- _reporter.displaySubtask( this, msg );
-
-
- List moduleList = earFile.getModuleRefs();
- for (int i = 0; i < moduleList.size(); i++) {
-
- ModuleRef ref = (ModuleRef) moduleList.get(i);
- try {
- if(ref.isWeb()) {
- validateWebAppRefs(ref); }
- else if( ref.isEJB() ) {
- validateEJBModuleRefs(ref);
- } else if(ref.isClient())
- validateAppClientRefs(ref);
- } catch (ArchiveWrappedException ex) {
- Exception nested = ex.getNestedException();
- if (!(nested instanceof NoModuleFileException)) {
- //Logger.getLogger().logError(ex);
- String[] params = new String[1];
- params[0] = ref.getUri();
- addError(EREF_CATEGORY, ERROR_MODULE_DD_FILE_NOT_FOUND, params);
- }
- //otherwise ignore it; there are other validations for this
- }
-
- }
- }
-
- /**
- * @param ref
- */
- private void validateAppClientRefs(ModuleRef ref) throws ArchiveWrappedException {
- ApplicationClient appClient = (ApplicationClientImpl)ref.getDeploymentDescriptor();
- List ejbRefs = new ArrayList();
- ejbRefs.addAll(appClient.getEjbReferences());
- validateEJBRefMandatoryElements(ejbRefs, ref.getUri());
- validateEJBRefs(ejbRefs, ref.getUri());
- if (appClient != null && appClient.getVersionID() <= J2EEVersionConstants.J2EE_1_3_ID) {
- Set allRefs = new HashSet();
- List resourceRefs = appClient.getResourceRefs();
- List resourceEnvRefs = appClient.getResourceEnvRefs();
- List serviceRefs = appClient.getServiceRefs();
-
- validateDuplicateEJBRefs(allRefs,ejbRefs);
- validateDuplicateResourceRefs(allRefs,resourceRefs);
- validateDuplicateResourceEnvRefs(allRefs,resourceEnvRefs);
- validateDuplicateServiceRefs(allRefs,serviceRefs);
- }
-
- }
-
- /**
- * @param ref
- * @throws ArchiveWrappedException
- */
- private void validateWebAppRefs(ModuleRef ref) throws ArchiveWrappedException {
- WebApp webApp = (WebApp)ref.getDeploymentDescriptor();
- List ejbRefs = new ArrayList();
- ejbRefs.addAll(webApp.getEjbRefs());
- ejbRefs.addAll(webApp.getEjbLocalRefs());
- validateEJBRefMandatoryElements(ejbRefs, ref.getUri());
- validateEJBRefs(ejbRefs, ref.getUri());
- if (webApp != null && webApp.getVersionID() <= J2EEVersionConstants.WEB_2_3_ID) {
- Set allRefs = new HashSet();
- List resourceRefs = webApp.getResourceRefs();
- List resourceEnvRefs = webApp.getResourceEnvRefs();
- List serviceRefs = webApp.getServiceRefs();
-
- validateDuplicateEJBRefs(allRefs,ejbRefs);
- validateDuplicateResourceRefs(allRefs,resourceRefs);
- validateDuplicateResourceEnvRefs(allRefs,resourceEnvRefs);
- validateDuplicateServiceRefs(allRefs,serviceRefs);
- }
- }
- /**
- * @param ref
- * @throws ArchiveWrappedException
- */
- private void validateEJBModuleRefs(ModuleRef ref) throws ArchiveWrappedException {
- EJBJar ejbJar = (EJBJar)ref.getDeploymentDescriptor();
- if( ejbJar != null ) {
- List ejbCollection = ejbJar.getEnterpriseBeans();
- if( ejbCollection != null || !ejbCollection.isEmpty() ) {
- Resource res = ejbJar.eResource();
- cleanUpAllRefSubTaskMessages(res);
- Iterator iterator = ejbCollection.iterator();
- while( iterator.hasNext() ) {
- EnterpriseBean ejbBean = (EnterpriseBean)iterator.next();
- if( ejbBean != null ) {
- List ejbRefs = new ArrayList();
- ejbRefs.addAll(ejbBean.getEjbRefs());
- ejbRefs.addAll(ejbBean.getEjbLocalRefs());
- validateEJBRefMandatoryElements(ejbRefs, ref.getUri());
- validateEJBRefs(ejbRefs, ref.getUri());
- if(ejbJar.getVersionID() <= J2EEVersionConstants.EJB_2_0_ID) {
- Set allRefs = new HashSet();
- List resourceRefs = ejbBean.getResourceRefs();
- List resourceEnvRefs = ejbBean.getResourceEnvRefs();
- List secRoleRefs = ejbBean.getSecurityRoleRefs();
- List serviceRefs = ejbBean.getServiceRefs();
- List messageDestRefs = ejbBean.getMessageDestinationRefs();
-
- validateDuplicateEJBRefs(allRefs,ejbRefs);
- validateDuplicateResourceRefs(allRefs,resourceRefs);
- validateDuplicateResourceEnvRefs(allRefs,resourceEnvRefs);
- validateDuplicateSecurityRoleRefs(allRefs,secRoleRefs);
- validateDuplicateServiceRefs(allRefs,serviceRefs);
- validateDuplicateMessageDestRefs(allRefs,messageDestRefs);
- }
- }
- }
- }
- }
-
- }
-
- /**
- * @param allRefs
- * @param serviceRefs
- */
- private void validateDuplicateServiceRefs(Set allRefs, List serviceRefs) {
- if (!serviceRefs.isEmpty()) {
- ServiceRef firstRef = (ServiceRef)(serviceRefs.get(0));
- if(!(firstRef.eContainer() instanceof EnterpriseBean))
- cleanUpSubTaskMessages(firstRef);
- for (int refNo = 0; refNo < serviceRefs.size(); refNo++) {
- ServiceRef ref = (ServiceRef) (serviceRefs.get(refNo));
- String refName = ref.getServiceRefName();
- String[] parms = new String[1];
- parms[0] = refName;
- if (!(allRefs.add(refName)))
- addError(EREF_CATEGORY, ERROR_EAR_DUPLICATE_SERVICEREF, parms,ref,SERVICE_REF_GROUP_NAME);
- }
- }
- }
-
- /**
- * @param allRefs
- * @param secRoleRefs
- */
- private void validateDuplicateSecurityRoleRefs(Set allRefs, List secRoleRefs) {
- if (!secRoleRefs.isEmpty()) {
- SecurityRoleRef firstRef = (SecurityRoleRef)(secRoleRefs.get(0));
- if(!(firstRef.eContainer() instanceof EnterpriseBean))
- cleanUpSubTaskMessages(firstRef);
- for (int refNo = 0; refNo < secRoleRefs.size(); refNo++) {
- SecurityRoleRef ref = (SecurityRoleRef) (secRoleRefs.get(refNo));
- String refName = ref.getName();
- String[] parms = new String[1];
- parms[0] = refName;
- if (!(allRefs.add(refName)))
- addError(EREF_CATEGORY, ERROR_EAR_DUPLICATE_SECURITYROLEREF, parms,ref,SEC_ROLE_REF_GROUP_NAME);
- }
- }
- }
-
- /**
- * @param allRefs
- * @param resourceEnvRefs
- */
- private void validateDuplicateResourceEnvRefs(Set allRefs, List resourceEnvRefs) {
- if (!resourceEnvRefs.isEmpty()) {
- ResourceEnvRef firstRef = (ResourceEnvRef)(resourceEnvRefs.get(0));
- if(!(firstRef.eContainer() instanceof EnterpriseBean))
- cleanUpSubTaskMessages(firstRef);
- for (int refNo = 0; refNo < resourceEnvRefs.size(); refNo++) {
- ResourceEnvRef ref = (ResourceEnvRef) (resourceEnvRefs.get(refNo));
- String refName = ref.getName();
- String[] parms = new String[1];
- parms[0] = refName;
- if (!(allRefs.add(refName)))
- addError(EREF_CATEGORY, ERROR_EAR_DUPLICATE_RESENVREF, parms,ref,RES_ENV_REF_GROUP_NAME);
- }
- }
- }
-
- /**
- * @param allRefs
- * @param resourceRefs
- */
- private void validateDuplicateResourceRefs(Set allRefs, List resourceRefs) {
- if (!resourceRefs.isEmpty()) {
- ResourceRef firstRef = (ResourceRef)(resourceRefs.get(0));
- if(!(firstRef.eContainer() instanceof EnterpriseBean))
- cleanUpSubTaskMessages(firstRef);
- for (int refNo = 0; refNo < resourceRefs.size(); refNo++) {
- ResourceRef ref = (ResourceRef) (resourceRefs.get(refNo));
- String refName = ref.getName();
- String[] parms = new String[1];
- parms[0] = refName;
- if (!(allRefs.add(refName)))
- addError(EREF_CATEGORY, ERROR_EAR_DUPLICATE_RESREF, parms,ref,RES_REF_GROUP_NAME);
- }
- }
- }
- /**
- * @param allRefs
- * @param ejbRefs
- */
- protected void validateDuplicateEJBRefs(Set allRefs, List ejbRefs) {
- if (!ejbRefs.isEmpty()) {
- EjbRef firstRef = (EjbRef)(ejbRefs.get(0));
- if(!(firstRef.eContainer() instanceof EnterpriseBean))
- cleanUpSubTaskMessages(firstRef);
- for (int refNo = 0; refNo < ejbRefs.size(); refNo++) {
- EjbRef ref = (EjbRefImpl) (ejbRefs.get(refNo));
- String refName = ref.getName();
- String[] parms = new String[1];
- parms[0] = refName;
- if (!(allRefs.add(refName)))
- addError(EREF_CATEGORY, ERROR_EAR_DUPLICATE_EJBREF, parms, ref, EJB_REF_GROUP_NAME);
- }
- }
- }
-
- /**
- * @param allRefs
- * @param ejbRefs
- */
- protected void validateDuplicateMessageDestRefs(Set allRefs, List messageDestRefs) {
- if (!messageDestRefs.isEmpty()) {
- MessageDestinationRef firstRef = (MessageDestinationRef)(messageDestRefs.get(0));
- if(!(firstRef.eContainer() instanceof EnterpriseBean))
- cleanUpSubTaskMessages(firstRef);
- for (int refNo = 0; refNo < messageDestRefs.size(); refNo++) {
- MessageDestinationRef ref = (MessageDestinationRef) (messageDestRefs.get(refNo));
- String refName = ref.getName();
- String[] parms = new String[1];
- parms[0] = refName;
- if (!(allRefs.add(refName)))
- addError(EREF_CATEGORY, ERROR_EAR_DUPLICATE_MESSSAGEDESTINATIONREF, parms,ref, MESSAGE_REF_GROUP_NAME);
- }
- }
- }
-
- /**
- * @param firstRef
- */
- protected void cleanUpSubTaskMessages(EObject ref) {
- //No Op - subclass overrides
- }
-
- protected void cleanUpAllRefSubTaskMessages(Resource res) {
- //No Op - subclass overrides
- }
-
- /**
- * Ejb refs to the running list of ejb refs.
- *
- * @param List currentRefs - List of current ejb refs to be added.
- * @param List ejbRefs - collection of running ejbrefs
- */
- public void addEJBRefs( List currentRefs, List ejbRefs ) {
- if( currentRefs == null || ejbRefs == null )
- return;
-
- ejbRefs.addAll( currentRefs );
- }// addEJBRefs
-
- /**
- * validate security constraints, roles, and security role refs.
- */
- public void validateSecurity() {
- EList earRoleList = appDD.getSecurityRoles();
- if (!earRoleList.isEmpty())
- validateEarRoles(earRoleList);
- EList moduleList = appDD.getModules();
- if (!moduleList.isEmpty()) {
-
- for (int i = 0; i < moduleList.size(); i++) {
- Module m = (Module) moduleList.get(i);
- if (m.isEjbModule()) {
- EList ejbRoles = m.getApplication().getSecurityRoles();
- if (!ejbRoles.isEmpty())
- validateEJBRolesWithEARRoles(earRoleList, ejbRoles);
- }// if
- if (m.isWebModule()) {
- EList webRoles = m.getApplication().getSecurityRoles();
- if (!webRoles.isEmpty())
- validateWEBRolesWithEARRoles(earRoleList, webRoles);
- }// if
- }// for
- }// if
- }// validateSecurity
-
- /**
- * Validates an ear for duplicate web contexts.
- */
- public void validateWebContexts() {
-
- EList moduleList = appDD.getModules();
- Map visitedWebContext = new HashMap();
-
- if( !moduleList.isEmpty() ) {
- Iterator iterator = moduleList.iterator();
- while( iterator.hasNext() ) {
- Module module = (Module)iterator.next();
- if( module.isWebModule() ) {
-
- WebModule webModule = (WebModule)module;
-
- if( webModule != null ) {
- if( visitedWebContext.containsKey( webModule.getContextRoot() ) ) {
- WebModule tempWebModule = (WebModule)visitedWebContext.get( webModule.getContextRoot() );
- String[] params = new String[3];
- params[0] = webModule.getContextRoot();
- params[1] = webModule.getUri();
- params[2] = tempWebModule.getUri();
- String tmp = NLS.bind(EARValidationMessageResourceHandler.MESSAGE_EAR_DUPICATE_ROOTCONTEXT_ERROR_, params);
-
- addLocalizedError(tmp, appDD);
- } else {
- visitedWebContext.put( webModule.getContextRoot(), webModule );
- }// if
-
- }// if
-
- }// if
- }// while
- }// if
- }// validateWebContexts
-
-
- /**
- * Checks if the modules are a spec level too high for the EAR file.
- */
- private void validateSpecLevel() {
- int earVersion = getVersionID(earFile);
- List modules = earFile.getModuleFiles();
-
- if( !modules.isEmpty() ) {
- Iterator iterator = modules.iterator();
- ModuleFile moduleFile = null;
- while (iterator.hasNext()) {
- moduleFile = (ModuleFile)iterator.next();
- if (moduleFile != null && getVersionID(moduleFile) > earVersion) {
- String[] params = new String[] {moduleFile.getURI(), earFile.getName()};
- String tmp = NLS.bind(EARValidationMessageResourceHandler.MESSAGE_INCOMPATIBLE_SPEC_WARNING_, params);
- addLocalizedWarning(tmp, appDD);
- }
- }
- }
- }
-
- /**
- * @param moduleFile
- * @return
- */
- private int getVersionID(ModuleFile moduleFile) {
- XMLResource res = null;
- try {
- res = (XMLResource) moduleFile.getDeploymentDescriptorResource();
- } catch (ResourceLoadException e) {
- //Ignore
- } catch (FileNotFoundException e) {
- //Ignore
- }
- if (res != null)
- return res.getJ2EEVersionID();
- return -1;
- }
-
-
- private void validateMessageDestinations() {
- validateMessageDestinationRefs();
- validateMDBMessageDestinations();
- }
- private void validateMDBMessageDestinations() {
- List moduleList = earFile.getModuleRefs();
-
- for (int i = 0; i < moduleList.size(); i++) {
- ModuleRef ref = (ModuleRef) moduleList.get(i);
- try {
- if( ref.isEJB() ) {
- EJBJar ejbJar = (EJBJar)ref.getDeploymentDescriptor();
- if( ejbJar != null ) {
- removeAllMessages(ejbJar,MESSAGE_DESTINATION_MDB_REF_GROUP_NAME);
- List ejbCollection = ejbJar.getEnterpriseBeans();
- if( ejbCollection != null || !ejbCollection.isEmpty() ) {
- Iterator iterator = ejbCollection.iterator();
- while( iterator.hasNext() ) {
- EnterpriseBean ejbBean = (EnterpriseBean)iterator.next();
- if( ejbBean != null ) {
- if (ejbBean.isMessageDriven()) {
- MessageDriven messageDrivenBean = (MessageDriven)ejbBean;
- if (messageDrivenBean.getVersionID() < J2EEVersionConstants.EJB_2_1_ID) continue;
- String link = messageDrivenBean.getLink();
- if (link != null && !isExistMessageDestinationLink(link, ref)) {
- String[] params = new String[4];
- params[0] = link;
- params[1] = messageDrivenBean.getName();
- params[2] = ref.getUri();
- params[3] = earFile.getName();
- addError(EREF_CATEGORY, ERROR_UNRESOLVED_MDB_MISSING_MESSAGE_DESTINATION, params,messageDrivenBean, MESSAGE_DESTINATION_MDB_REF_GROUP_NAME);
- }
-
- }
- }
- }
- }
- }
- }
- } catch (ArchiveWrappedException ex) {
- Exception nested = ex.getNestedException();
- if (!(nested instanceof NoModuleFileException)) {
- String[] params = new String[1];
- params[0] = ref.getUri();
- addError(EREF_CATEGORY, ERROR_MODULE_DD_FILE_NOT_FOUND, params);
- }
- }
-
- }
- }
-
-
- private void validateMessageDestinationRefs() {
- List moduleList = earFile.getModuleRefs();
- for (int i = 0; i < moduleList.size(); i++) {
- ModuleRef ref = (ModuleRef) moduleList.get(i);
- validateMessageDestinationRefs(ref);
- }
- }
- /**
- *
- */
- private void validateMessageDestinationRefs(ModuleRef moduleRef) {
- List destinationsRefs = getMessageDestinationRefs(moduleRef);
- clearUpSubTaskMessageDestinationMessages(destinationsRefs);
- for (int refNo = 0; refNo < destinationsRefs.size(); refNo++) {
- MessageDestinationRef ref = (MessageDestinationRef) (destinationsRefs.get(refNo));
- String link = ref.getLink() ;
- if (link == null) continue; // dont validate if the link is null
- if ( link.length()== 0) { // empty link is an error
- String[] params = new String[3];
- params[0] = ref.getName();
- params[1] = moduleRef.getUri();
- params[2] = earFile.getName();
-
- addError(EREF_CATEGORY, ERROR_EAR_MISSING_EMPTY_MESSSAGEDESTINATION, params,ref, MESSAGE_DESTINATION_REF_GROUP_NAME);
- } else if (!isExistMessageDestinationLink(link, moduleRef)) {
- String[] params = new String[4];
- params[0] = link;
- params[1] = ref.getName();
- params[2] = moduleRef.getUri();
- params[3] = earFile.getName();
-
- addError(EREF_CATEGORY, ERROR_EAR_MISSING_MESSSAGEDESTINATION, params,ref, MESSAGE_DESTINATION_REF_GROUP_NAME);
- }
- }
- }
-
-
- private void clearUpSubTaskMessageDestinationMessages(List destinationsRefs) {
- for (int refNo = 0; refNo < destinationsRefs.size(); refNo++) {
- MessageDestinationRef ref = (MessageDestinationRef) (destinationsRefs.get(refNo));
- removeAllMessages(ref,MESSAGE_DESTINATION_REF_GROUP_NAME);
- }
- }
-
- protected void removeAllMessages(EObject eObject, String groupName) {
-
- }
-
- /**
- * @param ref
- * @return
- */
- private boolean isExistMessageDestinationLink(String link, ModuleRef moduleRef) {
- if (link == null) return false;
- int index = link.indexOf('#');
- String destinationName;
- if (index == -1) {
- destinationName = link;
- } else {
- String moduleName = link.substring(0,index);
- destinationName = link.substring(index+1);
- moduleRef = getModuleRefByName(moduleName);
- if (moduleRef == null) return false;
-
- }
- List destinations = getMessageDestinations(moduleRef);
- for (int i = 0; i < destinations.size(); i++) {
- MessageDestination messageDestination = (MessageDestination) (destinations.get(i));
- if (destinationName.equals(messageDestination.getName())) return true;
- }
- return false;
- }
-
- private ModuleRef getModuleRefByName(String moduleName) {
- List moduleList = earFile.getModuleRefs();
- for (int i = 0; i < moduleList.size(); i++) {
- ModuleRef ref = (ModuleRef) moduleList.get(i);
- Module module = ref.getModule();
- if (moduleName.equals(module.getUri())) {
- return ref;
- }
- }
- return null;
- }
-
- private List getMessageDestinationRefs(ModuleRef ref) {
- List destinationRefs = new ArrayList();
-
- try {
- if(ref.isWeb()) {
- WebApp webApp = (WebApp)ref.getDeploymentDescriptor();
- destinationRefs.addAll(webApp.getMessageDestinationRefs());
- } else if( ref.isEJB() ) {
- EJBJar ejbJar = (EJBJar)ref.getDeploymentDescriptor();
- destinationRefs.addAll(getEJBMessageDestinationRefs(ejbJar));
- } else if(ref.isClient()) {
- ApplicationClient appClient = (ApplicationClientImpl)ref.getDeploymentDescriptor();
- destinationRefs.addAll(appClient.getMessageDestinationRefs());
- }
- } catch (ArchiveWrappedException ex) {
- Exception nested = ex.getNestedException();
- if (!(nested instanceof NoModuleFileException)) {
- String[] params = new String[1];
- params[0] = ref.getUri();
- addError(EREF_CATEGORY, ERROR_MODULE_DD_FILE_NOT_FOUND, params);
- }
- }
-
-
- return destinationRefs;
- }
-
- private List getEJBMessageDestinationRefs(EJBJar ejbJar) {
- List ejbMessageDestinationRefs = new ArrayList();
- if( ejbJar != null ) {
- List ejbCollection = ejbJar.getEnterpriseBeans();
- if( ejbCollection != null || !ejbCollection.isEmpty() ) {
- Iterator iterator = ejbCollection.iterator();
- while( iterator.hasNext() ) {
- EnterpriseBean ejbBean = (EnterpriseBean)iterator.next();
- if( ejbBean != null ) {
- ejbMessageDestinationRefs.addAll(ejbBean.getMessageDestinationRefs());
- }
- }
- }
- }
- return ejbMessageDestinationRefs;
- }
-
- private List getMessageDestinations(ModuleRef ref) {
- List destinations = new ArrayList();
- try {
- if(ref.isWeb()) {
- WebApp webApp = (WebApp)ref.getDeploymentDescriptor();
- destinations.addAll(webApp.getMessageDestinations());
- } else if( ref.isEJB() ) {
- EJBJar ejbJar = (EJBJar)ref.getDeploymentDescriptor();
- if (ejbJar != null && ejbJar.getAssemblyDescriptor() != null)
- destinations.addAll(ejbJar.getAssemblyDescriptor().getMessageDestinations());
- } else if(ref.isClient()) {
- ApplicationClient appClient = (ApplicationClientImpl)ref.getDeploymentDescriptor();
- destinations.addAll(appClient.getMessageDestinations());
- }
- } catch (ArchiveWrappedException ex) {
- Exception nested = ex.getNestedException();
- if (!(nested instanceof NoModuleFileException))
- Logger.getLogger().logError(ex);
- }
- return destinations;
- }
-
- public ISchedulingRule getSchedulingRule(IValidationContext helper) {
- _helper = helper;
- return null;
- }
-
-}// EarValidator
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EnterpriseBean11VRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EnterpriseBean11VRule.java
deleted file mode 100644
index 62e8d02c6..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EnterpriseBean11VRule.java
+++ /dev/null
@@ -1,1067 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.common.CommonPackage;
-import org.eclipse.jst.j2ee.common.EjbRef;
-import org.eclipse.jst.j2ee.common.EjbRefType;
-import org.eclipse.jst.j2ee.common.EnvEntry;
-import org.eclipse.jst.j2ee.common.EnvEntryType;
-import org.eclipse.jst.j2ee.common.SecurityRole;
-import org.eclipse.jst.j2ee.common.SecurityRoleRef;
-import org.eclipse.jst.j2ee.ejb.CMPAttribute;
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.jst.j2ee.ejb.Session;
-import org.eclipse.jst.j2ee.ejb.SessionType;
-import org.eclipse.jst.j2ee.ejb.TransactionType;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- * This class checks ejb-jar.xml for errors or potential errors.
- * If any problems are found, an error, warning, or info marker is added to the task list.
- *
- * 15.2.5.3 Declaration of security roles referenced from the bean's code
- * The Bean Provider is responsible for declaring in the security-role-ref elements of the deploy-ment
- * descriptor all the security role names used in the enterprise bean code. Declaring the security roles
- * references in the code allows the Application Assembler or Deployer to link the names of the security
- * roles used in the code to the security roles defined for an assembled application through the secu-rity-
- * role elements.
- * The Bean Provider must declare each security role referenced in the code using the secu-rity-
- * role-ref element as follows:
- * Declare the name of the security role using the role-name element. The name must be the
- * security role name that is used as a parameter to the isCallerInRole(String role-Name)
- * method.
- * Optional: Provide a description of the security role in the description element.
- * A security role reference, including the name defined by the role-name element, is scoped to the ses-sion
- * or entity bean element whose declaration contains the security-role-ref element.
- * The following example illustrates how an enterprise bean's references to security roles are declared in
- * the deployment descriptor.
- * ...
- * <enterprise-beans>
- * ...
- * <entity>
- * <ejb-name>AardvarkPayroll</ejb-name>
- * <ejb-class>com.aardvark.payroll.PayrollBean</ejb-class>
- * ...
- * <security-role-ref>
- * <description>
- * This security role should be assigned to the
- * employees of the payroll department who are
- * allowed to update employees' salaries.
- * </description>
- * <role-name>payroll</role-name>
- * </security-role-ref>
- * ...
- * </entity>
- * ...
- * </enterprise-beans>
- * ...
- *
- * The deployment descriptor above indicates that the enterprise bean AardvarkPayroll makes the
- * security check using isCallerInRole("payroll") in its business method.
- *
- *
- * 15.3.3 Linking security role references to security roles
- * If the Application Assembler defines the security-role elements in the deployment descriptor, he
- * or she is also responsible for linking all the security role references declared in the secu-rity-
- * role-ref elements to the security roles defined in the security-role elements.
- * The Application Assembler links each security role reference to a security role using the role-link
- * element. The value of the role-link element must be the name of one of the security roles defined in
- * a security-role element.
- * A role-link element must be used even if the value of role-name is the same as the value of the
- * role-link reference.
- * The following deployment descriptor example shows how to link the security role reference named
- * payroll to the security role named payroll-department.
- * ...
- * <enterprise-beans>
- * ...
- * <entity>
- * <ejb-name>AardvarkPayroll</ejb-name>
- * <ejb-class>com.aardvark.payroll.PayrollBean</ejb-class>
- * ...
- * <security-role-ref>
- * <description>
- * This role should be assigned to the
- * employees of the payroll department.
- * Members of this role have access to
- * anyone's payroll record.
- *
- * The role has been linked to the
- * payroll-department role.
- * </description>
- * <role-name>payroll</role-name>
- * <role-link>payroll-department</role-link>
- * </security-role-ref>
- * ...
- * </entity>
- * ...
- * </enterprise-beans>
- * ...
- */
-public class EnterpriseBean11VRule extends AValidationRule implements IMessagePrefixEjb11Constants {
- private static final Object ID = IValidationRuleList.EJB11_ENTERPRISEBEAN;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB11_SESSION_BEANCLASS, IValidationRuleList.EJB11_SESSION_HOME, IValidationRuleList.EJB11_SESSION_REMOTE, IValidationRuleList.EJB11_BMP_BEANCLASS, IValidationRuleList.EJB11_BMP_HOME, IValidationRuleList.EJB11_BMP_KEYCLASS, IValidationRuleList.EJB11_BMP_REMOTE, IValidationRuleList.EJB11_CMP_BEANCLASS, IValidationRuleList.EJB11_CMP_HOME, IValidationRuleList.EJB11_CMP_KEYCLASS, IValidationRuleList.EJB11_CMP_REMOTE};
- private static final Map MESSAGE_IDS;
-
- private List _securityRoles = null;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2801, new String[]{CHKJ2801 + SPEC});
- MESSAGE_IDS.put(CHKJ2802_NAMED, new String[]{CHKJ2802_NAMED + SPEC});
- MESSAGE_IDS.put(CHKJ2802_UNNAMED, new String[]{CHKJ2802_UNNAMED + SPEC});
- MESSAGE_IDS.put(CHKJ2803_NAMED, new String[]{CHKJ2803_NAMED + SPEC});
- MESSAGE_IDS.put(CHKJ2803_UNNAMED, new String[]{CHKJ2803_UNNAMED + SPEC});
- MESSAGE_IDS.put(CHKJ2804_NAMED, new String[]{CHKJ2804_NAMED + SPEC});
- MESSAGE_IDS.put(CHKJ2804_UNNAMED, new String[]{CHKJ2804_UNNAMED + SPEC});
- MESSAGE_IDS.put(CHKJ2806, new String[]{CHKJ2806 + SPEC});
- MESSAGE_IDS.put(CHKJ2807, new String[]{CHKJ2807 + SPEC});
- MESSAGE_IDS.put(CHKJ2808, new String[]{CHKJ2808 + SPEC});
- MESSAGE_IDS.put(CHKJ2809, new String[]{CHKJ2809 + SPEC});
-
- MESSAGE_IDS.put(CHKJ2810_NAMED, new String[]{CHKJ2810_NAMED + SPEC});
- MESSAGE_IDS.put(CHKJ2810_UNNAMED, new String[]{CHKJ2810_UNNAMED + SPEC});
- MESSAGE_IDS.put(CHKJ2811_NAMED, new String[]{CHKJ2811_NAMED + SPEC});
- MESSAGE_IDS.put(CHKJ2811_UNNAMED, new String[]{CHKJ2811_UNNAMED + SPEC});
- MESSAGE_IDS.put(CHKJ2812, new String[]{CHKJ2812 + SPEC});
-
- MESSAGE_IDS.put(CHKJ2820, new String[]{CHKJ2820 + SPEC});
- MESSAGE_IDS.put(CHKJ2822, new String[]{CHKJ2822 + SPEC});
- MESSAGE_IDS.put(CHKJ2823, new String[]{CHKJ2823 + SPEC});
- MESSAGE_IDS.put(CHKJ2824, new String[]{CHKJ2824 + SPEC});
- MESSAGE_IDS.put(CHKJ2827, new String[]{CHKJ2827 + SPEC});
- MESSAGE_IDS.put(CHKJ2828, new String[]{CHKJ2828 + SPEC});
-
- MESSAGE_IDS.put(CHKJ2830, new String[]{CHKJ2830 + SPEC});
- MESSAGE_IDS.put(CHKJ2831, new String[]{CHKJ2831 + SPEC});
- MESSAGE_IDS.put(CHKJ2832, new String[]{CHKJ2832 + SPEC});
- MESSAGE_IDS.put(CHKJ2833, new String[]{CHKJ2833 + SPEC});
- MESSAGE_IDS.put(CHKJ2834, new String[]{CHKJ2834 + SPEC});
- MESSAGE_IDS.put(CHKJ2835, new String[]{CHKJ2835 + SPEC});
- MESSAGE_IDS.put(CHKJ2836, new String[]{CHKJ2836 + SPEC});
- MESSAGE_IDS.put(CHKJ2837, new String[]{CHKJ2837 + SPEC});
- MESSAGE_IDS.put(CHKJ2838, new String[]{CHKJ2838 + SPEC});
- MESSAGE_IDS.put(CHKJ2839, new String[]{CHKJ2839 + SPEC});
-
- MESSAGE_IDS.put(CHKJ2840, new String[]{CHKJ2840 + SPEC});
- MESSAGE_IDS.put(CHKJ2841, new String[]{CHKJ2841 + SPEC});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- MESSAGE_IDS.put(CHKJ2852, new String[]{CHKJ2852});
-
- MESSAGE_IDS.put(CHKJ2908, new String[]{CHKJ2908 + SPEC});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public Object getTarget(Object parent, Object clazz) {
- // If called as a dependent, parent will be this EnterpriseBean.
- return parent;
- }
-
- /**
- * 6.5.3 The optional SessionSynchronization interface
- *...
- * Only a stateful Session bean with container-managed transaction demarcation may
- * implement the SessionSynchronization interface.
- *...
- * There is no need for a Session bean with bean-managed transaction to rely on the
- * synchronization call backs because the bean is in control of the commit the bean
- * knows when the transaction is about to be committed and it knows the outcome of the
- * transaction commit.
- *...
- */
- public boolean isValidSessionTypeElement(Session session) {
- // check syntax
- if (!session.isSetSessionType()) {
- return false;
- }
-
- if (session.getSessionType().getValue() == SessionType.STATEFUL) {
- return true;
- }
-
- if (session.getSessionType().getValue() == SessionType.STATELESS) {
- return true;
- }
-
- return false;
- }
-
- public boolean isValidTransactionTypeElement(Session sessionBean) {
- if (!sessionBean.isSetTransactionType()) {
- return false;
- }
-
- if (sessionBean.getTransactionType().getValue() == TransactionType.BEAN) {
- return true;
- }
-
- if (sessionBean.getTransactionType().getValue() == TransactionType.CONTAINER) {
- return true;
- }
-
- return false;
- }
-
-
- /**
- * If the bean components (home interface, remote interface, bean class, and primary
- * key) can all be found and reflected, return true. Else, add a validation error
- * against the bean, and return false.
- */
- public boolean validateBeanComponents(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- boolean isValid = true;
- // Don't need to check if the bean is null, because this method will
- // not be called if it is.
- try {
- ValidationRuleUtility.isValidTypeHierarchy(bean, bean.getEjbClass());
- }
- catch (InvalidInputException exc) {
- if (bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_EjbClass())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2802_NAMED, IEJBValidationContext.ERROR, bean, new String[] { bean.getEjbClass().getQualifiedName()}, this);
- vc.addMessage(message);
- }
- else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2802_UNNAMED, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- isValid = false;
- }
-
- try {
- ValidationRuleUtility.isValidTypeHierarchy(bean, bean.getHomeInterface());
- }
- catch (InvalidInputException exc) {
- if (bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_HomeInterface())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2803_NAMED, IEJBValidationContext.ERROR, bean, new String[] { bean.getHomeInterfaceName()}, this);
- vc.addMessage(message);
- }
- else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2803_UNNAMED, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- isValid = false;
- }
-
- try {
- ValidationRuleUtility.isValidTypeHierarchy(bean, bean.getRemoteInterface());
- }
- catch (InvalidInputException exc) {
- if (bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_RemoteInterface())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2804_NAMED, IEJBValidationContext.ERROR, bean, new String[] { bean.getRemoteInterfaceName()}, this);
- vc.addMessage(message);
- }
- else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2804_UNNAMED, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- isValid = false;
- }
-
- if (bean.isEntity()) {
- JavaClass primaryKey = ((Entity) bean).getPrimaryKey();
- try {
- ValidationRuleUtility.isValidTypeHierarchy(bean, primaryKey);
- }
- catch (InvalidInputException exc) {
- if (((Entity) bean).eIsSet(EjbPackage.eINSTANCE.getEntity_PrimaryKey())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2810_NAMED, IEJBValidationContext.ERROR, bean, new String[] { ((Entity) bean).getPrimaryKeyName()}, this);
- vc.addMessage(message);
- }
- else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2810_UNNAMED, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- isValid = false;
- }
- }
- return isValid;
- }
-
- public void validateCMPFieldElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean instanceof ContainerManagedEntity) {
- // check syntax of tag is okay
- ContainerManagedEntity cmp = (ContainerManagedEntity) bean;
- List fields = cmp.getPersistentAttributes();
- if ((fields == null) || (fields.size() == 0)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2812, IEJBValidationContext.ERROR, bean, new String[] { bean.getEjbClassName()}, this);
- vc.addMessage(message);
- return;
- }
-
- boolean mapsToMultipleFields = !ValidationRuleUtility.isPrimitivePrimaryKey((ContainerManagedEntity) bean);
- Iterator iterator = fields.iterator();
- Field field = null;
- List fieldNames = new ArrayList(fields.size());
- while (iterator.hasNext()) {
- CMPAttribute attrib = (CMPAttribute) iterator.next();
- if (attrib == null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("DDValidator.validateCMPFieldElement(EnterpriseBean)"); //$NON-NLS-1$
- entry.setText("CMPAttribute is null."); //$NON-NLS-1$
- logger.write(Level.FINEST, entry);
- }
- continue;
- }
-
- field = attrib.getField();
- if (field == null) {
- if (attrib.getName() != null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2811_NAMED, IEJBValidationContext.ERROR, bean, new String[] { attrib.getName(), bean.getEjbClassName()}, this);
- vc.addMessage(message);
- }
- else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2811_UNNAMED, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- continue;
- }
- else if (field.getName().equals(IMethodAndFieldConstants.FIELDNAME_SERIALVERSIONUID)) {
- // not a customer-entered field
- continue;
- }
-
- fieldNames.add(field.getName());
-
- try {
- // If the field is not a valid type
- ValidationRuleUtility.isValidType(ValidationRuleUtility.getType(field));
- }
- catch (InvalidInputException exc) {
- // field not identified
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2830, IEJBValidationContext.WARNING, bean, new String[] { field.getName()}, this);
- vc.addMessage(message);
- }
- }
-
- // 9.4.7.2
- if (mapsToMultipleFields && !ValidationRuleUtility.usesUnknownPrimaryKey(cmp)) {
- List primKeyFields = cmp.getPrimaryKey().getFieldsExtended();
-
- // (9.4.7.1 is validated in validatePrimKeyClassElement(bean)
- // check if the primary key class' fields exist in the container-managed fields
- iterator = primKeyFields.iterator();
-
- while (iterator.hasNext()) {
- Field keyField = (Field) iterator.next();
- if ((keyField.getName() != null) && (keyField.getName().equals(IMethodAndFieldConstants.FIELDNAME_SERIALVERSIONUID))) {
- // not a customer-entered field
- continue;
- }
-
- if (!fieldNames.contains(keyField.getName())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2831, IEJBValidationContext.WARNING, bean, new String[] { keyField.getName()}, this);
- vc.addMessage(message);
- }
- }
- }
-
- }
- }
-
- /**
- * This validateDeploymentDescriptor is called if the EJBJar could load, which means
- * that the syntax of the JAR is (mostly) correct.
- *
- * EJB spec 1.1, section C.4, "Added the requirement for the Bean Provider to specify whether the
- * enterprise bean uses a bean-managed or container-managed transaction."
- */
- public void validate(IEJBValidationContext vc, Object targetParent, Object target) {
- EJBJar ejbJar = null;
- if(targetParent instanceof EnterpriseBean) {
- // running as a dependent
- ejbJar = (EJBJar)vc.loadModel(EJBValidatorModelEnum.EJB_MODEL);
- }
- else {
- ejbJar = (EJBJar)targetParent;
- }
- EnterpriseBean bean = (EnterpriseBean)target;
-
- validate(vc, ejbJar, bean);
- }
-
- public void validate(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean == null) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2908, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
-
- // If bean isn't valid, don't perform any of the other
- // validation checks on it.
- return;
- }
-
- try {
- // Check if the class exists, etc.
- boolean reflected = validateBeanComponents(vc, ejbJar, bean); // assume everything will reflect properly
-
- validateEnterpriseTypeElement(vc, ejbJar, bean);
- validateEJBNameElement(vc, ejbJar, bean);
- validateReentrantElement(vc, ejbJar, bean);
- validateSessionTypeElement(vc, ejbJar, bean);
- validateTransactionTypeElement(vc, ejbJar, bean);
- validatePersistenceTypeElement(vc, ejbJar, bean);
- validateEnvironmentEntries(vc, ejbJar, bean);
-
- if (!reflected) {
- // Something didn't reflect properly, so don't continue with the
- // rest of the checks. Some metadata will be nonsense.
- return;
- }
-
- if (bean.isContainerManagedEntity()) {
- ContainerManagedEntity cmp = (ContainerManagedEntity) bean;
- if (cmp.getPrimKeyField() != null && !cmp.getPrimKeyField().eIsProxy()) {
- // Don't validate the fields if it's neither a primitive primary key nor a compound primary key.
- // If the user was attempting a primitive primary key, but did a typo in ejb-jar.xml,
- // the user will see a lot of strange messages logged against the fields in the primitive primary key.
- validateCMPFieldElement(vc, ejbJar, bean);
- }
- }
-
- validatePrimKeyClassElement(vc, ejbJar, bean);
- validateEJBRef(vc, ejbJar, bean);
- validateSecurityRoleRefElement(vc, ejbJar, bean);
- }
- catch(ValidationCancelledException e) {
- throw e;
- }
- /* unreachable catch block
- catch(ValidationException exc) {
- // If there's a problem, proceed with the next bean.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorConstants.CHKJ2852, IEJBValidationContext.WARNING, bean, new String[] { bean.getName() }, this);
- vc.addMessage(message);
- MsgLogger logger = vc.getMsgLogger();
- if (logger.isLoggingLevel(Level.FINER)) {
- logger.write(Level.FINER, exc);
- }
- }
- */
- catch (Throwable exc) {
- // If there's a problem, proceed with the next bean.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2852, IEJBValidationContext.WARNING, bean, new String[] { bean.getName() }, this);
- vc.addMessage(message);
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, exc);
- }
- }
- }
-
- public void validateEJBNameElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean == null) {
- return;
- }
-
- String name = bean.getName();
- if ((name == null) || (name.equals(""))) { //$NON-NLS-1$
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2801, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * Validate section 14.3 of the EJB 1.1 specification.
- *
- * 14.3 EJB References
- * 14.3.1 Bean Provider's responsibilities
- * 14.3.1.1 EJB reference programming interfaces
- * 14.3.1.2 Declaration of EJB references in deployment descriptor
- * 14.3.2 Application Assembler's responsibilities
- * 14.3.3 Deployer's responsibility
- * 14.3.4 Container Provider's responsibility
- */
- public void validateEJBRef(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean == null) {
- return;
- }
-
- List ejbRefs = bean.getEjbRefs();
- if ((ejbRefs == null) || (ejbRefs.size() == 0)) {
- return;
- }
-
- Iterator iterator = ejbRefs.iterator();
- EjbRef ref = null;
- while (iterator.hasNext()) {
- ref = (EjbRef) iterator.next();
- if (ref == null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("DDValidator.validateEJBRef(EnterpriseBean)"); //$NON-NLS-1$
- entry.setText("EjbRef is null in " + bean.getName()); //$NON-NLS-1$
- logger.write(Level.FINEST, entry);
- }
- continue;
- }
- // 14.3.1.1
- // Info mssg. "EJB spec recommends that all references to other enterprise beans be organized in the ejb subcontext of the bean's environment"
- EnterpriseBean namedEjb = null;
- if (ref.eIsSet(CommonPackage.eINSTANCE.getEjbRef_Link())) {
- // Load the EJB identified by the reference, if it exists.
- namedEjb = ejbJar.getEnterpiseBeanFromRef(ref);
- if (namedEjb != null) {
- // if it's null, let the EAR validator report it
- Integer ejbType = new Integer(ref.getType().getValue());
- boolean wrongType = false; // is the EJB, identified by ejb-link, of the type specified in the ejb-ref-type element?
- String type = (namedEjb instanceof Session) ? "Session" : "Entity"; //$NON-NLS-1$ //$NON-NLS-2$
- if (ejbType == null) {
- // Neither session nor entity?
- wrongType = true;
- }
- else if (ejbType.intValue() == EjbRefType.SESSION) {
- if (!(namedEjb instanceof Session)) {
- wrongType = true;
- }
- }
- else if (ejbType.intValue() == EjbRefType.ENTITY) {
- if (!(namedEjb instanceof Entity)) {
- wrongType = true;
- }
- }
- else {
- wrongType = true;
- }
- if (wrongType) {
- String[] parms = { namedEjb.getName(), type };
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2835, IEJBValidationContext.INFO, bean, parms, this);
- vc.addMessage(message);
- }
- }
- }
-
- // 14.3.1.2, 14.3.2, 14.3.4
- // Check that ejb-ref-name, ejb-ref-type, home, and remote have been defined, and exist
- validateHomeRef(vc, ejbJar, ref, namedEjb);
- validateRemoteRef(vc, ejbJar, ref, namedEjb);
-
- // 14.3.1.1
- // Info mssg. "EJB spec recommends that all references to other enterprise beans be organized in the ejb subcontext of the bean's environment"
- if (ref.getName() != null) {
- // If ejb name isn't set, that error would have been caught by one of the validateRef methods
- // Don't duplicate that effort here.
- String ejbName = ref.getName();
- if (!ejbName.startsWith("ejb/")) { //$NON-NLS-1$
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2838, IEJBValidationContext.INFO, bean, this);
- vc.addMessage(message);
- }
- }
- }
- }
-
- public void validateEnterpriseTypeElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- // Attempt in vain to validate the enterprise type element here, because
- // if it's not specified, there's a syntax error, and the
- // validateDeploymentDescriptor(IReporter, IValidationContext) would have been
- // called instead.
- /*
- if(! (bean.isSession() || bean.isEntity() )) {
- // no tag specified
- String beanName = (bean.getName() == null) ? "" : bean.getName();
- addValidationMessage(IEJBValidationContext.ERROR, IMessagePrefixEjb11Constants.EJB_DD_INVALID_ENTERPRISETYPE, new String[]{beanName}, bean);
- }
- */
- }
-
- /**
- * Validate section 14.3 of the EJB 1.1 specification.
- *
- * 14.2.1.2 Declaration of environment entries
- */
- public void validateEnvironmentEntries(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean == null) {
- return;
- }
-
- List envEntries = bean.getEnvironmentProperties();
- if ((envEntries == null) || (envEntries.size() == 0)) {
- return;
- }
-
- EnvEntry envEntry = null;
- Iterator iterator = envEntries.iterator();
- DuplicatesTable envNames = new DuplicatesTable();
- while (iterator.hasNext()) {
- envEntry = (EnvEntry) iterator.next();
- if (envEntry == null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("DDValidator.validateEnvironmentEntries(EnterpriseBean)"); //$NON-NLS-1$
- entry.setText("EjbEntry is null in " + bean.getName()); //$NON-NLS-1$
- logger.write(Level.FINEST, entry);
- }
- continue;
- }
-
- if (envEntry.getName() != null) {
- envNames.add(envEntry.getName());
- }
- else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2839, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
- }
-
- if (envEntry.isSetType()) {
- // 14.2.1.2; type must be one of these types: String, Integer, Boolean, Double, Byte, Short, Long, and Float.
- int type = envEntry.getType().getValue();
- if (!((type == EnvEntryType.BOOLEAN) || (type == EnvEntryType.BYTE) || (type == EnvEntryType.DOUBLE) || (type == EnvEntryType.FLOAT) || (type == EnvEntryType.INTEGER) || (type == EnvEntryType.LONG) || (type == EnvEntryType.SHORT) || (type == EnvEntryType.STRING))) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2840, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
- }
- }
- else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2840, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
- }
- }
-
- if (envNames.containsDuplicates()) {
- Iterator dups = envNames.getDuplicates().iterator();
- while (dups.hasNext()) {
- String name = (String) dups.next();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2841, IEJBValidationContext.WARNING, bean, new String[] { name }, this);
- vc.addMessage(message);
- }
- }
- }
-
- /**
- * If the metadata from the EjbRef is not valid, add a validation message.
- *
- * @parm EjbRef The <ejb-ref> element this method validates.
- * @parm EnterpriseBean If the <ejb-ref> uses an <ejb-link>, this is the enterprise bean identified by that link. If the link doesn't exist, or if the user has identified a bean which doesn't exist, this parameter will be null.
- */
- protected void validateHomeRef(IEJBValidationContext vc, EJBJar ejbJar, EjbRef ref, EnterpriseBean namedEjb) {
- boolean validType = true;
- EnterpriseBean bean = (EnterpriseBean)ref.eContainer();
- if (ref.eIsSet(CommonPackage.eINSTANCE.getEjbRef_Home())) {
- try {
- String homeName = ref.getHome();
- JavaHelpers type = ValidationRuleUtility.getType(homeName, bean);
- // Check that the home specified in the <home> element of the <ejb-ref> element
- // exists.
- ValidationRuleUtility.isValidType(type);
-
- if (namedEjb != null) {
- // Check that the home specified in the <home> element
- // is assignable to the home used by the named EJB in the
- // <ejb-link> element.
- JavaClass intfType = namedEjb.getHomeInterface();
- ValidationRuleUtility.isValidType(intfType);
-
- // Make sure that the identified home/remote interface in the ejb-ref
- // is of the same type as the one used by the bean.
- if (!ValidationRuleUtility.isAssignableFrom(type.getWrapper(), intfType)) {
- String[] parms = { namedEjb.getName(), intfType.getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2836, IEJBValidationContext.INFO, bean, parms, this);
- vc.addMessage(message);
- }
- }
- }
- catch (InvalidInputException exc) {
- validType = false;
- }
- }
- else {
- validType = false;
- }
-
- if (!validType) {
- String[] parms = { ref.getHome()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2832, IEJBValidationContext.INFO, bean, parms, this);
- vc.addMessage(message);
- }
- }
-
- public void validatePersistenceTypeElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- // Attempt in vain to validate the persistence type element here, because
- // if it's not specified, there's a syntax error, and the
- // validateDeploymentDescriptor(IReporter, IValidationContext) would have been
- // called instead.
- if (bean.isEntity()) {
- // check syntax
- Entity entityBean = (Entity) bean;
- if (!(entityBean.isContainerManagedEntity() || entityBean.isBeanManagedEntity())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2809, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- }
- }
- /**
- * If the primary key class reflected properly, return true. Else, return false.
- */
- public void validatePrimKeyClassElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean.isEntity()) {
- // check syntax
- if (bean instanceof ContainerManagedEntity) {
- ContainerManagedEntity cmp = (ContainerManagedEntity) bean;
- JavaClass clas = cmp.getPrimaryKey();
- if (clas != null && !clas.eIsProxy() && !isValidPrimKeyField(cmp,clas)) {
- // 9.4.7.1
- // user has specified both a prim-key-class and a primkey-field
- // can't use the CMPAttribute's field's name, because the primitive primary key returned is null
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2828, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- }
- }
- }
-
- /**
- * 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());
- }
-
- public void validateReentrantElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean.isEntity()) {
- // check syntax
- Entity entity = (Entity) bean;
- if (!entity.isSetReentrant()) {
- // Can only test if the reentrant attribute is set, because the model defaults it
- // to some boolean value if it isn't set.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2806, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- }
- }
-
- /**
- * If the metadata from the EjbRef is not valid, add a validation message.
- *
- * @parm EjbRef The ref whose home this method checks.
- * @parm EnterpriseBean If the EjbRef uses an <ejb-link> element, this is the enterprise bean identified by that element. It may be null, if the user has made a mistake.
- */
- protected void validateRemoteRef(IEJBValidationContext vc, EJBJar ejbJar, EjbRef ref, EnterpriseBean namedEjb) {
- boolean validType = true;
- EnterpriseBean bean = (EnterpriseBean)ref.eContainer();
- if (ref.eIsSet(CommonPackage.eINSTANCE.getEjbRef_Remote())) {
- try {
- String remoteName = ref.getRemote();
- JavaHelpers type = ValidationRuleUtility.getType(remoteName, bean);
- // Check that the home specified in the <home> element of the <ejb-ref> element
- // exists.
- ValidationRuleUtility.isValidType(type);
-
- if (namedEjb != null) {
- // Check that the home specified in the <home> element
- // is assignable to the home used by the named EJB in the
- // <ejb-link> element.
- JavaClass intfType = namedEjb.getRemoteInterface();
- ValidationRuleUtility.isValidType(intfType);
-
- // Make sure that the identified home/remote interface in the ejb-ref
- // is of the same type as the one used by the bean.
- if (!ValidationRuleUtility.isAssignableFrom(type.getWrapper(), intfType)) {
- String[] parms = { namedEjb.getName(), intfType.getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2837, IEJBValidationContext.INFO, bean, parms, this);
- vc.addMessage(message);
- }
- }
- }
- catch (InvalidInputException exc) {
- validType = false;
- }
- }
- else {
- validType = false;
- }
-
- if (!validType) {
- String[] parms = { ref.getRemote()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2833, IEJBValidationContext.INFO, bean, parms, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * 15.2.5.3 Declaration of security roles referenced from the bean's code
- * The Bean Provider is responsible for declaring in the security-role-ref
- * elements of the deployment descriptor all the security role names used
- * in the enterprise bean code. Declaring the security roles references in
- * the code allows the Application Assembler or Deployer to link the names
- * of the security roles used in the code to the security roles defined for
- * an assembled application through the security-role elements.
- * The Bean Provider must declare each security role referenced in the code
- * using the security-role-ref element as follows:
- * Declare the name of the security role using the role-name element.
- * The name must be the security role name that is used as a parameter to
- * the isCallerInRole(String role-Name) method.
- * Optional: Provide a description of the security role in the
- * description element. A security role reference, including the name defined
- * by the role-name element, is scoped to the session or entity bean element
- * whose declaration contains the security-role-ref element. The following
- * example illustrates how an enterprise bean's references to security roles
- * are declared in the deployment descriptor.
- * ...
- * <enterprise-beans>
- * ...
- * <entity>
- * <ejb-name>AardvarkPayroll</ejb-name>
- * <ejb-class>com.aardvark.payroll.PayrollBean</ejb-class>
- * ...
- * <security-role-ref>
- * <description>
- * This security role should be assigned to the
- * employees of the payroll department who are
- * allowed to update employees' salaries.
- * </description>
- * <role-name>payroll</role-name>
- * </security-role-ref>
- * ...
- * </entity>
- * ...
- * </enterprise-beans>
- * ...
- *
- * The deployment descriptor above indicates that the enterprise bean
- * AardvarkPayroll makes the security check using isCallerInRole("payroll")
- * in its business method.
- *
- *
- * 15.3.3 Linking security role references to security roles
- * If the Application Assembler defines the security-role elements in the
- * deployment descriptor, he or she is also responsible for linking all the
- * security role references declared in the security-role-ref elements to the
- * security roles defined in the security-role elements. The Application
- * Assembler links each security role reference to a security role using the
- * role-link element. The value of the role-link element must be the name of
- * one of the security roles defined in a security-role element.
- * A role-link element must be used even if the value of role-name is the
- * same as the value of the role-link reference.
- * The following deployment descriptor example shows how to link the security
- * role reference named payroll to the security role named payroll-department.
- * ...
- * <enterprise-beans>
- * ...
- * <entity>
- * <ejb-name>AardvarkPayroll</ejb-name>
- * <ejb-class>com.aardvark.payroll.PayrollBean</ejb-class>
- * ...
- * <security-role-ref>
- * <description>
- * This role should be assigned to the
- * employees of the payroll department.
- * Members of this role have access to
- * anyone's payroll record.
- *
- * The role has been linked to the
- * payroll-department role.
- * </description>
- * <role-name>payroll</role-name>
- * <role-link>payroll-department</role-link>
- * </security-role-ref>
- * ...
- * </entity>
- * ...
- * </enterprise-beans>
- * ...
- *
- */
- public void validateSecurityRoleRefElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean == null) {
- return;
- }
-
- /**
- * Need to build up a list of duplicate role names, but the validation message
- * needs to be registered against the duplicate SecurityRoleRef instance.
- * (Without the instance, we cannot get line numbers.)
- *
- * This class wrappers the SecurityRolRef instance so that the wrapper's
- * implemention of equals compares the names, but the validation message will
- * still be able to get the ref from the duplicate name.
- */
- class RoleRefWrapper {
- private SecurityRoleRef _ref = null;
-
- public RoleRefWrapper(SecurityRoleRef ref) {
- _ref = ref;
- }
-
- public boolean equals(Object o) {
- if (o instanceof RoleRefWrapper) {
- RoleRefWrapper other = (RoleRefWrapper) o;
- return _ref.getName().equals(other.getRoleRef().getName());
- }
- return false;
- }
-
- public SecurityRoleRef getRoleRef() {
- return _ref;
- }
- }
-
- boolean areSRolesDefined = ((_securityRoles != null) && (_securityRoles.size() > 0));
-
- List securityRoleRefs = bean.getSecurityRoleRefs();
- if ((securityRoleRefs != null) && (securityRoleRefs.size() != 0)) {
- // Check that each security role ref refers to a security role,
- // if security roles are defined in the assembly descriptor,
- // and that each referenced security role exists.
- DuplicatesTable roleRefNames = new DuplicatesTable();
- for (int i = 0; i < securityRoleRefs.size(); i++) {
- SecurityRoleRef ref = (SecurityRoleRef) securityRoleRefs.get(i);
-
- // Check that the role name is set (15.2.5.3)
- String roleName = ref.getName();
- if ((roleName == null) || (roleName.equals(""))) { //$NON-NLS-1$
- roleName = ""; //$NON-NLS-1$
- String beanName = (bean.getName() == null) ? "" : bean.getName(); //$NON-NLS-1$
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2822, IEJBValidationContext.WARNING, ref, new String[] { beanName }, this);
- vc.addMessage(message);
- }
- else {
- // Build up the list of names, to check for duplicates
- roleRefNames.add(new RoleRefWrapper(ref));
- }
-
- // Check that the role link is set (15.3.3)
- String roleLink = ref.getLink();
- boolean isLinkDefined = ((ref.eIsSet(CommonPackage.eINSTANCE.getSecurityRoleRef_Link())) && (roleLink != null) && (!roleLink.equals(""))); //$NON-NLS-1$
-
- if ((areSRolesDefined) && (!isLinkDefined)) {
- // must have role link defined (15.3.3)
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2823, IEJBValidationContext.WARNING, ref, this);
- vc.addMessage(message);
- }
- else if ((!areSRolesDefined) && (isLinkDefined)) {
- // must not have role link defined (15.2.5.3)
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2827, IEJBValidationContext.WARNING, ref, this);
- vc.addMessage(message);
- }
- else if (areSRolesDefined && isLinkDefined) {
- // check that the role listed in the link exists. (15.3.3)
- Iterator iterator = _securityRoles.iterator();
- boolean roleExists = false;
- while(iterator.hasNext()) {
- SecurityRole role = (SecurityRole)iterator.next();
- if(role.getRoleName().equals(roleLink)) {
- roleExists = true;
- break;
- }
- }
- if (!roleExists) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2824, IEJBValidationContext.WARNING, ref, new String[] { roleName }, this);
- vc.addMessage(message);
- }
- }
- }
-
- // Check for duplicates
- // Check that there are no duplicate role-names. (15.3.1)
- if (roleRefNames.containsDuplicates()) {
- List duplicates = roleRefNames.getDuplicates();
- Iterator iterator = duplicates.iterator();
- while (iterator.hasNext()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2820, IEJBValidationContext.WARNING, ((RoleRefWrapper) iterator.next()).getRoleRef(), this);
- vc.addMessage(message);
- }
- }
- roleRefNames.clear();
- }
- }
-
- /**
- * 6.5.3 The optional SessionSynchronization interface
- *...
- * Only a stateful Session bean with container-managed transaction demarcation may
- * implement the SessionSynchronization interface.
- *...
- * There is no need for a Session bean with bean-managed transaction to rely on the
- * synchronization call backs because the bean is in control of the commit the bean
- * knows when the transaction is about to be committed and it knows the outcome of the
- * transaction commit.
- *...
- */
- public void validateSessionTypeElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean.isSession()) {
- Session session = (Session) bean;
-
- // check syntax
- boolean isValidSess = isValidSessionTypeElement(session);
- if (!isValidSess) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2807, IEJBValidationContext.ERROR, session, this);
- vc.addMessage(message);
- }
- }
- }
-
- public void validateTransactionTypeElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean.isSession()) {
- // check syntax
- Session sessionBean = (Session) bean;
- if (!isValidTransactionTypeElement(sessionBean)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2808, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- }
- }
-
- /*
- * @see IValidationRule#reset()
- */
- public void reset() {
- super.reset();
- _securityRoles = null;
- }
-
- /*
- * @see IValidationRule#preValidate(IEJBValidationContext, Object, Object)
- */
- public void preValidate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException {
- super.preValidate(vc, targetParent, target);
-
- EJBJar ejbJar = (EJBJar)vc.loadModel(EJBValidatorModelEnum.EJB_MODEL);
- if(ejbJar == null) {
- return;
- }
-
- if(ejbJar.getAssemblyDescriptor() == null) {
- return;
- }
- _securityRoles = ejbJar.getAssemblyDescriptor().getSecurityRoles();
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EnterpriseBean20VRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EnterpriseBean20VRule.java
deleted file mode 100644
index 58262df3e..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/EnterpriseBean20VRule.java
+++ /dev/null
@@ -1,1258 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.common.CommonPackage;
-import org.eclipse.jst.j2ee.common.EjbRef;
-import org.eclipse.jst.j2ee.common.EjbRefType;
-import org.eclipse.jst.j2ee.common.EnvEntry;
-import org.eclipse.jst.j2ee.common.EnvEntryType;
-import org.eclipse.jst.j2ee.common.SecurityRole;
-import org.eclipse.jst.j2ee.common.SecurityRoleRef;
-import org.eclipse.jst.j2ee.ejb.ActivationConfig;
-import org.eclipse.jst.j2ee.ejb.ActivationConfigProperty;
-import org.eclipse.jst.j2ee.ejb.CMPAttribute;
-import org.eclipse.jst.j2ee.ejb.CMRField;
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-import org.eclipse.jst.j2ee.ejb.EjbPackage;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.jst.j2ee.ejb.MessageDriven;
-import org.eclipse.jst.j2ee.ejb.Session;
-import org.eclipse.jst.j2ee.ejb.internal.util.MDBActivationConfigModelUtil;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * @version 1.0
- * @author
- */
-public class EnterpriseBean20VRule extends AValidationRule implements IMessagePrefixEjb20Constants {
- private List _securityRoles = null;
- private static final Map MESSAGE_IDS;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_BMP_BEANCLASS, IValidationRuleList.EJB20_BMP_HOME, IValidationRuleList.EJB20_BMP_KEYCLASS, IValidationRuleList.EJB20_BMP_LOCAL, IValidationRuleList.EJB20_BMP_LOCALHOME, IValidationRuleList.EJB20_BMP_REMOTE, IValidationRuleList.EJB20_CMP_BEANCLASS, IValidationRuleList.EJB20_CMP_HOME, IValidationRuleList.EJB20_CMP_KEYCLASS, IValidationRuleList.EJB20_CMP_LOCAL, IValidationRuleList.EJB20_CMP_LOCALHOME, IValidationRuleList.EJB20_CMP_REMOTE, IValidationRuleList.EJB20_STATEFUL_SESSION_BEANCLASS, IValidationRuleList.EJB20_STATEFUL_SESSION_HOME, IValidationRuleList.EJB20_STATEFUL_SESSION_LOCAL, IValidationRuleList.EJB20_STATEFUL_SESSION_LOCALHOME, IValidationRuleList.EJB20_STATEFUL_SESSION_REMOTE, IValidationRuleList.EJB20_STATELESS_SESSION_BEANCLASS, IValidationRuleList.EJB20_STATELESS_SESSION_HOME, IValidationRuleList.EJB20_STATELESS_SESSION_LOCAL, IValidationRuleList.EJB20_STATELESS_SESSION_LOCALHOME, IValidationRuleList.EJB20_STATELESS_SESSION_REMOTE};
- private static String JMS_MESSAGING_TYPE = "javax.jms.MessageListener";
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2800_NAMED, new String[]{CHKJ2800_NAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2800_UNNAMED, new String[]{CHKJ2800_UNNAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2801, new String[]{CHKJ2801+SPEC});
- MESSAGE_IDS.put(CHKJ2802_NAMED, new String[]{CHKJ2802_NAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2802_UNNAMED, new String[]{CHKJ2802_UNNAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2803_NAMED, new String[]{CHKJ2803_NAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2803_UNNAMED, new String[]{CHKJ2803_UNNAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2804_NAMED, new String[]{CHKJ2804_NAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2804_UNNAMED, new String[]{CHKJ2804_UNNAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2805_NAMED, new String[]{CHKJ2805_NAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2805_UNNAMED, new String[]{CHKJ2805_UNNAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2806, new String[]{CHKJ2806+SPEC});
- MESSAGE_IDS.put(CHKJ2807, new String[]{CHKJ2807+SPEC});
- MESSAGE_IDS.put(CHKJ2808, new String[]{CHKJ2808+SPEC});
- MESSAGE_IDS.put(CHKJ2809, new String[]{CHKJ2809+SPEC});
- MESSAGE_IDS.put(CHKJ2810_NAMED, new String[]{CHKJ2810_NAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2810_UNNAMED, new String[]{CHKJ2810_UNNAMED+SPEC});
- MESSAGE_IDS.put(CHKJ2813, new String[]{CHKJ2813+SPEC});
- MESSAGE_IDS.put(CHKJ2820, new String[]{CHKJ2820+SPEC});
- MESSAGE_IDS.put(CHKJ2822, new String[]{CHKJ2822+SPEC});
- MESSAGE_IDS.put(CHKJ2823, new String[]{CHKJ2823+SPEC});
- MESSAGE_IDS.put(CHKJ2824, new String[]{CHKJ2824+SPEC});
- MESSAGE_IDS.put(CHKJ2825, new String[]{CHKJ2825+SPEC});
- MESSAGE_IDS.put(CHKJ2826, new String[]{CHKJ2826+SPEC});
- MESSAGE_IDS.put(CHKJ2827, new String[]{CHKJ2827+SPEC});
- MESSAGE_IDS.put(CHKJ2828, new String[]{CHKJ2828+SPEC});
- MESSAGE_IDS.put(CHKJ2830, new String[]{CHKJ2830+SPEC});
- MESSAGE_IDS.put(CHKJ2831, new String[]{CHKJ2831+SPEC});
- MESSAGE_IDS.put(CHKJ2832, new String[]{CHKJ2832+SPEC});
- MESSAGE_IDS.put(CHKJ2833, new String[]{CHKJ2833+SPEC});
- MESSAGE_IDS.put(CHKJ2834, new String[]{CHKJ2834+SPEC});
- MESSAGE_IDS.put(CHKJ2835, new String[]{CHKJ2835+SPEC});
- MESSAGE_IDS.put(CHKJ2836, new String[]{CHKJ2836+SPEC});
- MESSAGE_IDS.put(CHKJ2837, new String[]{CHKJ2837+SPEC});
- MESSAGE_IDS.put(CHKJ2838, new String[]{CHKJ2838+SPEC});
- MESSAGE_IDS.put(CHKJ2839, new String[]{CHKJ2839+SPEC});
- MESSAGE_IDS.put(CHKJ2840, new String[]{CHKJ2840+SPEC});
- MESSAGE_IDS.put(CHKJ2841, new String[]{CHKJ2841+SPEC});
- MESSAGE_IDS.put(CHKJ2845, new String[]{CHKJ2845+SPEC});
- MESSAGE_IDS.put(CHKJ2846, new String[]{CHKJ2846+SPEC});
- MESSAGE_IDS.put(CHKJ2847, new String[]{CHKJ2847+SPEC});
- MESSAGE_IDS.put(CHKJ2852, new String[]{CHKJ2852});
- MESSAGE_IDS.put(CHKJ2854, new String[]{CHKJ2854+SPEC});
- MESSAGE_IDS.put(CHKJ2855, new String[]{CHKJ2855+SPEC});
- MESSAGE_IDS.put(CHKJ2856, new String[]{CHKJ2856+SPEC});
- MESSAGE_IDS.put(CHKJ2857, new String[]{CHKJ2857+SPEC});
- MESSAGE_IDS.put(CHKJ2858, new String[]{CHKJ2858+SPEC});
- MESSAGE_IDS.put(CHKJ2859, new String[]{CHKJ2859+SPEC});
- MESSAGE_IDS.put(CHKJ2860, new String[]{CHKJ2860+SPEC});
- MESSAGE_IDS.put(CHKJ2880, new String[]{"CHKJ2880.s"+SPEC, "CHKJ2880.b"+SPEC, "CHKJ2880.c"+SPEC}); // special case; need diff spec number for each type of bean //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- MESSAGE_IDS.put(CHKJ2881, new String[]{"CHKJ2881.s"+SPEC, "CHKJ2881.b"+SPEC, "CHKJ2881.c"+SPEC}); // special case; need diff spec number for each type of bean //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- MESSAGE_IDS.put(CHKJ2882, new String[]{"CHKJ2882.s"+SPEC, "CHKJ2882.b"+SPEC, "CHKJ2882.c"+SPEC}); // special case; need diff spec number for each type of bean //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- MESSAGE_IDS.put(CHKJ2883, new String[]{"CHKJ2883.s"+SPEC, "CHKJ2883.b"+SPEC, "CHKJ2883.c"+SPEC}); // special case; need diff spec number for each type of bean //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- MESSAGE_IDS.put(CHKJ2884, new String[]{"CHKJ2884.s"+SPEC, "CHKJ2884.b"+SPEC, "CHKJ2884.c"+SPEC}); // special case; need diff spec number for each type of bean //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- MESSAGE_IDS.put(CHKJ2885, new String[]{"CHKJ2885.s"+SPEC, "CHKJ2885.b"+SPEC, "CHKJ2885.c"+SPEC}); // special case; need diff spec number for each type of bean //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public Object[] getDependsOn() {
- // EJBJar doesn't depend on anything else
- return DEPENDS_ON;
- }
-
- public Object getId() {
- return IValidationRuleList.EJB20_ENTERPRISEBEAN;
- }
-
- public Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public Object getTarget(Object parent, Object clazz) {
- return parent; // The parent will be an EnterpriseBean.
- }
-
- /*
- * @see IValidationRule#validate(IEJBValidationContext, Object, Object)
- */
- public void validate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException {
- Logger logger = vc.getMsgLogger();
- if(logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("EnterpriseBean20VRule - validate"); //$NON-NLS-1$
- entry.setText(getClass().getName() + "::validate(" + targetParent + ", " + target); //$NON-NLS-1$ //$NON-NLS-2$
- logger.write(Level.FINEST, entry);
- }
-
- EJBJar ejbJar = null;
- if(targetParent instanceof EnterpriseBean) {
- // running as a dependent
- ejbJar = (EJBJar)vc.loadModel(EJBValidatorModelEnum.EJB_MODEL);
- }
- else {
- ejbJar = (EJBJar)targetParent;
- }
- EnterpriseBean bean = (EnterpriseBean)target;
-
- validate(vc, ejbJar, bean);
- }
-
-
- public void validate(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) throws ValidationCancelledException, ValidationException {
- Logger logger = vc.getMsgLogger();
- try {
- // Check if the bean parts are reflected. Some rules can be validated
- // whether or not the bean is reflected.
- boolean reflected = validateBeanComponentsReflected(vc, ejbJar, bean);
-
- // These rules can be validated whether or not the bean is reflected.
- validateEJBNameElement(vc, ejbJar, bean);
- validateReentrantElement(vc, ejbJar, bean);
- validateSessionTypeElement(vc, ejbJar, bean);
- validateTransactionTypeElement(vc, ejbJar, bean);
- validatePersistenceTypeElement(vc, ejbJar, bean);
- validateEnvironmentEntries(vc, ejbJar, bean);
-
- // The rest of the rules cannot be validated because the bean isn't reflected.
- if (!reflected) {
- return;
- }
-
- validateLocalPairs(vc, ejbJar, bean);
- validateRemotePairs(vc, ejbJar, bean);
- validateLocalOrRemote(vc, ejbJar, bean);
-
- if (bean.isContainerManagedEntity()) {
- ContainerManagedEntity cmp = (ContainerManagedEntity) bean;
- if((cmp.getPrimKeyField() != null) && !cmp.getPrimKeyField().eIsProxy()) {
- // Don't validate the fields if it's neither a primitive primary key nor a compound primary key.
- // If the user was attempting a primitive primary key, but did a typo in ejb-jar.xml,
- // the user will see a lot of strange messages logged against the fields in the primitive primary key.
- validateCMPFieldElement(vc, ejbJar, cmp);
- }
- validateAbstractSchemaNameElement(vc, ejbJar, cmp);
- validateJavaIdentifier(vc, ejbJar, cmp);
- }
- if(bean.isMessageDriven() && bean.getVersionID() == J2EEVersionConstants.EJB_2_1_ID) {
- validateActivationConfiguration(vc, (MessageDriven)bean);
- }
- validatePrimKeyClassElement(vc, ejbJar, bean);
- validateEJBRef(vc, ejbJar, bean);
- }
- catch(ValidationCancelledException e) {
- throw e;
- }
- catch (Throwable exc) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2852, IEJBValidationContext.WARNING, bean, new String[]{J2EEConstants.EJBJAR_DD_SHORT_NAME, bean.getName()}, this);
- vc.addMessage(message);
- if (logger != null && logger.isLoggingLevel(Level.SEVERE)) {
- logger.write(Level.SEVERE, exc);
- }
- }
- }
-
- /**
- * If the bean components (home interface, remote interface, bean class, and primary
- * key) can all be found and reflected, return true. Let the DDValidator
- * report the error message against the bean if one of these types doesn't reflect.
- */
- public boolean validateBeanComponentsReflected(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- // Don't need to check if the bean is null, because this method will
- // not be called if it is.
- boolean isValid = true;
- try {
- ValidationRuleUtility.isValidTypeHierarchy(bean, bean.getEjbClass());
- }
- catch (InvalidInputException exc) {
- IMessage message = null;
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_EjbClass())) {
- message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2802_NAMED, IEJBValidationContext.ERROR, bean, new String[]{bean.getEjbClassName()}, this);
- }
- else {
- message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2802_UNNAMED, IEJBValidationContext.ERROR, bean, this);
- }
- vc.addMessage(message);
- isValid = false;
- }
-
- if(bean instanceof MessageDriven) {
- // don't need to check the rest
- return isValid;
- }
-
- try {
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_HomeInterface())) {
- ValidationRuleUtility.isValidTypeHierarchy(bean, bean.getHomeInterface());
- }
- }
- catch (InvalidInputException exc) {
- IMessage message = null;
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_HomeInterface())) {
- message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2803_NAMED, IEJBValidationContext.ERROR, bean, new String[]{bean.getHomeInterfaceName()}, this);
- }
- else {
- message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2803_UNNAMED, IEJBValidationContext.ERROR, bean, this);
- }
- vc.addMessage(message);
- isValid = false;
- }
-
- try {
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_RemoteInterface())) {
- ValidationRuleUtility.isValidTypeHierarchy(bean, bean.getRemoteInterface());
- }
- }
- catch (InvalidInputException exc) {
- IMessage message = null;
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_RemoteInterface())) {
- message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2804_NAMED, IEJBValidationContext.ERROR, bean, new String[]{bean.getRemoteInterfaceName()}, this);
- }
- else {
- message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2804_UNNAMED, IEJBValidationContext.ERROR, bean, this);
- }
- vc.addMessage(message);
- isValid = false;
- }
-
- try {
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_LocalHomeInterface())) {
- ValidationRuleUtility.isValidTypeHierarchy(bean, bean.getLocalHomeInterface());
- }
- }
- catch (InvalidInputException exc) {
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_LocalHomeInterface())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2805_NAMED, IEJBValidationContext.ERROR, bean, new String[]{bean.getLocalHomeInterfaceName()}, this);
- vc.addMessage(message);
- isValid = false;
- }
- else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2805_UNNAMED, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- isValid = false;
- }
- }
-
- try {
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_LocalInterface())) {
- ValidationRuleUtility.isValidTypeHierarchy(bean, bean.getLocalInterface());
- }
- }
- catch (InvalidInputException exc) {
- IMessage message = null;
- if(bean.eIsSet(EjbPackage.eINSTANCE.getEnterpriseBean_LocalInterface())) {
- message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2800_NAMED, IEJBValidationContext.ERROR, bean, new String[]{bean.getLocalInterfaceName()}, this);
- }
- else {
- message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2800_UNNAMED, IEJBValidationContext.ERROR, bean, this);
- }
- vc.addMessage(message);
- isValid = false;
- }
-
- if (bean.isEntity()) {
- JavaClass primaryKey = ((Entity) bean).getPrimaryKey();
- try {
- ValidationRuleUtility.isValidTypeHierarchy(bean, primaryKey);
- }
- catch (InvalidInputException exc) {
- IMessage message = null;
- if(((Entity)bean).eIsSet(EjbPackage.eINSTANCE.getEntity_PrimaryKey())) {
- message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2810_NAMED, IEJBValidationContext.ERROR, bean, new String[]{((Entity)bean).getPrimaryKeyName()}, this);
- }
- else {
- message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2810_UNNAMED, IEJBValidationContext.ERROR, bean, this);
- }
- vc.addMessage(message);
- isValid = false;
- }
- }
-
- return isValid;
- }
-
- public void validateCMPFieldElement(IEJBValidationContext vc, EJBJar ejbJar, ContainerManagedEntity cmp) {
- // check syntax of tag is okay
- List fields = cmp.getPersistentAttributes();
- if ((fields == null) || (fields.size() == 0)) {
- // unlike EJB 1.1 CMPs, this is legal.
- return;
- }
-
- boolean mapsToMultipleFields = !ValidationRuleUtility.isPrimitivePrimaryKey(cmp);
- Iterator iterator = fields.iterator();
-// Field field = null;
- List fieldNames = new ArrayList(fields.size());
- while (iterator.hasNext()) {
- CMPAttribute attrib = (CMPAttribute) iterator.next();
- if (attrib == null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("DDValidator.validateCMPFieldElement(EnterpriseBean)"); //$NON-NLS-1$
- entry.setText("CMPAttribute is null."); //$NON-NLS-1$
- logger.write(Level.FINEST, entry);
- }
- continue;
- }
-
- fieldNames.add(attrib.getName());
-
- JavaHelpers fieldType = attrib.getType();
- try {
- // If the field is not a valid type
- ValidationRuleUtility.isValidType(fieldType);
- }
- catch (InvalidInputException exc) {
- // field not identified
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2830, IEJBValidationContext.WARNING, cmp, new String[] { attrib.getName()}, this);
- vc.addMessage(message);
- continue; // if you can't reflect it, then you can't validate it
- }
-
- try {
- if(!fieldType.isPrimitive() &&
- !ValidationRuleUtility.isSerializable(fieldType, cmp)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2855, IEJBValidationContext.INFO, cmp, new String[] { attrib.getName()}, this);
- vc.addMessage(message);
- }
- }
- catch(InvalidInputException e) {
- String[] msgParm = (e.getJavaClass() == null) ? new String[]{} : new String[]{e.getJavaClass().getQualifiedName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2907, IEJBValidationContext.WARNING, cmp, msgParm, this);
- vc.addMessage(message);
- }
- }
-
- // 9.4.7.2
- if (mapsToMultipleFields && !ValidationRuleUtility.usesUnknownPrimaryKey(cmp)) {
- List primKeyFields = cmp.getPrimaryKey().getFieldsExtended();
-
- // (9.4.7.1 is validated in validatePrimKeyClassElement(bean)
- // check if the primary key class' fields exist in the container-managed fields
- iterator = primKeyFields.iterator();
-
- while (iterator.hasNext()) {
- Field keyField = (Field) iterator.next();
- if ((keyField.getName() != null) && (keyField.getName().equals(IMethodAndFieldConstants.FIELDNAME_SERIALVERSIONUID))) {
- // not a customer-entered field
- continue;
- }
-
- if (!fieldNames.contains(keyField.getName())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2831, IEJBValidationContext.WARNING, cmp, new String[] { keyField.getName()}, this);
- vc.addMessage(message);
- }
- }
- }
- }
-
- public void validateCMRFieldElement(IEJBValidationContext vc, EJBJar ejbJar, ContainerManagedEntity cmp) {
- if (cmp == null)
- return;
- switch(cmp.getVersionID()) {
- case J2EEVersionConstants.EJB_1_0_ID:
- case J2EEVersionConstants.EJB_1_1_ID:
- break;
- case J2EEVersionConstants.EJB_2_0_ID:
- case J2EEVersionConstants.EJB_2_1_ID: default:
- List fields = cmp.getCMRFields();
- Iterator iterator = fields.iterator();
- while(iterator.hasNext()) {
- CMRField field = (CMRField)iterator.next();
- String fieldName = field.getName();
- if((fieldName == null) || (fieldName.equals(""))) { //$NON-NLS-1$
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2857, IEJBValidationContext.INFO, cmp, new String[] { field.getName()}, this);
- vc.addMessage(message);
- continue; // don't look for the get methods
- }
- if(!ValidationRuleUtility.isValidJavaIdentifier(fieldName)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2857, IEJBValidationContext.INFO, cmp, new String[] { field.getName()}, this);
- vc.addMessage(message);
- }
-
- try {
- JavaHelpers fieldType = field.getType();
- if(!ValidationRuleUtility.isAssignableFrom(fieldType, cmp.getLocalInterface()) &&
- !ValidationRuleUtility.isAssignableFromCollection(fieldType, cmp) &&
- !ValidationRuleUtility.isAssignableFromSet(fieldType, cmp)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2856, IEJBValidationContext.INFO, cmp, new String[] { field.getName()}, this);
- vc.addMessage(message);
- }
- }
- catch(InvalidInputException e) {
- String[] msgParm = (e.getJavaClass() == null) ? new String[]{} : new String[]{e.getJavaClass().getQualifiedName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2907, IEJBValidationContext.WARNING, cmp, msgParm, this);
- vc.addMessage(message);
- }
- }
- break;
- }
- }
-
- public void validateEJBNameElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean == null) {
- return;
- }
-
- String name = bean.getName();
- if ((name == null) || (name.equals(""))) { //$NON-NLS-1$
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2801, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
-
- if(bean.isContainerManagedEntity() && bean.getVersionID() >= J2EEVersionConstants.EJB_2_0_ID) {
- if(!ValidationRuleUtility.isValidJavaIdentifier(name)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2813, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
- }
-
- // p. 466
- // "The name for an entity bean with cmp-version 2.x must conform
- // to the lexical rules for an NMTOKEN. The name for an entity bean with
- // cmp-version 2.x must not be a reserved literal in EJB QL.
- if(ValidationRuleUtility.isReservedWord(name)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2859, IEJBValidationContext.INFO, bean, this);
- vc.addMessage(message);
- }
- }
- }
-
- public void validateAbstractSchemaNameElement(IEJBValidationContext vc, EJBJar ejbJar, ContainerManagedEntity cmp) {
- if (cmp == null)
- return;
- switch(cmp.getVersionID()) {
- case J2EEVersionConstants.EJB_1_0_ID:
- case J2EEVersionConstants.EJB_1_1_ID:
- break;
- case J2EEVersionConstants.EJB_2_0_ID:
- case J2EEVersionConstants.EJB_2_1_ID: default:
-
- String name = cmp.getAbstractSchemaName();
- if(!ValidationRuleUtility.isValidJavaIdentifier(name)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2858, IEJBValidationContext.WARNING, cmp, this);
- vc.addMessage(message);
- }
-
- // Check that the name is not a reserved word
- if(ValidationRuleUtility.isReservedWord(name)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2860, IEJBValidationContext.INFO, cmp, this);
- vc.addMessage(message);
- }
- break;
- }
- }
-
- public void validateJavaIdentifier(IEJBValidationContext vc, EJBJar ejbJar, ContainerManagedEntity cmp) {
- /*
- * Don't duplicate the EJB QL validator's function.
- List queries = cmp.getQueries();
- Iterator iterator = queries.iterator();
- Query query = (Query)iterator.next();
- */
- }
-
-
- /**
- * Validate section 14.3 of the EJB 1.1 specification.
- *
- * 14.3 EJB References
- * 14.3.1 Bean Provider's responsibilities
- * 14.3.1.1 EJB reference programming interfaces
- * 14.3.1.2 Declaration of EJB references in deployment descriptor
- * 14.3.2 Application Assembler's responsibilities
- * 14.3.3 Deployer's responsibility
- * 14.3.4 Container Provider's responsibility
- */
- public void validateEJBRef(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean == null) {
- return;
- }
-
- List ejbRefs = bean.getEjbRefs();
- if ((ejbRefs == null) || (ejbRefs.size() == 0)) {
- return;
- }
-
- Iterator iterator = ejbRefs.iterator();
- EjbRef ref = null;
- while (iterator.hasNext()) {
- ref = (EjbRef) iterator.next();
- if (ref == null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("DDValidator.validateEJBRef(EnterpriseBean)"); //$NON-NLS-1$
- entry.setText("EjbRef is null in " + bean.getName()); //$NON-NLS-1$
- logger.write(Level.FINEST, entry);
- }
- continue;
- }
- // 14.3.1.1
- // Info mssg. "EJB spec recommends that all references to other enterprise beans be organized in the ejb subcontext of the bean's environment"
- EnterpriseBean namedEjb = null;
- if (ref.eIsSet(CommonPackage.eINSTANCE.getEjbRef_Link())) {
- // Load the EJB identified by the reference, if it exists.
- namedEjb = ejbJar.getEnterpiseBeanFromRef(ref);
- if (namedEjb != null) {
- // if the named EJB is null it could be in another EJBJar
- Integer ejbType = new Integer(ref.getType().getValue());
- boolean wrongType = false; // is the EJB, identified by ejb-link, of the type specified in the ejb-ref-type element?
- String type = (namedEjb instanceof Session) ? "Session" : "Entity"; //$NON-NLS-1$ //$NON-NLS-2$
- if (ejbType == null) {
- // Neither session nor entity?
- wrongType = true;
- }
- else if (ejbType.intValue() == EjbRefType.SESSION) {
- if (!(namedEjb instanceof Session)) {
- wrongType = true;
- }
- }
- else if (ejbType.intValue() == EjbRefType.ENTITY) {
- if (!(namedEjb instanceof Entity)) {
- wrongType = true;
- }
- }
- else {
- wrongType = true;
- }
- if (wrongType) {
- String[] parms = { namedEjb.getName(), type };
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2835, IEJBValidationContext.INFO, bean, parms, this);
- vc.addMessage(message);
- }
- }
- }
-
- // 14.3.1.2, 14.3.2, 14.3.4
- // Check that ejb-ref-name, ejb-ref-type, home, and remote have been defined, and exist
- validateHomeRef(vc, ejbJar, ref, namedEjb);
- validateRemoteRef(vc, ejbJar, ref, namedEjb);
-
- // 14.3.1.1
- // Info mssg. "EJB spec recommends that all references to other enterprise beans be organized in the ejb subcontext of the bean's environment"
- if (ref.eIsSet(CommonPackage.eINSTANCE.getEjbRef_Name())) {
- // If ejb name isn't set, that error would have been caught by one of the validateRef methods
- // Don't duplicate that effort here.
- String ejbName = ref.getName();
- if (!ejbName.startsWith("ejb/")) { //$NON-NLS-1$
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2838, IEJBValidationContext.INFO, bean, this);
- vc.addMessage(message);
- }
- }
- }
- }
-
- /**
- * Validate section 14.3 of the EJB 1.1 specification.
- *
- * 14.2.1.2 Declaration of environment entries
- */
- public void validateEnvironmentEntries(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean == null) {
- return;
- }
-
- List envEntries = bean.getEnvironmentProperties();
- if ((envEntries == null) || (envEntries.size() == 0)) {
- return;
- }
-
- EnvEntry envEntry = null;
- Iterator iterator = envEntries.iterator();
- DuplicatesTable envNames = new DuplicatesTable();
- while (iterator.hasNext()) {
- envEntry = (EnvEntry) iterator.next();
- if (envEntry == null) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = vc.getLogEntry();
- entry.setSourceID("DDValidator.validateEnvironmentEntries(EnterpriseBean)"); //$NON-NLS-1$
- entry.setText("EjbEntry is null in " + bean.getName()); //$NON-NLS-1$
- logger.write(Level.FINEST, entry);
- }
- continue;
- }
-
- if (envEntry.getName() != null) {
- envNames.add(envEntry.getName());
- }
- else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2839, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
- }
-
- if (envEntry.isSetType()) {
- // 14.2.1.2; type must be one of these types: String, Integer, Boolean, Double, Byte, Short, Long, and Float.
- int type = envEntry.getType().getValue();
- if (!((type == EnvEntryType.BOOLEAN) || (type == EnvEntryType.BYTE) || (type == EnvEntryType.DOUBLE) || (type == EnvEntryType.FLOAT) || (type == EnvEntryType.INTEGER) || (type == EnvEntryType.LONG) || (type == EnvEntryType.SHORT) || (type == EnvEntryType.STRING) || (type == EnvEntryType.CHARACTER))) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2840, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
- }
- }
- else {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2840, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
- }
- }
-
- if (envNames.containsDuplicates()) {
- Iterator dups = envNames.getDuplicates().iterator();
- while (dups.hasNext()) {
- String name = (String) dups.next();
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2841, IEJBValidationContext.WARNING, bean, new String[] { name }, this);
- vc.addMessage(message);
- }
- }
- }
-
- /**
- * If the metadata from the EjbRef is not valid, add a validation message.
- *
- * @parm EjbRef The <ejb-ref> element this method validates.
- * @parm EnterpriseBean If the <ejb-ref> uses an <ejb-link>, this is the enterprise bean identified by that link. If the link doesn't exist, or if the user has identified a bean which doesn't exist, this parameter will be null.
- */
- protected void validateHomeRef(IEJBValidationContext vc, EJBJar ejbJar, EjbRef ref, EnterpriseBean namedEjb) {
- boolean validType = true;
- EnterpriseBean bean = (EnterpriseBean)ref.eContainer();
- if (ref.eIsSet(CommonPackage.eINSTANCE.getEjbRef_Home())) {
- try {
- String homeName = ref.getHome();
- JavaHelpers type = ValidationRuleUtility.getType(homeName, bean);
- // Check that the home specified in the <home> element of the <ejb-ref> element
- // exists.
- ValidationRuleUtility.isValidType(type);
-
- if (namedEjb != null) {
- // Check that the home specified in the <home> element
- // is assignable to the home used by the named EJB in the
- // <ejb-link> element.
- JavaClass intfType = namedEjb.getHomeInterface();
- ValidationRuleUtility.isValidType(intfType);
-
- // Make sure that the identified home/remote interface in the ejb-ref
- // is of the same type as the one used by the bean.
- if (!ValidationRuleUtility.isAssignableFrom(type, intfType)) {
- String[] parms = { namedEjb.getName(), intfType.getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2836, IEJBValidationContext.INFO, bean, parms, this);
- vc.addMessage(message);
- }
- }
- }
- catch (InvalidInputException exc) {
- validType = false;
- }
- }
- else {
- validType = false;
- }
-
- if (!validType) {
- String[] parms = { ref.getHome()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2832, IEJBValidationContext.INFO, bean, parms, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * If the bean provides a local view, both parts of the view must exist.
- * If this method is being called, then all parts of the bean are reflected.
- */
- protected void validateLocalPairs(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if(bean instanceof MessageDriven) {
- // Message driven beans don't use local or remote views
- return;
- }
-
- JavaClass local = bean.getLocalInterface();
- JavaClass localHome = bean.getLocalHomeInterface();
- if((local != null ) && (localHome == null)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2880, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
- }
- else if((local == null) && (localHome != null)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2882, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
- }
- // otherwise either both are set or both are unset, and that's fine.
- }
-
- /**
- * If the bean provides a remote view, both parts of the view must exist.
- * If this method is being called, then all parts of the bean are reflected.
- */
- protected void validateRemotePairs(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if(bean instanceof MessageDriven) {
- // Message driven beans don't use local or remote views
- return;
- }
-
- JavaClass remote = bean.getRemoteInterface();
- JavaClass home = bean.getHomeInterface();
- if((remote != null) && (home == null)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2881, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
- }
- else if((remote == null) && (home != null)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2883, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
- }
- // otherwise either both are set or both are unset, and that's fine.
- }
-
- /**
- * The bean must provide either a local view, or a remote view, or both.
- */
- protected void validateLocalOrRemote(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if(bean instanceof MessageDriven) {
- // Message driven beans don't use local or remote views
- return;
- }
-
- JavaClass local = bean.getLocalInterface();
- JavaClass localHome = bean.getLocalHomeInterface();
- JavaClass remote = bean.getRemoteInterface();
- JavaClass remoteHome = bean.getHomeInterface();
-
- if((localHome == null) && (remoteHome == null)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2884, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
- }
-
- if((local == null) && (remote == null)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2885, IEJBValidationContext.WARNING, bean, this);
- vc.addMessage(message);
- }
- }
-
- public void validatePersistenceTypeElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- // Attempt in vain to validate the persistence type element here, because
- // if it's not specified, there's a syntax error, and the
- // validateDeploymentDescriptor(IReporter, IValidationContext) would have been
- // called instead.
- if (bean.isEntity()) {
- // check syntax
- Entity entityBean = (Entity) bean;
- if (!(entityBean.isContainerManagedEntity() || entityBean.isBeanManagedEntity())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2809, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- }
- }
-
- /**
- * If the primary key class reflected properly, return true. Else, return false.
- */
- public void validatePrimKeyClassElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean.isEntity()) {
- // check syntax
- if (bean instanceof ContainerManagedEntity) {
- ContainerManagedEntity cmp = (ContainerManagedEntity) bean;
- CMPAttribute attr = cmp.getPrimKeyField();
- if((attr != null) && !attr.eIsProxy() && !isValidPrimKeyField(cmp,attr)) {
- // 9.4.7.1
- // user has specified both a prim-key-class and a primkey-field
- // can't use the CMPAttribute's field's name, because the primitive primary key returned is null
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2828, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- }
- }
- }
-
- /**
- * If the prim key is specified in the xml, answer whether it is the same as the derived primaryKeyAttribute
- */
- public boolean isValidPrimKeyField(ContainerManagedEntity cmp, CMPAttribute attr) {
- return cmp.getPrimaryKeyName().equals(attr.getType().getJavaName());
- }
-
- public void validateReentrantElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean.isEntity()) {
- // check syntax
- Entity entity = (Entity) bean;
- if (!entity.eIsSet(EjbPackage.eINSTANCE.getEntity_Reentrant())) {
- // Can only test if the reentrant attribute is set, because the model defaults it
- // to some boolean value if it isn't set.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2806, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- }
- }
-
- /**
- * If the metadata from the EjbRef is not valid, add a validation message.
- *
- * @parm EjbRef The ref whose home this method checks.
- * @parm EnterpriseBean If the EjbRef uses an <ejb-link> element, this is the enterprise bean identified by that element. It may be null, if the user has made a mistake.
- */
- protected void validateRemoteRef(IEJBValidationContext vc, EJBJar ejbJar, EjbRef ref, EnterpriseBean namedEjb) {
- boolean validType = true;
- EnterpriseBean bean = (EnterpriseBean)ref.eContainer();
- if (ref.eIsSet(CommonPackage.eINSTANCE.getEjbRef_Remote())) {
- try {
- String remoteName = ref.getRemote();
- JavaHelpers type = ValidationRuleUtility.getType(remoteName, bean);
- // Check that the home specified in the <home> element of the <ejb-ref> element
- // exists.
- ValidationRuleUtility.isValidType(type);
-
- if (namedEjb != null) {
- // Check that the home specified in the <home> element
- // is assignable to the home used by the named EJB in the
- // <ejb-link> element.
- JavaClass intfType = namedEjb.getRemoteInterface();
- ValidationRuleUtility.isValidType(intfType);
-
- // Make sure that the identified home/remote interface in the ejb-ref
- // is of the same type as the one used by the bean.
- if (!ValidationRuleUtility.isAssignableFrom(type, intfType)) {
- String[] parms = { namedEjb.getName(), intfType.getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2837, IEJBValidationContext.INFO, bean, parms, this);
- vc.addMessage(message);
- }
- }
- }
- catch (InvalidInputException exc) {
- validType = false;
- }
- }
- else {
- validType = false;
- }
-
- if (!validType) {
- String[] parms = { ref.getRemote()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2833, IEJBValidationContext.INFO, bean, parms, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * 15.2.5.3 Declaration of security roles referenced from the bean's code
- * The Bean Provider is responsible for declaring in the security-role-ref
- * elements of the deployment descriptor all the security role names used
- * in the enterprise bean code. Declaring the security roles references in
- * the code allows the Application Assembler or Deployer to link the names
- * of the security roles used in the code to the security roles defined for
- * an assembled application through the security-role elements.
- * The Bean Provider must declare each security role referenced in the code
- * using the security-role-ref element as follows:
- * Declare the name of the security role using the role-name element.
- * The name must be the security role name that is used as a parameter to
- * the isCallerInRole(String role-Name) method.
- * Optional: Provide a description of the security role in the
- * description element. A security role reference, including the name defined
- * by the role-name element, is scoped to the session or entity bean element
- * whose declaration contains the security-role-ref element. The following
- * example illustrates how an enterprise bean's references to security roles
- * are declared in the deployment descriptor.
- * ...
- * <enterprise-beans>
- * ...
- * <entity>
- * <ejb-name>AardvarkPayroll</ejb-name>
- * <ejb-class>com.aardvark.payroll.PayrollBean</ejb-class>
- * ...
- * <security-role-ref>
- * <description>
- * This security role should be assigned to the
- * employees of the payroll department who are
- * allowed to update employees' salaries.
- * </description>
- * <role-name>payroll</role-name>
- * </security-role-ref>
- * ...
- * </entity>
- * ...
- * </enterprise-beans>
- * ...
- *
- * The deployment descriptor above indicates that the enterprise bean
- * AardvarkPayroll makes the security check using isCallerInRole("payroll")
- * in its business method.
- *
- *
- * 15.3.3 Linking security role references to security roles
- * If the Application Assembler defines the security-role elements in the
- * deployment descriptor, he or she is also responsible for linking all the
- * security role references declared in the security-role-ref elements to the
- * security roles defined in the security-role elements. The Application
- * Assembler links each security role reference to a security role using the
- * role-link element. The value of the role-link element must be the name of
- * one of the security roles defined in a security-role element.
- * A role-link element must be used even if the value of role-name is the
- * same as the value of the role-link reference.
- * The following deployment descriptor example shows how to link the security
- * role reference named payroll to the security role named payroll-department.
- * ...
- * <enterprise-beans>
- * ...
- * <entity>
- * <ejb-name>AardvarkPayroll</ejb-name>
- * <ejb-class>com.aardvark.payroll.PayrollBean</ejb-class>
- * ...
- * <security-role-ref>
- * <description>
- * This role should be assigned to the
- * employees of the payroll department.
- * Members of this role have access to
- * anyone's payroll record.
- *
- * The role has been linked to the
- * payroll-department role.
- * </description>
- * <role-name>payroll</role-name>
- * <role-link>payroll-department</role-link>
- * </security-role-ref>
- * ...
- * </entity>
- * ...
- * </enterprise-beans>
- * ...
- *
- */
- public void validateSecurityRoleRefElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean == null) {
- return;
- }
-
- /**
- * Need to build up a list of duplicate role names, but the validation message
- * needs to be registered against the duplicate SecurityRoleRef instance.
- * (Without the instance, we cannot get line numbers.)
- *
- * This class wrappers the SecurityRoleRef instance so that the wrapper's
- * implemention of equals compares the names, but the validation message will
- * still be able to get the ref from the duplicate name.
- */
- class RoleRefWrapper {
- private SecurityRoleRef _ref = null;
-
- public RoleRefWrapper(SecurityRoleRef ref) {
- _ref = ref;
- }
-
- public boolean equals(Object o) {
- if (o instanceof RoleRefWrapper) {
- RoleRefWrapper other = (RoleRefWrapper) o;
- return _ref.getName().equals(other.getRoleRef().getName());
- }
- return false;
- }
-
- public SecurityRoleRef getRoleRef() {
- return _ref;
- }
- }
-
- boolean areSRolesDefined = ((_securityRoles != null) && (_securityRoles.size() > 0));
-
- List securityRoleRefs = bean.getSecurityRoleRefs();
- if ((securityRoleRefs != null) && (securityRoleRefs.size() != 0)) {
- // Check that each security role ref refers to a security role,
- // if security roles are defined in the assembly descriptor,
- // and that each referenced security role exists.
- DuplicatesTable roleRefNames = new DuplicatesTable();
- for (int i = 0; i < securityRoleRefs.size(); i++) {
- SecurityRoleRef ref = (SecurityRoleRef) securityRoleRefs.get(i);
-
- // Check that the role name is set (15.2.5.3)
- String roleName = ref.getName();
- if ((roleName == null) || (roleName.equals(""))) { //$NON-NLS-1$
- roleName = ""; //$NON-NLS-1$
- String beanName = (bean.getName() == null) ? "" : bean.getName(); //$NON-NLS-1$
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2822, IEJBValidationContext.WARNING, ref, new String[] { beanName }, this);
- vc.addMessage(message);
- }
- else {
- // Build up the list of names, to check for duplicates
- roleRefNames.add(new RoleRefWrapper(ref));
- }
-
- // Check that the role link is set (15.3.3)
- String roleLink = ref.getLink();
- boolean isLinkDefined = ((ref.eIsSet(CommonPackage.eINSTANCE.getSecurityRoleRef_Link())) && (roleLink != null) && (!roleLink.equals(""))); //$NON-NLS-1$
-
- if ((areSRolesDefined) && (!isLinkDefined)) {
- // must have role link defined (15.3.3)
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2823, IEJBValidationContext.WARNING, ref, this);
- vc.addMessage(message);
- }
- else if ((!areSRolesDefined) && (isLinkDefined)) {
- // must not have role link defined (15.2.5.3)
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2827, IEJBValidationContext.WARNING, ref, this);
- vc.addMessage(message);
- }
- else if (areSRolesDefined && isLinkDefined) {
- // check that the role listed in the link exists. (15.3.3)
- Iterator iterator = _securityRoles.iterator();
- boolean roleExists = false;
- while(iterator.hasNext()) {
- SecurityRole role = (SecurityRole)iterator.next();
- if(role.getRoleName().equals(roleLink)) {
- roleExists = true;
- break;
- }
- }
- if (!roleExists) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2824, IEJBValidationContext.WARNING, ref, new String[] { roleName }, this);
- vc.addMessage(message);
- }
- }
- }
-
- // Check for duplicates
- // Check that there are no duplicate role-names. (15.3.1)
- if (roleRefNames.containsDuplicates()) {
- List duplicates = roleRefNames.getDuplicates();
- Iterator iterator = duplicates.iterator();
- while (iterator.hasNext()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2820, IEJBValidationContext.WARNING, ((RoleRefWrapper) iterator.next()).getRoleRef(), this);
- vc.addMessage(message);
- }
- }
- roleRefNames.clear();
- }
- }
-
- /**
- * 6.5.3 The optional SessionSynchronization interface
- *...
- * Only a stateful Session bean with container-managed transaction demarcation may
- * implement the SessionSynchronization interface.
- *...
- * There is no need for a Session bean with bean-managed transaction to rely on the
- * synchronization call backs because the bean is in control of the commit the bean
- * knows when the transaction is about to be committed and it knows the outcome of the
- * transaction commit.
- *...
- */
- public void validateSessionTypeElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean.isSession()) {
- Session session = (Session) bean;
-
- // check syntax
- boolean isValidSess = ValidationRuleUtility.isValidSessionTypeElement(session);
- if (!isValidSess) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2807, IEJBValidationContext.ERROR, session, this);
- vc.addMessage(message);
- }
-
- }
- }
- public void validateTransactionTypeElement(IEJBValidationContext vc, EJBJar ejbJar, EnterpriseBean bean) {
- if (bean.isSession()) {
- // check syntax
- Session sessionBean = (Session) bean;
- if (!ValidationRuleUtility.isValidTransactionTypeElement(sessionBean)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2808, IEJBValidationContext.ERROR, bean, this);
- vc.addMessage(message);
- }
- }
- }
-
- /*
- * @see IValidationRule#reset()
- */
- public void reset() {
- super.reset();
- _securityRoles = null;
- }
-
- /*
- * @see IValidationRule#preValidate(IEJBValidationContext, Object, Object)
- */
- public void preValidate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException {
- super.preValidate(vc, targetParent, target);
-
- EJBJar ejbJar = (EJBJar)vc.loadModel(EJBValidatorModelEnum.EJB_MODEL);
- if(ejbJar == null) {
- return;
- }
-
- if(ejbJar.getAssemblyDescriptor() == null) {
- return;
- }
- _securityRoles = ejbJar.getAssemblyDescriptor().getSecurityRoles();
- }
-
- /**
- * Need to build up a list of duplicate EJB names, but the validation message
- * needs to be registered against the duplicate EnterpriseBean instance.
- * (Without the instance, we cannot get line numbers.)
- *
- * This class wrappers the EnterpriseBean instance so that the wrapper's
- * implemention of equals compares the names, but the validation message will
- * still be able to get the ref from the duplicate name.
- */
- class EjbNameWrapper {
- private EnterpriseBean _bean = null;
-
- public EjbNameWrapper(EnterpriseBean bean) {
- _bean = bean;
- }
-
- public boolean equals(Object o) {
- if (o instanceof EnterpriseBean) {
- EnterpriseBean other = (EnterpriseBean) o;
- return _bean.getName().equals(other.getName());
- }
- return false;
- }
-
- public EnterpriseBean getBean() {
- return _bean;
- }
- }
-
- class ASNameWrapper {
- private ContainerManagedEntity _bean = null;
-
- public ASNameWrapper(ContainerManagedEntity bean) {
- _bean = bean;
- }
-
- public boolean equals(Object o) {
- if (o instanceof ContainerManagedEntity) {
- ContainerManagedEntity other = (ContainerManagedEntity) o;
- return _bean.getAbstractSchemaName().equals(other.getAbstractSchemaName());
- }
- return false;
- }
-
- public EnterpriseBean getBean() {
- return _bean;
- }
- }
- /**
- * @param driven
- */
- private void validateActivationConfiguration(IEJBValidationContext vc, MessageDriven bean) {
- ActivationConfig config = bean.getActivationConfig();
- if(config != null) {
- List configProperties = config.getConfigProperties();
- if(configProperties != null && !configProperties.isEmpty()) {
- HashSet namePropertySet = new HashSet();
- for(int i = 0; i < configProperties.size(); i++) {
- ActivationConfigProperty property = (ActivationConfigProperty)configProperties.get(i);
- boolean doesNotExists = namePropertySet.add(property.getName());
- if(!doesNotExists) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2886, IMessage.HIGH_SEVERITY, bean, bean.getEjbJar(),new String[] {property.getName(),bean.getName()},this);
- vc.addMessage(message);
- }
- if(isJMSMDB(bean)) {
- validationAckModeActivationConfig(vc, bean, property);
- validateDestinationTypeActivationConfig(vc, bean, property);
- validateDurabilityActivationConfig(vc, bean, configProperties, property);
- }
- }
- }
- }
- }
-
- private boolean isJMSMDB(MessageDriven bean) {
- return bean.getMessagingType() == null || bean.getMessagingType().getQualifiedName().equals(JMS_MESSAGING_TYPE);
- }
-
- private void validationAckModeActivationConfig(IEJBValidationContext vc, MessageDriven bean, ActivationConfigProperty property) {
- if(property.getName().equals(MDBActivationConfigModelUtil.ackModeKey) && !Arrays.asList(MDBActivationConfigModelUtil.ackModeValues).contains(property.getValue())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2887, IMessage.HIGH_SEVERITY, bean, bean.getEjbJar(),new String[] {property.getName(),property.getValue(),bean.getName()},this);
- vc.addMessage(message);
- }
- }
-
- /**
- * @param vc
- * @param bean
- * @param property
- */
- private void validateDestinationTypeActivationConfig(IEJBValidationContext vc, MessageDriven bean, ActivationConfigProperty property) {
- if(property.getName().equals(MDBActivationConfigModelUtil.destinationTypeKey) && !Arrays.asList(MDBActivationConfigModelUtil.destinationTypeValues).contains(property.getValue())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2887, IMessage.HIGH_SEVERITY, bean, bean.getEjbJar(),new String[] {property.getName(),property.getValue(),bean.getName()},this);
- vc.addMessage(message);
- }
- JavaClass messageDestination = bean.getMessageDestination();
- if(messageDestination != null && messageDestination.getQualifiedName() != null && (property.getName().equals(MDBActivationConfigModelUtil.destinationTypeKey) && !(messageDestination.getQualifiedName().equals(property.getValue())))) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2890, IMessage.HIGH_SEVERITY, bean, bean.getEjbJar(),new String[] {messageDestination.getQualifiedName(),property.getValue(),bean.getName()},this);
- vc.addMessage(message);
- }
- }
- /**
- * @param vc
- * @param bean
- * @param configProperties
- * @param property
- */
- private void validateDurabilityActivationConfig(IEJBValidationContext vc, MessageDriven bean, List configProperties, ActivationConfigProperty property) {
- if(property.getName().equals(MDBActivationConfigModelUtil.durabilityKey) && !Arrays.asList(MDBActivationConfigModelUtil.durabilityValue).contains(property.getValue())) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2887, IMessage.HIGH_SEVERITY, bean, bean.getEjbJar(),new String[] {property.getName(),property.getValue(),bean.getName()},this);
- vc.addMessage(message);
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IClassVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IClassVRule.java
deleted file mode 100644
index c1814237d..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IClassVRule.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.List;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-
-
-/**
- * @version 1.0
- * @author
- */
-public interface IClassVRule extends IValidationRule {
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException;
-
- // Because calling JavaClass::getMethodsExtended() is an expensive call, need to call it once
- // per class instead of multiple times per class. However, each class in the bean needs different
- // lists:
- // 1. Key class needs no lists.
- // 2. Home interface (remote & local) needs the bean class' getMethodsExtended list.
- // 3. Component interface (remote & local) needs the bean class' getMethodsExtended list.
- // 4. Bean class needs the remote home, local home, remote component, and local component's getMethodsExtended list.
- // Given that the lists are different depending on the class implementation, add a List[] as a final parameter, and each
- // implementation can figure out what the List[] needs to be populated with, if anything. (i.e., the
- // key class will probably pass in a null instead of an empty List.)
- //
- // Similar reasoning for the List[] of getFieldsExtended().
- public List[] getMethodsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException;
- public List[] getFieldsExtended(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException;
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtended) throws ValidationCancelledException, InvalidInputException, ValidationException;
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field, List[] fieldsExtended) throws ValidationCancelledException, InvalidInputException, ValidationException;
-
- public void register(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtended) throws ValidationCancelledException, InvalidInputException, ValidationException;
- public void register(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field, List[] fieldsExtended) throws ValidationCancelledException, InvalidInputException, ValidationException;
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IComponentType.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IComponentType.java
deleted file mode 100644
index aed0fb8d8..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IComponentType.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-
-
-/**
- * @version 1.0
- * @author
- */
-public interface IComponentType extends IEJBInterfaceType {
- public JavaClass getHomeInterface(EnterpriseBean bean);
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBInterfaceType.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBInterfaceType.java
deleted file mode 100644
index ee43c0f77..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBInterfaceType.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.List;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-
-
-/**
- * @version 1.0
- * @author
- */
-public interface IEJBInterfaceType extends IEJBType {
- public boolean isEJBInterfaceMethod(EnterpriseBean bean, Method method) throws InvalidInputException, ValidationCancelledException;
- public JavaHelpers getOverExposedLocalType(EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException, ValidationCancelledException;
- public void validateApplicationExceptionRules(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException, ValidationCancelledException;
- public void validateRMI_IIOPTypeRules(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists, boolean checkReturnType) throws InvalidInputException, ValidationCancelledException;
- public boolean followRemoteExceptionRules(EnterpriseBean bean, Method method) throws InvalidInputException, ValidationCancelledException;
- public boolean followRMI_IIOPInheritanceRules(EnterpriseBean bean, JavaClass clazz) throws InvalidInputException, ValidationCancelledException;
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBType.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBType.java
deleted file mode 100644
index e7dd49300..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBType.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public interface IEJBType extends ITypeConstants, IMethodAndFieldConstants {
- public static int REMOTE = 0x1;
- public static int LOCAL = 0x2;
- public static int NEITHER = 0x4;
-
- public long[] getSupertypes();
- public long[] getShouldNotBeSupertypes();
-
- /**
- * If the name of the method does not match one of the method names which this
- * rule validates, what type should the method be considered? (e.g. home or business).
- */
- public long getDefaultMethodType();
- public long[] getKnownMethodTypes();
-
- public long[] getMethodsWhichMustExist();
- public long[] getMethodsWhichMustNotExist();
-
- public int isRemote();
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBValidationContext.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBValidationContext.java
deleted file mode 100644
index a56d66f59..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBValidationContext.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-public interface IEJBValidationContext extends IValidationContext {
- public static final int ERROR = IMessage.HIGH_SEVERITY;
- public static final int WARNING = IMessage.NORMAL_SEVERITY;
- public static final int INFO = IMessage.LOW_SEVERITY;
-
-
- public IValidator getValidator();
- public IValidationContext getHelper();
- public IReporter getReporter();
-
- public IMessage getMessage(); // returns an empty IMessage which can be reused
- public Logger getMsgLogger();
-
- public void terminateIfCancelled() throws ValidationCancelledException;
-
- public LogEntry getLogEntry();
-
- public Object loadModel(String symbolicName);
- public Object loadModel(String symbolicName, Object[] parms);
-
- public void removeAllMessages();
- public void removeMessages(Object target);
- public void removeMessages(Object target, String groupIdentifier);
-
- public void addMessage(IMessage message);
- public void addMessage(int severity, String messageId);
- public void addMessage(int severity, String messageId, String[] parms);
- public void addMessage(int severity, String messageId, Object target);
- public void addMessage(int severity, String messageId, String[] parms, Object target);
- public void addMessage(int severity, String messageId, Object target, String groupName);
- public void addMessage(int severity, String messageId, String[] parms, Object target, String groupName);
-
- public void subtask(String messageId);
- public void subtask(String messageId, String[] parms);
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBValidatorConstants.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBValidatorConstants.java
deleted file mode 100644
index 90f88fd76..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBValidatorConstants.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-public interface IEJBValidatorConstants {
- // Name of .properties file
- public static final String BUNDLE_NAME = "ejbvalidator"; //$NON-NLS-1$
-
- // Name of logger
- public static final String LOGNAME = "EJBValidatorLog"; //$NON-NLS-1$
-
- // Status constants which do not require a message prefix (e.g. ABCD0000E)
- public static final String STATUS_VALIDATING = "STATUS_VALIDATING"; //$NON-NLS-1$
-
- public static final String NULL_PRIMARY_KEY = "<primary-key>"; // when a key class name needs to be displayed, but that class is null, display this instead //$NON-NLS-1$
- public static final String NULL_BEAN_CLASS = "<ejb-class>"; // when a bean class name needs to be displayed, but that class is null, display this instead //$NON-NLS-1$
- public static final String NULL_LOCAL_HOME = "<local-home>"; // when a local-home class name needs to be displayed, but that class is null, display this instead //$NON-NLS-1$
- public static final String NULL_LOCAL = "<local>"; // when a local class name needs to be displayed, but that class is null, display this instead //$NON-NLS-1$
- public static final String NULL_HOME = "<home>"; // when a home class name needs to be displayed, but that class is null, display this instead //$NON-NLS-1$
- public static final String NULL_REMOTE = "<remote>"; // when a remote class name needs to be displayed, but that class is null, display this instead //$NON-NLS-1$
-
- // We use a string here because this interface is shipped with WAS, but
- // J2EECorePlugin is not. Therefore having the J2EECorePlugin.PLUGIN_ID
- // dependency works fine in the tooling env, but will result in NoClassDefFound in WAS
- public static final String J2EE_CORE_PLUGIN = "org.eclipse.jst.j2ee.internal.core"; // $NON-NLS-1$ //$NON-NLS-1$
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBValidatorMessageConstants.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBValidatorMessageConstants.java
deleted file mode 100644
index 2cdedbab8..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IEJBValidatorMessageConstants.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-/**
- * This interface holds the message constants that are common across
- * specifications. (e.g. internal error messages, checks that are the same.)
- */
-public interface IEJBValidatorMessageConstants {
- // Constants used in message ids
- static final String ON_BASE = ".i"; // String to be registered against a base type, not the JavaClass being validated. (Inherited method.) //$NON-NLS-1$
- static final String ON_THIS = ".m"; // String to be registered against the JavaClass being validated. (Method impl on JavaClass itself.) //$NON-NLS-1$
-
- // Internal errors and such
- static final String CHKJ2041 = "CHKJ2041"; // unnamed package (Java Language Specification) //$NON-NLS-1$
- static final String CHKJ2433 = "CHKJ2433"; // cannot reflect //$NON-NLS-1$
- static final String CHKJ2456 = "CHKJ2456"; // Should throw X or there may be compile errors in the deploy code. //$NON-NLS-1$
- static final String CHKJ2852 = "CHKJ2852"; // Throwable caught while validating ejb-jar.xml //$NON-NLS-1$
- static final String CHKJ2900 = "CHKJ2900"; // Internal error while running EJB validator //$NON-NLS-1$
- static final String CHKJ2905 = "CHKJ2905"; // EJB Validator could not run because ejb-jar.xml could not be loaded. //$NON-NLS-1$
- static final String CHKJ2907 = "CHKJ2907"; // Type X, or one of its supertypes, cannot be reflected. Check the classpath. //$NON-NLS-1$
-
- // Specification rules
- static final String CHKJ2003E = "CHKJ2003E"; // implement javax.ejb.SessionSynchronization (can be error or info depending on context) //$NON-NLS-1$
- static final String CHKJ2003I = "CHKJ2003I"; // implement javax.ejb.SessionSynchronization (can be error or info depending on context) //$NON-NLS-1$
-
- static final String CHKJ2014 = "CHKJ2014"; // class must be, or must not be, abstract //$NON-NLS-1$
- static final String CHKJ2015 = "CHKJ2015"; // class must be, or must not be, final //$NON-NLS-1$
- static final String CHKJ2017 = "CHKJ2017"; // class/interface must extend/implement X //$NON-NLS-1$
- static final String CHKJ2019 = "CHKJ2019"; // key class must be serializable/a legal value type in RMI-IIOP //$NON-NLS-1$
-
- static final String CHKJ2022 = "CHKJ2022"; // class must be public //$NON-NLS-1$
- static final String CHKJ2023 = "CHKJ2023"; // a matching method (for this component method) must exist on the bean class //$NON-NLS-1$
-
- static final String CHKJ2040 = "CHKJ2040"; // "this" must not be passed as a method argument or result //$NON-NLS-1$
-
- static final String CHKJ2103 = "CHKJ2103"; // In component inheritance, the bean class must inherit X. //$NON-NLS-1$
- static final String CHKJ2104 = "CHKJ2104"; // In component inheritance, the home class must not inherit X. //$NON-NLS-1$
- static final String CHKJ2105 = "CHKJ2105"; // In component inheritance, the component interface must extend X. //$NON-NLS-1$
- static final String CHKJ2106 = "CHKJ2106"; // In component inheritance, the bean must use X as its primary key. //$NON-NLS-1$
-
- static final String CHKJ2205 = "CHKJ2205"; // primary key field X must be public //$NON-NLS-1$
- static final String CHKJ2206 = "CHKJ2206"; // primary key field X must be a <cmp-field> (and in EJB 1.1, also a field of the bean class) //$NON-NLS-1$
-
- static final String CHKJ2402 = "CHKJ2402"; // The create method must return the remote interface type //$NON-NLS-1$
- static final String CHKJ2403 = "CHKJ2403"; // The finder method must return X or a collection thereof. //$NON-NLS-1$
- static final String CHKJ2407 = "CHKJ2407"; // The ejbFind method must return X or a collection thereof. //$NON-NLS-1$
-
- static final String CHKJ2411 = "CHKJ2411"; // The name of the method must not start with "ejb". //$NON-NLS-1$
-
- static final String CHKJ2801 = "CHKJ2801"; // missing <ejb-name> //$NON-NLS-1$
- static final String CHKJ2802_NAMED = "CHKJ2802.named";// <ejb-class> cannot be reflected //$NON-NLS-1$
- static final String CHKJ2802_UNNAMED = "CHKJ2802.unnamed";// unknown <ejb-class> //$NON-NLS-1$
- static final String CHKJ2803_NAMED = "CHKJ2803.named";// <home> cannot be reflected //$NON-NLS-1$
- static final String CHKJ2803_UNNAMED = "CHKJ2803.unnamed";// unknown <home> //$NON-NLS-1$
- static final String CHKJ2804_NAMED = "CHKJ2804.named";// <remote> cannot be reflected //$NON-NLS-1$
- static final String CHKJ2804_UNNAMED = "CHKJ2804.unnamed";// unknown <remote> //$NON-NLS-1$
- static final String CHKJ2806 = "CHKJ2806";// <reentrant> must be either "True" or "False" //$NON-NLS-1$
- static final String CHKJ2807 = "CHKJ2807"; // <session-type> must be either "Stateful" or "Stateless" //$NON-NLS-1$
- static final String CHKJ2808 = "CHKJ2808"; // <transaction-type> must be either "Bean" or "Container" //$NON-NLS-1$
- static final String CHKJ2809 = "CHKJ2809"; // <persistence-type> must be either "Bean" or "Container" //$NON-NLS-1$
-
- static final String CHKJ2810_NAMED = "CHKJ2810.named";// <prim-key-class> cannot be reflected //$NON-NLS-1$
- static final String CHKJ2810_UNNAMED = "CHKJ2810.unnamed";// unknown <prim-key-class> //$NON-NLS-1$
- static final String CHKJ2811_NAMED = "CHKJ2811.named";// <field-name> must exist on the bean class //$NON-NLS-1$
- static final String CHKJ2811_UNNAMED = "CHKJ2811.unnamed";// <field-name> must exist //$NON-NLS-1$
- static final String CHKJ2812 = "CHKJ2812"; // Bean class must specify at least one of its fields as a <cmp-field> //$NON-NLS-1$
- static final String CHKJ2814 = "CHKJ2814"; // <method>'s <ejb-name> should specify a known enterprise bean //$NON-NLS-1$
-
- static final String CHKJ2820 = "CHKJ2820"; // <security-role-ref> must be unique. //$NON-NLS-1$
- static final String CHKJ2822 = "CHKJ2822"; // <security-role-ref> must define a <role-name> //$NON-NLS-1$
- static final String CHKJ2823 = "CHKJ2823"; // <security-role-ref> should define a <role-link> //$NON-NLS-1$
- static final String CHKJ2824 = "CHKJ2824"; // <security-role-ref> must identify a known <security-role> //$NON-NLS-1$
- static final String CHKJ2825 = "CHKJ2825"; // <security-role> should define the <role-name> element. //$NON-NLS-1$
- static final String CHKJ2826 = "CHKJ2826"; // <security-role> name should be unique. //$NON-NLS-1$
- static final String CHKJ2827 = "CHKJ2827"; // Cannot use a <role-link> without <security-role> elements. //$NON-NLS-1$
- static final String CHKJ2828 = "CHKJ2828"; // Cannot use a <primkey-field> element without a primitive primary key. //$NON-NLS-1$
- static final String CHKJ2829 = "CHKJ2829"; // Every field in the primary key must exist on the bean class. //$NON-NLS-1$
-
- static final String CHKJ2830 = "CHKJ2830"; // The type of the field cannot be reflected. //$NON-NLS-1$
- static final String CHKJ2831 = "CHKJ2831"; // X must be declared as a <cmp-field> element. //$NON-NLS-1$
- static final String CHKJ2832 = "CHKJ2832"; // <ejb-ref>'s home cannot be found in the EJB module. //$NON-NLS-1$
- static final String CHKJ2833 = "CHKJ2833"; // <ejb-ref>'s remote cannot be found in the EJB module. //$NON-NLS-1$
- static final String CHKJ2834 = "CHKJ2834"; // <ejb-ref>'s bean cannot be found in the EJB module. //$NON-NLS-1$
- static final String CHKJ2835 = "CHKJ2835"; // Bean X is a Y type. Update the <ejb-ref-type> element. //$NON-NLS-1$
- static final String CHKJ2836 = "CHKJ2836"; // Bean X uses home Y. Update the <ejb-ref> element. //$NON-NLS-1$
- static final String CHKJ2837 = "CHKJ2837"; // Bean X uses remote Y. Update the <ejb-ref> element. //$NON-NLS-1$
- static final String CHKJ2838 = "CHKJ2838"; // It is recommended that all references to enterprise beans be organized in the "ejb" subcontext. //$NON-NLS-1$
- static final String CHKJ2839 = "CHKJ2839"; // <env-entry-name> of the <env-entry> element must exist. //$NON-NLS-1$
-
- static final String CHKJ2840 = "CHKJ2840"; // <env-entry-type> of the <env-entry> element must exist. //$NON-NLS-1$
- static final String CHKJ2841 = "CHKJ2841"; // The X name, in the <env-entry> element, must be unique in the bean. //$NON-NLS-1$
- static final String CHKJ2842 = "CHKJ2842"; // <method-params> is ignored when <method-name> is "*" //$NON-NLS-1$
- static final String CHKJ2843 = "CHKJ2843"; // <method> X must exist on bean Y. //$NON-NLS-1$
- static final String CHKJ2844 = "CHKJ2844"; // At least one <method> should exist in a <method-permission>. //$NON-NLS-1$
- static final String CHKJ2845 = "CHKJ2845"; // At least one <role-name> should exist in a <method-permission>. //$NON-NLS-1$
- static final String CHKJ2846 = "CHKJ2846"; // No methods can be found for this <method-permission> //$NON-NLS-1$
- static final String CHKJ2847 = "CHKJ2847"; // No methods can be found for this <container-transaction> //$NON-NLS-1$
- static final String CHKJ2849 = "CHKJ2849"; // Cannot validate component inheritance of X because Y cannot be reflected. //$NON-NLS-1$
-
- static final String CHKJ2875 = "CHKJ2875"; // EJB Client JAR must exist and be in the same EAR as this EJB JAR. //$NON-NLS-1$
-
- static final String CHKJ2850 = "CHKJ2850"; // Cannot validate <method> because X, or one of its supertypes, cannot be reflected. //$NON-NLS-1$
-
- static final String CHKJ2895 = "CHKJ2895"; // duplicate <ejb-name> //$NON-NLS-1$
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IFieldType.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IFieldType.java
deleted file mode 100644
index c96f7013f..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IFieldType.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-
-
-public abstract interface IFieldType {
- public static final String NO_MESSAGE_PREFIX = ""; // For the two getMessageId_X methods, if the method never requires that particular message, return this message prefix instead //$NON-NLS-1$
-
- public long getId();
-
- public boolean isFieldType(EnterpriseBean bean, JavaClass clazz, Field field);
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IHomeType.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IHomeType.java
deleted file mode 100644
index 4c6594295..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IHomeType.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-
-
-/**
- * @version 1.0
- * @author
- */
-public interface IHomeType extends IEJBInterfaceType {
- public JavaClass getComponentInterface(EnterpriseBean bean);
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ILocalType.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ILocalType.java
deleted file mode 100644
index afa0a0723..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ILocalType.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-/**
- * @version 1.0
- * @author
- */
-public interface ILocalType {
- public int IS_REMOTE = IEJBType.LOCAL;
- public int MESSAGE_REMOTE_EXCEPTION_SEVERITY = IEJBValidationContext.WARNING; // If a method throws a RemoteException when it shouldn't, that's a deprecated use, hence a warning.
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMessagePrefixEjb11Constants.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMessagePrefixEjb11Constants.java
deleted file mode 100644
index 0d823f8f2..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMessagePrefixEjb11Constants.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-
-/**
- * This interface holds the message constants that are specific
- * to the EJB 1.1 specification.
- */
-public interface IMessagePrefixEjb11Constants extends IEJBValidatorMessageConstants {
- /*package*/ static final String SPEC = ".ejb11"; // EJB specification being validated //$NON-NLS-1$
-
-
- /*package*/ static final String CHKJ2001 = "CHKJ2001"; // The key class must implement the X method. //$NON-NLS-1$
- /*package*/ static final String CHKJ2002 = "CHKJ2002"; // This class should implement a matching ejbPostCreate method for this method. //$NON-NLS-1$
- /*package*/ static final String CHKJ2004 = "CHKJ2004"; // The bean class should not implement the ejbFind method. //$NON-NLS-1$
- /*package*/ static final String CHKJ2005 = "CHKJ2005"; // The method must be either a create method or a find method. //$NON-NLS-1$
- /*package*/ static final String CHKJ2006 = "CHKJ2006"; // The bean class must have a public constructor that takes no arguments. //$NON-NLS-1$
- /*package*/ static final String CHKJ2007 = "CHKJ2007"; // The bean class should not declare the finalize() method. //$NON-NLS-1$
- /*package*/ static final String CHKJ2008 = "CHKJ2008"; // The bean class must contain at least one ejbCreate method. //$NON-NLS-1$
- /*package*/ static final String CHKJ2009 = "CHKJ2009"; // The bean class must contain at least one ejbFindByPrimaryKey method. //$NON-NLS-1$
- /*package*/ static final String CHKJ2010 = "CHKJ2010"; // The home interface must contain at least one create method. //$NON-NLS-1$
- /*package*/ static final String CHKJ2011 = "CHKJ2011"; // The home interface must contain at least one findByPrimaryKey method. //$NON-NLS-1$
- /*package*/ static final String CHKJ2012 = "CHKJ2012"; // This type must be an interface. //$NON-NLS-1$
- /*package*/ static final String CHKJ2013 = "CHKJ2013"; // The bean class must implement X. //$NON-NLS-1$
- /*package*/ static final String CHKJ2020 = "CHKJ2020"; // The key class must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2021 = "CHKJ2021"; // The key class must define a public default constructor. //$NON-NLS-1$
- /*package*/ static final String CHKJ2024 = "CHKJ2024"; // X must not exist. Only create() may exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2025 = "CHKJ2025"; // X must not exist. Only ejbCreate() may exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2026 = "CHKJ2026"; // The bean class must implement a matching ejbCreate method for this method. //$NON-NLS-1$
- /*package*/ static final String CHKJ2028 = "CHKJ2028"; // This method will not be called unless a matching ejbCreate method is defined. //$NON-NLS-1$
- /*package*/ static final String CHKJ2029 = "CHKJ2029"; // This method will not be called unless a matching create method is defined on the home. //$NON-NLS-1$
- /*package*/ static final String CHKJ2030 = "CHKJ2030"; // This method must have a matching ejbFind method in the bean class. //$NON-NLS-1$
- /*package*/ static final String CHKJ2032 = "CHKJ2032"; // Bean class X must declare at least one container managed field. //$NON-NLS-1$
- /*package*/ static final String CHKJ2033 = "CHKJ2033"; // The setEntityContext method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2034 = "CHKJ2034"; // The unsetEntityContext method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2035 = "CHKJ2035"; // The ejbActivate method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2036 = "CHKJ2036"; // The ejbPassivate method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2037 = "CHKJ2037"; // The ejbRemove method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2038 = "CHKJ2038"; // The ejbLoad method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2039 = "CHKJ2039"; // The ejbStore method must exist. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2100 = "CHKJ2100"; // Both ends of the role must use the same number of attributes. //$NON-NLS-1$
- /*package*/ static final String CHKJ2101 = "CHKJ2101"; // Both ends of the role must use the same type. //$NON-NLS-1$
- /*package*/ static final String CHKJ2102 = "CHKJ2102"; // Either a finder descriptor, or a matching custom finder method, must be defined. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2200 = "CHKJ2200"; // The static field must be final. //$NON-NLS-1$
- /*package*/ static final String CHKJ2201 = "CHKJ2201"; // The field must not be transient. //$NON-NLS-1$
- /*package*/ static final String CHKJ2202 = "CHKJ2202"; // The field type is invalid for a <cmp-field>. //$NON-NLS-1$
- /*package*/ static final String CHKJ2203 = "CHKJ2203"; // The field must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2207 = "CHKJ2207"; // Field X on bean Y must be the same type as the <primkey-field>. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2400_bus = "CHKJ2400.bus"; // Deprecated use of RemoteException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2400_ejbCreate = "CHKJ2400.ejbCreate"; // Deprecated use of RemoteException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2400_ejbFind = "CHKJ2400.ejbFind"; // Deprecated use of RemoteException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2400_ejbPostCreate = "CHKJ2400.ejbPostCreate"; // Deprecated use of RemoteException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2401 = "CHKJ2401"; // This method must return void. //$NON-NLS-1$
- /*package*/ static final String CHKJ2405 = "CHKJ2405"; // findByPrimaryKey must have the <prim-key-class> as its argument. //$NON-NLS-1$
- /*package*/ static final String CHKJ2406 = "CHKJ2406"; // This method should return the primary key type. //$NON-NLS-1$
- /*package*/ static final String CHKJ2408_bus = "CHKJ2408.bus"; // This method must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2408_ejbCreate = "CHKJ2408.ejbCreate"; // This method must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2408_ejbFind = "CHKJ2408.ejbFind"; // This method must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2408_ejbPostCreate = "CHKJ2408.ejbPostCreate"; // This method must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2409_bus = "CHKJ2409.bus"; // This method must not be final. //$NON-NLS-1$
- /*package*/ static final String CHKJ2409_ejbCreate = "CHKJ2409.ejbCreate"; //This method must not be final. //$NON-NLS-1$
- /*package*/ static final String CHKJ2409_ejbFind = "CHKJ2409.ejbFind"; // This method must not be final. //$NON-NLS-1$
- /*package*/ static final String CHKJ2409_ejbPostCreate = "CHKJ2409.ejbPostCreate"; // This method must not be final. //$NON-NLS-1$
- /*package*/ static final String CHKJ2410_bus = "CHKJ2410.bus"; // This method must not be static. //$NON-NLS-1$
- /*package*/ static final String CHKJ2410_ejbCreate = "CHKJ2410.ejbCreate"; // This method must not be static. //$NON-NLS-1$
- /*package*/ static final String CHKJ2410_ejbFind = "CHKJ2410.ejbFind"; // This method must not be static. //$NON-NLS-1$
- /*package*/ static final String CHKJ2410_ejbPostCreate = "CHKJ2410.ejbPostCreate"; // This method must not be static. //$NON-NLS-1$
- /*package*/ static final String CHKJ2412 = "CHKJ2412"; // The return type of this method must be serializable at runtime. //$NON-NLS-1$
- /*package*/ static final String CHKJ2413 = "CHKJ2413"; // The argument must be serializable at runtime. //$NON-NLS-1$
- /*package*/ static final String CHKJ2414 = "CHKJ2414"; // This method must throw exception X. //$NON-NLS-1$
- /*package*/ static final String CHKJ2415 = "CHKJ2415"; // The return type must match the return type of the matching method. //$NON-NLS-1$
- /*package*/ static final String CHKJ2418 = "CHKJ2418"; // This method must return void. //$NON-NLS-1$
- /*package*/ static final String CHKJ2419 = "CHKJ2419"; // This method must be a create method. //$NON-NLS-1$
- /*package*/ static final String CHKJ2420 = "CHKJ2420"; // X must be thrown by the corresponding method on the home interface. //$NON-NLS-1$
- /*package*/ static final String CHKJ2432 = "CHKJ2432"; // X must be thrown by the corresponding method on the remote interface. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2908 = "CHKJ2908"; // An enterprise bean cannot be reflected. Run the XML validator. //$NON-NLS-1$
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMessagePrefixEjb20Constants.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMessagePrefixEjb20Constants.java
deleted file mode 100644
index 8c11d3566..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMessagePrefixEjb20Constants.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-
-/**
- * This interface holds the message constants that are specific to the
- * EJB 2.0 specification (e.g. MDB-only messages).
- */
-public interface IMessagePrefixEjb20Constants extends IEJBValidatorMessageConstants {
- /*package*/ static final String SPEC = ".ejb20"; // EJB specification being validated //$NON-NLS-1$
- /*package*/ static final String ON_BASE_SPEC = ON_BASE + SPEC;
- /*package*/ static final String ON_THIS_SPEC = ON_THIS + SPEC;
- /*package*/ static final String CHKJ = null; // Placeholder for a message id when the id hasn't been created in the .properties file
-
- /*package*/ static final String CHKJ2018 = "CHKJ2018"; // This dependent value class must be serializable. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2043 = "CHKJ2043"; // This dependent value class must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2044 = "CHKJ2044"; // This dependent value class must not be abstract. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2050_acc = "CHKJ2050.acc"; // An accessor method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_constr = "CHKJ2050.constr"; // A public default constructor must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_create = "CHKJ2050.create"; // A create method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_ejbActivate = "CHKJ2050.ejbActivate"; // The ejbActivate method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_ejbCreate = "CHKJ2050.ejbCreate"; // An ejbCreate method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_ejbFind = "CHKJ2050.ejbFind"; // An ejbFind method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_ejbFindByPrimaryKey = "CHKJ2050.ejbFindByPrimaryKey"; // An ejbFindByPrimaryKey method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_ejbHome = "CHKJ2050.ejbHome"; // An ejbHome method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_ejbLoad = "CHKJ2050.ejbLoad"; // An ejbLoad method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_ejbPassivate = "CHKJ2050.ejbPassivate"; // An ejbPassivate method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_ejbPostCreate = "CHKJ2050.ejbPostCreate"; // An ejbPostCreate method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_ejbRemove = "CHKJ2050.ejbRemove"; // An ejbRemove method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_ejbSelect = "CHKJ2050.ejbSelect"; // An ejbSelect method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_ejbStore = "CHKJ2050.ejbStore"; // An ejbStore method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_equals = "CHKJ2050.equals"; // An equals method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_find = "CHKJ2050.find"; // An find method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_findByPrimaryKey = "CHKJ2050.findByPrimaryKey"; // An findByPrimaryKey method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_hashCode = "CHKJ2050.hashCode"; // An hashCode method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_home = "CHKJ2050.home"; // An home method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_onMessage = "CHKJ2050.onMessage"; // An onMessage method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_setEntityContext = "CHKJ2050.setEntityContext"; // An setEntityContext method must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2050_unsetEntityContext = "CHKJ2050.unsetEntityContext"; // An unsetEntityContext method must exist. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2404 = "CHKJ2404"; // Application exception X must extend java.lang.Exception. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2416 = "CHKJ2416"; // Application exception X must not extend java.lang.RuntimeException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2421 = "CHKJ2421"; // ejbCreate must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2422 = "CHKJ2422"; // ejbCreate must not be final. //$NON-NLS-1$
- /*package*/ static final String CHKJ2423 = "CHKJ2423"; // ejbCreate must not be static. //$NON-NLS-1$
- /*package*/ static final String CHKJ2424 = "CHKJ2424"; // ejbCreate must return void. //$NON-NLS-1$
- /*package*/ static final String CHKJ2426 = "CHKJ2426"; // ejbPostCreate must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2427 = "CHKJ2427"; // ejbPostCreate must not be final. //$NON-NLS-1$
- /*package*/ static final String CHKJ2428 = "CHKJ2428"; // ejbPostCreate must not be static. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2430 = "CHKJ2430"; // X must exist for this ejbHome method to be called. //$NON-NLS-1$
- /*package*/ static final String CHKJ2431 = "CHKJ2431"; // ejbHome must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2439 = "CHKJ2439"; // ejbHome must not be static. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2441 = "CHKJ2441"; // business method must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2442 = "CHKJ2442"; // business method must not be final. //$NON-NLS-1$
- /*package*/ static final String CHKJ2443 = "CHKJ2443"; // business method must not be static. //$NON-NLS-1$
- /*package*/ static final String CHKJ2445 = "CHKJ2445"; // onMessage must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2446 = "CHKJ2446"; // onMessage must not be final. //$NON-NLS-1$
- /*package*/ static final String CHKJ2447 = "CHKJ2447"; // onMessage must not be static. //$NON-NLS-1$
- /*package*/ static final String CHKJ2449 = "CHKJ2449"; // accessor method must be public. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2450 = "CHKJ2450"; // accessor method must be abstract //$NON-NLS-1$
- /*package*/ static final String CHKJ2452 = "CHKJ2452"; // A transient field should not be the {0} type. //$NON-NLS-1$
- /*package*/ static final String CHKJ2453 = "CHKJ2453"; // Transient fields are discouraged. //$NON-NLS-1$
- /*package*/ static final String CHKJ2454 = "CHKJ2454"; // CMR and CMP fields must not be defined on the bean class. //$NON-NLS-1$
- /*package*/ static final String CHKJ2457 = "CHKJ2457"; // ejbFind must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2458 = "CHKJ2458"; // ejbFind must not be final. //$NON-NLS-1$
- /*package*/ static final String CHKJ2459 = "CHKJ2459"; // ejbFind must not be static. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2461 = "CHKJ2461"; // This interface must follow RMI-IIOP rules for interfaces. //$NON-NLS-1$
- /*package*/ static final String CHKJ2462 = "CHKJ2462"; // The method name must not start with "create". //$NON-NLS-1$
- /*package*/ static final String CHKJ2463 = "CHKJ2463"; // The method name must not start with "find". //$NON-NLS-1$
- /*package*/ static final String CHKJ2464 = "CHKJ2464"; // The method name must not start with "remove" //$NON-NLS-1$
- /*package*/ static final String CHKJ2465 = "CHKJ2465"; // home method X must throw Y for Z. //$NON-NLS-1$
- /*package*/ static final String CHKJ2466 = "CHKJ2466"; // remote home method X must not expose the Y type. //$NON-NLS-1$
- /*package*/ static final String CHKJ2467 = "CHKJ2467"; // This method must throw CreateException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2468 = "CHKJ2468"; // This interface must follow RMI-IIOP rules for remote interfaces. //$NON-NLS-1$
- /*package*/ static final String CHKJ2469 = "CHKJ2469"; // This method (EJBObject or EJBLocalObject) is provided by the container. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2470 = "CHKJ2470"; // This component matching method must return X. //$NON-NLS-1$
- /*package*/ static final String CHKJ2471 = "CHKJ2471"; // This component matching method must throw X. //$NON-NLS-1$
- /*package*/ static final String CHKJ2472 = "CHKJ2472"; // This method must not pass X as an argument or result type. //$NON-NLS-1$
- /*package*/ static final String CHKJ2473 = "CHKJ2473"; // This (CMR) method must not be exposed. //$NON-NLS-1$
- /*package*/ static final String CHKJ2474 = "CHKJ2474"; // This method must not expose X. //$NON-NLS-1$
- /*package*/ static final String CHKJ2475 = "CHKJ2475"; // findByPrimaryKey's argument must be the primary key. //$NON-NLS-1$
- /*package*/ static final String CHKJ2476 = "CHKJ2476"; // This method must be the create/ejbCreate method. //$NON-NLS-1$
- /*package*/ static final String CHKJ2477 = "CHKJ2477"; // This method must throw FinderException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2478 = "CHKJ2478"; // This method must not throw ObjectNotFoundException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2479 = "CHKJ2479"; // findByPrimaryKey must return X. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2480 = "CHKJ2480"; // CMP/CMR field name must begin with a lowercase letter. //$NON-NLS-1$
- /*package*/ static final String CHKJ2481 = "CHKJ2481"; // field X must be a <cmp-field> //$NON-NLS-1$
- /*package*/ static final String CHKJ2482 = "CHKJ2482"; // field X must be a <cmr-field> //$NON-NLS-1$
- /*package*/ static final String CHKJ2483 = "CHKJ2483"; // CMP/CMR field should not be exposed //$NON-NLS-1$
- /*package*/ static final String CHKJ2484 = "CHKJ2484"; // CMP/CMR field must be either a primitive or a serializable type. //$NON-NLS-1$
- /*package*/ static final String CHKJ2485 = "CHKJ2485"; // ejbSelect method must be abstract. //$NON-NLS-1$
- /*package*/ static final String CHKJ2486 = "CHKJ2486"; // ejbSelect must return X or a collection thereof. //$NON-NLS-1$
- /*package*/ static final String CHKJ2487 = "CHKJ2487"; // ejbSelect must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2488 = "CHKJ2488"; // ejbSelect must throw FinderException //$NON-NLS-1$
- /*package*/ static final String CHKJ2489 = "CHKJ2489"; // Field must be the primary key type. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2490 = "CHKJ2490"; // This method must not be exposed. //$NON-NLS-1$
- /*package*/ static final String CHKJ2492 = "CHKJ2492"; // ejbRemove must be public. //$NON-NLS-1$
- /*package*/ static final String CHKJ2493 = "CHKJ2493"; // ejbRemove must not be final. //$NON-NLS-1$
- /*package*/ static final String CHKJ2494 = "CHKJ2494"; // ejbRemove must not be static. //$NON-NLS-1$
- /*package*/ static final String CHKJ2495 = "CHKJ2495"; // This find method must be associated with a query element in ejb-jar.xml. //$NON-NLS-1$
- /*package*/ static final String CHKJ2496 = "CHKJ2496"; // This ejbSelect method must be associated with a query element in ejb-jar.xml. //$NON-NLS-1$
- /*package*/ static final String CHKJ2497 = "CHKJ2497"; // ejbCreate must throw CreateException. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2500_ejbCreate = "CHKJ2500.ejbCreate"; // X must be serializable at runtime. //$NON-NLS-1$
- /*package*/ static final String CHKJ2500_ejbHome = "CHKJ2500.ejbHome"; // X must be serializable at runtime. //$NON-NLS-1$
- /*package*/ static final String CHKJ2500_ejbFind = "CHKJ2500.ejbFind"; // X must be serializable at runtime. //$NON-NLS-1$
- /*package*/ static final String CHKJ2500_business = "CHKJ2500.bus"; // X must be serializable at runtime. //$NON-NLS-1$
- /*package*/ static final String CHKJ2500_home = "CHKJ2500.home"; // X must be serializable at runtime. //$NON-NLS-1$
- /*package*/ static final String CHKJ2500_create = "CHKJ2500.create"; // X must be serializable at runtime. //$NON-NLS-1$
- /*package*/ static final String CHKJ2500_find = "CHKJ2500.find"; // X must be serializable at runtime. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2501_ejbCreate = "CHKJ2501.ejbCreate"; // ejbCreate must not throw application exceptions. //$NON-NLS-1$
- /*package*/ static final String CHKJ2501_ejbRemove = "CHKJ2501.ejbRemove"; // ejbRemove must not throw application exceptions. //$NON-NLS-1$
- /*package*/ static final String CHKJ2501_onMessage = "CHKJ2501.onMessage"; // ejbRemove must not throw application exceptions. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2502_ejbFind = "CHKJ2502.ejbFind"; // ejbFind must not exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2502_ejbSelect = "CHKJ2502.ejbSelect"; // ejbSelect must not exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2502_finalize = "CHKJ2502.finalize"; // finalize must not exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2502 = "CHKJ2502"; // This method must not exist. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2503_bus = "CHKJ2503.bus"; // The business method must throw/not throw RemoteException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2503_create = "CHKJ2503.create"; // This method must throw/not throw RemoteException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2503_ejbCreate = "CHKJ2503.ejbCreate"; // This method must throw/not throw RemoteException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2503_ejbFind = "CHKJ2503.ejbFind"; // This method must throw/not throw RemoteException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2503_ejbHome = "CHKJ2503.ejbHome"; // This method must throw/not throw RemoteException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2503_ejbPostCreate = "CHKJ2503.ejbPostCreate"; // This method must throw/not throw RemoteException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2503_find = "CHKJ2503.find"; // This method must throw/not throw RemoteException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2503_home = "CHKJ2503.home"; // This method must throw/not throw RemoteException. //$NON-NLS-1$
- /*package*/ static final String CHKJ2503_onMessage = "CHKJ2503.onMessage"; // This method must throw/not throw RemoteException. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2504_business = "CHKJ2504.business"; // The matching method must exist on the bean class. //$NON-NLS-1$
- /*package*/ static final String CHKJ2504_create = "CHKJ2504.create"; // The matching method must exist on the bean class. //$NON-NLS-1$
- /*package*/ static final String CHKJ2504_find = "CHKJ2504.find"; // The matching method must exist on the bean class. //$NON-NLS-1$
- /*package*/ static final String CHKJ2504_home = "CHKJ2504.home"; // The matching method must exist on the bean class. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2505_ejbPostCreate = "CHKJ2505.ejbPostCreate"; // This method must return void. //$NON-NLS-1$
- /*package*/ static final String CHKJ2505_onMessage = "CHKJ2505.onMessage"; // This method must return void. //$NON-NLS-1$
- /*package*/ static final String CHKJ2505_ejbRemove = "CHKJ2505.ejbRemove"; // This method must return void. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2800_NAMED = "CHKJ2800.named"; // <local> cannot be reflected. //$NON-NLS-1$
- /*package*/ static final String CHKJ2800_UNNAMED = "CHKJ2800.unnamed"; // <local> must exist. //$NON-NLS-1$
- /*package*/ static final String CHKJ2805_NAMED = "CHKJ2805.named"; // <local-home> cannot be reflected //$NON-NLS-1$
- /*package*/ static final String CHKJ2805_UNNAMED = "CHKJ2805.unnamed"; // <local-home> must exist. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2813 = "CHKJ2813"; // <ejb-name> X must be a valid Java identifier. //$NON-NLS-1$
- /*package*/ static final String CHKJ2816 = "CHKJ2816"; // <ejb-relation-name> must be unique in ejb-jar.xml. //$NON-NLS-1$
- /*package*/ static final String CHKJ2817 = "CHKJ2817"; // <ejb-relationship-role-name> must be unique within an <ejb-relation> //$NON-NLS-1$
- /*package*/ static final String CHKJ2818 = "CHKJ2818"; // The value of the <multiplicity> element must be either "One" or "Many" //$NON-NLS-1$
- /*package*/ static final String CHKJ2819 = "CHKJ2819"; // <abstract-schema-name> {0} must be a valid Java identifier //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2821 = "CHKJ2821"; // <relationship-role-source> {0} must exist in the module //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2848 = "CHKJ2848"; // <cascade-delete> must be used with a <multiplicity> of "One" //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2854 = "CHKJ2854"; // <abstract-schema-name> {0} must be unique within the ejb-jar.xml file //$NON-NLS-1$
- /*package*/ static final String CHKJ2855 = "CHKJ2855"; // <cmp-field> {0} must be a Java primitive or a Java serializable type //$NON-NLS-1$
- /*package*/ static final String CHKJ2856 = "CHKJ2856"; // <cmr-field> {0} must be the {1} type or a collection thereof //$NON-NLS-1$
- /*package*/ static final String CHKJ2857 = "CHKJ2857"; // <cmr-field> {0} must be a valid Java identifier and begin with a lowercase letter //$NON-NLS-1$
- /*package*/ static final String CHKJ2858 = "CHKJ2858"; // <abstract-schema-name> must exist //$NON-NLS-1$
- /*package*/ static final String CHKJ2859 = "CHKJ2859"; // Reserved identifier {0} cannot be used as an <ejb-name> //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2860 = "CHKJ2860"; // Reserved identifier {0} cannot be used as an <abstract-schema-name> //$NON-NLS-1$
- /*package*/ static final String CHKJ2866 = "CHKJ2866"; // <cmr-field> {0} must be defined on {1} //$NON-NLS-1$
- /*package*/ static final String CHKJ2867 = "CHKJ2867"; // This bean can have only unidirectional relationships to other beans //$NON-NLS-1$
- /*package*/ static final String CHKJ2868 = "CHKJ2868"; // The value of the <cmr-field-type> element must be either "java.util.Collection" or "java.util.Set" //$NON-NLS-1$
- /*package*/ static final String CHKJ2869 = "CHKJ2869"; // At least one <ejb-relationship-role> must define a <cmr-field> //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2870 = "CHKJ2870"; // <ejb-name> {0} must exist //$NON-NLS-1$
- /*package*/ static final String CHKJ2871 = "CHKJ2871"; // <ejb-name> {0} must refer to a CMP bean //$NON-NLS-1$
- /*package*/ static final String CHKJ2872 = "CHKJ2872"; // The value of the <cmp-version> element must be either "1.x" or "2.x" //$NON-NLS-1$
- /*package*/ static final String CHKJ2873 = "CHKJ2873"; // Migrate this bean's datasource binding to a CMP Connection Factory binding. //$NON-NLS-1$
- /*package*/ static final String CHKJ2874 = "CHKJ2874"; // Migrate this EJB module's default datasource binding to a default CMP Connection Factory binding. //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2880 = "CHKJ2880"; // This bean must provide a <local-home> //$NON-NLS-1$
- /*package*/ static final String CHKJ2881 = "CHKJ2881"; // This bean must provide a <home> //$NON-NLS-1$
- /*package*/ static final String CHKJ2882 = "CHKJ2882"; // This bean must provide a <local> //$NON-NLS-1$
- /*package*/ static final String CHKJ2883 = "CHKJ2883"; // This bean must provide a <remote> //$NON-NLS-1$
- /*package*/ static final String CHKJ2884 = "CHKJ2884"; // This bean must provide either a <local-home> or a <home> //$NON-NLS-1$
- /*package*/ static final String CHKJ2885 = "CHKJ2885"; // This bean must provide either a <local> or a <remote> //$NON-NLS-1$
-
- /*package*/ static final String CHKJ2886 = "CHKJ2886.ejb21"; // Duplicate activation config: "{0}" exist in message drvien bean: "{1}" //$NON-NLS-1$
- /*package*/ static final String CHKJ2887 = "CHKJ2887.ejb21"; // The activation config with name : "{0}" has invalid value : "1" for message drvien bean: "{2}" //$NON-NLS-1$
- /*package*/ static final String CHKJ2888 = "CHKJ2888.ejb21"; // The activation config: "{0}" can only exist for a destination type: "{1}" //$NON-NLS-1$
- /*package*/ static final String CHKJ2889 = "CHKJ2889.ejb21"; // The message destination is not set for bean: "{0}" //$NON-NLS-1$
- /*package*/ static final String CHKJ2890 = "CHKJ2890.ejb21"; // The message destination type "{0}" and destination type activation config property value "{1}" do not match for bean: "{2}" //$NON-NLS-1$
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMethodAndFieldConstants.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMethodAndFieldConstants.java
deleted file mode 100644
index 4476f1fdd..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMethodAndFieldConstants.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-public interface IMethodAndFieldConstants {
- public static final long NO_METHODS = 0x0;
- public static final long EXCLUDED_METHOD = ValidationRuleUtility.method_and_field_counter; // 0x1 (1)
- public static final long EXCLUDED_FIELD = (ValidationRuleUtility.method_and_field_counter <<= 1); // 0x2 (2)
- public static final long OTHER_FIELD = (ValidationRuleUtility.method_and_field_counter <<= 1); // 0x4 (4)
-
- public static final long ACCESSOR = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x8 (8)
- public static final long BUSINESS = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x10 (16)
-
- public static final long CLINIT = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x20 (32)
- public static final long CONSTRUCTOR = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x40 (64)
- public static final long CONSTRUCTOR_NOPARM = CONSTRUCTOR | (ValidationRuleUtility.method_and_field_counter <<= 1); // 0x40|0x80 (192)
- public static final long CREATE = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x100 (256)
- public static final long CREATE_NOPARM = CREATE | (ValidationRuleUtility.method_and_field_counter <<= 1); //0x100|0x200 (768)
-
- public static final long EJBACTIVATE_NOPARM = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x400 (1024)
- public static final long EJBCREATE = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x800 (2048)
- public static final long EJBCREATE_NOPARM = EJBCREATE | (ValidationRuleUtility.method_and_field_counter <<= 1);//0x800|0x1000 (6144)
- public static final long EJBFIND = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x2000 (8192)
- public static final long EJBFINDBYPRIMARYKEY = EJBFIND | (ValidationRuleUtility.method_and_field_counter <<= 1); //0x2000|0x4000 (24576)
- public static final long EJBHOME = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x8000 (32768)
- public static final long EJBLOAD_NOPARM = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x10000 (65536)
- public static final long EJBPASSIVATE_NOPARM = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x20000 (131,072)
- public static final long EJBPOSTCREATE = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x40000 (262,144)
- public static final long EJBREMOVE_NOPARM = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x80000 (524,288)
- public static final long EJBSELECT = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x100000 (1,048,576)
- public static final long EJBSTORE_NOPARM = (ValidationRuleUtility.method_and_field_counter <<= 1);//0x200000 (2,097,152)
- public static final long EQUALS = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x400000 (4,194,304)
-
- public static final long FIND = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x800000 (8,388,608)
- public static final long FINDBYPRIMARYKEY = FIND | (ValidationRuleUtility.method_and_field_counter <<= 1); //0x1000000 (25,165,824)
- public static final long FINALIZE_NOPARM = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x2000000 (33,554,432)
-
- public static final long HASHCODE_NOPARM = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x4000000 (67,108,864)
- public static final long HELPER = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x8000000 (134,217,728)
- public static final long HOME = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x10000000 (268,435,456)
-
- public static final long ONMESSAGE = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x20000000 (536,870,912)
-
- public static final long SERIALVERSIONUID = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x40000000 (1,073,741,824)
- public static final long SETSESSIONCONTEXT = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x80000000 (2,147,483,648)
- public static final long SETENTITYCONTEXT = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x100000000 (4,294,967,296)
-
- public static final long UNSETENTITYCONTEXT_NOPARM = (ValidationRuleUtility.method_and_field_counter <<= 1); //0x200000000 (8,589,934,592)
-
-
- // prefixes of some method names
- /*package*/ static final String PREFIX_C = "c"; //$NON-NLS-1$
- /*package*/ static final String PREFIX_EJB = "ejb"; //$NON-NLS-1$
- /*package*/ static final String PREFIX_EJBC = "ejbC"; //$NON-NLS-1$
- /*package*/ static final String PREFIX_EJBF = "ejbF"; //$NON-NLS-1$
- /*package*/ static final String PREFIX_EJBFIND = "ejbFind"; //$NON-NLS-1$
- /*package*/ static final String PREFIX_EJBHOME = "ejbHome"; //$NON-NLS-1$
- /*package*/ static final String PREFIX_EJBSELECT = "ejbSelect"; //$NON-NLS-1$
- /*package*/ static final String PREFIX_F = "f"; //$NON-NLS-1$
- /*package*/ static final String PREFIX_FIND = "find"; //$NON-NLS-1$
- /*package*/ static final String PREFIX_GET = "get"; //$NON-NLS-1$
- /*package*/ static final String PREFIX_SELECT = "select"; //$NON-NLS-1$
- /*package*/ static final String PREFIX_SET = "set"; //$NON-NLS-1$
-
- // method names
- /*package*/ static final String METHODNAME_CREATE = "create"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_EJBACTIVATE = "ejbActivate"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_EJBCREATE = "ejbCreate"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_EJBFINDBYPRIMARYKEY = "ejbFindByPrimaryKey"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_EJBLOAD = "ejbLoad"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_EJBPASSIVATE = "ejbPassivate"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_EJBPOSTCREATE = "ejbPostCreate"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_EJBREMOVE = "ejbRemove"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_EJBSTORE = "ejbStore"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_EQUALS = "equals"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_FINALIZE = "finalize"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_FINDBYPRIMARYKEY = "findByPrimaryKey"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_HASHCODE = "hashCode"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_ONMESSAGE = "onMessage"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_REMOVE = "remove"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_SETSESSIONCONTEXT = "setSessionContext"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_SETENTITYCONTEXT = "setEntityContext"; //$NON-NLS-1$
- /*package*/ static final String METHODNAME_UNSETENTITYCONTEXT = "unsetEntityContext"; //$NON-NLS-1$
-
- // field names
- /*package*/ static final String FIELDNAME_SERIALVERSIONUID = "serialVersionUID"; //$NON-NLS-1$
-
- // For substitution into strings
- /*package*/ static final String METHODSIGNATURE_EQUALS = "equals(java.lang.Object)"; //$NON-NLS-1$
- /*package*/ static final String METHODSIGNATURE_HASHCODE = "hashCode()"; //$NON-NLS-1$
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMethodType.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMethodType.java
deleted file mode 100644
index fd031affe..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IMethodType.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.List;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-
-
-public abstract interface IMethodType {
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method);
-
- public long getId();
-
- /**
- * Return true if this method type is a default type for an enterprise bean's class.
- * For example, if the method on the home is neither a create nor a find method, then
- * it is assumed to be the default type, a home method.
- */
- public boolean isDefaultType();
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists);
-
- public String getMessageId_messageMissing(); // required method is missing
- public String getMessageId_messageExists(); // method should not exist
- public String getMessageId_messageRemoteException(); // method throws (or doesn't throw) RemoteException
- public String getMessageId_messageMissingMatching(); // method is missing its matching method on the bean class
- public String getMessageId_messageRMI_IIOPParm(); // parameter or return type is not a legal RMI-IIOP type
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IRemoteType.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IRemoteType.java
deleted file mode 100644
index 5db5385ef..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IRemoteType.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-/**
- * @version 1.0
- * @author
- */
-public interface IRemoteType {
- public int IS_REMOTE = IEJBType.REMOTE;
- public int MESSAGE_REMOTE_EXCEPTION_SEVERITY = IEJBValidationContext.ERROR; // If a method does not throw an exception when it should, RMIC blows up, hence this situation is an error.
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ITypeConstants.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ITypeConstants.java
deleted file mode 100644
index 608ef1fc0..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ITypeConstants.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-public interface ITypeConstants {
- public static long NO_SUPERTYPE = 0x0;
-
- public static long LOCAL_COMPONENT_INTERFACE = ClassUtility.supertype_counter; // 0x1 (1)
- public static long REMOTE_COMPONENT_INTERFACE = (ClassUtility.supertype_counter <<= 1); // 0x2 (2)
-
- public static long JAVAX_EJB_ENTITYBEAN = (ClassUtility.supertype_counter <<= 1); // 0x4 (4)
- public static long JAVAX_EJB_EJBLOCALHOME = (ClassUtility.supertype_counter <<= 1); //0x8 (8)
- public static long JAVAX_EJB_EJBLOCALOBJECT = (ClassUtility.supertype_counter <<= 1);//0x10 (16)
- public static long JAVAX_EJB_EJBHOME = (ClassUtility.supertype_counter <<= 1); //0x20 (32)
- public static long JAVAX_EJB_EJBOBJECT = (ClassUtility.supertype_counter <<= 1); //0x40 (64)
-
- public static long JAVA_LANG_OBJECT = (ClassUtility.supertype_counter <<= 1);//0x80 (128)
-
- public static long JAVAX_EJB_MESSAGEDRIVENBEAN = (ClassUtility.supertype_counter <<= 1); //0x100 (256)
- public static long JAVAX_JMS_MESSAGELISTENER = (ClassUtility.supertype_counter <<= 1); //0x200 (512)
-
- public static long JAVAX_EJB_SESSIONBEAN = (ClassUtility.supertype_counter <<= 1); //0x400 (1024)
- public static long JAVAX_EJB_SESSIONSYNCHRONIZATION = (ClassUtility.supertype_counter <<= 1); // 0x800 (2048)
-
- // primitive types
- /*package*/ static final String VOID = "void"; //$NON-NLS-1$
-
- // class and interface types
- /*package*/ static final String CLASSNAME_JAVA_IO_IOEXCEPTION = "java.io.IOException"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVA_IO_SERIALIZABLE = "java.io.Serializable"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVA_LANG_OBJECT = "java.lang.Object"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVA_LANG_EXCEPTION = "java.lang.Exception"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVA_LANG_RUNTIMEEXCEPTION = "java.lang.RuntimeException"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVA_RMI_REMOTE = "java.rmi.Remote"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVA_RMI_REMOTEEXCEPTION = "java.rmi.RemoteException"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVA_UTIL_COLLECTION = "java.util.Collection"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVA_UTIL_ENUMERATION = "java.util.Enumeration"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVA_UTIL_SET = "java.util.Set"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_CREATEEXCEPTION = "javax.ejb.CreateException"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_ENTITYBEAN = "javax.ejb.EntityBean"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_EJBEXCEPTION = "javax.ejb.EJBException"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_EJBHOME = "javax.ejb.EJBHome"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_EJBLOCALHOME = "javax.ejb.EJBLocalHome"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_EJBOBJECT = "javax.ejb.EJBObject"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_EJBLOCALOBJECT = "javax.ejb.EJBLocalObject"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_ENTITYCONTEXT = "javax.ejb.EntityContext"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_FINDEREXCEPTION = "javax.ejb.FinderException"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_MESSAGEDRIVENBEAN = "javax.ejb.MessageDrivenBean"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_OBJECTNOTFOUNDEXCEPTION = "javax.ejb.ObjectNotFoundException"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_SESSIONBEAN = "javax.ejb.SessionBean"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_SESSIONCONTEXT = "javax.ejb.SessionContext"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_EJB_SESSIONSYNCHRONIZATION = "javax.ejb.SessionSynchronization"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_JMS_MESSAGE = "javax.jms.Message"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_JMS_MESSAGELISTENER = "javax.jms.MessageListener"; //$NON-NLS-1$
- /*package*/ static final String CLASSNAME_JAVAX_TRANSACTION_USERTRANSACTION = "javax.transaction.UserTransaction"; //$NON-NLS-1$
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IValidationRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IValidationRule.java
deleted file mode 100644
index e54a185df..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IValidationRule.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.wst.validation.internal.core.ValidationException;
-
-
-public interface IValidationRule {
- /**
- * Returns the id of this rule. Given this id, this rule can be loaded from
- * the AbstractEJBValidationRuleFactory.
- */
- public Object getId();
-
- /**
- * Returns the ids of the rules which this rule depends on. (That is,
- * if one of these rules runs, then this rule needs to be run.)
- */
- public Object[] getDependsOn();
-
- /**
- * Add a validation rule which needs to be notified when this rule is run.
- */
- public void addDependent(IValidationRule rule);
-
- /**
- * Return a collection of the IValidationRules which depend on this rule.
- */
- public Set getDependents();
-
- /**
- * Given the target's parent and the changed target, return the target which
- * this rule should validate. For example, if a bean class changes, then the
- * target parent would be the EnterpriseBean, and this rule could return
- * the home interface, or the component interface, or the key class, etc.
- */
- public Object getTarget(Object targetParent, Object target);
-
- /**
- * If any information needs to be calculated before the validate method is called,
- * then that information should be calculated here. This cached information should
- * be cleaned up in the postValidate method.
- */
- public void preValidate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException;
-
- /**
- * Validate the target object. Report all messages, load models, etc.
- * through the IValidtionContext parameter.
- */
- public void validate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException;
-
- /**
- * This method cleans up any resources calculated or cached in the preValidate method.
- * This method is called after the validate method has completed.
- */
- public void postValidate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException;
-
- /**
- * To enable this rule for reuse, reset any stored values (which were calculated
- * during validation) to the default value.
- */
- public void reset();
-
- /**
- * Return a mapping of CHKJ message id to the message id in the resource bundle.
- */
- public Map getMessageIds();
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IValidationRuleList.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IValidationRuleList.java
deleted file mode 100644
index 29c390be6..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/IValidationRuleList.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-public interface IValidationRuleList {
- public static final Object EJB11_EJBJAR = new Integer(1); // EJB 1.1 projects
- public static final Object EJB11_EJBEXT = new Integer(2); // EJB 1.1 projects
- public static final Object EJB20_EJBJAR = new Integer(3); // EJB 2.0 projects
- public static final Object EJB20_EJBEXT = new Integer(4); // EJB 2.0 projects
-
- public static final Object EJB11_ENTERPRISEBEAN = new Integer(5); // EJB 1.1 or EJB 2.0 projects
- public static final Object EJB20_ENTERPRISEBEAN = new Integer(6); // EJB 2.0 projects
-
- public static final Object EJB11_SESSION_BEANCLASS = new Integer(7); // EJB 1.1 or EJB 2.0 projects
- public static final Object EJB11_SESSION_REMOTE = new Integer(8); // EJB 1.1 or EJB 2.0 projects
- public static final Object EJB11_SESSION_HOME = new Integer(9); // EJB 1.1 or EJB 2.0 projects
-
- public static final Object EJB11_CMP_BEANCLASS = new Integer(10); // EJB 1.1 or EJB 2.0 projects
- public static final Object EJB11_CMP_REMOTE = new Integer(11); // EJB 1.1 or EJB 2.0 projects
- public static final Object EJB11_CMP_HOME = new Integer(12); // EJB 1.1 or EJB 2.0 projects
- public static final Object EJB11_CMP_KEYCLASS = new Integer(13); // EJB 1.1 or EJB 2.0 projects
-
- public static final Object EJB11_BMP_BEANCLASS = new Integer(14); // EJB 1.1 or EJB 2.0 projects
- public static final Object EJB11_BMP_REMOTE = new Integer(15); // EJB 1.1 or EJB 2.0 projects
- public static final Object EJB11_BMP_HOME = new Integer(16); // EJB 1.1 or EJB 2.0 projects
- public static final Object EJB11_BMP_KEYCLASS = new Integer(17); // EJB 1.1 or EJB 2.0 projects
-
- public static final Object EJB20_STATELESS_SESSION_BEANCLASS = new Integer(18); // EJB 2.0 projects
- public static final Object EJB20_STATELESS_SESSION_REMOTE = new Integer(19); // EJB 2.0 projects
- public static final Object EJB20_STATELESS_SESSION_HOME = new Integer(20); // EJB 2.0 projects
- public static final Object EJB20_STATELESS_SESSION_LOCAL = new Integer(21); // EJB 2.0 projects
- public static final Object EJB20_STATELESS_SESSION_LOCALHOME = new Integer(22); // EJB 2.0 projects
-
- public static final Object EJB20_STATEFUL_SESSION_BEANCLASS = new Integer(23); // EJB 2.0 projects
- public static final Object EJB20_STATEFUL_SESSION_REMOTE = new Integer(24); // EJB 2.0 projects
- public static final Object EJB20_STATEFUL_SESSION_HOME = new Integer(25); // EJB 2.0 projects
- public static final Object EJB20_STATEFUL_SESSION_LOCAL = new Integer(26); // EJB 2.0 projects
- public static final Object EJB20_STATEFUL_SESSION_LOCALHOME = new Integer(27); // EJB 2.0 projects
-
- public static final Object EJB20_CMP_BEANCLASS = new Integer(28); // EJB 2.0 projects
- public static final Object EJB20_CMP_REMOTE = new Integer(29); // EJB 2.0 projects
- public static final Object EJB20_CMP_HOME = new Integer(30); // EJB 2.0 projects
- public static final Object EJB20_CMP_LOCAL = new Integer(31); // EJB 2.0 projects
- public static final Object EJB20_CMP_LOCALHOME = new Integer(32); // EJB 2.0 projects
- public static final Object EJB20_CMP_KEYCLASS = new Integer(33); // EJB 2.0 projects
-
- public static final Object EJB20_BMP_BEANCLASS = new Integer(34); // EJB 2.0 projects
- public static final Object EJB20_BMP_REMOTE = new Integer(35); // EJB 2.0 projects
- public static final Object EJB20_BMP_HOME = new Integer(36); // EJB 2.0 projects
- public static final Object EJB20_BMP_LOCAL = new Integer(37); // EJB 2.0 projects
- public static final Object EJB20_BMP_LOCALHOME = new Integer(38); // EJB 2.0 projects
- public static final Object EJB20_BMP_KEYCLASS = new Integer(39); // EJB 2.0 projects
-
- public static final Object EJB20_MESSAGE_BEANCLASS = new Integer(40); // EJB 2.0 projects
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/InvalidInputException.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/InvalidInputException.java
deleted file mode 100644
index 51c673a23..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/InvalidInputException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import org.eclipse.jem.java.JavaClass;
-
-/**
- * This exception is thrown when either a type cannot be reflected
- * or when expected input (e.g. the remote interface) is null.
- */
-public class InvalidInputException extends Exception {
- /**
- *
- */
- private static final long serialVersionUID = 7811046448684869845L;
- private JavaClass _class = null;
-
- /**
- * This constructor should be used only when there is no information
- * available to identify what is invalid.
- */
- public InvalidInputException() {
- this(null);
- }
-
- /**
- * This constructor is used when the given type cannot be reflected.
- */
- public InvalidInputException(JavaClass clazz) {
- _class = clazz;
- }
-
- public JavaClass getJavaClass() {
- return _class;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/J2EEMessageConstants.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/J2EEMessageConstants.java
deleted file mode 100644
index 6715687c4..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/J2EEMessageConstants.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-/**
- * Message key constants for J2EE validators.
- */
-public interface J2EEMessageConstants {
- public static final String EREF_CATEGORY = "erefvalidation"; //$NON-NLS-1$
- public static final String WAR_CATEGORY = "warvalidation"; //$NON-NLS-1$
- public static final String EAR_CATEGORY = "earvalidation"; //$NON-NLS-1$
- public static final String EJBJAR_CATEGORY = "ejbjarvalidation"; //$NON-NLS-1$
- public static final String APLICATIONCLIENT_CATEGORY = "applicationclientvalidation"; //$NON-NLS-1$
- public static final String VALIDATOR_NAME = "validator.name"; //$NON-NLS-1$
- public static final String ERROR_EAR_MISSING_EREFNAME = "ERROR_EAR_MISSING_EREFNAME"; //$NON-NLS-1$
- public static final String ERROR_EAR_MISSING_EREFTYPE = "ERROR_EAR_MISSING_EREFTYPE"; //$NON-NLS-1$
- public static final String ERROR_EAR_INVALID_EREFTYPE = "ERROR_EAR_INVALID_EREFTYPE"; //$NON-NLS-1$
- public static final String ERROR_EAR_MISSING_EREFHOME = "ERROR_EAR_MISSING_EREFHOME"; //$NON-NLS-1$
- public static final String ERROR_EAR_MISSING_EREFREMOTE = "ERROR_EAR_MISSING_EREFREMOTE"; //$NON-NLS-1$
- public static final String ERROR_EAR_MISSING_EJB_ROLE = "ERROR_EAR_MISSING_EJB_ROLE"; //$NON-NLS-1$
- public static final String ERROR_EAR_DUPLICATE_RESREF = "ERROR_EAR_DUPLICATE_RESREF"; //$NON-NLS-1$
- public static final String ERROR_EAR_DUPLICATE_SERVICEREF = "ERROR_EAR_DUPLICATE_SERVICEREF"; //$NON-NLS-1$
- public static final String ERROR_EAR_DUPLICATE_SECURITYROLEREF = "ERROR_EAR_DUPLICATE_SECURITYROLEREF"; //$NON-NLS-1$
- public static final String ERROR_EAR_DUPLICATE_EJBREF = "ERROR_EAR_DUPLICATE_EJBREF"; //$NON-NLS-1$
- public static final String ERROR_EAR_DUPLICATE_RESENVREF = "ERROR_EAR_DUPLICATE_RESENVREF"; //$NON-NLS-1$
- public static final String ERROR_EAR_DUPLICATE_MESSSAGEDESTINATIONREF = "ERROR_EAR_DUPLICATE_MESSSAGEDESTINATIONREF"; //$NON-NLS-1$
- public static final String ERROR_EAR_MISSING_MESSSAGEDESTINATION = "ERROR_EAR_MISSING_MESSSAGEDESTINATION"; //$NON-NLS-1$
- public static final String ERROR_EAR_MISSING_EMPTY_MESSSAGEDESTINATION = "ERROR_EAR_MISSING_EMPTY_MESSSAGEDESTINATION"; //$NON-NLS-1$
- public static final String ERROR_UNRESOLVED_MDB_MISSING_MESSAGE_DESTINATION = "ERROR_UNRESOLVED_MDB_MISSING_MESSAGE_DESTINATION";//$NON-NLS-1$
- public static final String ERROR_MODULE_DD_FILE_NOT_FOUND = "ERROR_MODULE_DD_FILE_NOT_FOUND";//$NON-NLS-1$
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/J2EEValidationResourceHandler.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/J2EEValidationResourceHandler.java
deleted file mode 100644
index c35b84637..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/J2EEValidationResourceHandler.java
+++ /dev/null
@@ -1,499 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.MissingResourceException;
-
-public class J2EEValidationResourceHandler {
- private static java.util.Hashtable handlers = new java.util.Hashtable();
- protected ClassLoader resourceClassLoader;
- protected java.util.Locale locale = null;
- protected String bundleName = null;
- protected java.util.ResourceBundle bundle = null;
-/**
- * ResourceHandler constructor. This constructor uses the default locale.
- *
- */
-public J2EEValidationResourceHandler() {
- super();
-}
-/**
- * ResourceHandler constructor.
- *
- * @param The Locale object containing the locale to be used to locate the resource bundle.
- */
-public J2EEValidationResourceHandler(Locale locale) {
- super();
- setLocale(locale);
-}
-/**
- * Getter for the resource bundle property. This property is lazily initialized using the
- * locale property; so that property must be set before calling this method.
- *
- * @return The ResourceBundle object containing the messages to be handled by this instance.
- */
-public java.util.ResourceBundle getBundle() {
- if (this.bundle == null) {
- try {
- if (getResourceClassLoader() == null)
- this.bundle = java.util.ResourceBundle.getBundle(getBundleName(),getLocale());
- else
- this.bundle = java.util.ResourceBundle.getBundle(getBundleName(),getLocale(), getResourceClassLoader());
- } catch (MissingResourceException e) {
- System.out.println("Exception retrieving bundle: " + getBundleName() +//$NON-NLS-1$
- " using locale: " + getLocale().toString());//$NON-NLS-1$
- e.printStackTrace();
- } // endtry
- } // endif
- return this.bundle;
-}
-
-/**
- * Insert the method's description here.
- * Creation date: (1/5/01 2:26:24 PM)
- * @return java.lang.String
- */
-public java.lang.String getBundleName() {
- return bundleName;
-}
-/**
- * Get the message with the specified key.
- *
- * @param fileName The name of the property file that contains the message.
- * @param key The key for the message to be retrieved.
- */
-
-public static String getExternalizedMessage(String fileName, String key, Class aClass) {
-
- return getHandler(fileName, aClass).getMessage(key);
-
-}
-/**
- * Get the message template with the specified key, and format the message using
- * the specified Object array.
- *
- * @param fileName The name of the property file that contains the message.
- * @param key The key for the message to be retrieved.
- * @param arg The Object array containing the substitution values for the message.
- * @return The message string.
- */
-public static String getExternalizedMessage(String fileName, String key, Class aClass, Object arg[]) {
-
- return getHandler(fileName, aClass).getMessage(key, arg);
-}
-/**
- * Get the message template with the specified key, and format the message using
- * the specified Object array.
- *
- * @param fileName The name of the property file that contains the message.
- * @param key The key for the message to be retrieved.
- * @param arg The Object array containing the substitution values for the message.
- * @return The message string.
- */
-public static String getExternalizedMessage(String fileName, String key, Class aClass, Object arg[], Locale locale) {
-
- return getHandler(fileName, aClass, locale).getMessage(key, arg);
-}
-/**
- * Get the message template with the specified key, and format the message using
- * the specified String argument.
- *
- * @param fileName The name of the property file that contains the message.
- * @param key The key for the message to be retrieved.
- * @param arg1 The argument containing the substitution values for the message variable 1.
- * @return The message string.
- */
-public static String getExternalizedMessage(String fileName, String key, Class aClass, String arg1) {
-
- return getHandler(fileName, aClass).getMessage(key, arg1);
-
-}
-/**
- * Get the message template with the specified key, and format the message using
- * the specified String arguments.
- *
- * @param fileName The name of the property file that contains the message.
- * @param key The key for the message to be retrieved.
- * @param arg1 The argument containing the substitution values for the message variable 1.
- * @param arg2 The argument containing the substitution values for the message variable 2.
- * @return The message string.
- */
-
-public static String getExternalizedMessage(String fileName, String key, Class aClass, String arg1, String arg2) {
-
- return getHandler(fileName, aClass).getMessage(key, arg1, arg2);
-
-}
-/**
- * Get the message template with the specified key, and format the message using
- * the specified String arguments.
- *
- * @param fileName The name of the property file that contains the message.
- * @param key The key for the message to be retrieved.
- * @param arg1 The argument containing the substitution values for the message variable 1.
- * @param arg2 The argument containing the substitution values for the message variable 2.
- * @param arg3 The argument containing the substitution values for the message variable 3.
- * @return The message string.
- */
-
-public static String getExternalizedMessage(String fileName, String key, Class aClass, String arg1, String arg2, String arg3) {
-
- return getHandler(fileName, aClass).getMessage(key, arg1, arg2, arg3);
-
-}
-/**
- * Get the message template with the specified key, and format the message using
- * the specified String arguments.
- *
- * @param fileName The name of the property file that contains the message.
- * @param key The key for the message to be retrieved.
- * @param arg1 The argument containing the substitution values for the message variable 1.
- * @param arg2 The argument containing the substitution values for the message variable 2.
- * @param arg3 The argument containing the substitution values for the message variable 3.
- * @param arg4 The argument containing the substitution values for the message variable 4.
- * @return The message string.
- */
-
-public static String getExternalizedMessage(String fileName, String key, Class aClass, String arg1, String arg2, String arg3, String arg4) {
-
- return getHandler(fileName, aClass).getMessage(key, arg1, arg2, arg3, arg4);
-
-}
-/**
- * Get the message template with the specified key, and format the message using
- * the specified String arguments.
- *
- * @param fileName The name of the property file that contains the message.
- * @param key The key for the message to be retrieved.
- * @param arg1 The argument containing the substitution values for the message variable 1.
- * @param arg2 The argument containing the substitution values for the message variable 2.
- * @param arg3 The argument containing the substitution values for the message variable 3.
- * @param arg4 The argument containing the substitution values for the message variable 4.
- * @param arg4 The argument containing the substitution values for the message variable 4.
- * @param arg5 The argument containing the substitution values for the message variable 5.
- * @return The message string.
- */
-
-public static String getExternalizedMessage(String fileName, String key, Class aClass,
- String arg1,
- String arg2,
- String arg3,
- String arg4,
- String arg5) {
-
- return getHandler(fileName, aClass).getMessage(key,
- arg1,
- arg2,
- arg3,
- arg4,
- arg5);
-
-}
-/**
- * Get the message with the specified key.
- *
- * @param fileName The name of the property file that contains the message.
- * @param key The key for the message to be retrieved.
- */
-
-public static String getExternalizedMessage(String fileName, String key, Class aClass, Locale locale) {
-
- return getHandler(fileName, aClass, locale).getMessage(key);
-
-}
-/**
- * Get the static instance of this class that corresponds to the passed property file.
- *
- * @return The resource handler object which can be used to obtain messages.
- */
-public static J2EEValidationResourceHandler getHandler(String fileName, Class aClass) {
- return getHandler(fileName,aClass,Locale.getDefault());
-}
-/**
- * Get the static instance of this class that corresponds to the passed property file.
- *
- * @return The resource handler object which can be used to obtain messages.
- */
-public static J2EEValidationResourceHandler getHandler(String fileName, Class aClass, Locale locale) {
- String handlerKey = getHandlerKey(fileName, locale);
- if (handlers.get(handlerKey) == null) {
- J2EEValidationResourceHandler temp = new J2EEValidationResourceHandler(locale);
- temp.setResourceClassLoader(aClass.getClassLoader());
- temp.setBundleName(fileName);
- handlers.put(handlerKey,temp);
- }
-
- return (J2EEValidationResourceHandler)(handlers.get(handlerKey));
-}
- private static String getHandlerKey(String _baseName, Locale locale) {
- StringBuffer localeName = new StringBuffer("_").append(locale.toString());//$NON-NLS-1$
- if (locale.toString().equals(""))//$NON-NLS-1$
- localeName.setLength(0);
- return _baseName + localeName.toString();
- }
-/**
- * Insert the method's description here.
- * Creation date: (1/26/2001 1:04:50 PM)
- * @return java.lang.ClassLoader
- */
-public java.lang.ClassLoader getResourceClassLoader() {
- return resourceClassLoader;
-}
-/**
- * Insert the method's description here.
- * Creation date: (1/26/2001 1:04:50 PM)
- * @param newResourceClassLoader java.lang.ClassLoader
- */
-public void setResourceClassLoader(java.lang.ClassLoader newResourceClassLoader) {
- resourceClassLoader = newResourceClassLoader;
-}
-
-/**
- * Setter for the locale property.
- *
- * @param The locale.
- */
-public void setLocale(Locale locale) {
- this.locale = locale;
-}
-
-/**
- * Insert the method's description here.
- * Creation date: (1/5/01 2:26:24 PM)
- * @param newBundleName java.lang.String
- */
-public void setBundleName(java.lang.String newBundleName) {
- bundleName = newBundleName;
-}
-
-
-/**
- * Getter for the locale property.
- *
- * @return The locale.
- */
-public Locale getLocale() {
- if (locale == null)
- locale = Locale.getDefault();
- return locale;
-}
-
-/**
- * Get the message with the specified key.
- *
- * @param key The key for the message to be retrieved.
- */
-
-public String getMessage(String key) {
- String temp = null;
- try {
- temp = getBundle().getString(key);
- }
- catch (MissingResourceException ex) {
- System.out.println("Resource Exception: " + ex);//$NON-NLS-1$
- temp = "<<Key: " + key + " not found in resource: " + getBundleName() + ">>";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
- return temp;
-}
-
-/**
- * Get the message template with the specified key, and format the message using
- * the specified Object array.
- *
- * @param key The key for the message to be retrieved.
- * @param arg The Object array containing the substitution values for the message.
- * @return The message string.
- */
-public String getMessage(String key, Object arg[]) {
- String temp = null;
- try {
- temp = MessageFormat.format(getBundle().getString(key), arg);
- }
- catch (MissingResourceException ex) {
- System.out.println("Resource Exception: " + ex);//$NON-NLS-1$
- temp = "<<Key: " + key + " not found in resource: " + getBundleName() + ">>";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
- return temp;
-}
-
-/**
- * Get the message template with the specified key, and format the message using
- * the specified String argument.
- *
- * @param key The key for the message to be retrieved.
- * @param arg1 The argument containing the substitution values for the message variable 1.
- * @return The message string.
- */
-public String getMessage(String key, String arg1) {
-
- String temp = null;
- try {
- if (arg1 != null) {
- Object msgobj[] = new Object[1];
- msgobj[0] = arg1;
- temp = getMessage(key, msgobj);
- }
- else {
- temp = getMessage(key);
- }
- }
- catch (MissingResourceException ex) {
- System.out.println("Resource Exception: " + ex);//$NON-NLS-1$
- temp = "<<Key: " + key + " not found in resource: " + getBundleName() + ">>";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
- return temp;
-}
-
-/**
- * Get the message template with the specified key, and format the message using
- * the specified String arguments.
- *
- * @param key The key for the message to be retrieved.
- * @param arg1 The argument containing the substitution values for the message variable 1.
- * @param arg2 The argument containing the substitution values for the message variable 2.
- * @return The message string.
- */
-
-public String getMessage(String key, String arg1, String arg2) {
- String temp = null;
- try {
- if ((arg1 != null) && (arg2 != null)) {
- Object msgobj[] = new Object[2];
- msgobj[0] = arg1;
- msgobj[1] = arg2;
- temp = getMessage(key, msgobj);
- }
- else {
- temp = getMessage(key);
- }
- }
- catch (MissingResourceException ex) {
- System.out.println("Resource Exception: " + ex);//$NON-NLS-1$
- temp = "<<Key: " + key + " not found in resource: " + getBundleName() + ">>";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
- return temp;
-
-}
-
-/**
- * Get the message template with the specified key, and format the message using
- * the specified String arguments.
- *
- * @param key The key for the message to be retrieved.
- * @param arg1 The argument containing the substitution values for the message variable 1.
- * @param arg2 The argument containing the substitution values for the message variable 2.
- * @param arg3 The argument containing the substitution values for the message variable 3.
- * @return The message string.
- */
-
-public String getMessage(String key, String arg1, String arg2, String arg3) {
- String temp = null;
- try {
- if ((arg1 != null) && (arg2 != null) && (arg3 != null)) {
- Object msgobj[] = new Object[3];
- msgobj[0] = arg1;
- msgobj[1] = arg2;
- msgobj[2] = arg3;
- temp = getMessage(key, msgobj);
- }
- else {
- temp = getMessage(key);
- }
- }
- catch (MissingResourceException ex) {
- System.out.println("Resource Exception: " + ex);//$NON-NLS-1$
- temp = "<<Key: " + key + " not found in resource: " + getBundleName() + ">>";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
- return temp;
-
-}
-
-/**
- * Get the message template with the specified key, and format the message using
- * the specified String arguments.
- *
- * @param key The key for the message to be retrieved.
- * @param arg1 The argument containing the substitution values for the message variable 1.
- * @param arg2 The argument containing the substitution values for the message variable 2.
- * @param arg3 The argument containing the substitution values for the message variable 3.
- * @param arg4 The argument containing the substitution values for the message variable 4.
- * @return The message string.
- */
-
-public String getMessage(String key, String arg1, String arg2, String arg3, String arg4) {
- String temp = null;
- try {
- if ((arg1 != null) && (arg2 != null) && (arg3 != null) && (arg4 != null)) {
- Object msgobj[] = new Object[4];
- msgobj[0] = arg1;
- msgobj[1] = arg2;
- msgobj[2] = arg3;
- msgobj[3] = arg4;
- temp = getMessage(key, msgobj);
- }
- else {
- temp = getMessage(key);
- }
- }
- catch (MissingResourceException ex) {
- System.out.println("Resource Exception: " + ex);//$NON-NLS-1$
- temp = "<<Key: " + key + " not found in resource: " + getBundleName() + ">>";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
- return temp;
-}
-
-/**
- * Get the message template with the specified key, and format the message using
- * the specified String arguments.
- *
- * @param key The key for the message to be retrieved.
- * @param arg1 The argument containing the substitution values for the message variable 1.
- * @param arg2 The argument containing the substitution values for the message variable 2.
- * @param arg3 The argument containing the substitution values for the message variable 3.
- * @param arg4 The argument containing the substitution values for the message variable 4.
- * @param arg4 The argument containing the substitution values for the message variable 4.
- * @param arg5 The argument containing the substitution values for the message variable 5.
- * @return The message string.
- */
-
-public String getMessage(String key,
- String arg1,
- String arg2,
- String arg3,
- String arg4,
- String arg5) {
-
- String temp = null;
- try {
- if ((arg1 != null) && (arg2 != null) && (arg3 != null) &&
- (arg4 != null) && (arg5 != null) ) {
- Object msgobj[] = new Object[5];
- msgobj[0] = arg1;
- msgobj[1] = arg2;
- msgobj[2] = arg3;
- msgobj[3] = arg4;
- msgobj[4] = arg5;
- temp = getMessage(key, msgobj);
- }
- else {
- temp = getMessage(key);
- }
- }
- catch (MissingResourceException ex) {
- System.out.println("Resource Exception: " + ex);//$NON-NLS-1$
- temp = "<<Key: " + key + " not found in resource: " + getBundleName() + ">>";//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
- return temp;
-
-}
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/J2EEValidator.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/J2EEValidator.java
deleted file mode 100644
index 287be9911..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/J2EEValidator.java
+++ /dev/null
@@ -1,596 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.jst.j2ee.common.EjbRef;
-import org.eclipse.jst.j2ee.common.internal.impl.ResourceRefImpl;
-import org.eclipse.jst.j2ee.common.internal.impl.SecurityRoleImpl;
-import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-import org.eclipse.wst.validation.internal.ResourceConstants;
-import org.eclipse.wst.validation.internal.ResourceHandler;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.operations.LocalizedMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;
-
-
-/**
- * Insert the type's description here. Creation date: (3/9/2001 3:34:39 PM)
- *
- * @author: Administrator
- */
-public abstract class J2EEValidator implements IValidatorJob, J2EEMessageConstants {
- protected IReporter _reporter;
- protected IValidationContext _helper;
- protected IStatus status = OK_STATUS;
-
-
- public J2EEValidator() {
- initialize();
- }
-
- /**
- * <p>
- * Create am <em>error</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require no arguments.
- * </p>
- *
- * @param msgId
- * The ID of the message to be created.
- */
-
- public void addError(String msgId) {
- addError(getBaseName(), msgId, null);
- }
-
- /**
- * <p>
- * Create am <em>error</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require no arguments.
- * </p>
- *
- * @param msgId
- * The ID of the message to be created.
- */
-
- public void addError(String msgId, String[] msgArgs) {
- addError(getBaseName(), msgId, msgArgs);
- }
-
- /**
- * <p>
- * Create am <em>error</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require no arguments.
- * </p>
- *
- * @param msgCategory
- * The base name of the message bundle to use.
- * @param msgId
- * The ID of the message to be created.
- */
-
- public void addError(String msgCategory, String msgId) {
- addError(msgCategory, msgId, null);
- }
-
- /**
- * <p>
- * Create an <em>error</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require one or more arguments.
- * </p>
- *
- * @param msgCategory
- * The base name of the message bundle to use.
- * @param msgId
- * The ID of the message to be created.
- * @param msgArgs
- * The parameters for the message.
- */
-
- public void addError(String bundleName, String msgId, String[] msgArgs) {
- this.addError(bundleName, msgId, msgArgs, null);
- }
-
- /**
- * <p>
- * Create an <em>error</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require one or more arguments.
- * </p>
- *
- * @param msgCategory
- * The base name of the message bundle to use.
- * @param msgId
- * The ID of the message to be created.
- * @param msgArgs
- * The parameters for the message.
- */
-
- public void addError(String bundleName, String msgId, String[] msgArgs, Object target) {
- _reporter.addMessage(this, new Message(bundleName, IMessage.HIGH_SEVERITY, msgId, msgArgs, target));
- }
-
- public void addError(String bundleName, String msgId, String[] msgArgs, Object target, String groupName) {
- IMessage message = new Message(bundleName, IMessage.HIGH_SEVERITY, msgId, msgArgs, target);
- message.setGroupName(groupName);
- _reporter.addMessage(this, message);
- }
-
- public void addError(String bundleName, String msgId, String[] msgArgs, Object target, String groupName, int lineNumber) {
- IMessage message = new Message(bundleName, IMessage.HIGH_SEVERITY, msgId, msgArgs, target);
- message.setLineNo(lineNumber);
- message.setGroupName(groupName);
-
- _reporter.addMessage(this, message);
-
- }
-
- public void addLocalizedError(String msg, Object target) {
- _reporter.addMessage(this, new LocalizedMessage(IMessage.HIGH_SEVERITY, msg, target));
- }
-
- public void addLocalizedError(String msg, Object target, int lineNumber) {
- IMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, msg, target);
- message.setLineNo(lineNumber);
- _reporter.addMessage(this, message);
- }
-
- /**
- * <p>
- * Create an <em>informational</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require no arguments.
- * </p>
- *
- * @param msgId
- * The ID of the message to be created.
- */
-
- public void addInfo(String msgId) {
- addInfo(getBaseName(), msgId, null);
- }
-
- /**
- * <p>
- * Create an <em>informational</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require no arguments.
- * </p>
- *
- * @param msgId
- * The ID of the message to be created.
- * @param msgArgs
- * The parameters for the message.
- */
-
- public void addInfo(String msgId, String[] msgArgs) {
- addInfo(getBaseName(), msgId, msgArgs);
- }
-
- /**
- * <p>
- * Create an <em>informational</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require no arguments.
- * </p>
- *
- * @param msgCategory
- * The base name of the message bundle to use.
- * @param msgId
- * The ID of the message to be created.
- */
-
- public void addInfo(String msgCategory, String msgId) {
- addInfo(msgCategory, msgId, null);
- }
-
- /**
- * <p>
- * Create an <em>informational</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require one or more arguments.
- * </p>
- *
- * @param msgCategory
- * The base name of the message bundle to use.
- * @param msgId
- * The ID of the message to be created.
- * @param msgArgs
- * The parameters for the message.
- */
-
- public void addInfo(String bundleName, String msgId, String[] msgArgs) {
- addInfo(bundleName, msgId, msgArgs, null);
- }
-
- /**
- * <p>
- * Create an <em>informational</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require one or more arguments.
- * </p>
- *
- * @param msgCategory
- * The base name of the message bundle to use.
- * @param msgId
- * The ID of the message to be created.
- * @param msgArgs
- * The parameters for the message.
- */
-
- public void addInfo(String bundleName, String msgId, String[] msgArgs, Object target) {
- _reporter.addMessage(this, new Message(bundleName, IMessage.LOW_SEVERITY, msgId, msgArgs, target));
- }
-
- public void addLocalizedInfo(String msg, Object target) {
- _reporter.addMessage(this, new LocalizedMessage(IMessage.LOW_SEVERITY, msg, target));
- }
-
- /**
- * <p>
- * Create a <em>warning</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require no arguments.
- * </p>
- *
- * @param msgId
- * The ID of the message to be created.
- */
-
- public void addWarning(String msgId) {
- addWarning(getBaseName(), msgId, null);
- }
-
- /**
- * <p>
- * Create a <em>warning</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require no arguments.
- * </p>
- *
- * @param msgId
- * The ID of the message to be created.
- * @param msgArgs
- * The parameters for the message.
- */
-
- public void addWarning(String msgId, String[] msgArgs) {
- addWarning(getBaseName(), msgId, msgArgs);
- }
-
- /**
- * <p>
- * Create a <em>warning</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require no arguments.
- * </p>
- *
- * @param msgCategory
- * The base name of the message bundle to use.
- * @param msgId
- * The ID of the message to be created.
- */
-
- public void addWarning(String msgCategory, String msgId) {
- addWarning(msgCategory, msgId, null);
- }
-
- /**
- * <p>
- * Create a <em>warning</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require one or more arguments.
- * </p>
- *
- * @param msgCategory
- * The base name of the message bundle to use.
- * @param msgId
- * The ID of the message to be created.
- * @param msgArgs
- * The parameters for the message.
- */
-
- public void addWarning(String bundleName, String msgId, String[] msgArgs) {
- addWarning(bundleName, msgId, msgArgs, null);
- }
-
- /**
- * <p>
- * Create a <em>warning</em> message and route it to the cached reporter. This form of
- * <code>addError</code> is for messages which require one or more arguments.
- * </p>
- *
- * @param msgCategory
- * The base name of the message bundle to use.
- * @param msgId
- * The ID of the message to be created.
- * @param msgArgs
- * The parameters for the message.
- */
-
- public void addWarning(String bundleName, String msgId, String[] msgArgs, Object target) {
- _reporter.addMessage(this, new Message(bundleName, IMessage.NORMAL_SEVERITY, msgId, msgArgs, target));
- }
-
- public void addWarning(String bundleName, String msgId, String[] msgArgs, Object target, String groupName) {
- IMessage message = new Message(bundleName, IMessage.NORMAL_SEVERITY, msgId, msgArgs, target);
- message.setGroupName(groupName);
- _reporter.addMessage(this, message);
- }
-
- public void addLocalizedWarning(String msg, Object target) {
- _reporter.addMessage(this, new LocalizedMessage(IMessage.NORMAL_SEVERITY, msg, target));
- }
- public void addLocalizedWarning(String msg, Object target, String groupName) {
- IMessage message = new LocalizedMessage(IMessage.NORMAL_SEVERITY, msg, target);
- message.setGroupName(groupName);
- _reporter.addMessage(this, message);
- }
-
- /**
- * Perform any resource cleanup once validation is complete.
- */
- public void cleanup() {
- _reporter = null;
- }
-
- /**
- * Perform any resource cleanup once validation is complete. If cleanup will take some time, the
- * IValidator should report subtask information to the user through the IReporter parameter. The
- * AReporter parameter will not be null.
- *
- * @deprecated Use cleanup()
- */
- public void cleanup(IReporter reporter) {
- _reporter = null;
- }
-
- /**
- * Returns the name of the Validator, as it should be displayed in the UI. The ValidationBuilder
- * uses this string as input to the IProgressMonitor. i.e., At some point during the validation
- * process, the Validation Builder will output this string: "{0} is validating {1}.", where {0}
- * is the string that this method returns, and {1} is the name of the current resource.
- */
- public String[] get1Param(String string1) {
- String[] parms = new String[1];
- parms[0] = string1;
- return parms;
- }
-
- /**
- * Returns the name of the Validator, as it should be displayed in the UI. The ValidationBuilder
- * uses this string as input to the IProgressMonitor. i.e., At some point during the validation
- * process, the Validation Builder will output this string: "{0} is validating {1}.", where {0}
- * is the string that this method returns, and {1} is the name of the current resource.
- */
- public String[] get2Param(String string1, String string2) {
- String[] parms = new String[2];
- parms[0] = string1;
- parms[1] = string2;
- return parms;
- }
-
- /**
- * Returns the name of the Validator, as it should be displayed in the UI. The ValidationBuilder
- * uses this string as input to the IProgressMonitor. i.e., At some point during the validation
- * process, the Validation Builder will output this string: "{0} is validating {1}.", where {0}
- * is the string that this method returns, and {1} is the name of the current resource.
- */
- public String[] get3Param(String string1, String string2, String string3) {
- String[] parms = new String[2];
- parms[0] = string1;
- parms[1] = string2;
- parms[2] = string3;
- return parms;
- }
-
- /**
- * <p>
- * Answer the id of the resource bundle which is used by the receiver.
- * </p>
- */
-
- public abstract String getBaseName();
-
- /**
- * Returns a localized message from a resource bundle.
- *
- * @param msgCategory
- * The baseName of the resource bundle (filename minus any locale suffix)
- * @param msgId
- * The key of the message to lookup from the bundle.
- * @param msgArgs
- * An array of arguments that will be substituted into any message arguments in the
- * message's value.
- * @param locale
- * The locale to retrieve the message text from.
- */
- public String getMessage(String msgCategory, String msgId, String[] msgArgs, Locale locale) {
- return J2EEValidationResourceHandler.getExternalizedMessage(msgCategory, msgId, getClass(), msgArgs, locale);
- }
-
- /**
- * Returns a localized message from a resource bundle.
- *
- * @param msgCategory
- * The baseName of the resource bundle (filename minus any locale suffix)
- * @param msgId
- * The key of the message to lookup from the bundle.
- * @param locale
- * The locale to retrieve the message text from.
- */
- public String getMessage(String msgCategory, String msgId, Locale locale) {
- return J2EEValidationResourceHandler.getExternalizedMessage(msgCategory, msgId, getClass(), locale);
- }
-
- /**
- * Returns the name of the Validator, as it should be displayed in the UI. The ValidationBuilder
- * uses this string as input to the IProgressMonitor. i.e., At some point during the validation
- * process, the Validation Builder will output this string: "{0} is validating {1}.", where {0}
- * is the string that this method returns, and {1} is the name of the current resource.
- */
- public String getName() {
- return getName(Locale.getDefault());
- }
-
- /**
- * <p>
- * Returns the name of the Validator, as it should be displayed in the UI. The ValidationBuilder
- * uses this string as input to the IProgressMonitor. i.e., At some point during the validation
- * process, the Validation Builder will output this string:
- * </p>
- *
- * <pre>
- * &quot;{0} is validating {1}.&quot;,
- * </pre>
- *
- * <p>
- * where
- * </p>
- *
- * <pre>
- * {0} is the string that this method returns,
- * </pre>
- *
- * <p>
- * and
- * </p>
- *
- * <pre>
- * {1} is the name of the current resource.
- * </pre>
- *
- * @param locale
- * The locale from which to retrieve the name text.
- */
-
- public String getName(Locale locale) {
- return getMessage(getBaseName(), VALIDATOR_NAME, locale);
- }
-
- /**
- * Returns the name of the Validator, as it should be displayed in the UI. The ValidationBuilder
- * uses this string as input to the IProgressMonitor. i.e., At some point during the validation
- * process, the Validation Builder will output this string: "{0} is validating {1}.", where {0}
- * is the string that this method returns, and {1} is the name of the current resource.
- */
- public String[] getParam1(String string1) {
- String[] parms = new String[1];
- parms[0] = string1;
- return parms;
- }
-
- protected void initialize() {
- // Default
- }
-
- /**
- * This is the method which performs the validation on the MOF model. <br>
- * <br>
- * <code>helper</code> and <code>reporter</code> may not be null. <code>changedFiles</code>
- * may be null, if a full build is desired. <br>
- * <br>
- * <code>helper</code> loads a EObject. The EObject is the root of the MOF model about to be
- * validated. When this object is traversed, you can reach every element in the MOF model which
- * needs to be validated. <br>
- * <br>
- * <code>reporter</code> is an instance of an IReporter interface, which is used for
- * interaction with the user. <br>
- * <br>
- * <code>changedFiles</code> is an array of file names which have changed since the last
- * validation. If <code>changedFiles</code> is null, or if it is an empty array, then a full
- * build is performed. Otherwise, validation on just the files listed in the Vector is
- * performed.
- */
-
- public void validate(IValidationContext inHelper, IReporter inReporter) throws ValidationException {
- _helper = inHelper;
- _reporter = inReporter;
- if ((inHelper == null) || (inReporter == null)) {
- return;
- }
- }
-
- public IStatus validateInJob(IValidationContext inHelper, IReporter inReporter) throws ValidationException {
-
- _helper = inHelper;
- _reporter = inReporter;
- status = OK_STATUS;
- return status;
- }
-
- /**
- * Validate EJB references.
- */
- protected void validateEJBRefManadatoryElements(EjbRef eref, String ownerName) {
- String[] parms = new String[2];
- parms[0] = eref.getName();
- parms[1] = ownerName;
-
- if ((eref.getName() == null) || (eref.getName().trim().length() == 0))
- addWarning(EREF_CATEGORY, ERROR_EAR_MISSING_EREFNAME, parms, eref);
- if (eref.isSetType()) {
- if (eref.getType() == null)
- addWarning(EREF_CATEGORY, ERROR_EAR_INVALID_EREFTYPE, parms);
- } else
- addWarning(EREF_CATEGORY, ERROR_EAR_MISSING_EREFTYPE, parms);
-
- String refHome = eref.getHome();
- if ((refHome == null) || (refHome.trim().length() == 0))
- addWarning(EREF_CATEGORY, ERROR_EAR_MISSING_EREFHOME, parms, eref);
-
- if ((eref.getRemote() == null) || (eref.getRemote().trim().length() == 0))
- addWarning(EREF_CATEGORY, ERROR_EAR_MISSING_EREFREMOTE, parms, eref);
- }
-
- /**
- * Validate for duplicates in EAR Roles.
- */
- protected void validateResourceRefs(List resourceRefs) {
-
- int numRefs = resourceRefs.size();
- Set refSet = new HashSet(numRefs);
-
- for (int refNo = 0; refNo < numRefs; refNo++) {
- String refName = ((ResourceRefImpl) (resourceRefs.get(refNo))).getName();
- String[] parms = new String[1];
- parms[0] = refName;
- if (!(refSet.add(refName)))
- addError(EREF_CATEGORY, ERROR_EAR_DUPLICATE_RESREF, parms, resourceRefs.get(refNo));
- }
- }
-
- /**
- * Validate the existance of Web Roles within the EAR Roles and duplicates in Web Roles.
- */
- protected void validateWEBRolesWithEARRoles(EList earRoleList, EList warRoles) {
- int numRoles = warRoles.size();
-
- // TFB This implementation requires a 'small' list of warRoles.
- // If 'warRoles' gets too big then another implementation
- // will be necessary.
-
- for (int roleNo = 0; roleNo < numRoles; roleNo++) {
- if( _reporter.isCancelled() ){
- String msg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED);
- status = WTPCommonPlugin.createErrorStatus(msg);
- }
-
- SecurityRoleImpl nextRole = (SecurityRoleImpl) (warRoles.get(roleNo));
- String[] parms = new String[1];
- parms[0] = nextRole.getRoleName();
- if (!(earRoleList.contains(nextRole)))
- addWarning(WAR_CATEGORY, ERROR_EAR_MISSING_EJB_ROLE, parms, nextRole);
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/MessageDrivenBeanClassVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/MessageDrivenBeanClassVRule.java
deleted file mode 100644
index 8a24f775b..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/MessageDrivenBeanClassVRule.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.MessageDriven;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class MessageDrivenBeanClassVRule extends ABeanClassVRule implements IEJBType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_MESSAGE_BEANCLASS;
- private static final Object[] DEPENDS_ON = null;
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".mb"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_MESSAGEDRIVENBEAN, JAVAX_JMS_MESSAGELISTENER};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final boolean SHOULD_VALIDATE_TRANSIENT_FIELD = false;
- private final boolean SHOULD_BE_ABSTRACT = false;
- private final int IS_REMOTE = NEITHER;
-
- private final boolean SHOULD_BE_FINAL = false;
- private final boolean SHOULD_BE_PUBLIC = true;
-
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{ONMESSAGE, CONSTRUCTOR_NOPARM, EJBCREATE_NOPARM, EJBREMOVE_NOPARM};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{FINALIZE_NOPARM};
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, ONMESSAGE, CONSTRUCTOR_NOPARM, CONSTRUCTOR, EJBCREATE_NOPARM, EJBCREATE, EJBREMOVE_NOPARM, FINALIZE_NOPARM};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2050_constr, new String[]{CHKJ2050_constr+EXT});
- MESSAGE_IDS.put(CHKJ2050_onMessage, new String[]{CHKJ2050_onMessage+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbCreate, new String[]{CHKJ2050_ejbCreate+EXT});
- MESSAGE_IDS.put(CHKJ2050_setEntityContext, new String[]{CHKJ2050_setEntityContext+EXT});
- MESSAGE_IDS.put(CHKJ2050_unsetEntityContext, new String[]{CHKJ2050_unsetEntityContext+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbActivate, new String[]{CHKJ2050_ejbActivate+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbPassivate, new String[]{CHKJ2050_ejbPassivate+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbRemove, new String[]{CHKJ2050_ejbRemove+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbLoad, new String[]{CHKJ2050_ejbLoad+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbStore, new String[]{CHKJ2050_ejbStore+EXT});
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
- MESSAGE_IDS.put(CHKJ2040, new String[]{CHKJ2040+EXT});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
- MESSAGE_IDS.put(CHKJ2014, new String[]{CHKJ2014+EXT});
- MESSAGE_IDS.put(CHKJ2022, new String[]{CHKJ2022+EXT});
- MESSAGE_IDS.put(CHKJ2015, new String[]{CHKJ2015+EXT});
-
- MESSAGE_IDS.put(CHKJ2103, new String[]{CHKJ2103+SPEC});
- MESSAGE_IDS.put(CHKJ2421, new String[]{CHKJ2421+BEXT, CHKJ2421+MEXT});
- MESSAGE_IDS.put(CHKJ2422, new String[]{CHKJ2422+BEXT, CHKJ2422+MEXT});
- MESSAGE_IDS.put(CHKJ2423, new String[]{CHKJ2423+BEXT, CHKJ2423+MEXT});
- MESSAGE_IDS.put(CHKJ2424, new String[]{CHKJ2424+BEXT, CHKJ2424+MEXT});
- MESSAGE_IDS.put(CHKJ2426, new String[]{CHKJ2426+BEXT, CHKJ2426+MEXT});
-
- MESSAGE_IDS.put(CHKJ2427, new String[]{CHKJ2427+BEXT, CHKJ2427+MEXT});
- MESSAGE_IDS.put(CHKJ2428, new String[]{CHKJ2428+BEXT, CHKJ2428+MEXT});
- MESSAGE_IDS.put(CHKJ2431, new String[]{CHKJ2431+BEXT, CHKJ2431+MEXT});
- MESSAGE_IDS.put(CHKJ2439, new String[]{CHKJ2439+BEXT, CHKJ2439+MEXT});
-
- MESSAGE_IDS.put(CHKJ2445, new String[]{CHKJ2445+BEXT, CHKJ2445+MEXT});
- MESSAGE_IDS.put(CHKJ2446, new String[]{CHKJ2446+BEXT, CHKJ2446+MEXT});
- MESSAGE_IDS.put(CHKJ2447, new String[]{CHKJ2447+BEXT, CHKJ2447+MEXT});
- MESSAGE_IDS.put(CHKJ2501_ejbCreate, new String[]{CHKJ2501_ejbCreate+BEXT, CHKJ2501_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2501_ejbRemove, new String[]{CHKJ2501_ejbRemove+BEXT, CHKJ2501_ejbRemove+MEXT});
- MESSAGE_IDS.put(CHKJ2501_onMessage, new String[]{CHKJ2501_onMessage+BEXT, CHKJ2501_onMessage+MEXT});
-
- MESSAGE_IDS.put(CHKJ2492, new String[]{CHKJ2492+BEXT, CHKJ2492+MEXT});
- MESSAGE_IDS.put(CHKJ2493, new String[]{CHKJ2493+BEXT, CHKJ2493+MEXT});
- MESSAGE_IDS.put(CHKJ2494, new String[]{CHKJ2494+BEXT, CHKJ2494+MEXT});
-
- MESSAGE_IDS.put(CHKJ2502_finalize, new String[]{CHKJ2502_finalize+BEXT, CHKJ2502_finalize+MEXT});
-
- MESSAGE_IDS.put(CHKJ2503_onMessage, new String[]{CHKJ2503_onMessage+BEXT, CHKJ2503_onMessage+MEXT});
-
- MESSAGE_IDS.put(CHKJ2505_ejbRemove, new String[]{CHKJ2505_ejbRemove+BEXT, CHKJ2505_ejbRemove+MEXT});
- MESSAGE_IDS.put(CHKJ2505_onMessage, new String[]{CHKJ2505_onMessage+BEXT, CHKJ2505_onMessage+MEXT});
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final boolean shouldValidateTransientField() {
- return SHOULD_VALIDATE_TRANSIENT_FIELD;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final boolean followEjbCreateReturnTypeRules(EnterpriseBean bean, Method method) {
- return method.isVoid();
- }
-
- public final boolean shouldBeAbstract(JavaClass clazz) {
- return SHOULD_BE_ABSTRACT;
- }
-
- public final boolean shouldBeFinal(JavaClass clazz) {
- return SHOULD_BE_FINAL;
- }
-
- public final boolean shouldBePublic(JavaClass clazz) {
- return SHOULD_BE_PUBLIC;
- }
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final JavaHelpers getEjbCreateReturnType(EnterpriseBean bean, Method method) throws InvalidInputException {
- return ValidationRuleUtility.getType(ITypeConstants.VOID, bean);
- }
-
- public final String getEjbCreateReturnTypeName(EnterpriseBean bean, Method method) throws InvalidInputException {
- return ITypeConstants.VOID;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-
- public final void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- long methodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedLists, this);
-
- if((methodType & ONMESSAGE) == ONMESSAGE) {
- validateOnMessageMethod(vc, bean, clazz, method);
- }
- else if((methodType & EJBCREATE) == EJBCREATE) {
- validateEjbCreateMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
- else if((methodType & EJBREMOVE_NOPARM) == EJBREMOVE_NOPARM) {
- validateEjbRemoveMethod(vc, bean, clazz, method);
- }
- else {
- // Method isn't supposed to be here. Let the validateMethodsWhichMustNotExist
- // take care of it.
- }
- }
-
- public String getMatchingHomeMethodName(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- return getNoMatchingMethodName(vc, method);
- }
-
- public void validateEjbCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- super.validateEjbCreateMethod(vc, bean, clazz, method, methodsExtendedLists);
-
- if(ValidationRuleUtility.throwsApplicationException(method, bean)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2501_ejbCreate, IEJBValidationContext.INFO, bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
-
- public void validateEjbRemoveMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException, InvalidInputException, ValidationException {
- super.validateEjbRemoveMethod(vc, bean, clazz, method);
-
- if(ValidationRuleUtility.throwsApplicationException(method, bean)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2501_ejbRemove, IEJBValidationContext.INFO, bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
-
- public boolean validateEjbCreateMethodExceptions() {
- // Don't check for CreateException
- return false;
- }
-
- /**
- * @param vc
- * @param bean
- * @param clazz
- * @throws InvalidInputException
- */
- protected void validateShouldBeSuperTypes(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- if((bean.getVersionID() == J2EEVersionConstants.EJB_2_0_ID) || (bean.getVersionID() == J2EEVersionConstants.EJB_2_1_ID)){
- JavaClass jclass = ((MessageDriven)bean).getMessagingType();
- if( jclass != null ){
- if (jclass.getQualifiedName().equals(ITypeConstants.CLASSNAME_JAVAX_JMS_MESSAGELISTENER)){
- super.validateShouldBeSuperTypes(vc,bean,clazz);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jst.j2ee.internal.model.validation.ejb.ejb20rules.impl.ATypeVRule#validateMethodsWhichMustExist(org.eclipse.jst.j2ee.internal.model.validation.IValidationContext, org.eclipse.jst.j2ee.internal.ejb.EnterpriseBean, org.eclipse.jem.java.JavaClass)
- */
- public void validateMethodsWhichMustExist(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException,
- ValidationCancelledException, ValidationException {
- if((bean.getVersionID() == J2EEVersionConstants.EJB_2_0_ID) || (bean.getVersionID() == J2EEVersionConstants.EJB_2_1_ID)){
- JavaClass jclass = ((MessageDriven)bean).getMessagingType();
- if( jclass != null ){
- if (jclass.getQualifiedName().equals(ITypeConstants.CLASSNAME_JAVAX_JMS_MESSAGELISTENER)){
- super.validateMethodsWhichMustExist(vc, bean, clazz);
- }
- }
- }
-
- }
- public void validateOnMessageMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // IWAD4396 = This method must be public. Read section 15.7.4 of the EJB 2.0 specification.
- if(!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2445, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4397 = This method must not be final. Read section 15.7.4 of the EJB 2.0 specification.
- if(method.isFinal()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2446, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4398 = This method must not be static. Read section 15.7.4 of the EJB 2.0 specification.
- if(method.isStatic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2447, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // IWAD4399 = This method must return void. Read section 15.7.4 of the EJB 2.0 specification.
- // IWAD4400 = This method must not throw application exceptions. Read section 15.7.4 of the EJB 2.0 specification.
- if(!method.isVoid()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2505_onMessage, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(ValidationRuleUtility.throwsApplicationException(method, bean)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2501_onMessage, IEJBValidationContext.INFO, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if(!followRemoteExceptionRules(bean, method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2503_onMessage, IEJBValidationContext.WARNING, bean, clazz, method, this);
- vc.addMessage(message);
- }
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/MessageUtility.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/MessageUtility.java
deleted file mode 100644
index 4ae32f131..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/MessageUtility.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.common.SecurityRole;
-import org.eclipse.jst.j2ee.common.SecurityRoleRef;
-import org.eclipse.jst.j2ee.ejb.AssemblyDescriptor;
-import org.eclipse.jst.j2ee.ejb.CommonRelationshipRole;
-import org.eclipse.jst.j2ee.ejb.EJBJar;
-import org.eclipse.jst.j2ee.ejb.EJBRelation;
-import org.eclipse.jst.j2ee.ejb.EJBRelationshipRole;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.MethodElement;
-import org.eclipse.jst.j2ee.ejb.MethodPermission;
-import org.eclipse.jst.j2ee.ejb.MethodTransaction;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class MessageUtility {
- public static final String NO_MESSAGE_ID = ""; //$NON-NLS-1$
-
- private static MessageUtility inst = null;
-
- private MessageUtility() {
- //Default
- }
-
- public static MessageUtility getUtility() {
- if(inst == null) {
- inst = new MessageUtility();
- }
- return inst;
- }
-
- public static String getGroupName(Object targetParent) {
- if(targetParent == null) {
- // No context to associate the message with
- return null;
- }
-
- // So far, the only target parent which is used as a group name is the EnterpriseBean
- if(targetParent instanceof EnterpriseBean) {
- EnterpriseBean bean = (EnterpriseBean)targetParent;
- if(bean == null) {
- return null;
- }
-
- if(bean.getName() != null) {
- return bean.getName();
- }
- return ((XMIResource)bean.eResource()).getID(bean);
- }
-
- return null;
- }
-
- protected String getMessageId(Object messageNumber, EnterpriseBean bean, IValidationRule rule) {
- if(messageNumber == null) {
- return NO_MESSAGE_ID;
- }
-
- Map ids = rule.getMessageIds();
- if((ids == null) || (ids.size() == 0)) {
- return messageNumber.toString();
- }
-
- int index = -1;
-
- String[] result = (String[])ids.get(messageNumber);
- if(result == null) {
- return messageNumber.toString();
- }
- else if(result.length == 1) {
- if(result[0].equals("")) { //$NON-NLS-1$
- return messageNumber.toString();
- }
- return result[0];
- }
- else {
- // By convention, this is the order of the entries in the String[]
- if(bean.isSession()) {
- index = 0;
- }
- else if(bean.isContainerManagedEntity()) {
- index = 1;
- }
- else if(bean.isBeanManagedEntity()) {
- index = 2;
- }
- else if(bean.isMessageDriven()) {
- index = 3;
- }
- else {
- // what the heck is it?
- return messageNumber.toString();
- }
-
- if((result.length <= index) || (result[index].equals(""))) { //$NON-NLS-1$
- return messageNumber.toString();
- }
-
- return result[index];
- }
- }
-
- /*
- * Use this method when the message is not registered on a method.
- */
- protected String getMessageId(Object messageNumber, IValidationRule rule) {
- if(messageNumber == null) {
- return NO_MESSAGE_ID;
- }
-
- Map ids = rule.getMessageIds();
- if((ids == null) || (ids.size() == 0)) {
- return messageNumber.toString();
- }
-
- String[] result = (String[])ids.get(messageNumber);
- if((result == null) || (result.length == 0) || (result[0].equals(""))) { //$NON-NLS-1$
- return messageNumber.toString();
- }
- return result[0];
- }
-
- /*
- * Use this method when the message is registered on a method.
- */
- protected String getMessageId(Object messageNumber, IValidationRule rule, boolean isMethodOnClass) {
- if(messageNumber == null) {
- return NO_MESSAGE_ID;
- }
-
- Map ids = rule.getMessageIds();
- if((ids == null) || (ids.size() == 0)) {
- return messageNumber.toString();
- }
-
- String[] messages = (String[])ids.get(messageNumber);
- String result = null;
- if(messages != null) {
- if(isMethodOnClass && messages.length == 2) {
- result = messages[1];
- }
- else if (messages.length >= 1) {
- result = messages[0];
- }
- }
-
- if((result == null) || (result.equals(""))) { //$NON-NLS-1$
- return messageNumber.toString();
- }
-
- return result;
- }
-
- protected IMessage getMessage(IEJBValidationContext vc, int severity, String id, String[] parms, Object target, String groupName) {
- IMessage message = vc.getMessage();
- message.setSeverity(severity);
- message.setId(id);
- message.setParams(parms);
- message.setTargetObject(target);
- message.setGroupName(groupName);
- return message;
- }
-
- /**
- * For use only by the DD VRules.
- */
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EJBJar target, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, null, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, SecurityRole target, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, null, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, SecurityRoleRef target, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, null, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, MethodElement target, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, null, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, MethodTransaction target, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, null, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, MethodPermission target, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, null, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EJBRelationshipRole target, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, null, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, CommonRelationshipRole target, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, null, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EJBRelation target, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, null, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, AssemblyDescriptor target, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, null, target, null);
- }
-
- /**
- * For use only by the DD VRules.
- */
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EJBJar target, String[] parms, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, parms, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, MethodElement target, String[] parms, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, parms, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EJBRelationshipRole target, String[] parms, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, parms, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, SecurityRoleRef target, String[] parms, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, parms, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EJBRelation target, String[] parms, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, parms, target, null);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EnterpriseBean bean, Object target, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, null, target, getGroupName(bean));
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EnterpriseBean bean, Object target, String[] parms, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, parms, target, getGroupName(bean));
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EnterpriseBean bean, IValidationRule rule) {
- String id = getMessageId(messageNumber, bean, rule);
- return getMessage(vc, severity, id, null, bean, getGroupName(bean));
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EnterpriseBean bean, String[] parms, IValidationRule rule) {
- String id = getMessageId(messageNumber, bean, rule);
- return getMessage(vc, severity, id, parms, bean, getGroupName(bean));
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EnterpriseBean bean, JavaClass clazz, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, null, clazz, getGroupName(bean));
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EnterpriseBean bean, JavaClass clazz, String[] additionalParms, IValidationRule rule) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, additionalParms, clazz, getGroupName(bean));
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EnterpriseBean bean, JavaClass clazz, Method method, IValidationRule rule) {
- if(method == null) {
- return getMessage(vc, messageNumber, severity, bean, clazz, rule);
- }
-
- return getMessage(vc, messageNumber, severity, null, clazz, method, method.getMethodElementSignature(), ValidationRuleUtility.onClass(clazz, method), getGroupName(bean), rule);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EnterpriseBean bean, JavaClass clazz, Method method, String[] additionalParms, IValidationRule rule) {
- if(method == null) {
- return getMessage(vc, messageNumber, severity, bean, clazz, additionalParms, rule);
- }
-
- return getMessage(vc, messageNumber, severity, additionalParms, clazz, method, method.getMethodElementSignature(), ValidationRuleUtility.onClass(clazz, method), getGroupName(bean), rule);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EnterpriseBean bean, JavaClass clazz, Field field, IValidationRule rule) {
- if(field == null) {
- return getMessage(vc, messageNumber, severity, bean, clazz, rule);
- }
-
- return getMessage(vc, messageNumber, severity, null, clazz, field, field.getName(), ValidationRuleUtility.onClass(clazz, field), getGroupName(bean), rule);
- }
-
- public IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, EnterpriseBean bean, JavaClass clazz, Field field, String[] additionalParms, IValidationRule rule) {
- if(field == null) {
- return getMessage(vc, messageNumber, severity, bean, clazz, additionalParms, rule);
- }
-
- return getMessage(vc, messageNumber, severity, additionalParms, clazz, field, field.getName(), ValidationRuleUtility.onClass(clazz, field), getGroupName(bean), rule);
- }
-
- protected IMessage getMessage(IEJBValidationContext vc, Object messageNumber, int severity, String[] additionalParms, JavaClass clazz, EObject fieldOrMethod, String fieldOrMethodName, boolean isMethodOnClass, String groupName, IValidationRule rule) {
- if(fieldOrMethod == null) {
- String id = getMessageId(messageNumber, rule);
- return getMessage(vc, severity, id, additionalParms, clazz, groupName);
- }
-
- String[] parms = null;
- EObject target = null;
- if(isMethodOnClass) {
- // leave parms null since no parms are needed
- target = fieldOrMethod;
- parms = additionalParms;
- }
- else {
- if(additionalParms == null) {
- parms = new String[]{fieldOrMethodName};
- }
- else {
- parms = new String[additionalParms.length + 1];
- parms[0] = fieldOrMethodName;
- System.arraycopy(additionalParms, 0, parms, 1, additionalParms.length);
- }
- target = clazz;
- }
-
- String id = getMessageId(messageNumber, rule, isMethodOnClass);
- return getMessage(vc, severity, id, parms, target, groupName);
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/MethodUtility.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/MethodUtility.java
deleted file mode 100644
index 85408bd36..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/MethodUtility.java
+++ /dev/null
@@ -1,2149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.JavaParameter;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-
-
-public final class MethodUtility {
- private static MethodUtility _inst = null;
- private long[] _methodTypeIndex;
- private IMethodType[] _methodTypes;
- private long[] _fieldTypeIndex;
- private IFieldType[] _fieldTypes;
-
- private MethodUtility() {
- buildTypeList();
- }
-
- public static MethodUtility getUtility() {
- if(_inst == null) {
- _inst = new MethodUtility();
- }
- return _inst;
- }
-
- protected IMethodType[] getMethodTypes() {
- return _methodTypes;
- }
-
- public IFieldType getFieldType(long type) {
- int index = Arrays.binarySearch(_fieldTypeIndex, type);
- if(index > _fieldTypes.length) {
- return null;
- }
-
- if(index < 0) {
- return null;
- }
-
- if(_fieldTypes[index].getId() != type) {
- return null;
- }
-
- return _fieldTypes[index];
- }
-
- public IMethodType getMethodType(long type) {
- int index = Arrays.binarySearch(_methodTypeIndex, type);
- if(index > _methodTypes.length) {
- return null;
- }
-
- if(index < 0) {
- return null;
- }
-
- if(_methodTypes[index].getId() != type) {
- return null;
- }
-
- return _methodTypes[index];
- }
-
- public long getMethodTypeId(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists, IEJBType rule) {
- IMethodType mType = getMethodType(bean, clazz, method, methodsExtendedLists, rule);
- if(mType == null) {
- return rule.getDefaultMethodType();
- }
-
- return mType.getId();
- }
-
- public long getFieldTypeId(EnterpriseBean bean, JavaClass clazz, Field field, IEJBType rule) {
- IFieldType mType = getFieldType(bean, clazz, field, rule);
- if(mType == null) {
- return IMethodAndFieldConstants.EXCLUDED_FIELD;
- }
-
- return mType.getId();
- }
-
- public IFieldType getFieldType(EnterpriseBean bean, JavaClass clazz, Field field, IEJBType rule) {
- IFieldType[] knownFieldTypes = _fieldTypes;
- if(knownFieldTypes == null) {
- return null;
- }
-
- for(int i=0; i<knownFieldTypes.length; i++) {
- IFieldType mt = knownFieldTypes[i];
- if(mt == null) {
- continue;
- }
-
- if(mt.isFieldType(bean, clazz, field)) {
- return mt;
- }
- }
-
- // If it's not one of the recognized methods, which dynamically-named
- // method type is it?
- return null;
- }
-
- public IMethodType getMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists, IEJBType rule) {
- long[] knownMethodTypes = rule.getKnownMethodTypes();
- if(knownMethodTypes == null) {
- return null;
- }
-
- for(int i=0; i<knownMethodTypes.length; i++) {
- IMethodType mt = getMethodType(knownMethodTypes[i]);
- if(mt == null) {
- continue;
- }
-
- if(mt.isDefaultType()) {
- continue;
- }
-
- if(mt.isMethodType(bean, clazz, method, methodsExtendedLists)) {
- return mt;
- }
- }
-
- // If it's not one of the recognized methods, which dynamically-named
- // method type is it?
- return getMethodType(rule.getDefaultMethodType());
- }
-
- private void buildTypeList() {
- int typeCount = 29; // This is the number of identifiable methods in IMethodAndFieldConstants
- _methodTypeIndex = new long[typeCount];
- _methodTypes = new IMethodType[typeCount];
- int count = 0;
-
- int fieldTypeCount = 1; // This is the number of identifiable fields in IMethodAndFieldConstants
- _fieldTypeIndex = new long[fieldTypeCount];
- _fieldTypes = new IFieldType[fieldTypeCount];
- int fieldCount = 0;
-
- // The index of the type in the long[] is equal to the
- // index of the IMethodType in the IMethodType[]. By using
- // this technique instead of a HashMap, we don't need to
- // create an Integer every time we need to locate the
- // IMethodType.
- _methodTypeIndex[count] = IMethodAndFieldConstants.ACCESSOR;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.ACCESSOR;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return ""; // this method will never be called //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_acc;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method exists
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "ACCESSOR::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "ACCESSOR::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "ACCESSOR::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "ACCESSOR::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.BUSINESS;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.BUSINESS;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- if(method == null) {
- return ""; //$NON-NLS-1$
- }
- return method.getName();
- }
-
- public String getMessageId_messageMissing() {
- // Never check to see if a business method is missing
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "BUSINESS::getMessageId_messageMissing"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if a business method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "BUSINESS::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
- return IMessagePrefixEjb20Constants.CHKJ2503_bus;
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
- return IMessagePrefixEjb20Constants.CHKJ2504_business;
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
- return IMessagePrefixEjb20Constants.CHKJ2500_business;
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- // It's a business method if it's exposed on the component interface.
- // HACK ... depends on the fact that ABeanClassVRule, and its subtypes, are the only classes that will ever have a BUSINESS method.
- if(ValidationRuleUtility.getMethod(method, method.getName(), ABeanClassVRule.getRemoteComponentMethodsExtended(methodsExtendedLists)) != null) {
- return true;
- }
-
- if(ValidationRuleUtility.getMethod(method, method.getName(), ABeanClassVRule.getRemoteComponentMethodsExtended(methodsExtendedLists)) != null) {
- return true;
- }
-
- // internal helper method
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.CLINIT;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.CLINIT;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "clinit"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- // Never check to see if <clinit> is missing
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CLINIT::getMessageId_messageMissing"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CLINIT::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CLINIT::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CLINIT::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CLINIT::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().equals("<clinit>")) { //$NON-NLS-1$
- return true;
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- // Be careful to keep the order of these declarations the same as they are in
- // IMethodAndFieldConstants. Each method type is an ascending number, and if they
- // go out of order, the binary search can't find the method type.
- _methodTypeIndex[count] = IMethodAndFieldConstants.CONSTRUCTOR;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.CONSTRUCTOR;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return clazz.getName();
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_constr;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CONSTRUCTOR::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CONSTRUCTOR::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CONSTRUCTOR::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CONSTRUCTOR::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.isConstructor()) {
- return true;
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.CONSTRUCTOR_NOPARM;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.CONSTRUCTOR_NOPARM;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return clazz.getName() + "()"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_constr;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CONSTRUCTOR_NOPARM::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CONSTRUCTOR_NOPARM::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CONSTRUCTOR_NOPARM::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CONSTRUCTOR_NOPARM::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.isConstructor()) {
- // This class must define a public constructor which takes no parameters. Read section 7.10.1 of the EJB 2.0 specification.
- if(ValidationRuleUtility.isPublic(method)) {
- if(method.getParameters().size() == 0) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.CREATE;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.CREATE;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "create"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_create;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CREATE::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
- return IMessagePrefixEjb20Constants.CHKJ2503_create;
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
- return IMessagePrefixEjb20Constants.CHKJ2504_create;
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
- return IMessagePrefixEjb20Constants.CHKJ2500_create;
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().startsWith(IMethodAndFieldConstants.METHODNAME_CREATE)) {
- return true;
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.CREATE_NOPARM;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.CREATE_NOPARM;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "create()"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_create;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "CREATE_NOPARM::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
- return IMessagePrefixEjb20Constants.CHKJ2503_create;
- }
-
- public String getMessageId_messageMissingMatching() {
- return IMessagePrefixEjb20Constants.CHKJ2504_create;
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
- return IMessagePrefixEjb20Constants.CHKJ2500_create;
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().startsWith(IMethodAndFieldConstants.METHODNAME_CREATE)) {
- if(method.listParametersWithoutReturn().length == 0) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.EJBACTIVATE_NOPARM;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.EJBACTIVATE_NOPARM;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "ejbActivate()"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_ejbActivate;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBACTIVATE_NOPARM::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBACTIVATE_NOPARM::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBACTIVATE_NOPARM::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBACTIVATE_NOPARM::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().equals(IMethodAndFieldConstants.METHODNAME_EJBACTIVATE)) {
- if(method.listParametersWithoutReturn().length == 0) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.EJBCREATE;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.EJBCREATE;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "ejbCreate"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_ejbCreate;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBCREATE::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
- return IMessagePrefixEjb20Constants.CHKJ2503_ejbCreate;
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBCREATE::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
- return IMessagePrefixEjb20Constants.CHKJ2500_ejbCreate;
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().startsWith(IMethodAndFieldConstants.METHODNAME_EJBCREATE)) {
- return true;
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.EJBCREATE_NOPARM;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.EJBCREATE_NOPARM;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "ejbCreate()"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_ejbCreate;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBCREATE_NOPARM::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
- return IMessagePrefixEjb20Constants.CHKJ2503_ejbCreate;
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBCREATE_NOPARM::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBCREATE_NOPARM::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().startsWith(IMethodAndFieldConstants.METHODNAME_EJBCREATE)) {
- if(method.listParametersWithoutReturn().length == 0) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.EJBFIND;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.EJBFIND;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- if(method == null) {
- return "ejbFind"; //$NON-NLS-1$
- }
- return method.getName();
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_ejbFind;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
- return IMessagePrefixEjb20Constants.CHKJ2502_ejbFind;
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
- return IMessagePrefixEjb20Constants.CHKJ2503_ejbFind;
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBFIND::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
- return IMessagePrefixEjb20Constants.CHKJ2500_ejbFind;
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().startsWith(IMethodAndFieldConstants.PREFIX_EJBFIND)) {
- return true;
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.EJBFINDBYPRIMARYKEY;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.EJBFINDBYPRIMARYKEY;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- StringBuffer buffer = new StringBuffer("ejbFindByPrimaryKey("); //$NON-NLS-1$
- String pkName = ""; //$NON-NLS-1$
- if(bean instanceof Entity) {
- JavaClass pk = ((Entity)bean).getPrimaryKey();
- pkName = ((pk == null) ? IEJBValidatorConstants.NULL_PRIMARY_KEY : pk.getQualifiedName());
- }
- buffer.append(pkName);
- buffer.append(")"); //$NON-NLS-1$
- return buffer.toString();
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_ejbFindByPrimaryKey;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBFINDBYPRIMARYKEY::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
- return IMessagePrefixEjb20Constants.CHKJ2503_ejbFind;
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBFINDBYPRIMARYKEY::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBFINDBYPRIMARYKEY::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().startsWith(IMethodAndFieldConstants.PREFIX_EJBFIND)) {
- if(method.getName().equals(IMethodAndFieldConstants.METHODNAME_EJBFINDBYPRIMARYKEY)) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.EJBHOME;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.EJBHOME;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- if(method == null) {
- return "ejbHome"; //$NON-NLS-1$
- }
- return method.getName();
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_ejbHome;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBHOME::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
- return IMessagePrefixEjb20Constants.CHKJ2503_ejbHome;
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBHOME::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
- return IMessagePrefixEjb20Constants.CHKJ2500_ejbHome;
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().startsWith(IMethodAndFieldConstants.PREFIX_EJBHOME)) {
- return true;
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.EJBLOAD_NOPARM;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.EJBLOAD_NOPARM;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "ejbLoad()"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_ejbLoad;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBLOAD::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBLOAD::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBLOAD::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBLOAD::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().equals(IMethodAndFieldConstants.METHODNAME_EJBLOAD)) {
- if(method.listParametersWithoutReturn().length == 0) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.EJBPASSIVATE_NOPARM;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.EJBPASSIVATE_NOPARM;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "ejbPassivate()"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_ejbPassivate;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBPASSIVATE::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBPASSIVATE::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBPASSIVATE::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBPASSIVATE::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().equals(IMethodAndFieldConstants.METHODNAME_EJBPASSIVATE)) {
- if(method.listParametersWithoutReturn().length == 0) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.EJBPOSTCREATE;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.EJBPOSTCREATE;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "ejbPostCreate"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- // Can only dynamically check if ejbPostCreate is missing,
- // based on what type of ejbCreate methods exist.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBPOSTCREATE::getMessageId_messageMissing"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBPOSTCREATE::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- return IMessagePrefixEjb20Constants.CHKJ2503_ejbPostCreate;
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBPOSTCREATE::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBPOSTCREATE::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().startsWith(IMethodAndFieldConstants.METHODNAME_EJBPOSTCREATE)) {
- return true;
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.EJBREMOVE_NOPARM;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.EJBREMOVE_NOPARM;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "ejbRemove()"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_ejbRemove;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBREMOVE::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBREMOVE::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBREMOVE::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBREMOVE::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().equals(IMethodAndFieldConstants.METHODNAME_EJBREMOVE)) {
- if(method.listParametersWithoutReturn().length == 0) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.EJBSELECT;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.EJBSELECT;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- if(method == null) {
- return "ejbSelect"; //$NON-NLS-1$
- }
- return method.getName();
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_ejbSelect;
- }
-
- public String getMessageId_messageExists() {
- return IMessagePrefixEjb20Constants.CHKJ2502_ejbSelect;
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBSELECT::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBSELECT::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBSELECT::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().startsWith(IMethodAndFieldConstants.PREFIX_EJBSELECT)) {
- return true;
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.EJBSTORE_NOPARM;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.EJBSTORE_NOPARM;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "ejbStore()"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_ejbStore;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBSTORE::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBSTORE::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBSTORE::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EJBSTORE::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().equals(IMethodAndFieldConstants.METHODNAME_EJBSTORE)) {
- if(method.listParametersWithoutReturn().length == 0) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.EQUALS;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.EQUALS;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "equals(Object)"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_equals;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EQUALS::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EQUALS::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EQUALS::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "EQUALS::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().startsWith(IMethodAndFieldConstants.METHODNAME_EQUALS)) {
- JavaParameter[] parm = method.listParametersWithoutReturn();
- if(parm.length == 1) {
- try {
- JavaHelpers object = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_LANG_OBJECT, bean);
- JavaHelpers parmType = parm[0].getJavaType();
-
- if(object.equals(parmType)) {
- return true;
- }
- }
- catch(InvalidInputException e) {
- return false;
- }
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.FIND;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.FIND;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- if(method == null) {
- return "find"; //$NON-NLS-1$
- }
- return method.getName();
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_find;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "FIND::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
- return IMessagePrefixEjb20Constants.CHKJ2503_find;
- }
-
- public String getMessageId_messageMissingMatching() {
- return IMessagePrefixEjb20Constants.CHKJ2504_find;
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
- return IMessagePrefixEjb20Constants.CHKJ2500_find;
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().startsWith(IMethodAndFieldConstants.PREFIX_FIND)) {
- return true;
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.FINDBYPRIMARYKEY;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.FINDBYPRIMARYKEY;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "findByPrimaryKey"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_findByPrimaryKey;
- }
-
- public String getMessageId_messageExists() {
- return IMessagePrefixEjb20Constants.CHKJ2500_find;
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
- return IMessagePrefixEjb20Constants.CHKJ2503_find;
- }
-
- public String getMessageId_messageMissingMatching() {
- return IMessagePrefixEjb20Constants.CHKJ2504_find;
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- return IMessagePrefixEjb20Constants.CHKJ2500_find;
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().startsWith(IMethodAndFieldConstants.PREFIX_FIND)) {
- if(method.getName().startsWith(IMethodAndFieldConstants.METHODNAME_FINDBYPRIMARYKEY)) {
- return true;
- }
- }
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.FINALIZE_NOPARM;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.FINALIZE_NOPARM;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "finalize()"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- // Never check to see if finalize is missing
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "FINALIZE::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
- return IMessagePrefixEjb20Constants.CHKJ2502_finalize;
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "FINALIZE::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "FINALIZE::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "FINALIZE::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().equals(IMethodAndFieldConstants.METHODNAME_FINALIZE)) {
- if(method.listParametersWithoutReturn().length ==0) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.HASHCODE_NOPARM;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.HASHCODE_NOPARM;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "hashCode()"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_hashCode;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "HASHCODE::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "HASHCODE::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "HASHCODE::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "HASHCODE::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().equals(IMethodAndFieldConstants.METHODNAME_HASHCODE)) {
- if(method.listParametersWithoutReturn().length == 0) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.HOME;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.HOME;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "home"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_home;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "HOME::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
- return IMessagePrefixEjb20Constants.CHKJ2503_home;
- }
-
- public String getMessageId_messageMissingMatching() {
- return IMessagePrefixEjb20Constants.CHKJ2504_home;
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
- return IMessagePrefixEjb20Constants.CHKJ2500_home;
- }
-
- public boolean isDefaultType() {
- return true;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- return true;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.ONMESSAGE;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.ONMESSAGE;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "onMessage"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_onMessage;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "ONMESSAGE::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "ONMESSAGE::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "ONMESSAGE::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "ONMESSAGE::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().equals(IMethodAndFieldConstants.METHODNAME_ONMESSAGE)) {
- JavaParameter[] parms = method.listParametersWithoutReturn();
- if(parms.length == 1) {
- try {
- JavaHelpers jmsMessage = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVAX_JMS_MESSAGE, bean);
- JavaHelpers parmType = parms[0].getJavaType();
-
- if(jmsMessage.equals(parmType)) {
- return true;
- }
- }
- catch(InvalidInputException e) {
- return false;
- }
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.SETENTITYCONTEXT;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.SETENTITYCONTEXT;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "setEntityContext"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_setEntityContext;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "SETENTITYCONTEXT::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "SETENTITYCONTEXT::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "SETENTITYCONTEXT::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "SETENTITYCONTEXT::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().equals(IMethodAndFieldConstants.METHODNAME_SETENTITYCONTEXT)) {
- JavaParameter[] parm = method.listParametersWithoutReturn();
- if(parm.length == 1) {
- try {
- JavaHelpers entityContext = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVAX_EJB_ENTITYCONTEXT, bean);
- JavaHelpers parmType = parm[0].getJavaType();
-
- if(entityContext.equals(parmType)) {
- return true;
- }
- }
- catch(InvalidInputException e) {
- return false;
- }
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _methodTypeIndex[count] = IMethodAndFieldConstants.UNSETENTITYCONTEXT_NOPARM;
- _methodTypes[count++] = new IMethodType() {
- public long getId() {
- return IMethodAndFieldConstants.UNSETENTITYCONTEXT_NOPARM;
- }
-
- public String getMethodName(EnterpriseBean bean, JavaClass clazz, Method method) {
- return "unsetEntityContext()"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissing() {
- return IMessagePrefixEjb20Constants.CHKJ2050_unsetEntityContext;
- }
-
- public String getMessageId_messageExists() {
- // Never statically check to see if this method is present
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "UNSETENTITYCONTEXT::getMessageId_messageExists"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRemoteException() {
- // Don't need to know if this method throws a RemoteException.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "UNSETENTITYCONTEXT::getMessageId_messageRemoteException"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageMissingMatching() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "UNSETENTITYCONTEXT::getMessageId_messageMissingMatching"; //$NON-NLS-1$
- }
-
- public String getMessageId_messageRMI_IIOPParm() {
- // This method doesn't need a matching method.
-// return NO_MESSAGE_PREFIX;
- // Because it's difficult to find out which method has been called unexpectedly,
- // instead of returning the same string for all NO_MESSAGE_PREFIX cases,
- // instead return a message id which uniquely identifies which method was called.
- return "UNSETENTITYCONTEXT::getMessageId_messageRMI_IIOPParm"; //$NON-NLS-1$
- }
-
- public boolean isDefaultType() {
- return false;
- }
-
- public boolean isMethodType(EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- if(method == null) {
- return false;
- }
-
- if(method.getName().equals(IMethodAndFieldConstants.METHODNAME_UNSETENTITYCONTEXT)) {
- if(method.listParametersWithoutReturn().length == 0) {
- return true;
- }
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- _fieldTypeIndex[fieldCount] = IMethodAndFieldConstants.SERIALVERSIONUID;
- _fieldTypes[fieldCount++] = new IFieldType() {
- public long getId() {
- return IMethodAndFieldConstants.SERIALVERSIONUID;
- }
-
- public boolean isFieldType(EnterpriseBean bean, JavaClass clazz, Field field) {
- if(field == null) {
- return false;
- }
-
- if(field.getName().equals(IMethodAndFieldConstants.FIELDNAME_SERIALVERSIONUID)) {
- return true;
- }
-
- return false;
- }
-
- public String toString() {
- return String.valueOf(getId());
- }
- };
-
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/RoleHelper.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/RoleHelper.java
deleted file mode 100644
index aa446a876..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/RoleHelper.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import java.util.List;
-
-import org.eclipse.jst.j2ee.ejb.CommonRelationshipRole;
-import org.eclipse.jst.j2ee.internal.EjbModuleExtensionHelper;
-
-
-/**
- * This class is a copy of org.eclipse.jst.j2ee.internal.ejb.codegen.helpers.RoleHelper.
- * org.eclipse.jst.j2ee.internal.ejb.codegen.helpers.RoleHelper cannot be used
- * directly by the EJB Validator (to calculate role method names) because
- * it uses classes which are not used by WebSphere. Until the long-term
- * fix can be put in, this class will be used.
- */
-public class RoleHelper {
- static final String KEY_GETTER_NAME_PATTERN = "get{0}Key";//$NON-NLS-1$
- static final String KEY_SETTER_NAME_PATTERN = "privateSet{0}Key";//$NON-NLS-1$
- static final String LINK_GETTER_NAME_PATTERN = "get{0}Link";//$NON-NLS-1$
- static final String ADD_NAME_PREFIX = "add";//$NON-NLS-1$
- static final String GETTER_NAME_PREFIX = "get"; //$NON-NLS-1$
- static final String REMOVE_NAME_PREFIX = "remove";//$NON-NLS-1$
- static final String SECONDARY_ADD_NAME_PREFIX = "secondaryAdd";//$NON-NLS-1$
- static final String SECONDARY_REMOVE_NAME_PREFIX = "secondaryRemove";//$NON-NLS-1$
- static final String SECONDARY_SETTER_NAME_PREFIX = "secondarySet";//$NON-NLS-1$
- static final String SETTER_NAME_PREFIX = "set"; //$NON-NLS-1$
- protected EjbModuleExtensionHelper modHelper;
-/**
- * RoleHelper constructor comment.
- */
-public RoleHelper() {
- super();
-}
-/**
- * Collect the names of the methods that were added to the bean class
- * for a particular role.
- */
-public static void collectRoleMethodNames(CommonRelationshipRole aRole, List aList) {
- if (aRole == null || aList == null) return;
- aList.add(getLinkGetterName(aRole));
- if (aRole.isForward()) {
- aList.add(getKeyGetterName(aRole));
- aList.add(getKeySetterName(aRole));
- }
- if (aRole.isNavigable())
- aList.add(getGetterName(aRole));
- if (!isMany(aRole)) {
- try {
- if(aRole.getOppositeAsCommonRole() != null) {
- if (!aRole.getOppositeAsCommonRole().isKey())
- aList.add(getSetterName(aRole));
- if (!aRole.isKey()) {
- aList.add(getSecondarySetterName(aRole));
- }
- }
- }
- catch(NullPointerException exc) {
- // If a NullPointerException is caught, assume that the role isn't a key.
- // Just continue.
- }
- } else {
- aList.add(getSecondaryAddName(aRole));
- aList.add(getSecondaryRemoveName(aRole));
- if (aRole.isNavigable()) {
- try {
- if(aRole.getOppositeAsCommonRole() != null) {
- if (!aRole.getOppositeAsCommonRole().isKey()) {
- aList.add(getAddName(aRole));
- }
- }
- }
- catch(NullPointerException exc) {
- // If a NullPointerException is thrown, just assume that the opposite isn't a key.
- }
- if (aRole.getOppositeAsCommonRole() != null && !aRole.getOppositeAsCommonRole().isRequired())
- aList.add(getRemoveName(aRole));
- }
- }
-}
-/**
- * Return aString where the first character is uppercased.
- */
-public static final String firstAsUppercase(String aString) {
- if (aString != null && aString.length() >0 && !Character.isUpperCase(aString.charAt(0))) {
- char[] chars = aString.toCharArray();
- chars[0] = Character.toUpperCase(chars[0]);
- return String.valueOf(chars);
- }
- return aString;
-}
-protected static String format(String pattern, String[] replacements) {
- return java.text.MessageFormat.format(pattern, replacements);
-}
-/**
- * Return the add method name for @aRole.
- * It will be in the format "add{aRole name}".
- * For example, a role named "department" would return
- * addDepartment.
- */
-public static String getAddName(CommonRelationshipRole aRole) {
- if (aRole == null) return null;
- String arg = firstAsUppercase(aRole.getName());
- return ADD_NAME_PREFIX + arg;
-}
-/**
- * Return the getter method name for @aRole.
- * It will be in the format "get{aRole name}".
- * For example, a role named "department" would return
- * getDepartment.
- */
-public static String getGetterName(CommonRelationshipRole aRole) {
- if (aRole == null) return null;
- String arg = firstAsUppercase(aRole.getName());
- return GETTER_NAME_PREFIX + arg;
-}
-/**
- * Return the key getter method name for @aRole.
- * It will be in the format "get{aRole name}Key".
- * For example, a role named "department" would return
- * getDepartmentKey.
- */
-public static String getKeyGetterName(CommonRelationshipRole aRole) {
- if (aRole == null) return null;
- String arg = firstAsUppercase(aRole.getName());
- return format(KEY_GETTER_NAME_PATTERN, new String[]{arg});
-}
-/**
- * Return the key setter method name for @aRole.
- * It will be in the format "privateSet{aRole name}Key".
- * For example, a role named "department" would return
- * privateSetDepartmentKey.
- */
-public static String getKeySetterName(CommonRelationshipRole aRole) {
- if (aRole == null) return null;
- String arg = firstAsUppercase(aRole.getName());
- return format(KEY_SETTER_NAME_PATTERN, new String[]{arg});
-}
-/**
- * Return the link getter method name for @aRole.
- * It will be in the format "get{aRole name}Link".
- * For example, a role named "department" would return
- * getDepartmentLink.
- */
-public static String getLinkGetterName(CommonRelationshipRole aRole) {
- if (aRole == null) return null;
- String arg = firstAsUppercase(aRole.getName());
- return format(LINK_GETTER_NAME_PATTERN, new String[]{arg});
-}
-/**
- * Return the remove method name for @aRole.
- * It will be in the format "remove{aRole name}".
- * For example, a role named "department" would return
- * removeDepartment.
- */
-public static String getRemoveName(CommonRelationshipRole aRole) {
- if (aRole == null) return null;
- String arg = firstAsUppercase(aRole.getName());
- return REMOVE_NAME_PREFIX + arg;
-}
-/**
- * Return the secondary add method name for @aRole.
- * It will be in the format "secondaryAdd{aRole name}".
- * For example, a role named "department" would return
- * secondaryAddDepartment.
- */
-public static String getSecondaryAddName(CommonRelationshipRole aRole) {
- if (aRole == null) return null;
- String arg = firstAsUppercase(aRole.getName());
- return SECONDARY_ADD_NAME_PREFIX + arg;
-}
-/**
- * Return the secondary remove method name for @aRole.
- * It will be in the format "secondaryRemove{aRole name}".
- * For example, a role named "department" would return
- * secondaryRemoveDepartment.
- */
-public static String getSecondaryRemoveName(CommonRelationshipRole aRole) {
- if (aRole == null) return null;
- String arg = firstAsUppercase(aRole.getName());
- return SECONDARY_REMOVE_NAME_PREFIX + arg;
-}
-/**
- * Return the secondary setter method name for @aRole.
- * It will be in the format "secondarySet{aRole name}".
- * For example, a role named "department" would return
- * secondarySetDepartment.
- */
-public static String getSecondarySetterName(CommonRelationshipRole aRole) {
- if (aRole == null) return null;
- String arg = firstAsUppercase(aRole.getName());
- return SECONDARY_SETTER_NAME_PREFIX + arg;
-}
-/**
- * Return the setter method name for @aRole.
- * It will be in the format "set{aRole name}".
- * For example, a role named "department" would return
- * setDepartment.
- */
-public static String getSetterName(CommonRelationshipRole aRole) {
- if (aRole == null) return null;
- String arg = firstAsUppercase(aRole.getName());
- return SETTER_NAME_PREFIX + arg;
-}
-/**
- * Return true if the multiplicity is many.
- */
-public static boolean isMany(CommonRelationshipRole aRole) {
- return aRole != null && aRole.isMany();
-}
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionBeanClassVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionBeanClassVRule.java
deleted file mode 100644
index 128f00c44..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionBeanClassVRule.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Session;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class StatefulSessionBeanClassVRule extends ASessionBeanClassVRule implements IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_STATEFUL_SESSION_BEANCLASS;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_STATEFUL_SESSION_HOME, IValidationRuleList.EJB20_STATEFUL_SESSION_LOCALHOME, IValidationRuleList.EJB20_STATEFUL_SESSION_LOCAL, IValidationRuleList.EJB20_STATEFUL_SESSION_REMOTE};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".sb"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
- private static final String SMSSGID = ".sfb"; //$NON-NLS-1$
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_SESSIONBEAN};
-
- private final long[] SHOULD_NOT_BE_SUPERTYPES = new long[]{LOCAL_COMPONENT_INTERFACE, REMOTE_COMPONENT_INTERFACE};
- private final boolean SHOULD_BE_ABSTRACT = false;
- private final boolean SHOULD_BE_FINAL = false;
- private final boolean SHOULD_BE_PUBLIC = true;
- private final boolean SHOULD_VALIDATE_TRANSIENT_FIELD = true;
-
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{EJBCREATE, CONSTRUCTOR_NOPARM, EJBREMOVE_NOPARM, EJBPASSIVATE_NOPARM};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{FINALIZE_NOPARM};
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, CONSTRUCTOR_NOPARM, CONSTRUCTOR, EJBCREATE, EJBCREATE_NOPARM, EJBREMOVE_NOPARM, EJBACTIVATE_NOPARM, EJBPASSIVATE_NOPARM, FINALIZE_NOPARM, BUSINESS};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2003I, new String[]{CHKJ2003I+SPEC});
- MESSAGE_IDS.put(CHKJ2014, new String[]{CHKJ2014+EXT});
- MESSAGE_IDS.put(CHKJ2015, new String[]{CHKJ2015+EXT});
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2022, new String[]{CHKJ2022+EXT});
-
- MESSAGE_IDS.put(CHKJ2040, new String[]{CHKJ2040+EXT});
-
- MESSAGE_IDS.put(CHKJ2050_constr, new String[]{CHKJ2050_constr+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbCreate, new String[]{CHKJ2050_ejbCreate + SMSSGID + SPEC}); // special case (stateful message differs from stateless message)
- MESSAGE_IDS.put(CHKJ2050_ejbRemove, new String[]{CHKJ2050_ejbRemove+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbPassivate, new String[]{CHKJ2050_ejbPassivate+EXT});
-
- MESSAGE_IDS.put(CHKJ2103, new String[]{CHKJ2103+SPEC});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2411, new String[]{CHKJ2411+BEXT, CHKJ2411+MEXT});
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2421, new String[]{CHKJ2421+BEXT, CHKJ2421+MEXT});
- MESSAGE_IDS.put(CHKJ2422, new String[]{CHKJ2422+BEXT, CHKJ2422+MEXT});
- MESSAGE_IDS.put(CHKJ2423, new String[]{CHKJ2423+BEXT, CHKJ2423+MEXT});
- MESSAGE_IDS.put(CHKJ2424, new String[]{CHKJ2424+BEXT, CHKJ2424+MEXT});
- MESSAGE_IDS.put(CHKJ2426, new String[]{CHKJ2426+BEXT, CHKJ2426+MEXT});
- MESSAGE_IDS.put(CHKJ2427, new String[]{CHKJ2427+BEXT, CHKJ2427+MEXT});
- MESSAGE_IDS.put(CHKJ2428, new String[]{CHKJ2428+BEXT, CHKJ2428+MEXT});
-
- MESSAGE_IDS.put(CHKJ2431, new String[]{CHKJ2431+BEXT, CHKJ2431+MEXT});
- MESSAGE_IDS.put(CHKJ2439, new String[]{CHKJ2439+BEXT, CHKJ2439+MEXT});
-
- MESSAGE_IDS.put(CHKJ2441, new String[]{CHKJ2441+BEXT, CHKJ2441+MEXT});
- MESSAGE_IDS.put(CHKJ2442, new String[]{CHKJ2442+BEXT, CHKJ2442+MEXT});
- MESSAGE_IDS.put(CHKJ2443, new String[]{CHKJ2443+BEXT, CHKJ2443+MEXT});
-
- MESSAGE_IDS.put(CHKJ2452, new String[]{CHKJ2452+BEXT, CHKJ2452+MEXT});
- MESSAGE_IDS.put(CHKJ2453, new String[]{CHKJ2453+BEXT, CHKJ2453+MEXT});
- MESSAGE_IDS.put(CHKJ2456, new String[]{CHKJ2456+ON_BASE, CHKJ2456+ON_THIS}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2493, new String[]{CHKJ2493+BEXT, CHKJ2493+MEXT});
- MESSAGE_IDS.put(CHKJ2494, new String[]{CHKJ2494+BEXT, CHKJ2494+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_ejbCreate, new String[]{CHKJ2500_ejbCreate+BEXT, CHKJ2500_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2500_business, new String[]{CHKJ2500_business+BEXT, CHKJ2500_business+MEXT});
- MESSAGE_IDS.put(CHKJ2502_finalize, new String[]{CHKJ2502_finalize+BEXT, CHKJ2502_finalize+MEXT});
-
- MESSAGE_IDS.put(CHKJ2503_bus, new String[]{CHKJ2503_bus+BEXT, CHKJ2503_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2503_ejbCreate, new String[]{CHKJ2503_ejbCreate+BEXT, CHKJ2503_ejbCreate+MEXT});
-
- MESSAGE_IDS.put(CHKJ2505_ejbRemove, new String[]{CHKJ2505_ejbRemove+BEXT, CHKJ2505_ejbRemove+MEXT});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final boolean shouldValidateTransientField() {
- return SHOULD_VALIDATE_TRANSIENT_FIELD;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final boolean shouldBeAbstract(JavaClass clazz) {
- return SHOULD_BE_ABSTRACT;
- }
-
- public final boolean shouldBeFinal(JavaClass clazz) {
- return SHOULD_BE_FINAL;
- }
-
- public final boolean shouldBePublic(JavaClass clazz) {
- return SHOULD_BE_PUBLIC;
- }
-
- public final int isRemote() {
- return NEITHER;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final JavaHelpers getEjbCreateReturnType(EnterpriseBean bean, Method method) throws InvalidInputException {
- return ValidationRuleUtility.getType(ITypeConstants.VOID, bean);
- }
-
- public final String getEjbCreateReturnTypeName(EnterpriseBean bean, Method method) throws InvalidInputException {
- return ITypeConstants.VOID;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- long methodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedLists, this);
-
- if((methodType & EJBCREATE) == EJBCREATE) {
- validateEjbCreateMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
- else if((methodType & EJBPOSTCREATE) == EJBPOSTCREATE) {
- validateEjbPostCreateMethod(vc, bean, clazz, method);
- }
- else if((methodType & EJBREMOVE_NOPARM) == EJBREMOVE_NOPARM) {
- validateEjbRemoveMethod(vc, bean, clazz, method);
- }
- else if((methodType & BUSINESS) == BUSINESS) {
- validateBusinessMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
- else {
- // Method isn't supposed to be here. Let the validateMethodsWhichMustNotExist
- // take care of it.
- }
- }
-
- public String getMatchingHomeMethodName(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- long methodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedLists, this);
-
- if((methodType & EJBCREATE) == EJBCREATE) {
- return getMatchingEjbCreateMethodName(vc, method);
- }
- else if((methodType & EJBPOSTCREATE) == EJBPOSTCREATE) {
- return getMatchingEjbPostCreateMethodName(vc, method);
- }
- else if((methodType & EJBREMOVE_NOPARM) == EJBREMOVE_NOPARM) {
- return getNoMatchingMethodName(vc, method);
- }
- else if((methodType & BUSINESS) == BUSINESS) {
- return getMatchingBusinessMethodName(vc, method);
- }
- else {
- // Method isn't supposed to be here.
- return getNoMatchingMethodName(vc, method);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.validation.internal.core.core.ejb.ejb20.rules.IClassVRule#validate(org.eclipse.wst.validation.internal.core.core.ejb.IValidationContext, org.eclipse.jst.j2ee.internal.ejb.EnterpriseBean, org.eclipse.jem.internal.java.JavaClass)
- */
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException {
- super.validate(vc, bean, clazz);
- Session session = (Session)bean;
- boolean isBeanManagedStateful = (ValidationRuleUtility.isValidTransactionTypeElement(session) && ValidationRuleUtility.isBeanManagedSession(session) && ValidationRuleUtility.isStateful(session));
-
- if (isBeanManagedStateful) {
- /*
- * 6.5.3 The optional SessionSynchronization interface
- *...
- * Only a stateful Session bean with container-managed transaction demarcation may
- * implement the SessionSynchronization interface.
- *...
- * There is no need for a Session bean with bean-managed transaction to rely on the
- * synchronization call backs because the bean is in control of the commit the bean
- * knows when the transaction is about to be committed and it knows the outcome of the
- * transaction commit.
- *...
- */
- try {
- JavaHelpers ss = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVAX_EJB_SESSIONSYNCHRONIZATION, bean);
- if (ValidationRuleUtility.isAssignableFrom(bean.getEjbClass(), ss)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2003I, IEJBValidationContext.INFO, bean, bean.getEjbClass(), this);
- vc.addMessage(message);
- }
- }
- catch (InvalidInputException e) {
- String[] msgParm = { ValidationRuleUtility.getQualifiedName(bean.getEjbClass()), ValidationRuleUtility.getQualifiedName(e.getJavaClass())};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2907, IEJBValidationContext.WARNING, bean, msgParm, this);
- vc.addMessage(message);
- }
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionLocalComponentVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionLocalComponentVRule.java
deleted file mode 100644
index c08a32fcf..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionLocalComponentVRule.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class StatefulSessionLocalComponentVRule extends AComponentVRule implements ILocalType, IComponentType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_STATEFUL_SESSION_LOCAL;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_STATEFUL_SESSION_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".slc"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBLOCALOBJECT};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = null;
- private static final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2023, new String[]{CHKJ2023+BEXT, CHKJ2023+MEXT});
-
- MESSAGE_IDS.put(CHKJ2105, new String[]{CHKJ2105+SPEC});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2468, new String[]{CHKJ2468+BEXT, CHKJ2468+MEXT});
- MESSAGE_IDS.put(CHKJ2469, new String[]{CHKJ2469+BEXT, CHKJ2469+MEXT});
-
- MESSAGE_IDS.put(CHKJ2470, new String[]{CHKJ2470+BEXT, CHKJ2470+MEXT});
- MESSAGE_IDS.put(CHKJ2471, new String[]{CHKJ2471+BEXT, CHKJ2471+MEXT});
- MESSAGE_IDS.put(CHKJ2472, new String[]{CHKJ2472+BEXT, CHKJ2472+MEXT});
-
- MESSAGE_IDS.put(CHKJ2503_bus, new String[]{CHKJ2503_bus+BEXT, CHKJ2503_bus+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionLocalHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionLocalHomeVRule.java
deleted file mode 100644
index 476d0ba7c..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionLocalHomeVRule.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class StatefulSessionLocalHomeVRule extends ASessionHomeVRule implements ILocalType, IHomeType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_STATEFUL_SESSION_LOCALHOME;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_STATEFUL_SESSION_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".slh"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
- private static final String SFMSSGID = ".sflh"; //$NON-NLS-1$
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBLOCALHOME};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{CREATE};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, CREATE};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2040, new String[]{CHKJ2040+EXT});
-
- MESSAGE_IDS.put(CHKJ2050_create, new String[]{CHKJ2050_create+EXT});
-
- MESSAGE_IDS.put(CHKJ2104, new String[]{CHKJ2104+SPEC});
- MESSAGE_IDS.put(CHKJ2402, new String[]{CHKJ2402+SFMSSGID+ON_BASE+SPEC, CHKJ2402+SFMSSGID+ON_THIS+SPEC}); // special case (diff string than stateless bean)
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2461, new String[]{CHKJ2461+BEXT, CHKJ2461+MEXT});
- MESSAGE_IDS.put(CHKJ2465, new String[]{CHKJ2465+BEXT, CHKJ2465+MEXT});
- MESSAGE_IDS.put(CHKJ2466, new String[]{CHKJ2466+BEXT, CHKJ2466+MEXT});
- MESSAGE_IDS.put(CHKJ2467, new String[]{CHKJ2467+BEXT, CHKJ2467+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_create, new String[]{CHKJ2500_create+BEXT, CHKJ2500_create+MEXT});
- MESSAGE_IDS.put(CHKJ2502, new String[]{CHKJ2502+BEXT, CHKJ2502+MEXT});
- MESSAGE_IDS.put(CHKJ2503_create, new String[]{CHKJ2503_create+BEXT, CHKJ2503_create+MEXT});
- MESSAGE_IDS.put(CHKJ2504_create, new String[]{CHKJ2504_create+BEXT, CHKJ2504_create+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionRemoteComponentVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionRemoteComponentVRule.java
deleted file mode 100644
index e97d380a3..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionRemoteComponentVRule.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class StatefulSessionRemoteComponentVRule extends AComponentVRule implements IRemoteType, IComponentType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_STATEFUL_SESSION_REMOTE;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_STATEFUL_SESSION_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".src"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBOBJECT};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = null;
- private static final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2023, new String[]{CHKJ2023+BEXT, CHKJ2023+MEXT});
-
- MESSAGE_IDS.put(CHKJ2105, new String[]{CHKJ2105+SPEC});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2500_create, new String[]{CHKJ2500_create+BEXT, CHKJ2500_create+MEXT});
- MESSAGE_IDS.put(CHKJ2500_home, new String[]{CHKJ2500_home+BEXT, CHKJ2500_home+MEXT});
- MESSAGE_IDS.put(CHKJ2503_bus, new String[]{CHKJ2503_bus+BEXT, CHKJ2503_bus+MEXT});
-
- MESSAGE_IDS.put(CHKJ2468, new String[]{CHKJ2468+BEXT, CHKJ2468+MEXT});
- MESSAGE_IDS.put(CHKJ2469, new String[]{CHKJ2469+BEXT, CHKJ2469+MEXT});
-
- MESSAGE_IDS.put(CHKJ2470, new String[]{CHKJ2470+BEXT, CHKJ2470+MEXT});
- MESSAGE_IDS.put(CHKJ2471, new String[]{CHKJ2471+BEXT, CHKJ2471+MEXT});
- MESSAGE_IDS.put(CHKJ2472, new String[]{CHKJ2472+BEXT, CHKJ2472+MEXT});
- MESSAGE_IDS.put(CHKJ2500_business, new String[]{CHKJ2500_business+BEXT, CHKJ2500_business+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionRemoteHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionRemoteHomeVRule.java
deleted file mode 100644
index df034061c..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatefulSessionRemoteHomeVRule.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class StatefulSessionRemoteHomeVRule extends ASessionHomeVRule implements IRemoteType, IHomeType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_STATEFUL_SESSION_HOME;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_STATEFUL_SESSION_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".srh"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE + SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS + SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
- private static final String SFMSSGID = ".sfrh"; //$NON-NLS-1$
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBHOME};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{CREATE};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, CREATE};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2040, new String[]{CHKJ2040+EXT});
-
- MESSAGE_IDS.put(CHKJ2050_create, new String[]{CHKJ2050_create+EXT});
-
- MESSAGE_IDS.put(CHKJ2104, new String[]{CHKJ2104+SPEC});
- MESSAGE_IDS.put(CHKJ2402, new String[]{CHKJ2402+SFMSSGID+ON_BASE+SPEC, CHKJ2402+SFMSSGID+ON_THIS+SPEC});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2461, new String[]{CHKJ2461+BEXT, CHKJ2461+MEXT});
- MESSAGE_IDS.put(CHKJ2465, new String[]{CHKJ2465+BEXT, CHKJ2465+MEXT});
- MESSAGE_IDS.put(CHKJ2466, new String[]{CHKJ2466+BEXT, CHKJ2466+MEXT});
- MESSAGE_IDS.put(CHKJ2467, new String[]{CHKJ2467+BEXT, CHKJ2467+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_create, new String[]{CHKJ2500_create+BEXT, CHKJ2500_create+MEXT});
- MESSAGE_IDS.put(CHKJ2502, new String[]{CHKJ2502+BEXT, CHKJ2502+MEXT});
- MESSAGE_IDS.put(CHKJ2503_create, new String[]{CHKJ2503_create+BEXT, CHKJ2503_create+MEXT});
- MESSAGE_IDS.put(CHKJ2504_create, new String[]{CHKJ2504_create+BEXT, CHKJ2504_create+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionBeanClassVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionBeanClassVRule.java
deleted file mode 100644
index 621a11199..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionBeanClassVRule.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class StatelessSessionBeanClassVRule extends ASessionBeanClassVRule implements IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_STATELESS_SESSION_BEANCLASS;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_STATELESS_SESSION_HOME, IValidationRuleList.EJB20_STATELESS_SESSION_LOCALHOME, IValidationRuleList.EJB20_STATELESS_SESSION_REMOTE, IValidationRuleList.EJB20_STATELESS_SESSION_LOCAL};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".sb"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE + SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS + SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
- private static final String SMSSGID = ".ssb"; //$NON-NLS-1$
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_SESSIONBEAN};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = new long[]{LOCAL_COMPONENT_INTERFACE, REMOTE_COMPONENT_INTERFACE};
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{EJBCREATE_NOPARM, CONSTRUCTOR_NOPARM, EJBREMOVE_NOPARM, EJBPASSIVATE_NOPARM};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{FINALIZE_NOPARM};
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, CONSTRUCTOR_NOPARM, EJBCREATE_NOPARM, CONSTRUCTOR, EJBREMOVE_NOPARM, EJBACTIVATE_NOPARM, EJBPASSIVATE_NOPARM, FINALIZE_NOPARM, BUSINESS};
-
- private final boolean SHOULD_BE_ABSTRACT = false;
- private final boolean SHOULD_BE_FINAL = false;
- private final boolean SHOULD_BE_PUBLIC = true;
- private final boolean SHOULD_VALIDATE_TRANSIENT_FIELD = true;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2003E, new String[]{CHKJ2003E+SPEC});
- MESSAGE_IDS.put(CHKJ2014, new String[]{CHKJ2014+EXT});
- MESSAGE_IDS.put(CHKJ2015, new String[]{CHKJ2015+EXT});
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2022, new String[]{CHKJ2022+EXT});
-
- MESSAGE_IDS.put(CHKJ2040, new String[]{CHKJ2040+EXT});
-
- MESSAGE_IDS.put(CHKJ2050_constr, new String[]{CHKJ2050_constr+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbCreate, new String[]{CHKJ2050_ejbCreate+SMSSGID+SPEC});
- MESSAGE_IDS.put(CHKJ2050_ejbRemove, new String[]{CHKJ2050_ejbRemove+EXT});
- MESSAGE_IDS.put(CHKJ2050_ejbPassivate, new String[]{CHKJ2050_ejbPassivate+EXT});
-
- MESSAGE_IDS.put(CHKJ2103, new String[]{CHKJ2103+SPEC});
-
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
- MESSAGE_IDS.put(CHKJ2411, new String[]{CHKJ2411+BEXT, CHKJ2411+MEXT});
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2421, new String[]{CHKJ2421+BEXT, CHKJ2421+MEXT});
- MESSAGE_IDS.put(CHKJ2422, new String[]{CHKJ2422+BEXT, CHKJ2422+MEXT});
- MESSAGE_IDS.put(CHKJ2423, new String[]{CHKJ2423+BEXT, CHKJ2423+MEXT});
- MESSAGE_IDS.put(CHKJ2424, new String[]{CHKJ2424+BEXT, CHKJ2424+MEXT});
- MESSAGE_IDS.put(CHKJ2426, new String[]{CHKJ2426+BEXT, CHKJ2426+MEXT});
- MESSAGE_IDS.put(CHKJ2427, new String[]{CHKJ2427+BEXT, CHKJ2427+MEXT});
- MESSAGE_IDS.put(CHKJ2428, new String[]{CHKJ2428+BEXT, CHKJ2428+MEXT});
-
- MESSAGE_IDS.put(CHKJ2431, new String[]{CHKJ2431+BEXT, CHKJ2431+MEXT});
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2439, new String[]{CHKJ2439+BEXT, CHKJ2439+MEXT});
-
- MESSAGE_IDS.put(CHKJ2441, new String[]{CHKJ2441+BEXT, CHKJ2441+MEXT});
- MESSAGE_IDS.put(CHKJ2442, new String[]{CHKJ2442+BEXT, CHKJ2442+MEXT});
- MESSAGE_IDS.put(CHKJ2443, new String[]{CHKJ2443+BEXT, CHKJ2443+MEXT});
-
- MESSAGE_IDS.put(CHKJ2452, new String[]{CHKJ2452+BEXT, CHKJ2452+MEXT});
- MESSAGE_IDS.put(CHKJ2453, new String[]{CHKJ2453+BEXT, CHKJ2453+MEXT});
- MESSAGE_IDS.put(CHKJ2456, new String[]{CHKJ2456+ON_BASE, CHKJ2456+ON_THIS}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2476, new String[]{CHKJ2476+SMSSGID + ON_BASE+SPEC, CHKJ2476+SMSSGID+ON_THIS+SPEC});
- MESSAGE_IDS.put(CHKJ2492, new String[]{CHKJ2492+BEXT, CHKJ2492+MEXT});
- MESSAGE_IDS.put(CHKJ2493, new String[]{CHKJ2493+BEXT, CHKJ2493+MEXT});
- MESSAGE_IDS.put(CHKJ2494, new String[]{CHKJ2494+BEXT, CHKJ2494+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_ejbCreate, new String[]{CHKJ2500_ejbCreate+BEXT, CHKJ2500_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2500_business, new String[]{CHKJ2500_business+BEXT, CHKJ2500_business+MEXT});
- MESSAGE_IDS.put(CHKJ2502_finalize, new String[]{CHKJ2502_finalize+BEXT, CHKJ2502_finalize+MEXT});
-
- MESSAGE_IDS.put(CHKJ2503_bus, new String[]{CHKJ2503_bus+BEXT, CHKJ2503_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2503_ejbCreate, new String[]{CHKJ2503_ejbCreate+BEXT, CHKJ2503_ejbCreate+MEXT});
-
- MESSAGE_IDS.put(CHKJ2505_ejbRemove, new String[]{CHKJ2505_ejbRemove+BEXT, CHKJ2505_ejbRemove+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final boolean shouldValidateTransientField() {
- return SHOULD_VALIDATE_TRANSIENT_FIELD;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final boolean shouldBeAbstract(JavaClass clazz) {
- return SHOULD_BE_ABSTRACT;
- }
-
- public final boolean shouldBeFinal(JavaClass clazz) {
- return SHOULD_BE_FINAL;
- }
-
- public final boolean shouldBePublic(JavaClass clazz) {
- return SHOULD_BE_PUBLIC;
- }
-
- public final int isRemote() {
- return NEITHER;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final JavaHelpers getEjbCreateReturnType(EnterpriseBean bean, Method method) throws InvalidInputException {
- return ValidationRuleUtility.getType(ITypeConstants.VOID, bean);
- }
-
- public final String getEjbCreateReturnTypeName(EnterpriseBean bean, Method method) throws InvalidInputException {
- return ITypeConstants.VOID;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- long methodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedLists, this);
-
- if((methodType & EJBCREATE) == EJBCREATE) {
- validateEjbCreateMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
- else if((methodType & EJBPOSTCREATE) == EJBPOSTCREATE) {
- validateEjbPostCreateMethod(vc, bean, clazz, method);
- }
- else if((methodType & EJBREMOVE_NOPARM) == EJBREMOVE_NOPARM) {
- validateEjbRemoveMethod(vc, bean, clazz, method);
- }
- else if((methodType & BUSINESS) == BUSINESS) {
- validateBusinessMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
- else {
- // Method isn't supposed to be here. Let the validateMethodsWhichMustNotExist
- // take care of it.
- }
- }
-
- public String getMatchingHomeMethodName(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) {
- long methodType = MethodUtility.getUtility().getMethodTypeId(bean, clazz, method, methodsExtendedLists, this);
-
- if((methodType & EJBCREATE) == EJBCREATE) {
- return getMatchingEjbCreateMethodName(vc, method);
- }
- else if((methodType & EJBPOSTCREATE) == EJBPOSTCREATE) {
- return getMatchingEjbPostCreateMethodName(vc, method);
- }
- else if((methodType & EJBREMOVE_NOPARM) == EJBREMOVE_NOPARM) {
- return getNoMatchingMethodName(vc, method);
- }
- else if((methodType & BUSINESS) == BUSINESS) {
- return getMatchingBusinessMethodName(vc, method);
- }
- else {
- // Method isn't supposed to be here.
- return getNoMatchingMethodName(vc, method);
- }
- }
-
- public void validateEjbCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method, List[] methodsExtendedLists) throws ValidationCancelledException, InvalidInputException, ValidationException {
- if((method.listParametersWithoutReturn().length != 0) || (!IMethodAndFieldConstants.METHODNAME_EJBCREATE.equals(method.getName()))) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb20Constants.CHKJ2476, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
- else {
- super.validateEjbCreateMethod(vc, bean, clazz, method, methodsExtendedLists);
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.wst.validation.internal.core.core.ejb.ejb20.rules.IClassVRule#validate(org.eclipse.wst.validation.internal.core.core.ejb.IValidationContext, org.eclipse.jst.j2ee.internal.ejb.EnterpriseBean, org.eclipse.jem.internal.java.JavaClass)
- */
- public void validate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws ValidationCancelledException, InvalidInputException, ValidationException {
- // TODO Auto-generated method stub
- super.validate(vc, bean, clazz);
- /*
- * 6.5.3 The optional SessionSynchronization interface
- *...
- * Only a stateful Session bean with container-managed transaction demarcation may
- * implement the SessionSynchronization interface.
- *...
- * There is no need for a Session bean with bean-managed transaction to rely on the
- * synchronization call backs because the bean is in control of the commit the bean
- * knows when the transaction is about to be committed and it knows the outcome of the
- * transaction commit.
- *...
- */
- try {
- JavaHelpers ss = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVAX_EJB_SESSIONSYNCHRONIZATION, bean);
- if (ValidationRuleUtility.isAssignableFrom(bean.getEjbClass(), ss)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2003E, IEJBValidationContext.ERROR, bean, bean.getEjbClass(), this);
- vc.addMessage(message);
- }
- }
- catch (InvalidInputException e) {
- String[] msgParm = { ValidationRuleUtility.getQualifiedName(bean.getEjbClass()), ValidationRuleUtility.getQualifiedName(e.getJavaClass())};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2907, IEJBValidationContext.WARNING, bean, msgParm, this);
- vc.addMessage(message);
- }
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionLocalComponentVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionLocalComponentVRule.java
deleted file mode 100644
index c8cc3d9ab..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionLocalComponentVRule.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class StatelessSessionLocalComponentVRule extends AComponentVRule implements ILocalType, IComponentType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_STATELESS_SESSION_LOCAL;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_STATELESS_SESSION_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".slc"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBLOCALOBJECT};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = null;
- private static final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2023, new String[]{CHKJ2023+BEXT, CHKJ2023+MEXT});
-
- MESSAGE_IDS.put(CHKJ2105, new String[]{CHKJ2105+SPEC});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2468, new String[]{CHKJ2468+BEXT, CHKJ2468+MEXT});
- MESSAGE_IDS.put(CHKJ2469, new String[]{CHKJ2469+BEXT, CHKJ2469+MEXT});
-
- MESSAGE_IDS.put(CHKJ2470, new String[]{CHKJ2470+BEXT, CHKJ2470+MEXT});
- MESSAGE_IDS.put(CHKJ2471, new String[]{CHKJ2471+BEXT, CHKJ2471+MEXT});
- MESSAGE_IDS.put(CHKJ2472, new String[]{CHKJ2472+BEXT, CHKJ2472+MEXT});
-
- MESSAGE_IDS.put(CHKJ2503_bus, new String[]{CHKJ2503_bus+BEXT, CHKJ2503_bus+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionLocalHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionLocalHomeVRule.java
deleted file mode 100644
index ebb83b446..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionLocalHomeVRule.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class StatelessSessionLocalHomeVRule extends AStatelessHomeVRule implements ILocalType, IHomeType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_STATELESS_SESSION_LOCALHOME;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_STATELESS_SESSION_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".slh"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
- private static final String SMSSGID = ".sslh"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBLOCALHOME};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{CREATE_NOPARM};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, CREATE_NOPARM, CREATE, FINALIZE_NOPARM};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2050_create, new String[]{CHKJ2050_create+SMSSGID+SPEC});
-
- MESSAGE_IDS.put(CHKJ2104, new String[]{CHKJ2104+SPEC});
- MESSAGE_IDS.put(CHKJ2402, new String[]{CHKJ2402+SMSSGID+ON_BASE+SPEC, CHKJ2402+SMSSGID+ON_THIS+SPEC});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2461, new String[]{CHKJ2461+BEXT, CHKJ2461+MEXT});
- MESSAGE_IDS.put(CHKJ2465, new String[]{CHKJ2465+BEXT, CHKJ2465+MEXT});
- MESSAGE_IDS.put(CHKJ2466, new String[]{CHKJ2466+BEXT, CHKJ2466+MEXT});
- MESSAGE_IDS.put(CHKJ2467, new String[]{CHKJ2467+BEXT, CHKJ2467+MEXT});
-
- MESSAGE_IDS.put(CHKJ2476, new String[]{CHKJ2476+BEXT, CHKJ2476+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_create, new String[]{CHKJ2500_create+BEXT, CHKJ2500_create+MEXT});
- MESSAGE_IDS.put(CHKJ2500_home, new String[]{CHKJ2500_home+BEXT, CHKJ2500_home+MEXT});
- MESSAGE_IDS.put(CHKJ2502, new String[]{CHKJ2502+BEXT, CHKJ2502+MEXT});
- MESSAGE_IDS.put(CHKJ2503_create, new String[]{CHKJ2503_create+BEXT, CHKJ2503_create+MEXT});
- MESSAGE_IDS.put(CHKJ2504_create, new String[]{CHKJ2504_create+BEXT, CHKJ2504_create+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionRemoteComponentVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionRemoteComponentVRule.java
deleted file mode 100644
index ebfd6fde6..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionRemoteComponentVRule.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class StatelessSessionRemoteComponentVRule extends AComponentVRule implements IRemoteType, IComponentType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_STATELESS_SESSION_REMOTE;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_STATELESS_SESSION_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".src"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBOBJECT};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
-
- private final long[] METHODS_WHICH_MUST_EXIST = null;
- private static final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2023, new String[]{CHKJ2023+BEXT, CHKJ2023+MEXT});
-
- MESSAGE_IDS.put(CHKJ2105, new String[]{CHKJ2105+SPEC});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2468, new String[]{CHKJ2468+BEXT, CHKJ2468+MEXT});
- MESSAGE_IDS.put(CHKJ2469, new String[]{CHKJ2469+BEXT, CHKJ2469+MEXT});
-
- MESSAGE_IDS.put(CHKJ2470, new String[]{CHKJ2470+BEXT, CHKJ2470+MEXT});
- MESSAGE_IDS.put(CHKJ2471, new String[]{CHKJ2471+BEXT, CHKJ2471+MEXT});
- MESSAGE_IDS.put(CHKJ2472, new String[]{CHKJ2472+BEXT, CHKJ2472+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_business, new String[]{CHKJ2500_business+BEXT, CHKJ2500_business+MEXT});
- MESSAGE_IDS.put(CHKJ2500_create, new String[]{CHKJ2500_create+BEXT, CHKJ2500_create+MEXT});
- MESSAGE_IDS.put(CHKJ2500_home, new String[]{CHKJ2500_home+BEXT, CHKJ2500_home+MEXT});
- MESSAGE_IDS.put(CHKJ2503_bus, new String[]{CHKJ2503_bus+BEXT, CHKJ2503_bus+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionRemoteHomeVRule.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionRemoteHomeVRule.java
deleted file mode 100644
index f25b17f4e..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/StatelessSessionRemoteHomeVRule.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @version 1.0
- * @author
- */
-public final class StatelessSessionRemoteHomeVRule extends AStatelessHomeVRule implements IRemoteType, IHomeType, IMessagePrefixEjb20Constants {
- private static final Object ID = IValidationRuleList.EJB20_STATELESS_SESSION_HOME;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB20_STATELESS_SESSION_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- private static final String MSSGID = ".srh"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE_SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS_SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
- private static final String SMSSGID = ".ssrh"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
-
- private final long[] SUPERTYPES = new long[]{JAVAX_EJB_EJBHOME};
- private final long[] SHOULD_NOT_BE_SUPERTYPES = null;
- private final long[] METHODS_WHICH_MUST_EXIST = new long[]{CREATE_NOPARM};
- private final long[] METHODS_WHICH_MUST_NOT_EXIST = new long[]{};
-
- private final long[] KNOWN_METHOD_TYPES = new long[]{CLINIT, CREATE_NOPARM, CREATE, FINALIZE_NOPARM};
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2040, new String[]{CHKJ2040+EXT});
-
- MESSAGE_IDS.put(CHKJ2050_create, new String[]{CHKJ2050_create+SMSSGID+SPEC});
-
- MESSAGE_IDS.put(CHKJ2104, new String[]{CHKJ2104+SPEC});
- MESSAGE_IDS.put(CHKJ2402, new String[]{CHKJ2402+SMSSGID+ON_BASE+SPEC, CHKJ2402+SMSSGID+ON_THIS+SPEC});
- MESSAGE_IDS.put(CHKJ2404, new String[]{CHKJ2404+ON_BASE_SPEC, CHKJ2404+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2416, new String[]{CHKJ2416+ON_BASE_SPEC, CHKJ2416+ON_THIS_SPEC}); // special case (shared by all types)
-
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
-
- MESSAGE_IDS.put(CHKJ2461, new String[]{CHKJ2461+BEXT, CHKJ2461+MEXT});
- MESSAGE_IDS.put(CHKJ2465, new String[]{CHKJ2465+BEXT, CHKJ2465+MEXT});
- MESSAGE_IDS.put(CHKJ2466, new String[]{CHKJ2466+BEXT, CHKJ2466+MEXT});
- MESSAGE_IDS.put(CHKJ2467, new String[]{CHKJ2467+BEXT, CHKJ2467+MEXT});
-
- MESSAGE_IDS.put(CHKJ2476, new String[]{CHKJ2476+BEXT, CHKJ2476+MEXT});
-
- MESSAGE_IDS.put(CHKJ2500_create, new String[]{CHKJ2500_create+BEXT, CHKJ2500_create+MEXT});
- MESSAGE_IDS.put(CHKJ2500_home, new String[]{CHKJ2500_home+BEXT, CHKJ2500_home+MEXT});
- MESSAGE_IDS.put(CHKJ2502, new String[]{CHKJ2502+BEXT, CHKJ2502+MEXT});
- MESSAGE_IDS.put(CHKJ2503_create, new String[]{CHKJ2503_create+BEXT, CHKJ2503_create+MEXT});
- MESSAGE_IDS.put(CHKJ2504_create, new String[]{CHKJ2504_create+BEXT, CHKJ2504_create+MEXT});
-
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final long[] getBaseTypes() {
- return getSupertypes();
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final int getMessageRemoteExceptionSeverity() {
- return MESSAGE_REMOTE_EXCEPTION_SEVERITY;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public final long[] getSupertypes() {
- return SUPERTYPES;
- }
-
- public final long[] getShouldNotBeSupertypes() {
- return SHOULD_NOT_BE_SUPERTYPES;
- }
-
- public final int isRemote() {
- return IS_REMOTE;
- }
-
- public final long[] getMethodsWhichMustExist() {
- return METHODS_WHICH_MUST_EXIST;
- }
-
- public final long[] getMethodsWhichMustNotExist() {
- return METHODS_WHICH_MUST_NOT_EXIST;
- }
-
- public final long[] getKnownMethodTypes() {
- return KNOWN_METHOD_TYPES;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPBean.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPBean.java
deleted file mode 100644
index 85cba0dc0..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPBean.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * This class checks entity bean classes for errors or potential errors.
- * If any problems are found, an error, warning, or info marker is added to the task list.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- *
- * All 9.2.X sections describe BMP requirements.
- * If a CMP requirement is different than these, then the differences are
- * documented in 9.4.X sections.
- */
-public class ValidateBMPBean extends AValidateEntityBean implements IMessagePrefixEjb11Constants {
- private static final String MSSGID = ".eb"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE + SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS + SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private static final Object ID = IValidationRuleList.EJB11_BMP_BEANCLASS;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB11_BMP_HOME, IValidationRuleList.EJB11_BMP_REMOTE, IValidationRuleList.EJB11_BMP_KEYCLASS};
- private static final Map MESSAGE_IDS;
-
- boolean hasPKMethod = false;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2002, new String[]{CHKJ2002+BEXT, CHKJ2002+MEXT});
- MESSAGE_IDS.put(CHKJ2006, new String[]{CHKJ2006+EXT});
- MESSAGE_IDS.put(CHKJ2007, new String[]{CHKJ2007+EXT});
- MESSAGE_IDS.put(CHKJ2009, new String[]{CHKJ2009+EXT});
-
- MESSAGE_IDS.put(CHKJ2013, new String[]{CHKJ2013+EXT});
- MESSAGE_IDS.put(CHKJ2014, new String[]{CHKJ2014+EXT});
- MESSAGE_IDS.put(CHKJ2015, new String[]{CHKJ2015+EXT});
-
- MESSAGE_IDS.put(CHKJ2022, new String[]{CHKJ2022+EXT});
- MESSAGE_IDS.put(CHKJ2028, new String[]{CHKJ2028+BEXT, CHKJ2028+MEXT});
- MESSAGE_IDS.put(CHKJ2029, new String[]{CHKJ2029+BEXT, CHKJ2029+MEXT});
-
- MESSAGE_IDS.put(CHKJ2033, new String[]{CHKJ2033+EXT});
- MESSAGE_IDS.put(CHKJ2034, new String[]{CHKJ2034+EXT});
- MESSAGE_IDS.put(CHKJ2035, new String[]{CHKJ2035+EXT});
- MESSAGE_IDS.put(CHKJ2036, new String[]{CHKJ2036+EXT});
- MESSAGE_IDS.put(CHKJ2037, new String[]{CHKJ2037+EXT});
- MESSAGE_IDS.put(CHKJ2038, new String[]{CHKJ2038+EXT});
- MESSAGE_IDS.put(CHKJ2039, new String[]{CHKJ2039+EXT});
-
- MESSAGE_IDS.put(CHKJ2103, new String[]{CHKJ2103 + SPEC});
- MESSAGE_IDS.put(CHKJ2200, new String[]{CHKJ2200+ON_BASE+SPEC, CHKJ2200+ON_THIS+SPEC}); // CHKJ2200 is a special case. It's shared by all bean types.
-
- MESSAGE_IDS.put(CHKJ2400_bus, new String[]{CHKJ2400_bus+BEXT, CHKJ2400_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2400_ejbCreate, new String[]{CHKJ2400_ejbCreate+BEXT, CHKJ2400_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2400_ejbFind, new String[]{CHKJ2400_ejbFind+BEXT, CHKJ2400_ejbFind+MEXT});
- MESSAGE_IDS.put(CHKJ2400_ejbPostCreate, new String[]{CHKJ2400_ejbPostCreate+BEXT, CHKJ2400_ejbPostCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2406, new String[]{CHKJ2406+BEXT, CHKJ2406+MEXT});
- MESSAGE_IDS.put(CHKJ2407, new String[]{CHKJ2407+BEXT, CHKJ2407+MEXT});
- MESSAGE_IDS.put(CHKJ2408_bus, new String[]{CHKJ2408_bus+BEXT, CHKJ2408_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2408_ejbCreate, new String[]{CHKJ2408_ejbCreate+BEXT, CHKJ2408_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2408_ejbFind, new String[]{CHKJ2408_ejbFind+BEXT, CHKJ2408_ejbFind+MEXT});
- MESSAGE_IDS.put(CHKJ2408_ejbPostCreate, new String[]{CHKJ2408_ejbPostCreate+BEXT, CHKJ2408_ejbPostCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2409_bus, new String[]{CHKJ2409_bus+BEXT, CHKJ2409_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2409_ejbCreate, new String[]{CHKJ2409_ejbCreate+BEXT, CHKJ2409_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2409_ejbFind, new String[]{CHKJ2409_ejbFind+BEXT, CHKJ2409_ejbFind+MEXT});
- MESSAGE_IDS.put(CHKJ2409_ejbPostCreate, new String[]{CHKJ2409_ejbPostCreate+BEXT, CHKJ2409_ejbPostCreate+MEXT});
-
- MESSAGE_IDS.put(CHKJ2410_bus, new String[]{CHKJ2410_bus+BEXT, CHKJ2410_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2410_ejbCreate, new String[]{CHKJ2410_ejbCreate+BEXT, CHKJ2410_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2410_ejbFind, new String[]{CHKJ2410_ejbFind+BEXT, CHKJ2410_ejbFind+MEXT});
- MESSAGE_IDS.put(CHKJ2410_ejbPostCreate, new String[]{CHKJ2410_ejbPostCreate+BEXT, CHKJ2410_ejbPostCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2411, new String[]{CHKJ2411+BEXT, CHKJ2411+MEXT});
- MESSAGE_IDS.put(CHKJ2412, new String[]{CHKJ2412+BEXT, CHKJ2412+MEXT});
- MESSAGE_IDS.put(CHKJ2413, new String[]{CHKJ2413+BEXT, CHKJ2413+MEXT});
- MESSAGE_IDS.put(CHKJ2414, new String[]{CHKJ2414+BEXT, CHKJ2414+MEXT});
- MESSAGE_IDS.put(CHKJ2418, new String[]{CHKJ2418+BEXT, CHKJ2418+MEXT});
-
- MESSAGE_IDS.put(CHKJ2420, new String[]{CHKJ2420+BEXT, CHKJ2420+MEXT});
-
- MESSAGE_IDS.put(CHKJ2432, new String[]{CHKJ2432+BEXT, CHKJ2432+MEXT});
-
- MESSAGE_IDS.put(CHKJ2041, new String[]{CHKJ2041}); // special case. Shared by all types.
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2456, new String[]{CHKJ2456+ON_BASE, CHKJ2456+ON_THIS}); // special case (shared by all types)
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- protected void incrementFindByPrimaryKeyCount(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) {
- if (method == null) {
- return;
- }
- hasPKMethod = true;
- }
-
- /**
- * Checks to see if @ejbMethod is one of the required methods.
- */
- protected void primValidateExistence(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException {
- super.primValidateExistence(vc, bean, clazz, ejbMethod);
-
- // BMPs must implement ejbFindByPrimaryKey. If it isn't implemented, validateMethodExists() will
- // output an error. (hasPKMethod = true implies implemented, otherwise not implemented)
- if (!hasPKMethod && IMethodAndFieldConstants.METHODNAME_EJBFINDBYPRIMARYKEY.equals(ejbMethod.getName())) {
- incrementFindByPrimaryKeyCount(vc, bean, clazz, ejbMethod);
- }
- vc.terminateIfCancelled();
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.6
- */
- public void validateBusinessMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- // Perform common BMP/CMP business method checks
- super.validateBusinessMethod(vc, bean, clazz, method);
-
- // No specific BMP business method checks.
- // All of the points in 9.2.6 are common to both BMPs & CMPs.
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.2
- */
- public void validateClass(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- // All of the above checks are performed by the parent.
- super.validateClass(vc, bean, clazz);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.5
- */
- public void validateEjbFindMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- // A finder method name must start with the prefix "ejbFind"
- // (e.g. ejbFindByPrimaryKey, ejbFindLargeAccounts, ejbFindLateShipments).
- // The method which calls this method performs the above check.
-
- // Every entity bean must define the ejbFindByPrimaryKey method. The result type for
- // this method must be the primary key type (i.e. the ejbFindByPrimaryKey method must
- // be a single-object finder).
- if (method == null) {
- return;
- }
-
- vc.terminateIfCancelled();
- // A finder method must be declared as public.
- if (!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2408_ejbFind, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // The method must not be declared as final or static.
- if (method.isStatic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2410_ejbFind, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if (method.isFinal()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2409_ejbFind, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // The method argument types must be legal types for RMI-IIOP.
- validateLegalRMIMethodArguments(vc, bean, clazz, method);
-
- // The return type of a finder method must be the entity bean's primary key type,
- // or a collection of primary keys (see Section Subsection 9.1.8).
- validateEjbFindMethod_key(vc, bean, clazz, method);
-
- // Compatibility Note: EJB 1.0 allowed the finder methods to throw the
- // java.rmi.RemoteException to indicate a non-application exception.
- // This practice is deprecated in EJB 1.1 -- an EJB 1.1 compliant enterprise bean
- // should throw the javax.ejb.EJBException or another java.lang.RuntimeException
- // to indicate non-application exceptions to the Container (see Section 12.2.2).
- validateNoRemoteException(vc, bean, clazz, method, IMessagePrefixEjb11Constants.CHKJ2400_ejbFind);
-
- validateEjbFindMethod_homeDep(vc, bean, clazz, method);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.5
- */
- public void validateEjbFindMethod_key(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- if (method == null) {
- return;
- }
- // The return type of a finder method must be the entity bean's primary key type,
- // or a collection of primary keys (see Section Subsection 9.1.8).
- vc.terminateIfCancelled();
-
- JavaHelpers returnType = method.getReturnType();
-
- JavaClass primaryKey = ((Entity) bean).getPrimaryKey();
- ValidationRuleUtility.isValidTypeHierarchy(bean, primaryKey);
-
- if( !(ValidationRuleUtility.isAssignableFrom(returnType, primaryKey) ||
- ValidationRuleUtility.isAssignableFromCollection(returnType, bean) ||
- ValidationRuleUtility.isAssignableFromEnumeration(returnType, bean)
- )) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2407, IEJBValidationContext.WARNING, bean, clazz, method, new String[] { primaryKey.getQualifiedName()}, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * Checks that the ejbPostCreate method follows the EJB 1.1. specification.
- * Section: 9.2.4
- */
- public void validateEjbPostCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- // Perform common BMP/CMP ejbPostCreate method checks
- super.validateEjbPostCreateMethod(vc, bean, clazz, method);
-
- // No specific BMP ejbPostCreate method checks.
- // All of the points in 9.2.4 are common to both BMPs & CMPs.
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.5
- */
- public void validateMethodExists(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- super.validateMethodExists(vc, bean, clazz);
-
- if (!hasPKMethod) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2009, IEJBValidationContext.ERROR, bean, clazz, new String[] { clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
- }
-
- public void verifyFieldExists(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- /*
- // Plus, check that at least one field exists on the bean.
- List fields = getFields();
- if((fields == null) || (fields.size() == 0)) {
- addValidationMessage(IEJBValidationContext.WARNING, IMessagePrefixEjb11Constants.EJB_BMP_NOFIELDS, new String[] {getModelObjectName()}, getModelObject());
- return;
- }
- */
- }
-
- /*
- * @see IValidationRule#preValidate(IEJBValidationContext, Object, Object)
- */
- public void preValidate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException {
- super.preValidate(vc, targetParent, target);
- hasPKMethod = false;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPHome.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPHome.java
deleted file mode 100644
index 222d6439b..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPHome.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-
-
-/**
- * This class checks bean managed entity home classes for errors or potential errors.
- * If any problems are found, an error, warning, or info marker is added to the task list.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- * Section: 9.2.8
- */
-public class ValidateBMPHome extends AValidateEntityHome implements IMessagePrefixEjb11Constants {
- private static final String MSSGID = ".eh"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE + SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS + SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private static final Object ID = IValidationRuleList.EJB11_BMP_HOME;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB11_BMP_BEANCLASS, IValidationRuleList.EJB11_BMP_KEYCLASS};
- private static final Map MESSAGE_IDS;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2005, new String[]{CHKJ2005+BEXT, CHKJ2005+MEXT});
-
- MESSAGE_IDS.put(CHKJ2011, new String[]{CHKJ2011+EXT});
- MESSAGE_IDS.put(CHKJ2012, new String[]{CHKJ2012+EXT});
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2026, new String[]{CHKJ2026+BEXT, CHKJ2026+MEXT});
-
- MESSAGE_IDS.put(CHKJ2030, new String[]{CHKJ2030+BEXT, CHKJ2030+MEXT});
-
- MESSAGE_IDS.put(CHKJ2104, new String[]{CHKJ2104 + SPEC});
- MESSAGE_IDS.put(CHKJ2402, new String[]{CHKJ2402+BEXT, CHKJ2402+MEXT});
- MESSAGE_IDS.put(CHKJ2403, new String[]{CHKJ2403+BEXT, CHKJ2403+MEXT});
- MESSAGE_IDS.put(CHKJ2405, new String[]{CHKJ2405+BEXT, CHKJ2405+MEXT});
-
- MESSAGE_IDS.put(CHKJ2412, new String[]{CHKJ2412+BEXT, CHKJ2412+MEXT});
- MESSAGE_IDS.put(CHKJ2413, new String[]{CHKJ2413+BEXT, CHKJ2413+MEXT});
- MESSAGE_IDS.put(CHKJ2414, new String[]{CHKJ2414+BEXT, CHKJ2414+MEXT});
- MESSAGE_IDS.put(CHKJ2415, new String[]{CHKJ2415+BEXT, CHKJ2415+MEXT});
-
- MESSAGE_IDS.put(CHKJ2041, new String[]{CHKJ2041}); // special case. Shared by all types.
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.8
- */
- public void validateFindMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- super.validateFindMethod(vc, bean, clazz, method);
-
- if (method == null) {
- return;
- }
-
- // The verifyMatchingBeanFindMethod checks for the two following requirements:
- //
- // Each finder method must be named "find<METHOD>" (e.g. findLargeAccounts), and it
- // must match one of the ejbFind<METHOD> methods defined in the entity bean class
- // (e.g. ejbFindLargeAccounts). The matching ejbFind<METHOD> method must have the
- // same number and types of arguments. (Note that the return type may be different.)
- //
- // All the exceptions defined in the throws clause of an ejbFind method of the
- // entity bean class must be included in the throws clause of the matching find
- // method of the home interface.
- validateFindMethod_beanDep(vc, bean, clazz, method);
-
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.8
- */
- public void validateFindMethod_beanDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- if (method == null) {
- return;
- }
-
- // The verifyMatchingBeanFindMethod checks for the two following requirements:
- //
- // Each finder method must be named "find<METHOD>" (e.g. findLargeAccounts), and it
- // must match one of the ejbFind<METHOD> methods defined in the entity bean class
- // (e.g. ejbFindLargeAccounts). The matching ejbFind<METHOD> method must have the
- // same number and types of arguments. (Note that the return type may be different.)
- //
- // All the exceptions defined in the throws clause of an ejbFind method of the
- // entity bean class must be included in the throws clause of the matching find
- // method of the home interface.
- validateMatchingBeanFindMethod(vc, bean, clazz, method);
-
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPKey.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPKey.java
deleted file mode 100644
index 10c4adf1b..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPKey.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-
-
-/**
- * Validate a BMP key.
- */
-public class ValidateBMPKey extends AValidateKeyClass implements IMessagePrefixEjb11Constants {
- private static final String MSSGID = ".eb"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
-
- private static final Object ID = IValidationRuleList.EJB11_BMP_KEYCLASS;
- private static final Object[] DEPENDS_ON = null;
- private static final Map MESSAGE_IDS;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2001, new String[]{CHKJ2001+EXT});
-
- MESSAGE_IDS.put(CHKJ2019, new String[]{CHKJ2019+EXT});
-
-//Don't use that AValidateEJB method MESSAGE_IDS.put(CHKJ2412, new String[]{CHKJ2412+EXT});
-//Don't use that AValidateEJB method MESSAGE_IDS.put(CHKJ2413, new String[]{CHKJ2413+EXT});
-//Don't use that AValidateEJB method MESSAGE_IDS.put(CHKJ2414, new String[]{CHKJ2414+EXT});
-
- MESSAGE_IDS.put(CHKJ2041, new String[]{CHKJ2041}); // special case. Shared by all types.
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- /**
- * This method actually does the validation.
- */
- public void primValidate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- //super.primValidate(ejbMethod);
-
- //Nothing to do.
- }
-
- /**
- * Checks to see if @ejbMethod is one of the required methods.
- */
- protected void primValidateExistence(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- //super.validateExistence(ejbMethod);
-
- // Nothing to do
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPRemote.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPRemote.java
deleted file mode 100644
index 8ad649d92..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateBMPRemote.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * Validates the remote interface of a BMP bean.
- */
-public class ValidateBMPRemote extends AValidateRemote implements IMessagePrefixEjb11Constants {
- private static final String MSSGID = ".er"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE + SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS + SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private static final Object ID = IValidationRuleList.EJB11_BMP_REMOTE;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB11_BMP_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2012, new String[]{CHKJ2012+EXT});
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2023, new String[]{CHKJ2023+BEXT, CHKJ2023+MEXT});
-
- MESSAGE_IDS.put(CHKJ2105, new String[]{CHKJ2105 + SPEC});
-
- MESSAGE_IDS.put(CHKJ2412, new String[]{CHKJ2412+BEXT, CHKJ2412+MEXT});
- MESSAGE_IDS.put(CHKJ2413, new String[]{CHKJ2413+BEXT, CHKJ2413+MEXT});
- MESSAGE_IDS.put(CHKJ2414, new String[]{CHKJ2414+BEXT, CHKJ2414+MEXT});
- MESSAGE_IDS.put(CHKJ2415, new String[]{CHKJ2415+BEXT, CHKJ2415+MEXT});
-
- MESSAGE_IDS.put(CHKJ2041, new String[]{CHKJ2041}); // special case. Shared by all types.
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateCMPBean.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateCMPBean.java
deleted file mode 100644
index f5bfa8792..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateCMPBean.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.ejb.CMPAttribute;
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- * This class checks entity bean classes for errors or potential errors.
- * If any problems are found, an error, warning, or info marker is added to the task list.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- *
- *
- * All 9.2.X sections describe BMP requirements.
- * If a CMP requirement is different than these, then the differences are
- * documented in 9.4.X sections.
- */
-public class ValidateCMPBean extends AValidateEntityBean implements IMessagePrefixEjb11Constants {
- private List _containerManagedFields = null;
-
- private static final String MSSGID = ".eb"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE + SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS + SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private static final Object ID = IValidationRuleList.EJB11_CMP_BEANCLASS;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB11_CMP_HOME, IValidationRuleList.EJB11_CMP_REMOTE};
- private static final Map MESSAGE_IDS;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2002, new String[]{CHKJ2002+BEXT, CHKJ2002+MEXT});
- MESSAGE_IDS.put(CHKJ2004, new String[]{CHKJ2004+BEXT, CHKJ2004+MEXT});
- MESSAGE_IDS.put(CHKJ2006, new String[]{CHKJ2006+EXT});
- MESSAGE_IDS.put(CHKJ2007, new String[]{CHKJ2007+EXT});
-
- MESSAGE_IDS.put(CHKJ2013, new String[]{CHKJ2013+EXT});
- MESSAGE_IDS.put(CHKJ2014, new String[]{CHKJ2014+EXT});
- MESSAGE_IDS.put(CHKJ2015, new String[]{CHKJ2015+EXT});
-
- MESSAGE_IDS.put(CHKJ2022, new String[]{CHKJ2022+EXT});
- MESSAGE_IDS.put(CHKJ2028, new String[]{CHKJ2028+BEXT, CHKJ2028+MEXT});
- MESSAGE_IDS.put(CHKJ2029, new String[]{CHKJ2029+BEXT, CHKJ2029+MEXT});
-
- MESSAGE_IDS.put(CHKJ2032, new String[]{CHKJ2032+EXT});
- MESSAGE_IDS.put(CHKJ2033, new String[]{CHKJ2033+EXT});
- MESSAGE_IDS.put(CHKJ2034, new String[]{CHKJ2034+EXT});
- MESSAGE_IDS.put(CHKJ2035, new String[]{CHKJ2035+EXT});
- MESSAGE_IDS.put(CHKJ2036, new String[]{CHKJ2036+EXT});
- MESSAGE_IDS.put(CHKJ2037, new String[]{CHKJ2037+EXT});
- MESSAGE_IDS.put(CHKJ2038, new String[]{CHKJ2038+EXT});
- MESSAGE_IDS.put(CHKJ2039, new String[]{CHKJ2039+EXT});
-
- MESSAGE_IDS.put(CHKJ2103, new String[]{CHKJ2103 + SPEC});
- MESSAGE_IDS.put(CHKJ2200, new String[]{CHKJ2200+ON_BASE+SPEC, CHKJ2200+ON_THIS+SPEC}); // CHKJ2200 is a special case. It's shared by all bean types.
- MESSAGE_IDS.put(CHKJ2201, new String[]{CHKJ2201+BEXT, CHKJ2201+MEXT});
- MESSAGE_IDS.put(CHKJ2202, new String[]{CHKJ2202+BEXT, CHKJ2202+MEXT});
- MESSAGE_IDS.put(CHKJ2203, new String[]{CHKJ2203+BEXT, CHKJ2203+MEXT});
- MESSAGE_IDS.put(CHKJ2207, new String[]{CHKJ2207+EXT, CHKJ2207+EXT}); // special case where the message id is the same regardless of whether or not the method is inherited
-
- MESSAGE_IDS.put(CHKJ2400_bus, new String[]{CHKJ2400_bus+BEXT, CHKJ2400_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2400_ejbCreate, new String[]{CHKJ2400_ejbCreate+BEXT, CHKJ2400_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2400_ejbFind, new String[]{CHKJ2400_ejbFind+BEXT, CHKJ2400_ejbFind+MEXT});
- MESSAGE_IDS.put(CHKJ2400_ejbPostCreate, new String[]{CHKJ2400_ejbPostCreate+BEXT, CHKJ2400_ejbPostCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2406, new String[]{CHKJ2406+BEXT, CHKJ2406+MEXT});
- MESSAGE_IDS.put(CHKJ2408_bus, new String[]{CHKJ2408_bus+BEXT, CHKJ2408_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2408_ejbCreate, new String[]{CHKJ2408_ejbCreate+BEXT, CHKJ2408_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2408_ejbPostCreate, new String[]{CHKJ2408_ejbPostCreate+BEXT, CHKJ2408_ejbPostCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2409_bus, new String[]{CHKJ2409_bus+BEXT, CHKJ2409_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2409_ejbCreate, new String[]{CHKJ2409_ejbCreate+BEXT, CHKJ2409_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2409_ejbFind, new String[]{CHKJ2409_ejbFind+BEXT, CHKJ2409_ejbFind+MEXT});
- MESSAGE_IDS.put(CHKJ2409_ejbPostCreate, new String[]{CHKJ2409_ejbPostCreate+BEXT, CHKJ2409_ejbPostCreate+MEXT});
-
- MESSAGE_IDS.put(CHKJ2410_bus, new String[]{CHKJ2410_bus+BEXT, CHKJ2410_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2410_ejbCreate, new String[]{CHKJ2410_ejbCreate+BEXT, CHKJ2410_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2410_ejbFind, new String[]{CHKJ2410_ejbFind+BEXT, CHKJ2410_ejbFind+MEXT});
- MESSAGE_IDS.put(CHKJ2410_ejbPostCreate, new String[]{CHKJ2410_ejbPostCreate+BEXT, CHKJ2410_ejbPostCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2411, new String[]{CHKJ2411+BEXT, CHKJ2411+MEXT});
- MESSAGE_IDS.put(CHKJ2412, new String[]{CHKJ2412+BEXT, CHKJ2412+MEXT});
- MESSAGE_IDS.put(CHKJ2413, new String[]{CHKJ2413+BEXT, CHKJ2413+MEXT});
- MESSAGE_IDS.put(CHKJ2414, new String[]{CHKJ2414+BEXT, CHKJ2414+MEXT});
- MESSAGE_IDS.put(CHKJ2418, new String[]{CHKJ2418+BEXT, CHKJ2418+MEXT});
- MESSAGE_IDS.put(CHKJ2420, new String[]{CHKJ2420+BEXT, CHKJ2420+MEXT});
- MESSAGE_IDS.put(CHKJ2432, new String[]{CHKJ2432+BEXT, CHKJ2432+MEXT});
-
- MESSAGE_IDS.put(CHKJ2041, new String[]{CHKJ2041}); // special case. Shared by all types.
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2456, new String[]{CHKJ2456+ON_BASE, CHKJ2456+ON_THIS}); // special case (shared by all types)
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public void reset() {
- super.reset();
- _containerManagedFields = null;
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- protected List getContainerManagedFields() {
- return _containerManagedFields;
- }
-
- protected boolean hasContainerManagedField() {
- return (getContainerManagedFields() != null && getContainerManagedFields().size() > 0);
- }
-
- public boolean isContainerManagedField(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field) {
- if (field == null) {
- return false;
- }
- return getContainerManagedFields() != null && getContainerManagedFields().contains(field.getName());
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.4.1
- *
- * Return true if the field is the enterprise bean's home interface.
- */
- protected boolean isContainerManagedHome_homeDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field) throws InvalidInputException {
- if (field == null) {
- return false;
- }
-
- if (bean == null) {
- return false;
- }
-
- JavaClass homeIntf = bean.getHomeInterface();
- ValidationRuleUtility.isValidTypeHierarchy(bean, homeIntf);
-
- return ValidationRuleUtility.isAssignableFrom(ValidationRuleUtility.getType(field), homeIntf);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.4.1
- *
- * Return true if the field is the enterprise bean's remote interface.
- */
- protected boolean isContainerManagedRemote_remoteDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field) throws InvalidInputException {
- if (field == null) {
- return false;
- }
-
- if (bean == null) {
- return false;
- }
-
- JavaClass remoteIntf = bean.getRemoteInterface();
- ValidationRuleUtility.isValidTypeHierarchy(bean, remoteIntf);
-
- return ValidationRuleUtility.isAssignableFrom(ValidationRuleUtility.getType(field), remoteIntf);
- }
-
- private List loadContainerManagedFields(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // The validation in this class, of the fields, is performed against the
- // container-managed fields, not the fields of this class directly.
- if (bean == null) {
- return Collections.EMPTY_LIST;
- }
-
- List fields = null;
- try {
- List cmpAttributes = ((ContainerManagedEntity) bean).getPersistentAttributes();
- if (cmpAttributes != null && !cmpAttributes.isEmpty()) {
- fields = new ArrayList(cmpAttributes.size());
- for (int i = 0; i < cmpAttributes.size(); i++)
- fields.add(((CMPAttribute) cmpAttributes.get(i)).getName());
- }
- }
- catch (Throwable exc) {
- Logger logger = vc.getMsgLogger();
- if (logger != null && logger.isLoggingLevel(Level.FINER)) {
- logger.write(Level.FINER, exc);
- }
- fields = Collections.EMPTY_LIST;
- }
- return fields;
- }
-
- /**
- * EJB 1.1 specification
- * Section: 18.1.2
- */
- public void primValidate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field) throws InvalidInputException {
- super.primValidate(vc, bean, clazz, field);
-
- vc.terminateIfCancelled();
-
- validateContainerManagedField(vc, bean, clazz, field);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.6
- */
- public void validateBusinessMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- // Perform common BMP/CMP business method checks
- if (!isEjbRelationshipRoleMethod(vc, bean, clazz, method))
- super.validateBusinessMethod(vc, bean, clazz, method);
-
- // No specific CMP business method checks.
- // All of the points in 9.2.6 are common to both BMPs & CMPs.
- }
-
- protected void validateBusinessMethodNoRemoteException(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- if (!isEjbRelationshipRoleMethod(vc, bean, clazz, method))
- super.validateBusinessMethodNoRemoteException(vc, bean, clazz, method); // EJB 2.0 added "throws InvalidInputException above"
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.2.2
- */
- public void validateClass(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- // All of the above checks are performed by the parent.
- super.validateClass(vc, bean, clazz);
-
- validatePrimitivePrimaryKey(vc, bean, clazz); // if this class uses a primitive primary key, the type of the key must be the same as the type of the field
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.4.1
- */
- protected void validateContainerManagedField(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field) throws InvalidInputException {
- if (isContainerManagedField(vc, bean, clazz, field)) {
- if (field == null) {
- return;
- }
-
- vc.terminateIfCancelled();
-
- if (!ValidationRuleUtility.isPublic(field)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2203, IEJBValidationContext.ERROR, bean, clazz, field, this);
- vc.addMessage(message);
- }
-
- if (field.isTransient()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2201, IEJBValidationContext.ERROR, bean, clazz, field, this);
- vc.addMessage(message);
- }
-
- // Check if it's a reference to the home or remote interface.
- validateContainerManagedField_dependent(vc, bean, clazz, field);
- }
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.4.1
- *
- * Return true if the field is either the enterprise bean's remote interface,
- * or the enterprise bean's home interface.
- */
- protected void validateContainerManagedField_dependent(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field) throws InvalidInputException {
- if (field == null) {
- return;
- }
-
- JavaHelpers fieldType = ValidationRuleUtility.getType(field);
-
- if (!ValidationRuleUtility.isSerializable(fieldType, bean)) {
- // If it were primitive, it would be serializable, so two checks were done in that one line of code.
- //
- // Check if it's the enterprise bean's remote or home interface
- vc.terminateIfCancelled();
- if (!(isContainerManagedHome_homeDep(vc, bean, clazz, field)) || (isContainerManagedRemote_remoteDep(vc, bean, clazz, field))) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2202, IEJBValidationContext.WARNING, bean, clazz, field, this);
- vc.addMessage(message);
- }
- }
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.4.6
- */
- public void validateEjbFindMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- if (method == null) {
- throw new InvalidInputException();
- }
-
- // Only BMPs implement finder methods.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2004, IEJBValidationContext.WARNING, bean, clazz, method, new String[] { clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
-
- /**
- * Checks that the ejbPostCreate method follows the EJB 1.1. specification.
- * Section: 9.2.4 and 9.4.2
- */
- public void validateEjbPostCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- // Perform common BMP/CMP ejbPostCreate method checks
- super.validateEjbPostCreateMethod(vc, bean, clazz, method);
-
- // No specific CMP ejbPostCreateMethod checks.
- // All of the points in 9.2.4 are common to both BMPs & CMPs.
- }
-
- protected void validatePrimitivePrimaryKey(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- ContainerManagedEntity cmp = (ContainerManagedEntity) bean; // bean is checked for null in AValidateEJB.validate() method, so don't need to check for it here.
-
- if (ValidationRuleUtility.isPrimitivePrimaryKey(cmp)) {
- // primitive primary key
-
- // primary key that maps to a single field in the entity bean class
- // The field's type must be the primary key type.
- CMPAttribute keyAttribute = cmp.getPrimKeyField();
- Field keyField = (keyAttribute == null) ? null : keyAttribute.getField();
- JavaClass primaryKey = cmp.getPrimaryKey();
- if ((keyField == null) || !ValidationRuleUtility.isAssignableFrom((JavaHelpers)keyField.getEType(), primaryKey)) {
- String[] msgParm = { keyAttribute.getName(), primaryKey.getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2207, IEJBValidationContext.ERROR, bean, clazz, keyField, msgParm, this);
- vc.addMessage(message);
- }
- }
- }
-
- /**
- * Check that at least one field exists on the bean.
- */
- public void verifyFieldExists(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- if (!hasContainerManagedField()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2032, IEJBValidationContext.WARNING, bean, clazz, new String[] { clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
- }
- /*
- * @see IValidationRule#preValidate(IEJBValidationContext, Object, Object)
- */
- public void preValidate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException {
- super.preValidate(vc, targetParent, target);
- _containerManagedFields = loadContainerManagedFields(vc, (EnterpriseBean)targetParent, (JavaClass)target);
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateCMPKey.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateCMPKey.java
deleted file mode 100644
index 185b8a232..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateCMPKey.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.CMPAttribute;
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * This class checks entity bean classes for errors or potential errors.
- * If any problems are found, an error, warning, or info marker is added to the task list.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- *
- *
- * All 9.2.X sections describe BMP requirements. (And the bulk of those
- * are implemented in ValidateKeyClass.)
- * If a CMP requirement is different than these, then the differences are
- * documented in 9.4.X sections.
- */
-public class ValidateCMPKey extends AValidateKeyClass implements IMessagePrefixEjb11Constants {
- private boolean hasAConstructor = false;
- private boolean hasDefaultConstructor = false;
- private Set _beanFieldNames = new HashSet();
-
- private static final String MSSGID = ".eb"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE + SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS + SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private static final Object ID = IValidationRuleList.EJB11_CMP_KEYCLASS;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB11_CMP_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2001, new String[]{CHKJ2001+EXT});
-
- MESSAGE_IDS.put(CHKJ2019, new String[]{CHKJ2019+EXT});
-
- MESSAGE_IDS.put(CHKJ2020, new String[]{CHKJ2020+EXT});
- MESSAGE_IDS.put(CHKJ2021, new String[]{CHKJ2021+EXT});
-
- MESSAGE_IDS.put(CHKJ2205, new String[]{CHKJ2205+BEXT, CHKJ2205+MEXT});
- MESSAGE_IDS.put(CHKJ2206, new String[]{CHKJ2206+BEXT, CHKJ2206+MEXT}); // special case where the id is the same regardless of whether the method is inherited or not
-
-//AValidateEJB method not used MESSAGE_IDS.put(CHKJ2412, new String[]{CHKJ2412+BEXT, CHKJ2412+MEXT});
-//AValidateEJB method not used MESSAGE_IDS.put(CHKJ2413, new String[]{CHKJ2413+BEXT, CHKJ2413+MEXT});
-//AValidateEJB method not used MESSAGE_IDS.put(CHKJ2414, new String[]{CHKJ2414+BEXT, CHKJ2414+MEXT});
-
- MESSAGE_IDS.put(CHKJ2041, new String[]{CHKJ2041}); // special case. Shared by all types.
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2829, new String[]{CHKJ2829 + SPEC});
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public void reset() {
- super.reset();
- _beanFieldNames.clear();
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public Object getTarget(Object parent, Object clazz) {
- if(parent == null) {
- return null;
- }
-
- ContainerManagedEntity cmp = (ContainerManagedEntity)parent;
- if(ValidationRuleUtility.isPrimitivePrimaryKey(cmp)) {
- return null; // do not validate a primitive primary key
- }
-
- return cmp.getPrimaryKey();
- }
-
- public final Object getId() {
- return ID;
- }
-
- /*
- * EJB 1.1 specification
- * Section: 9.4.7.1 and 9.4.7.2
- */
- protected void buildFieldNameList(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) {
- // Build up the list of field names to be used in the field validation.
- vc.terminateIfCancelled();
-
- ContainerManagedEntity cmp = (ContainerManagedEntity) bean;
- if (cmp == null) {
- // Let the class validation throw the exception
- return;
- }
-
- if (!ValidationRuleUtility.isPrimitivePrimaryKey(cmp)) {
- List attributes = cmp.getPersistentAttributes();
- CMPAttribute attribute = null;
- Iterator iterator = attributes.iterator();
- while (iterator.hasNext()) {
- attribute = (CMPAttribute) iterator.next();
- try {
- // These are different fields than the ones validated by this
- // valImpl class, so don't need to worry about duplicate reflection
- // warnings logged against the same object.
- ValidationRuleUtility.isValidType(attribute.getType());
- _beanFieldNames.add(attribute.getName());
- }
- catch (InvalidInputException e) {
- //TODO (Dan) Change to use the attribute directly and not the field.
- reflectionWarning(vc, bean, clazz , attribute.getField(), e);
- }
- }
- }
- }
-
- /**
- * This method actually does the validation.
- *
- * EJB 1.1 specification
- * Section: 9.4.7.2
- */
- public void primValidate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Field field) throws InvalidInputException {
- // All fields in the primary key class must be declared as public.
- if (!ValidationRuleUtility.isPublic(field)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2205, IEJBValidationContext.WARNING, bean, clazz, field, this);
- vc.addMessage(message);
- }
-
- // The names of the fields in the primary key class must be a subset of the names of the container-managed
- // fields. (This allows the container to extract the primary key fields from an instance's container-managed
- // fields, and vice versa.)
- ContainerManagedEntity cmp = (ContainerManagedEntity) bean;
- // Don't need to check if cmp is null, because this method is called only by validateFields(),
- // and validateFields() won't call this method if the bean is null.
-
- if (!_beanFieldNames.contains(field.getName())) {
- JavaClass ejbClass = cmp.getEjbClass();
- ValidationRuleUtility.isValidType(ejbClass);
- String[] msgParm = { cmp.getName(), cmp.getEjbClass().getName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2206, IEJBValidationContext.WARNING, bean, clazz, field, msgParm, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * This method actually does the validation.
- */
- public void primValidate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- // super.primValidate(ejbMethod);
-
- //Nothing to do.
- }
-
- /**
- * Checks to see if @ejbMethod is one of the required methods.
- */
- protected void primValidateExistence(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- //super.validateExistence(ejbMethod);
-
- if (ejbMethod.isConstructor()) {
- // These booleans are used in the validateMethodExists() checks.
- hasAConstructor = true;
- if (ValidationRuleUtility.isPublic(ejbMethod) && (ejbMethod.listParametersWithoutReturn().length == 0)) {
- hasDefaultConstructor = true;
- }
- }
- }
-
- /**
- * 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);
- }
- }
- }
-
- /**
- * EJB 1.1 specification
- * Section: 9.4.7.2
- */
- public void validateMethodExists(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- super.validateMethodExists(vc, bean, clazz);
-
- // If the class has no constructors defined, Java inserts a public constructor with no arguments.
- // But if the class has at least one constructor defined, Java will not insert a constructor.
- if (!hasDefaultConstructor && hasAConstructor) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2021, IEJBValidationContext.ERROR, bean, clazz, new String[] { clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
- }
- /*
- * @see IValidationRule#preValidate(IEJBValidationContext, Object, Object)
- */
- public void preValidate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException {
- super.preValidate(vc, targetParent, target);
- hasAConstructor = false;
- hasDefaultConstructor = false;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateCMPRemote.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateCMPRemote.java
deleted file mode 100644
index 2a5ed9c3b..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateCMPRemote.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * Validates the remote interface of a CMP bean.
- */
-public class ValidateCMPRemote extends AValidateRemote implements IMessagePrefixEjb11Constants {
- private static final String MSSGID = ".er"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE + SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS + SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private static final Object ID = IValidationRuleList.EJB11_CMP_REMOTE;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB11_CMP_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2012, new String[]{CHKJ2012+EXT});
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2023, new String[]{CHKJ2023+BEXT, CHKJ2023+MEXT});
-
- MESSAGE_IDS.put(CHKJ2105, new String[]{CHKJ2105 + SPEC});
-
- MESSAGE_IDS.put(CHKJ2412, new String[]{CHKJ2412+BEXT, CHKJ2412+MEXT});
- MESSAGE_IDS.put(CHKJ2413, new String[]{CHKJ2413+BEXT, CHKJ2413+MEXT});
- MESSAGE_IDS.put(CHKJ2414, new String[]{CHKJ2414+BEXT, CHKJ2414+MEXT});
- MESSAGE_IDS.put(CHKJ2415, new String[]{CHKJ2415+BEXT, CHKJ2415+MEXT});
-
- MESSAGE_IDS.put(CHKJ2041, new String[]{CHKJ2041}); // special case. Shared by all types.
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateSessionBean.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateSessionBean.java
deleted file mode 100644
index 2a787beae..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateSessionBean.java
+++ /dev/null
@@ -1,495 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Session;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * This class checks Session home interface classes for errors or potential errors.
- * If any problems are found, an error, warning, or info marker is added to the task list.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- * Section: 6.8, 6.10.2, 6.10.3 and 6.10.4
- */
-public class ValidateSessionBean extends AValidateBean implements IMessagePrefixEjb11Constants {
- private boolean hasValidConstructor = false;
- private boolean hasAConstructor = false;
- private boolean hasDefaultCreateMethod = false;
- private Set createMethods = null;
-
- private static final String MSSGID = ".sb"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE + SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS + SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private static final Object ID = IValidationRuleList.EJB11_SESSION_BEANCLASS;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB11_SESSION_HOME, IValidationRuleList.EJB11_SESSION_REMOTE};
- private static final Map MESSAGE_IDS;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2003I, new String[]{CHKJ2003I + SPEC});
- MESSAGE_IDS.put(CHKJ2003E, new String[]{CHKJ2003E + SPEC});
-
- MESSAGE_IDS.put(CHKJ2006, new String[]{CHKJ2006+EXT});
- MESSAGE_IDS.put(CHKJ2007, new String[]{CHKJ2007+EXT});
- MESSAGE_IDS.put(CHKJ2008, new String[]{CHKJ2008+EXT});
-
- MESSAGE_IDS.put(CHKJ2013, new String[]{CHKJ2013+EXT});
- MESSAGE_IDS.put(CHKJ2014, new String[]{CHKJ2014+EXT});
- MESSAGE_IDS.put(CHKJ2015, new String[]{CHKJ2015+EXT});
-
- MESSAGE_IDS.put(CHKJ2022, new String[]{CHKJ2022+EXT});
- MESSAGE_IDS.put(CHKJ2025, new String[]{CHKJ2025+BEXT, CHKJ2025+MEXT});
-
- MESSAGE_IDS.put(CHKJ2040, new String[]{CHKJ2040+EXT});
-
- MESSAGE_IDS.put(CHKJ2103, new String[]{CHKJ2103 + SPEC});
- MESSAGE_IDS.put(CHKJ2200, new String[]{CHKJ2200+ON_BASE+SPEC, CHKJ2200+ON_THIS+SPEC}); // CHKJ2200 is a special case. It's shared by all bean types.
-
- MESSAGE_IDS.put(CHKJ2400_bus, new String[]{CHKJ2400_bus+BEXT, CHKJ2400_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2400_ejbCreate, new String[]{CHKJ2400_ejbCreate+BEXT, CHKJ2400_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2401, new String[]{CHKJ2401+BEXT, CHKJ2401+MEXT});
- MESSAGE_IDS.put(CHKJ2408_bus, new String[]{CHKJ2408_bus+BEXT, CHKJ2408_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2408_ejbCreate, new String[]{CHKJ2408_ejbCreate+BEXT, CHKJ2408_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2409_bus, new String[]{CHKJ2409_bus+BEXT, CHKJ2409_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2409_ejbCreate, new String[]{CHKJ2409_ejbCreate+BEXT, CHKJ2409_ejbCreate+MEXT});
-
- MESSAGE_IDS.put(CHKJ2410_bus, new String[]{CHKJ2410_bus+BEXT, CHKJ2410_bus+MEXT});
- MESSAGE_IDS.put(CHKJ2410_ejbCreate, new String[]{CHKJ2410_ejbCreate+BEXT, CHKJ2410_ejbCreate+MEXT});
- MESSAGE_IDS.put(CHKJ2411, new String[]{CHKJ2411+BEXT, CHKJ2411+MEXT});
- MESSAGE_IDS.put(CHKJ2412, new String[]{CHKJ2412+BEXT, CHKJ2412+MEXT});
- MESSAGE_IDS.put(CHKJ2413, new String[]{CHKJ2413+BEXT, CHKJ2413+MEXT});
- MESSAGE_IDS.put(CHKJ2414, new String[]{CHKJ2414+BEXT, CHKJ2414+MEXT});
-
- MESSAGE_IDS.put(CHKJ2420, new String[]{CHKJ2420+BEXT, CHKJ2420+MEXT});
-
- MESSAGE_IDS.put(CHKJ2432, new String[]{CHKJ2432+BEXT, CHKJ2432+MEXT});
-
- MESSAGE_IDS.put(CHKJ2041, new String[]{CHKJ2041}); // special case. Shared by all types.
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2456, new String[]{CHKJ2456+ON_BASE, CHKJ2456+ON_THIS}); // special case (shared by all types)
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public void reset() {
- super.reset();
- createMethods.clear();
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public ValidateSessionBean() {
- createMethods = new HashSet();
- }
-
- protected final String getParentName() {
- return ITypeConstants.CLASSNAME_JAVAX_EJB_SESSIONBEAN;
- }
-
- protected boolean hasCreateMethod() {
- if (hasDefaultCreateMethod == true)
- return true;
- if (createMethods.size() > 0)
- return true;
- return false;
- }
-
- protected void incrementCreateMethodCount(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) {
- if (method == null) {
- return;
- }
-
- if ((method.listParametersWithoutReturn().length == 0) && (!hasDefaultCreateMethod)) {
- hasDefaultCreateMethod = true;
- }
- else {
- // add it to the list, for reporting extraneous create methods, for stateless session beans (section 6.8)
- createMethods.add(method);
- }
- }
-
- public boolean isFrameworkMethod(String name) {
- if (super.isFrameworkMethod(name)) {
- return true;
- }
-
- // check for session-specific methods
- if (name.equals(IMethodAndFieldConstants.METHODNAME_SETSESSIONCONTEXT)) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Check that the ejbCreate methods and business methods follow the EJB 1.1 spec.
- * Section: 6.8, 6.10.2, 6.10.3 and 6.10.4
- */
- public void primValidate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- // super.primValidate(ejbMethod);
-
- vc.terminateIfCancelled();
-
- String name = ejbMethod.getName();
- if (name.equals(IMethodAndFieldConstants.METHODNAME_EJBCREATE)) {
- validateEjbCreateMethod(vc, bean, clazz, ejbMethod);
- }
- else if (name.equals(IMethodAndFieldConstants.METHODNAME_FINALIZE)) {
- validateFinalizeMethod(vc, bean, clazz, ejbMethod);
- }
- else if (ejbMethod.isConstructor()) {
- validateConstructor(vc, bean, clazz, ejbMethod);
- }
- else if (isBusinessMethod(vc, bean, clazz, ejbMethod)) {
- validateBusinessMethod(vc, bean, clazz, ejbMethod);
- }
- else if (!isFrameworkMethod(name)) {
- validateHelperMethod(vc, bean, clazz, ejbMethod);
- }
-
- vc.terminateIfCancelled();
-
- }
-
- /**
- * Checks to see if @ejbMethod is one of the required methods.
- */
- protected void primValidateExistence(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- //super.validateExistence(ejbMethod);
-
- if (IMethodAndFieldConstants.METHODNAME_EJBCREATE.equals(ejbMethod.getName()))
- incrementCreateMethodCount(vc, bean, clazz, ejbMethod);
- else if (ejbMethod.isConstructor())
- validateConstructor(vc, bean, clazz, ejbMethod);
- }
-
- /**
- * Test that the supplied business method follows the EJB 1.1 spec rules.
- * Section: 6.10.4
- */
- public void validateBusinessMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- super.validateBusinessMethod(vc, bean, clazz, method); // check method name does not start with 'ejb'
-
- // The method arguments and return value types must be legal types for RMI/IIOP.
- validateLegalRMIMethodWithoutExceptions(vc, bean, clazz, method);
-
- // The rest of the checks are performed in the validateMethod method.
- validateBusinessModifiersAndExceptions(vc, bean, clazz, method);
- }
-
- /**
- * Check that the session bean class definition follows the EJB 1.1 spec.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- * Section: 6.10.2
- */
- public void validateClass(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- vc.terminateIfCancelled();
- super.validateClass(vc, bean, clazz);
- // super.validateClass() performs the following checks:
- // - The class must implement, directly or indirectly, the javax.ejb.SessionBean
- // interface.
- // - The class must be defined as public, must not be final, and must not
- // be abstract.
-
- // If the class is a stateful session bean, it may optionally implement
- // the javax.ejb.SessionSynchronization interface.
-
- Session session = (Session)bean;
- boolean isStateless = ValidationRuleUtility.isStateless(bean);
- boolean isBeanManagedStateful = (ValidationRuleUtility.isBeanManagedSession(session) && ValidationRuleUtility.isStateful(session));
-
- if (isStateless) {
- /*
- * EJB 1.1 specification
- * Section: 6.5.3
- */
- try {
- if (ValidationRuleUtility.isAssignableFrom(bean.getEjbClass(), ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVAX_EJB_SESSIONSYNCHRONIZATION, bean))) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2003E, IEJBValidationContext.ERROR, bean, bean.getEjbClass(), this);
- vc.addMessage(message);
- }
- }
- catch (InvalidInputException e) {
- 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);
- vc.addMessage(message);
- }
- }
- else if (isBeanManagedStateful) {
- /*
- * EJB 1.1 specification
- * Section: 6.5.3
- */
- try {
- if (ValidationRuleUtility.isAssignableFrom(bean.getEjbClass(), ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVAX_EJB_SESSIONSYNCHRONIZATION, bean))) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2003I, IEJBValidationContext.INFO, bean, bean.getEjbClass(), this);
- vc.addMessage(message);
- }
- }
- catch (InvalidInputException e) {
- String[] msgParm = { bean.getEjbClass().getQualifiedName(), e.getJavaClass().getQualifiedName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2907, IEJBValidationContext.WARNING, bean, msgParm, this);
- vc.addMessage(message);
- }
- }
-
- // The session bean class may have superclasses and/or superinterfaces. If the
- // session bean has superclasses, then the business methods, the ejbCreate methods,
- // the methods of the SessionBean interface, and the methods of the optional
- // SessionSynchronization interface may be defined in the session bean class,
- // or in any of its superclasses.
- // - this is taken care of by the EJB MOF model. When asked if a JavaClass has a method,
- // the model checks the class' parents too.
-
- // The class may, but is not required to, implement the session bean's
- // remote interface [4] .
- // [4] If the session bean class does implement the remote interface, care must
- // be taken to avoid passing of this as a method argument or result. This
- // potential error can be avoided by choosing not to implement the remote
- // interface in the session bean class.
- validateClass_remoteDep(vc, bean, clazz);
- }
-
- /**
- * Check that the session bean class definition follows the EJB 1.1 spec.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- * Section: 6.10.2
- */
- public void validateClass_remoteDep(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- vc.terminateIfCancelled();
- // The class may, but is not required to, implement the session bean's
- // remote interface [4] .
- // [4] If the session bean class does implement the remote interface, care must
- // be taken to avoid passing of this as a method argument or result. This
- // potential error can be avoided by choosing not to implement the remote
- // interface in the session bean class.
- JavaClass remote = bean.getRemoteInterface();
- ValidationRuleUtility.isValidTypeHierarchy(bean, remote);
- if (ValidationRuleUtility.isAssignableFrom(clazz, remote)) {
- String[] msgParm = {clazz.getQualifiedName(), remote.getQualifiedName()};
- IMessage message = MessageUtility.getUtility().getMessage(vc, IEJBValidatorMessageConstants.CHKJ2040, IEJBValidationContext.INFO, bean, clazz, msgParm, this);
- vc.addMessage(message);
- }
-
- }
-
- protected void validateConstructor(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) {
- if (method == null) {
- return;
- }
-
- hasAConstructor = true;
- if (!hasValidConstructor && ValidationRuleUtility.isPublic(method) && (method.listParametersWithoutReturn().length == 0)) {
- hasValidConstructor = true;
- }
- }
-
- /**
- * Test that the supplied ejbCreate method follows the EJB 1.1 spec rules.
- * Section: 6.10.3
- */
- public void validateEjbCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- vc.terminateIfCancelled();
-
- // The method which calls this method has already tested that the method name is ejbCreate.
- if (method == null) {
- return;
- }
-
- // The return type must be void.
- JavaHelpers parmType = method.getReturnType();
- String returnTypeName = ((parmType == null) ? "" : parmType.getQualifiedName()); //$NON-NLS-1$
-
- if (!returnTypeName.equals(ITypeConstants.VOID)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2401, IEJBValidationContext.ERROR, bean, clazz, method, new String[] {clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
-
- // The method arguments must be legal types for RMI/IIOP.
- validateLegalRMIMethodArguments(vc, bean, clazz, method);
-
- validateEjbCreateModifiersAndExceptions(vc, bean, clazz, method);
-
- validateEjbCreateMethod_homeDep(vc, bean, clazz, method);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 6.10.2
- */
- protected void validateFinalizeMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) {
- if (method == null) {
- return;
- }
-
- if (method.listParametersWithoutReturn().length == 0) {
- // This is a warning, not an error, because EJB 1.0 allowed the finalize() method to be called. EJB 1.1 (section 6.10.2) specifically prohibits it.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2007, IEJBValidationContext.WARNING, bean, clazz, method, new String[] {clazz.getQualifiedName()}, this);
- vc.addMessage(message);
- }
- }
-
- /**
- * EJB 1.1 specification
- * Section: 6.8, 6.10.2 and 6.10.3
- */
- protected void validateMethodExists(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- final String[] modelObjectName = new String[] { clazz.getQualifiedName()};
- if (!hasValidConstructor && hasAConstructor) {
- // If a public constructor with no arguments does not exist explicitly,
- // Java will insert one as long as there are no constructors defined in the
- // class. If there is a constructor, Java does not insert a default constructor.
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2006, IEJBValidationContext.ERROR, bean, clazz, modelObjectName, this);
- vc.addMessage(message);
- }
-
- if (!hasCreateMethod()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2008, IEJBValidationContext.ERROR, bean, clazz, modelObjectName, this);
- vc.addMessage(message);
- }
-
- // The session bean class must define a single ejbCreate method that takes
- // no arguments.
- if (ValidationRuleUtility.isStateless(bean) && (createMethods.size() > 0)) {
- Iterator iterator = createMethods.iterator();
- while (iterator.hasNext()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2025, IEJBValidationContext.ERROR, bean, clazz, (Method) iterator.next(), modelObjectName, this);
- vc.addMessage(message);
- }
- }
- }
-
- /**
- * Test that the supplied method follows the EJB 1.1 spec rules.
- *
- * ejbCreate and business methods follow some of the same rules. This method checks those rules.
- * (Part of sections 6.10.3 and 6.10.4)
- */
- public void validateBusinessModifiersAndExceptions(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- // EJB 2.0 added "throws InvalidInputException" above
- vc.terminateIfCancelled();
- if (method == null)
- return;
-
- // The method must be declared as public.
- if (!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2408_bus, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // The method must not be declared as final or static.
- if (method.isStatic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2410_bus, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if (method.isFinal()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2409_bus, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // The throws clause may define arbitrary application exceptions, possibly
- // including the javax.ejb.CreateException.
- // Compatibility Note: EJB 1.0 allowed the business methods to throw the java.rmi.RemoteException
- // to indicate a non-application exception. This practice is deprecated in EJB 1.1 -- an EJB 1.1 compliant
- // enterprise bean should throw the javax.ejb.EJBException or another RuntimeException to
- // indicate non-application exceptions to the Container (see Section 12.2.2).
- validateNoRemoteException(vc, bean, clazz, method, IMessagePrefixEjb11Constants.CHKJ2400_bus);
- }
-
- public void validateEjbCreateModifiersAndExceptions(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- // EJB 2.0 added "throws InvalidInputException" above
- vc.terminateIfCancelled();
- if (method == null)
- return;
-
- // The method must be declared as public.
- if (!ValidationRuleUtility.isPublic(method)) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2408_ejbCreate, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // The method must not be declared as final or static.
- if (method.isStatic()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2410_ejbCreate, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- if (method.isFinal()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2409_ejbCreate, IEJBValidationContext.ERROR, bean, clazz, method, this);
- vc.addMessage(message);
- }
-
- // The throws clause may define arbitrary application exceptions, possibly
- // including the javax.ejb.CreateException.
- // Compatibility Note: EJB 1.0 allowed the business methods to throw the java.rmi.RemoteException
- // to indicate a non-application exception. This practice is deprecated in EJB 1.1 -- an EJB 1.1 compliant
- // enterprise bean should throw the javax.ejb.EJBException or another RuntimeException to
- // indicate non-application exceptions to the Container (see Section 12.2.2).
- validateNoRemoteException(vc, bean, clazz, method, IMessagePrefixEjb11Constants.CHKJ2400_ejbCreate);
- }
- /*
- * @see IValidationRule#preValidate(IEJBValidationContext, Object, Object)
- */
- public void preValidate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException {
- super.preValidate(vc, targetParent, target);
- hasValidConstructor = false;
- hasAConstructor = false;
- hasDefaultCreateMethod = false;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateSessionHome.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateSessionHome.java
deleted file mode 100644
index 528a43805..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateSessionHome.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-
-/**
- * This class checks Session home interface classes for errors or potential errors.
- * If any problems are found, an error, warning, or info marker is added to the task list.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- * Section: 6.8 and 6.10.6
- *
- */
-public class ValidateSessionHome extends AValidateHome implements IMessagePrefixEjb11Constants {
- private boolean hasDefaultCreateMethod = false;
- private Set createMethods = null;
-
- private static final String MSSGID = ".sh"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE + SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS + SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private static final Object ID = IValidationRuleList.EJB11_SESSION_HOME;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB11_SESSION_BEANCLASS, IValidationRuleList.EJB11_SESSION_REMOTE};
- private static final Map MESSAGE_IDS;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2005, new String[]{CHKJ2005+BEXT, CHKJ2005+MEXT});
- MESSAGE_IDS.put(CHKJ2010, new String[]{CHKJ2010+EXT});
-
- MESSAGE_IDS.put(CHKJ2011, new String[]{CHKJ2011+EXT});
- MESSAGE_IDS.put(CHKJ2012, new String[]{CHKJ2012+EXT});
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2024, new String[]{CHKJ2024+BEXT, CHKJ2024+MEXT});
- MESSAGE_IDS.put(CHKJ2026, new String[]{CHKJ2026+BEXT, CHKJ2026+MEXT});
-
- MESSAGE_IDS.put(CHKJ2104, new String[]{CHKJ2104 + SPEC});
-
- MESSAGE_IDS.put(CHKJ2402, new String[]{CHKJ2402+BEXT, CHKJ2402+MEXT});
- MESSAGE_IDS.put(CHKJ2403, new String[]{CHKJ2403+BEXT, CHKJ2403+MEXT});
- MESSAGE_IDS.put(CHKJ2405, new String[]{CHKJ2405+BEXT, CHKJ2405+MEXT});
-
- MESSAGE_IDS.put(CHKJ2412, new String[]{CHKJ2412+BEXT, CHKJ2412+MEXT});
- MESSAGE_IDS.put(CHKJ2413, new String[]{CHKJ2413+BEXT, CHKJ2413+MEXT});
- MESSAGE_IDS.put(CHKJ2414, new String[]{CHKJ2414+BEXT, CHKJ2414+MEXT});
- MESSAGE_IDS.put(CHKJ2415, new String[]{CHKJ2415+BEXT, CHKJ2415+MEXT});
- MESSAGE_IDS.put(CHKJ2419, new String[]{CHKJ2419+BEXT, CHKJ2419+MEXT});
-
- MESSAGE_IDS.put(CHKJ2041, new String[]{CHKJ2041}); // special case. Shared by all types.
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public void reset() {
- super.reset();
- createMethods.clear();
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-
- public ValidateSessionHome() {
- createMethods = new HashSet();
- }
-
- protected boolean hasCreateMethod() {
- if (hasDefaultCreateMethod == true)
- return true;
- if (createMethods.size() > 0)
- return true;
- return false;
- }
-
- protected void incrementCreateMethodCount(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) {
- if (method == null) {
- return;
- }
-
- if ((method.listParametersWithoutReturn().length == 0) && (!hasDefaultCreateMethod)) {
- hasDefaultCreateMethod = true;
- }
- else {
- // add it to the list, for reporting extraneous create methods, for stateless session beans (section 6.8)
- createMethods.add(method);
- }
- }
-
- /**
- * Check the session home interface's methods follow the EJB 1.1 spec.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- * Section: 6.8 and 6.10.6
- */
- public void primValidate(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method hiMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- // super.primValidate(hiMethod);
-
- vc.terminateIfCancelled();
-
- String name = hiMethod.getName();
- // Home interface should only declare create methods
- if (name.equals(IMethodAndFieldConstants.METHODNAME_CREATE)) {
- validateCreateMethod(vc, bean, clazz, hiMethod);
- }
- else {
- // Home interface should only declare create methods
- // (No methods other than create methods are listed in section 6.10.6,
- // but other sections of the spec, e.g. 9.2.2, explicitly list each type
- // of method which can be on a class/interface.)
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2419, IEJBValidationContext.ERROR, bean, clazz, hiMethod, this);
- vc.addMessage(message);
- }
-
- vc.terminateIfCancelled();
- }
-
- /**
- * Checks to see if @ejbMethod is one of the required methods.
- */
- protected void primValidateExistence(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method ejbMethod) throws InvalidInputException {
- // Can't invoke an abstract method
- //super.validateExistence(ejbMethod);
-
- if (IMethodAndFieldConstants.METHODNAME_CREATE.equals(ejbMethod.getName()))
- incrementCreateMethodCount(vc, bean, clazz, ejbMethod);
- }
-
- /**
- * Check that the session home class definition follows the EJB 1.1 spec.
- *
- * Enterprise JavaBeans Specification ("Specification")
- * Version: 1.1
- * Status: Final Release
- * Release: 12/17/99
- * URL: http://java.sun.com/products/ejb/docs.html
- * Section: 6.10.6
- */
- public void validateClass(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- vc.terminateIfCancelled();
- // Both of the above checks are performed by the ValidateHome class's validateClass method.
- super.validateClass(vc, bean, clazz);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 6.8 and 6.10.6
- */
- protected void validateCreateMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) throws InvalidInputException {
- if (method == null) {
- return;
- }
-
- // The methods defined in this interface must follow the rules for RMI/IIOP.
- // This means that their argument and return values must be of valid types
- // for RMI/IIOP, and that their throws clause must include the java.rmi.RemoteException.
- validateLegalRMIMethod(vc, bean, clazz, method);
-
- // Each create method must be named "create", and it must match one of
- // the ejbCreate methods defined in the session bean class. The matching
- // ejbCreate method must have the same number and types of arguments.
- // (Note that the return type is different.)
- // All the exceptions defined in the throws clause of an ejbCreate method
- // of the session bean class must be defined in the throws clause of the
- // matching create method of the home interface.
- // The throws clause must include javax.ejb.CreateException.
- validateCreateMethod_beanDep(vc, bean, clazz, method);
-
- // The throws clause must include javax.ejb.CreateException.
- if (!ValidationRuleUtility.throwsCreateException(bean, method)) {
- String[] msgParm = { ITypeConstants.CLASSNAME_JAVAX_EJB_CREATEEXCEPTION };
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2414, IEJBValidationContext.ERROR, bean, clazz, method, msgParm, this);
- vc.addMessage(message);
- }
-
- // Perform the checks which depend on another class in the enterprise bean.
- validateCreateMethod_remoteDep(vc, bean, clazz, method);
- }
-
- /**
- * EJB 1.1 specification
- * Section: 6.8 and 6.10.6
- */
- protected void validateMethodExists(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz) throws InvalidInputException {
- final String[] modelObjectName = new String[] { clazz.getQualifiedName()};
-
- // A session bean's home must define one or more create methods.
- if (!hasCreateMethod()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2010, IEJBValidationContext.ERROR, bean, clazz, modelObjectName, this);
- vc.addMessage(message);
- }
-
- // The home interface of a stateless session bean must have one create
- // method that takes no arguments and returns the session bean's remote
- // interface. There can be no other create methods in the home interface.
- if (ValidationRuleUtility.isStateless(bean) && (createMethods.size() > 0)) {
- Iterator iterator = createMethods.iterator();
- while (iterator.hasNext()) {
- IMessage message = MessageUtility.getUtility().getMessage(vc, IMessagePrefixEjb11Constants.CHKJ2024, IEJBValidationContext.ERROR, bean, clazz, (Method) iterator.next(), modelObjectName, this);
- vc.addMessage(message);
- }
- }
- }
- /*
- * @see IValidationRule#preValidate(IEJBValidationContext, Object, Object)
- */
- public void preValidate(IEJBValidationContext vc, Object targetParent, Object target) throws ValidationCancelledException, ValidationException {
- super.preValidate(vc, targetParent, target);
- hasDefaultCreateMethod = false;
- }
-
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateSessionRemote.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateSessionRemote.java
deleted file mode 100644
index 68220649d..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidateSessionRemote.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-
-/**
- * Validates the remote interface of a Session bean.
- */
-public class ValidateSessionRemote extends AValidateRemote implements IMessagePrefixEjb11Constants {
- private static final String MSSGID = ".sr"; // In messages, to identify which message version belongs to the BMP bean class, this id is used. //$NON-NLS-1$
- private static final String EXT = MSSGID + SPEC; // Extension to be used on non-method, non-field messages
- private static final String BEXT = MSSGID + ON_BASE + SPEC; // Extension to be used on a method/field message when the method/field is inherited from a base type
- private static final String MEXT = MSSGID + ON_THIS + SPEC; // Extension to be used on a method/field message when the method/field is implemented on the current type
-
- private static final Object ID = IValidationRuleList.EJB11_SESSION_REMOTE;
- private static final Object[] DEPENDS_ON = new Object[]{IValidationRuleList.EJB11_SESSION_BEANCLASS};
- private static final Map MESSAGE_IDS;
-
- static {
- MESSAGE_IDS = new HashMap();
-
- MESSAGE_IDS.put(CHKJ2012, new String[]{CHKJ2012+EXT});
- MESSAGE_IDS.put(CHKJ2017, new String[]{CHKJ2017+EXT});
-
- MESSAGE_IDS.put(CHKJ2023, new String[]{CHKJ2023+BEXT, CHKJ2023+MEXT});
-
- MESSAGE_IDS.put(CHKJ2105, new String[]{CHKJ2105 + SPEC});
-
- MESSAGE_IDS.put(CHKJ2412, new String[]{CHKJ2412+BEXT, CHKJ2412+MEXT});
- MESSAGE_IDS.put(CHKJ2413, new String[]{CHKJ2413+BEXT, CHKJ2413+MEXT});
- MESSAGE_IDS.put(CHKJ2414, new String[]{CHKJ2414+BEXT, CHKJ2414+MEXT});
- MESSAGE_IDS.put(CHKJ2415, new String[]{CHKJ2415+BEXT, CHKJ2415+MEXT});
-
- MESSAGE_IDS.put(CHKJ2041, new String[]{CHKJ2041}); // special case. Shared by all types.
- MESSAGE_IDS.put(CHKJ2433, new String[]{CHKJ2433});
- MESSAGE_IDS.put(CHKJ2907, new String[]{CHKJ2907});
- }
-
- public final Map getMessageIds() {
- return MESSAGE_IDS;
- }
-
- public final Object[] getDependsOn() {
- return DEPENDS_ON;
- }
-
- public final Object getId() {
- return ID;
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidationCancelledException.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidationCancelledException.java
deleted file mode 100644
index 1b9d6146c..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidationCancelledException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-/**
- * This exception should be thrown if the user cancels validation.
- */
-public class ValidationCancelledException extends RuntimeException {
- /**
- *
- */
- private static final long serialVersionUID = 7065655347030103289L;
-
- public ValidationCancelledException() {
- super();
- }
-}
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidationRuleUtility.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidationRuleUtility.java
deleted file mode 100644
index eac49077b..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/ValidationRuleUtility.java
+++ /dev/null
@@ -1,1627 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.text.MessageFormat;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.jem.java.ArrayType;
-import org.eclipse.jem.java.Field;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaHelpers;
-import org.eclipse.jem.java.JavaPackage;
-import org.eclipse.jem.java.JavaParameter;
-import org.eclipse.jem.java.JavaRefFactory;
-import org.eclipse.jem.java.JavaVisibilityKind;
-import org.eclipse.jem.java.Method;
-import org.eclipse.jem.util.emf.workbench.ProjectResourceSet;
-import org.eclipse.jem.util.logger.LogEntry;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.jst.j2ee.core.internal.plugin.J2EECorePlugin;
-import org.eclipse.jst.j2ee.ejb.CMPAttribute;
-import org.eclipse.jst.j2ee.ejb.CMRField;
-import org.eclipse.jst.j2ee.ejb.CommonRelationshipRole;
-import org.eclipse.jst.j2ee.ejb.ContainerManagedEntity;
-import org.eclipse.jst.j2ee.ejb.EJBRelationshipRole;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.ejb.Entity;
-import org.eclipse.jst.j2ee.ejb.Query;
-import org.eclipse.jst.j2ee.ejb.QueryMethod;
-import org.eclipse.jst.j2ee.ejb.Session;
-import org.eclipse.jst.j2ee.ejb.SessionType;
-import org.eclipse.jst.j2ee.ejb.TransactionType;
-import org.eclipse.jst.j2ee.ejb.internal.impl.LocalModelledPersistentAttributeFilter;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-
-/**
- * @version 1.0
- * @author
- */
-public final class ValidationRuleUtility {
- public static long method_and_field_counter = 0x1; // used by IMethodAndFieldConstants.java
- private static final String[] _reservedWords = new String[]{"SELECT", "FROM", "WHERE", "DISTINCT", "OBJECT", "NULL", "TRUE", "FALSE", "NOT", "AND", "OR", "BETWEEN", "LIKE", "IN", "AS", "UNKNOWN", "EMPTY", "MEMBER", "OF", "IS"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$
- private static final String COMMA = ", "; //$NON-NLS-1$
-
- private static LogEntry logEntry = null;
- private static Logger logger = null;
-
- public static HashMap helperMap = null;
- public static Map projectHelperMap = Collections.synchronizedMap( new HashMap() );
- private static HashSet commonClassNames = null;
-
- public static JavaClass getCMRFieldType(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, CMRField field) {
- CommonRelationshipRole role = field.getRole();
- if(!role.isMany()) {
- ContainerManagedEntity cmp = role.getTypeEntity();
- if(cmp == null) {
- return null;
- }
-
- JavaClass local = cmp.getLocalInterface();
- // If the user has made a mistake in ejb-jar.xml, and they are trying to make
- // a relationship to a cmp which does not have a local interface, an InvalidInputException
- // will be thrown. Let the DD validation catch that error; just return
- // when this happens.
- try {
- ValidationRuleUtility.isValidTypeHierarchy(cmp, local);
- }
- catch(InvalidInputException e) {
- return null;
- }
- return local;
- }
- // <cmr-field-type> is either a java.util.Collection or a java.util.Set (p. 464)
- return field.getCollectionType();
- }
-
-
-
-
- public static final boolean followsFinderExceptionRules(EnterpriseBean bean, Method method) throws InvalidInputException {
- return ValidationRuleUtility.throwsFinderException(bean, method);
- }
-
- public static final boolean followsObjectNotFoundExceptionRules(EnterpriseBean bean, Method method) throws InvalidInputException {
- JavaHelpers javaUtilEnumeration = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_UTIL_ENUMERATION, bean);
- if(ValidationRuleUtility.isAssignableFrom(method.getReturnType(), javaUtilEnumeration)) {
- // Only single object finder and select methods may throw this exception
- return !ValidationRuleUtility.throwsObjectNotFoundException(bean, method);
- }
-
- JavaHelpers javaUtilCollection = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_UTIL_COLLECTION, bean);
- if(ValidationRuleUtility.isAssignableFrom(method.getReturnType(), javaUtilCollection)) {
- // Only single object finder and select methods may throw this exception
- return !ValidationRuleUtility.throwsObjectNotFoundException(bean, method);
- }
-
- // It's a single finder/select method, so it can throw the exception, though it is not required to.
- return true;
- }
-
- /**
- * If it exists, return the Method from the method list which has the given
- * name and parameter types (in the same order as the array elements).
- *
- * This method is a duplicate of getMethodExtended(String, String[]).
- * For performance reasons, the code was duplicated instead of converting the
- * JavaParameter[] into a String[].
- */
- private static Method getMethod(String name, JavaParameter[] parameterTypes, List methodList) {
- if(methodList == null) {
- return null;
- }
-
- Method method = null;
- JavaParameter[] params = null;
- boolean found = false;
-
- Iterator iterator = methodList.iterator();
- while(iterator.hasNext()) {
- method = (Method)iterator.next();
-
- if (method.getName().equals(name)) {
- params = method.listParametersWithoutReturn();
-
- if (params.length == parameterTypes.length) {
- found = true; //Maybe; we need more info
-
- for (int j = 0; j < params.length; j++) {
- //if any one of the parameters doesn't match then flip back to false
- JavaHelpers parm = ((JavaHelpers)params[j].getEType());
- JavaHelpers type = ((JavaHelpers)parameterTypes[j].getEType());
- if(!isSameType(parm, type)) {
- found = false;
- break;
- }
- }
-
- if (found) {
- return method;
- }
- }
- }
- }
- return null;
- }
-
- private static Method getMethod(String name, JavaHelpers[] parameterTypes, List methodList) {
- if(methodList == null) {
- return null;
- }
-
- Method method = null;
- JavaParameter[] params = null;
- boolean found = false;
-
- Iterator iterator = methodList.iterator();
- while(iterator.hasNext()) {
- method = (Method)iterator.next();
-
- if (method.getName().equals(name)) {
- params = method.listParametersWithoutReturn();
-
- if (params.length == parameterTypes.length) {
- found = true; //Maybe; we need more info
-
- for (int j = 0; j < params.length; j++) {
- //if any one of the parameters doesn't match then flip back to false
- JavaHelpers parm = ((JavaHelpers)params[j].getEType());
- JavaHelpers type = parameterTypes[j];
- if(!isSameType(parm, type)) {
- found = false;
- break;
- }
- }
-
- if (found) {
- return method;
- }
- }
- }
- }
- return null;
- }
-
- /**
- * From JavaClass clazz, return a method, named methodNameToFind,
- * which has exactly the same arguments as methodToMatch.
- *
- * If no method exists with that name and argument list, return null.
- *
- * This method does not check the exceptions or return type.
- */
- public static Method getMethod(Method methodToMatch, String methodNameToFind, List methodsExtendedList) {
- if(methodsExtendedList == null) {
- // It is not invalid to call this method with a null List. A null List
- // means that a type whose methods need to be searched doesn't exist,
- // such as searching a local view, but the bean has only a remote view.
- return null;
- }
- return getMethod(methodNameToFind, methodToMatch.listParametersWithoutReturn(), methodsExtendedList);
- }
-
- /**
- * From JavaClass clazz, return a method, named methodNameToFind,
- * which has exactly the same arguments as methodToMatch.
- *
- * If no method exists with that name and argument list, return null.
- *
- * This method does not check the exceptions or return type.
- */
- public static Method getMethodExtended(JavaClass clazz, Method methodToMatch, String methodNameToFind) throws InvalidInputException {
- if ((clazz == null) || (methodToMatch == null) || (methodNameToFind == null)) {
- return null;
- }
-
- return getMethodExtended(clazz, methodNameToFind, methodToMatch.listParametersWithoutReturn());
- }
-
- /**
- * 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;
- }
-
- /**
- * Get the method of this name and these parameters. It will look up the supertype hierarchy.
- *
- * This method is a duplicate of getMethodExtended(String, JavaParameter[]).
- * For performance reasons, the code was duplicated instead of converting the
- * JavaHelpers[] into a JavaParameter[].
- */
- public static Method getMethodExtended(JavaClass clazz, String methodName, JavaHelpers[] parameterTypes) {
- return getMethodExtended(clazz, methodName, parameterTypes, null);
- }
-
- /**
- * Get the method of this name and these parameters. It will look up the supertype hierarchy.
- *
- * This method is a duplicate of getMethodExtended(String, JavaParameter[]).
- * For performance reasons, the code was duplicated instead of converting the
- * JavaHelpers[] into a JavaParameter[].
- *
- * If retType is null it means that the return type of the method doesn't need to be checked.
- * Otherwise, check that the return type matches too.
- */
- public static Method getMethodExtended(JavaClass clazz, String methodName, JavaHelpers[] parameterTypes, JavaHelpers retType) {
- 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) {
- if(retType != null) {
- JavaHelpers methRetType = method.getReturnType();
- if(isAssignableFrom(methRetType, retType)) {
- return method;
- }
- }
- else {
- return method;
- }
- }
-
- // else, search the parent
- clazz = clazz.getSupertype();
- }
- while ((method == null) && (clazz != null));
-
- return null;
- }
-
- /**
- * Get the method of this name and these parameters. It will look up the supertype hierarchy.
- *
- * This method is a duplicate of getMethodInterfaceExtended(String, String[], JavaClass).
- * For performance reasons, the code was duplicated instead of converting the
- * JavaParameter[] into a String[].
- */
- public static Method getMethodInterfaceExtended(JavaClass clazz, String methodName, JavaParameter[] 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;
- }
-
- 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;
- }
-
- /**
- * Return an array of the exceptions thrown by method but not methodToMatch.
- * If there are no such exceptions, return null. (Check the list of exceptions
- * in the method for each exception, or a parent of the exception.)
- */
- public static final Set getNotSubsetExceptions(EnterpriseBean bean, Method method, Method methodToMatch) {
- if((methodToMatch == null) || (method == null)) {
- return Collections.EMPTY_SET;
- }
-
- // All the exceptions defined in the throws clause of a method of the
- // entity bean class must be included in the throws clause of the matching
- // method of the home interface.
- //
- // Section 12.2.2
- // [15] A checked exception is one that is not a subclass of java.lang.RuntimeException
- // "Note that the javax.ejb.EJBException is a subclass of the java.lang.RuntimeException,
- // and therefore it does not have to be listed in the throws clauses of the business
- // methods."
- HashSet exceptions = new HashSet();
- List methToMatchExceptions = methodToMatch.getJavaExceptions();
- List foundMethExceptions = method.getJavaExceptions();
- for( int i = 0; i < foundMethExceptions.size(); i++ ) {
- JavaClass exc = (JavaClass)foundMethExceptions.get(i);
- if ( !isRuntimeException(exc, bean) && !isRemoteException(exc, bean) && !isExceptionInList(exc, methToMatchExceptions) ) {
- exceptions.add(exc);
- }
- }
-
- return exceptions;
- }
-
- /**
- * Return an array of the exceptions thrown by method but not methodToMatch.
- * If there are no such exceptions, return null. (Check the list of exceptions
- * in the method for each exception, or a child of the exception.)
- */
- public static final Set getNotSubsetSubtypeExceptions(EnterpriseBean bean, Method method, Method methodToMatch) {
- if((methodToMatch == null) || (method == null)) {
- return Collections.EMPTY_SET;
- }
-
- // All the exceptions defined in the throws clause of a method of the
- // entity bean class must be included in the throws clause of the matching
- // method of the home interface.
- //
- // Section 12.2.2
- // [15] A checked exception is one that is not a subclass of java.lang.RuntimeException
- // "Note that the javax.ejb.EJBException is a subclass of the java.lang.RuntimeException,
- // and therefore it does not have to be listed in the throws clauses of the business
- // methods."
- HashSet exceptions = new HashSet();
- List methToMatchExceptions = methodToMatch.getJavaExceptions();
- List foundMethExceptions = method.getJavaExceptions();
- for( int i = 0; i < foundMethExceptions.size(); i++ ) {
- JavaClass exc = (JavaClass)foundMethExceptions.get(i);
- if ( !isRuntimeException(exc, bean) && !isRemoteException(exc, bean) && !isSubtypeExceptionInList(exc, methToMatchExceptions) ) {
- exceptions.add(exc);
- }
- }
-
- return exceptions;
- }
-
- /**
- * Exclude root home interface methods
- */
- public static boolean isEJBHomeMethod(EnterpriseBean bean, Method method) {
- return isSameType(bean, method.getContainingJavaClass(), ITypeConstants.CLASSNAME_JAVAX_EJB_EJBHOME);
- }
-
- /**
- * Exclude root remote interface methods
- */
- public static boolean isEJBObjectMethod(EnterpriseBean bean, Method method) {
- return isSameType(bean, method.getContainingJavaClass(), ITypeConstants.CLASSNAME_JAVAX_EJB_EJBOBJECT);
- }
-
- /**
- * Return true if the exception, or a parent of the exception, is in the list of exceptions.
- */
- public static final boolean isExceptionInList(JavaClass exc, List exceptionList) {
- if((exc == null) || (exceptionList == null)) {
- return false;
- }
-
- if(!exc.isExistingType()) {
- return false;
- }
-
- Iterator iterator = exceptionList.iterator();
- while(iterator.hasNext()) {
- JavaClass exception = (JavaClass)iterator.next();
- if(isAssignableFrom(exc, exception)) {
- // If there is a reflection problem, do not swallow the exception or a
- // faulty message may appear. (i.e., "exc" is not thrown by "foo" when it
- // really is but one of foo's exceptions wasn't reflected.
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return true if the exception, or a child of the exception, is in the list of exceptions.
- */
- public static final boolean isSubtypeExceptionInList(JavaClass exc, List exceptionList) {
- if((exc == null) || (exceptionList == null)) {
- return false;
- }
-
- if(!exc.isExistingType()) {
- return false;
- }
-
- Iterator iterator = exceptionList.iterator();
- while(iterator.hasNext()) {
- JavaClass exception = (JavaClass)iterator.next();
- if(isAssignableFrom(exception, exc)) {
- // If there is a reflection problem, do not swallow the exception or a
- // faulty message may appear. (i.e., "exc" is not thrown by "foo" when it
- // really is but one of foo's exceptions wasn't reflected.
- return true;
- }
- }
- return false;
- }
-
- /**
- * Often, for validation messages, the validation message contains
- * the name of a class. But, sometimes, the validation message is
- * being generated because a class is null when it shouldn't be.
- * This method is a helper method which makes the construction of
- * the validation message a little less cluttered (i.e., instead
- * of checking if the class is null before constructing the
- * message, just call this method.)
- */
- public static final String getQualifiedName(JavaHelpers helper) {
- if(helper == null) {
- return ""; //$NON-NLS-1$
- }
- return helper.getJavaName();
- }
-
- /**
- * Return the method's parameters in a displayable format. e.g., if
- * the method signature is "public Integer foo(String a, String b, String c)"
- * then this method returns "String, String, String".
- */
- public static final String getParmsAsString(Method method) {
- if(method == null) {
- return ""; //$NON-NLS-1$
- }
-
- return getParmsAsString(method.listParametersWithoutReturn());
- }
-
- /**
- * Return the parameters in a displayable format.
- * @see getParmsAsString(Method)
- */
- public static final String getParmsAsString(JavaParameter[] parm) {
- if(parm.length == 0) {
- return ""; //$NON-NLS-1$
- }
-
- StringBuffer buffer = new StringBuffer();
- for(int i=0; i<parm.length; i++) {
- JavaHelpers type = parm[i].getJavaType();
- buffer.append(((type == null) ? "null" : type.getJavaName())); //$NON-NLS-1$
- buffer.append(COMMA);
- }
- return buffer.substring(0, buffer.length() - 2); // since "COMMA" is 2 char long, and the last COMMA isn't needed at the end, return everything up to but excluding the last COMMA
- }
-
- /**
- * Return the parameters in a displayable format.
- * @see getParmsAsString(Method)
- */
- public static final String getParmsAsString(JavaHelpers[] parm) {
- if(parm.length == 0) {
- return ""; //$NON-NLS-1$
- }
-
- StringBuffer buffer = new StringBuffer();
- for(int i=0; i<parm.length; i++) {
- JavaHelpers type = parm[i];
- buffer.append(((type == null) ? "null" : type.getJavaName())); //$NON-NLS-1$
- buffer.append(COMMA);
- }
- return buffer.substring(0, buffer.length() - 2); // since "COMMA" is 2 char long, and the last COMMA isn't needed at the end, return everything up to but excluding the last COMMA
- }
-
- /**
- * Returns the name of the type, e.g. "com.ibm.foo.MyFoo"
- * If the type is an array, the array type will be returned.
- * e.g. if the type is java.lang.String[], java.lang.String[] will
- * be returned, not the java.lang.String type.
- */
- public static final JavaHelpers getType(EClassifier classifier) {
- if(classifier == null) {
- return null;
- }
-
- JavaHelpers type = ((JavaHelpers)classifier);
-
- return type;
- }
-
- /**
- * javaClassName must be fully qualified
- */
- public static JavaHelpers getType(String javaClassName, EnterpriseBean ejb) throws InvalidInputException {
- if ((javaClassName == null) || (javaClassName.equals("") || (ejb == null))) //$NON-NLS-1$
- throw new InvalidInputException();
-
- Resource resource = ejb.eResource();
- if (resource == null) {
- throw new InvalidInputException();
- }
-
- JavaHelpers helper = null;
- if(commonClassNames == null || commonClassNames.isEmpty()) {
- initializeCommonClassNames();
- }
- if (commonClassNames.contains(javaClassName)) {
- ResourceSet rSet = resource.getResourceSet();
- ResourceSet set = resource == null ? null : resource.getResourceSet();
- IProject project = null;
- if (set instanceof ProjectResourceSet){
- project = ((ProjectResourceSet) set).getProject();
- }
-
- //helperMap = getHelperMap(rSet);
- //Object obj = getHelperMap(rSet).get(javaClassName);
- Object obj = getHelperMap(project).get(javaClassName);
- if (obj != null)
- return (JavaHelpers) obj;
- else {
- helper = getType(javaClassName,rSet);
- //getHelperMap(rSet).put(javaClassName, helper);
- getHelperMap(project).put(javaClassName, helper);
- }
- } else
- helper = getType(javaClassName, resource.getResourceSet());
- return helper;
- }
-
- protected static HashMap getHelperMap(IProject project){
- HashMap mapHelper = (HashMap)projectHelperMap.get( project );
- if( mapHelper == null ){
- mapHelper = new HashMap();
- projectHelperMap.put(project, mapHelper);
- }
- helperMap = mapHelper;
- return mapHelper;
- }
-
- private static void initializeCommonClassNames() {
- if(commonClassNames == null)
- commonClassNames = new HashSet();
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVA_IO_IOEXCEPTION);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVA_IO_SERIALIZABLE);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVA_LANG_OBJECT);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVA_LANG_EXCEPTION);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVA_LANG_RUNTIMEEXCEPTION);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVA_RMI_REMOTE);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVA_RMI_REMOTEEXCEPTION);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVA_UTIL_COLLECTION);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVA_UTIL_ENUMERATION);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVA_UTIL_SET);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_CREATEEXCEPTION);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_ENTITYBEAN);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_EJBEXCEPTION);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_EJBHOME);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_EJBLOCALHOME);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_EJBOBJECT);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_EJBLOCALOBJECT);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_ENTITYCONTEXT);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_FINDEREXCEPTION);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_MESSAGEDRIVENBEAN);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_OBJECTNOTFOUNDEXCEPTION);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_SESSIONBEAN);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_SESSIONCONTEXT);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_EJB_SESSIONSYNCHRONIZATION);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_JMS_MESSAGE);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_JMS_MESSAGELISTENER);
- commonClassNames.add(ITypeConstants.CLASSNAME_JAVAX_TRANSACTION_USERTRANSACTION);
- }
-
- /**
- * javaClassName must be fully qualified
- */
- public static JavaHelpers getType(String javaClassName, ResourceSet resourceSet) throws InvalidInputException {
- return getType(javaClassName, resourceSet, true);
- }
-
- /**
- * javaClassName must be fully qualified
- */
- public static JavaHelpers getType(String javaClassName, ResourceSet resourceSet, boolean throwExcIfNotValid) throws InvalidInputException {
- if((javaClassName == null) || (javaClassName.equals("") || (resourceSet == null))) { //$NON-NLS-1$
- Logger aLogger = getMsgLogger();
- if(aLogger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = getLogEntry();
- entry.setSourceID("ValidationRuleUtility.getType(String, ResourceSet, boolean)"); //$NON-NLS-1$
- String text = "invalid parameter; javaClassName = {0} and resourceSet = {1}";
- //entry.setText("invalid parameter; javaClassName = {0} and resourceSet = {1}"); //$NON-NLS-1$
- //entry.setTokens(new String[]{javaClassName, String.valueOf(resourceSet)});
- String result = MessageFormat.format(text,
- new String[]{javaClassName, String.valueOf(resourceSet)});
- entry.setText(result);
-
- entry.appendStackTrace();
- aLogger.write(Level.FINEST, entry);
- }
- throw new InvalidInputException();
- }
-
- // If the class doesn't exist, it will be reflected
- JavaHelpers helper = JavaRefFactory.eINSTANCE.reflectType(javaClassName, resourceSet);
- if(throwExcIfNotValid) {
- isValidType(helper); // check that the type has been reflected properly
- }
-
- return helper;
- }
-
- /**
- * @return
- */
- private static LogEntry getLogEntry() {
- if(logEntry == null) {
- logEntry = new LogEntry(IEJBValidatorConstants.BUNDLE_NAME);
- }
- logEntry.reset(); // reset the values so that we're not logging stale data
- return logEntry;
- }
-
- /**
- * @return
- */
- private static Logger getMsgLogger() {
- if(logger == null)
- logger = J2EECorePlugin.getPlugin().getMsgLogger();
- return logger;
- }
-
- public static final JavaHelpers getType(Field field) {
- if(field == null) {
- return null;
- }
-
- return (JavaHelpers)field.getEType();
- }
-
- /**
- * Return true if the JavaClass passed in has the Method defined
- * on it. Return false if the Method is defined on a supertype or
- * is not defined on the class at all.
- */
- public static final boolean onClass(JavaClass clazz, Method method) {
- if((clazz == null) || (method == null)) {
- return false;
- }
-
- return clazz.equals(method.getJavaClass());
- }
-
- /**
- * Return true if the JavaClass passed in has the Field defined
- * on it. Return false if the Field is defined on a supertype or
- * is not defined on the class at all.
- */
- public static final boolean onClass(JavaClass clazz, Field field) {
- if((clazz == null) || (field == null)) {
- return false;
- }
-
- return clazz.equals(field.getJavaClass());
- }
-
- public static final boolean isApplicationException(JavaClass exception, EnterpriseBean bean) {
- if(exception == null) {
- return false;
- }
-
- // Exempt EJBException from the application exception check because it'll drive users crazy to see
- // it flagged as an application exception.
- try {
- if(ValidationRuleUtility.isSameType(exception, getType(ITypeConstants.CLASSNAME_JAVAX_EJB_EJBEXCEPTION, bean))) {
- return false;
- }
- }
- catch(InvalidInputException e) {
- // logged in getType()
- // if EJBException can't be found, then there's probably a system JAR missing
- }
-
- // 18.1.1 Application exceptions
- // An application exception is an exception defined in the throws clause of a method of the enterprise
- // Bean's home and component interfaces, other than the java.rmi.RemoteException.
- return !isRemoteException(exception, bean);
- }
-
- public static final boolean isRemoteMethod(IEJBValidationContext vc, EnterpriseBean bean, JavaClass clazz, Method method) {
- try {
- JavaHelpers javaRmiRemote = ValidationRuleUtility.getType(ITypeConstants.CLASSNAME_JAVA_RMI_REMOTE, bean);
- if(isAssignableFrom(clazz, javaRmiRemote)) {
- return true;
- }
- }
- catch(InvalidInputException e) {
- return false;
- }
-
- return false;
- }
-
- public static final boolean isReservedWord(String name) {
- if(name == null) {
- return false;
- }
-
- String upperName = name.toUpperCase();
- for(int i=0; i<_reservedWords.length; i++) {
- if(upperName.equals(_reservedWords[i])) {
- return true;
- }
- }
- return false;
- }
-
- public static final boolean isRuntimeException(JavaClass clazz, EnterpriseBean bean) {
- if(clazz == null) {
- return false;
- }
-
- try {
- JavaHelpers runtimeExc = getType(ITypeConstants.CLASSNAME_JAVA_LANG_RUNTIMEEXCEPTION, bean);
- return isException(clazz, runtimeExc.getWrapper());
- }
- catch(InvalidInputException e) {
- return false;
- }
- }
-
- public static final boolean isRemoteException(JavaClass clazz, EnterpriseBean bean) {
- if(clazz == null) {
- return false;
- }
-
- try {
- JavaHelpers remoteExc = getType(ITypeConstants.CLASSNAME_JAVA_RMI_REMOTEEXCEPTION, bean);
- return isException(clazz, remoteExc.getWrapper());
- }
- catch(InvalidInputException e) {
- return false;
- }
- }
-
- /**
- * Return true if the clazz is an instance of the exception.
- */
- public static final boolean isException(JavaClass clazz, JavaClass exception) {
- if((clazz == null) || (exception == null)) {
- return false;
- }
-
- return isAssignableFrom(clazz, exception);
- }
-
- /**
- * Return true if the type is either java.util.Collection, or a type which inherits/extends java.util.Collection.
- * The bean is needed to retrieve the java.util.Collection type.
- */
- public static boolean isAssignableFromCollection(JavaHelpers type, EnterpriseBean bean) throws InvalidInputException {
- JavaHelpers javaUtilCollection = getType(ITypeConstants.CLASSNAME_JAVA_UTIL_COLLECTION, bean);
- return isAssignableFrom(type, javaUtilCollection);
- }
-
- /**
- * Return true if the type is either java.util.Enumeration, or a type which inherits/extends java.util.Enumeration.
- * The bean is needed to retrieve the java.util.Enumeration type.
- */
- public static boolean isAssignableFromEnumeration(JavaHelpers type, EnterpriseBean bean) throws InvalidInputException {
- JavaHelpers javaUtilEnumeration = getType(ITypeConstants.CLASSNAME_JAVA_UTIL_ENUMERATION, bean);
- return isAssignableFrom(type, javaUtilEnumeration);
- }
-
- /**
- * Return true if the type is either java.util.Set, or a type which inherits/extends java.util.Set.
- * The bean is needed to retrieve the java.util.Set type.
- */
- public static boolean isAssignableFromSet(JavaHelpers type, EnterpriseBean bean) throws InvalidInputException {
- JavaHelpers javaUtilSet = getType(ITypeConstants.CLASSNAME_JAVA_UTIL_SET, bean);
- return isAssignableFrom(type, javaUtilSet);
- }
-
- /**
- * Returns true if the type is either the compare type, or inherits/extends the compare type.
- */
- public static boolean isAssignableFrom(JavaHelpers type, JavaHelpers compareType) {
- if((type == null) || (compareType == null)) {
- return false;
- }
-
- if(type.isPrimitive() || compareType.isPrimitive()) {
- if(type.isPrimitive() && compareType.isPrimitive()) {
- return type.getPrimitive().equals(compareType.getPrimitive());
- }
- return false;
- }
- else if(type.isArray() && compareType.isArray()) {
- JavaClass classType = type.getWrapper();
- JavaClass classCompareType = compareType.getWrapper();
- if((classType == null) || (compareType == null)) {
- return false;
- }
- JavaHelpers finalType = ((ArrayType)classType).getFinalComponentType();
- JavaHelpers finalCompareType = ((ArrayType)classCompareType).getFinalComponentType();
- return isAssignableFrom(finalType, finalCompareType);
- }
- else {
- return compareType.getWrapper().isAssignableFrom(type.getWrapper());
- }
- }
-
- /**
- * Return true if the given method is associated with a query element in ejb-jar.xml.
- */
- public static final boolean isAssociatedWithQuery(ContainerManagedEntity cmp, Method method) {
- // Check method is associated with a query element in ejb-jar.xml.
- List queries = cmp.getQueries();
- Iterator iterator = queries.iterator();
- boolean found = false;
- while(iterator.hasNext()) {
- Query query = (Query)iterator.next();
- QueryMethod queryMethod = query.getQueryMethod();
- if(queryMethod == null) {
- // Let the EJBJarVRule report this
- continue;
- }
-
- if((queryMethod.getName() == null) || queryMethod.getName().equals("")) { //$NON-NLS-1$
- // Let the EJBJarVRule report this
- continue;
- }
-
- if(queryMethod.getName().equals(method.getName())) {
- found = true;
- break;
- }
- }
-
- return found;
- }
-
- public static final boolean isBeanManagedSession(EnterpriseBean bean) {
- if(bean == null) {
- return false;
- }
-
- if(bean.isEntity()) {
- return false;
- }
-
- return (((Session)bean).getTransactionType().getValue() == TransactionType.BEAN);
- }
-
- /**
- * Return true if this method is the static initializer used for interfaces ("<clinit>")
- */
- public static boolean isClinitMethod(EnterpriseBean bean, Method method) {
- if (method == null) {
- return false;
- }
-
- return method.getName().equals("<clinit>"); //$NON-NLS-1$
- }
-
- public static final boolean isJNDINamingContext(Field field) {
- return true;
- }
-
- /**
- * Return true if the field is defined on java.lang.Object.
- */
- public static boolean isJavaLangObjectField(EnterpriseBean bean, Field field) {
- return isSameType(bean, field.getContainingJavaClass(), ITypeConstants.CLASSNAME_JAVA_LANG_OBJECT);
- }
-
- /**
- * Return true if the method is defined on named class.
- */
- public static boolean isOwnedBy(EnterpriseBean bean, Method method, String className) {
- return isSameType(bean, method.getContainingJavaClass(), className);
- }
-
- /**
- * Return true if given class is the same as the named class.
- */
- public static boolean isSameType(EnterpriseBean bean, JavaClass owner, String className) {
- try {
- JavaHelpers helper = getType(className, bean);
- if(helper == null) {
- return false;
- }
-
- JavaClass object = helper.getWrapper();
-
- return isSameType(owner, object);
- }
- catch(InvalidInputException e) {
- return false;
- }
- }
-
- /**
- * Return true if given class is the same as the named class.
- */
- public static boolean isSameType(JavaHelpers owner, JavaHelpers object) {
- if(owner == null) {
- return false;
- }
-
- if(object == null) {
- return false;
- }
-
- if(owner.isPrimitive() && object.isPrimitive()) {
- // Both are JavaDataType
- return owner.getPrimitive().equals(object.getPrimitive());
- }
- else if(owner.isArray() && object.isArray()) {
- // Both are ArrayType
- ArrayType ownerArray = (ArrayType)owner;
- ArrayType objectArray = (ArrayType)object;
- return isSameType(ownerArray.getFinalComponentType(), objectArray.getFinalComponentType());
- }
- else if((owner.getWrapper() != null) && (object.getWrapper() != null)) {
- // Both are JavaClass
- return owner.getWrapper().equals(object.getWrapper());
- }
- else {
- // mismatching JavaHelpers type
- return false;
- }
- }
-
- /**
- * Return true if the method is defined on java.lang.Object.
- */
- public static boolean isJavaLangObjectMethod(EnterpriseBean bean, Method method) {
- return isSameType(bean, method.getContainingJavaClass(), ITypeConstants.CLASSNAME_JAVA_LANG_OBJECT);
- }
-
- public static final boolean isLegalRMI_IIOPInheritance(JavaClass clazz) {
- return true;
- }
-
- public static final boolean isLegalRMI_IIOPType(EnterpriseBean bean, JavaHelpers helper) throws InvalidInputException {
- if(helper == null) {
- return false;
- }
-
- return isSerializable(helper, bean);
- }
-
- public static final boolean isLocalType(EnterpriseBean bean, JavaHelpers type) {
- try {
- if(isSameType(type, getType(ITypeConstants.CLASSNAME_JAVA_LANG_OBJECT, bean))) {
- // If there's an undefined primary key (java.lang.Object), don't flag it as a local type.
- return false;
- }
- }
- catch(InvalidInputException e) {
- // Let the DD validation report this.
- return false;
- }
-
- if(isAssignableFrom(bean.getLocalInterface(), type)) {
- return true;
- }
-
- if(isAssignableFrom(bean.getLocalHomeInterface(), type)) {
- return true;
- }
-
- // Bit of a performance hack here.
- // Don't want to load and parse the entire EJBJar just to check if
- // this type is local, so assume that if the extends
- // javax.ejb.EJBLocalHome or javax.ejb.EJBLocalObject, then it's local.
- try {
- JavaHelpers ejbLocalHome = getType(ITypeConstants.CLASSNAME_JAVAX_EJB_EJBLOCALHOME, bean);
- if(isAssignableFrom(ejbLocalHome, type)) {
- return true;
- }
- }
- catch(InvalidInputException exc) {
- // ignore and try other type
- }
-
- try {
- JavaHelpers ejbLocalObject = getType(ITypeConstants.CLASSNAME_JAVAX_EJB_EJBLOCALOBJECT, bean);
- if(isAssignableFrom(ejbLocalObject, type)) {
- return true;
- }
- }
- catch(InvalidInputException exc) {
- // ignore
- }
-
- return false;
- }
-
-
-
- public static final boolean usesUnknownPrimaryKey(EnterpriseBean bean) {
- if(bean.isContainerManagedEntity()) {
- return usesUnknownPrimaryKey((ContainerManagedEntity)bean);
- }
- return false;
- }
-
- public static final boolean usesUnknownPrimaryKey(ContainerManagedEntity cmp) {
- if(cmp == null) {
- return false;
- }
-
- try {
- if(isSameType(cmp.getPrimaryKey(), getType(ITypeConstants.CLASSNAME_JAVA_LANG_OBJECT, cmp))) {
- return true;
- }
- }
- catch(InvalidInputException e) {
- // If java.lang.Object can't be found, there's bigger problems than validating
- // it mistakenly
- return false;
- }
-
- if(cmp.getVersionID() == J2EEVersionConstants.EJB_2_0_ID) {
- List cmpFields = cmp.getFilteredFeatures(LocalModelledPersistentAttributeFilter.singleton());
- if(cmpFields != null && !cmpFields.isEmpty()) {
- Iterator iterator = cmpFields.iterator();
- while(iterator.hasNext()) {
- CMPAttribute attrib = (CMPAttribute)iterator.next();
- if(isUnknownPrimaryKey(attrib)) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- public static final boolean isUnidirectionalRelationship(IEJBValidationContext vc, EJBRelationshipRole role) {
- // Page 131 of EJB 2.0:
- // A unidirectional relationship is implemented with a cmr-field on the entity bean instance from which
- // navigation can take place, and no related cmr-field on the entity bean instance that is the target of the
- // relationship. Unidirectional relationships are typically used when the Bean Provider wishes to restrict
- // the visibility of a relationship.
- Entity sourceEntity = role.getSource().getEntityBean();
- if(sourceEntity == null) {
- return false;
- }
-
- if(!sourceEntity.isContainerManagedEntity()) {
- return false;
- }
-
- CMRField sourceCMRField = role.getCmrField();
- if(sourceCMRField == null) {
- return false;
- }
-
- EJBRelationshipRole opposite = role.getOpposite();
- if(opposite == null) {
- return false;
- }
-
- CMRField oppositeCMRField = opposite.getCmrField();
- if(oppositeCMRField != null) {
- return false;
- }
-
- return true;
-
- }
-
-
-
- public static final boolean isUnknownPrimaryKey(CMPAttribute attrib) {
- if(attrib == null) {
- return false;
- }
-
- // Section 10.8.3
- // By definition, the deployer's generated CMP field's name is defined in the
- // ContainerManagedEntity.WAS_GENERATED_STRING_FIELD constant.
- return ContainerManagedEntity.WAS_GENERATED_STRING_FIELD.equals(attrib.getName());
- }
-
- public static final boolean isPrimitivePrimaryKey(ContainerManagedEntity cmp) {
- if(cmp == null) {
- return false;
- }
-
- if((cmp.getPrimKeyField() != null) && !cmp.getPrimKeyField().eIsProxy()) {
- return true;
- }
-
- return false;
- }
-
- public static final boolean isPublic(Field field) {
- if ( field == null )
- return false;
-
- return (JavaVisibilityKind.PUBLIC_LITERAL == field.getJavaVisibility());
- }
-
- public static final boolean isPublic( Method method ) {
- if ( method == null )
- return false;
-
- return (JavaVisibilityKind.PUBLIC_LITERAL == method.getJavaVisibility());
- }
-
- /**
- * Verifies that a given Class type is serializable.
- *
- * RMI 1.3 specification
- * 2.6 Parameter Passing in Remote Method Invocation
- * An argument to, or a return value from, a remote object can be any object that
- * is serializable. This includes primitive types, remote objects, and non-remote
- * objects that implement the java.io.Serializable interface.
- */
- public static final boolean isSerializable(JavaHelpers cl, EnterpriseBean bean) throws InvalidInputException {
- if(cl == null) {
- // assume it's void
- return true;
- }
-
- // Check if the type reflected properly
- isValidType(cl);
-
- if ( cl.isPrimitive() ) {
- // JavaHelpers is a JavaDataType
- return true;
- }
- else if(cl.isArray()) {
- ArrayType array = (ArrayType)cl;
- if(array.isPrimitiveArray()) {
- return true;
- }
- // else, not primitive, so check its contents
- cl = array.getFinalComponentType();
- }
-
- JavaHelpers remote = getType(ITypeConstants.CLASSNAME_JAVA_RMI_REMOTE, bean);
- if(isAssignableFrom(cl, remote)) {
- return true;
- }
-
- JavaHelpers serial = getType(ITypeConstants.CLASSNAME_JAVA_IO_SERIALIZABLE, bean);
- return isAssignableFrom(cl, serial);
- }
-
- public static final boolean isStateful(EnterpriseBean bean) {
- if(bean == null) {
- return false;
- }
-
- if(bean.isEntity()) {
- return false;
- }
-
- return (((Session)bean).getSessionType().getValue() == SessionType.STATEFUL);
- }
-
- public static final boolean isStateless(EnterpriseBean bean) {
- if(bean == null) {
- return false;
- }
-
- if(bean.isEntity()) {
- return false;
- }
-
- return (((Session)bean).getSessionType().getValue() == SessionType.STATELESS);
- }
-
- public static boolean isUnnamedPackage(JavaPackage pkg) {
- if(pkg == null) {
- return true;
- }
-
- String pkgName = pkg.getName();
- return ((pkgName == null) || (pkgName.equals(""))); //$NON-NLS-1$
- }
-
- public static final boolean isValidJavaIdentifier(String name) {
- if(name == null) {
- return false;
- }
-
- char[] nameChar = name.toCharArray();
- if(nameChar.length < 1) {
- return false;
- }
-
- if(!Character.isJavaIdentifierStart(nameChar[0])) {
- return false;
- }
- boolean isValidJavaIdentifier = true;
- for(int i=1; i<nameChar.length; i++) {
- if(!Character.isJavaIdentifierPart(nameChar[i])) {
- isValidJavaIdentifier = false;
- break;
- }
- }
- return isValidJavaIdentifier;
- }
-
- /**
- * 6.5.3 The optional SessionSynchronization interface
- *...
- * Only a stateful Session bean with container-managed transaction demarcation may
- * implement the SessionSynchronization interface.
- *...
- * There is no need for a Session bean with bean-managed transaction to rely on the
- * synchronization call backs because the bean is in control of the commit the bean
- * knows when the transaction is about to be committed and it knows the outcome of the
- * transaction commit.
- *...
- */
- public static final boolean isValidSessionTypeElement(Session session) {
- if(session == null) {
- return false;
- }
-
- // check syntax
- if(!session.isSetSessionType()) {
- return false;
- }
-
- if(session.getSessionType() == null) {
- return false;
- }
-
- if(session.getSessionType().getValue() == SessionType.STATEFUL) {
- return true;
- }
-
- if(session.getSessionType().getValue() == SessionType.STATELESS) {
- return true;
- }
-
- return false;
- }
-
- public static final boolean isValidTransactionTypeElement(Session sessionBean) {
- if(sessionBean == null) {
- return false;
- }
-
- if(!sessionBean.isSetTransactionType()) {
- return false;
- }
-
- if(sessionBean.getTransactionType() == null) {
- return false;
- }
-
- if(sessionBean.getTransactionType().getValue() == TransactionType.BEAN) {
- return true;
- }
-
- if(sessionBean.getTransactionType().getValue() == TransactionType.CONTAINER) {
- return true;
- }
-
- return false;
- }
-
- /**
- * If the type is not reflected properly, throw an InvalidInputException.
- */
- public static final void isValidType(JavaHelpers type) throws InvalidInputException {
- if(type == null) {
- // Cheating here. Should technically access the MsgLogger from the IEJBValidationContext
- // type, but when I started changing this method and the isValidTypeHierarchy method,
- // I ended up changing 42 files because these two methods are called directly or
- // indirectly from almost everywhere. That was too much change, so I cheated.
- Logger aLogger = getMsgLogger();
- if(aLogger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = getLogEntry();
- entry.setSourceID("ValidationRuleUtility.isValidType"); //$NON-NLS-1$
- entry.setText("type is null"); //$NON-NLS-1$
- entry.appendStackTrace();
- aLogger.write(Level.FINEST, entry);
- }
- throw new InvalidInputException();
- }
-
- if(type.getWrapper() != null) {
- // check if the type reflected properly. If there's any compile errors, or references to unresolved
- // classes, can output some mistaken error messages.
- // e.g. class is not serializable
- JavaClass wrapper = type.getWrapper();
- if(type.isArray()) {
- ArrayType array = (ArrayType)type;
- isValidType(array.getFinalComponentType());
- }
- else {
- 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);
- }
- throw new InvalidInputException(wrapper);
- }
- }
- }
- }
-
- /**
- * If the type is not reflected properly, throw an InvalidInputException.
- * This method, unlike isValidType, also checks every interface and class
- * parent of the passed-in type.
- */
- public static final void isValidTypeHierarchy(EnterpriseBean bean, JavaHelpers type) throws InvalidInputException {
- if(type == null) {
- // Cheating here. Should technically access the MsgLogger from the IEJBValidationContext
- // type, but when I started changing this method and the isValidType method,
- // I ended up changing 42 files because these two methods are called directly or
- // indirectly from almost everywhere. That was too much change, so I cheated.
- Logger aLogger = getMsgLogger();
- if(aLogger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = getLogEntry();
- entry.setSourceID("ValidationRuleUtility.isValidTypeHierarchy"); //$NON-NLS-1$
- entry.setText("type is null"); //$NON-NLS-1$
- entry.appendStackTrace();
- aLogger.write(Level.FINEST, entry);
- }
- throw new InvalidInputException();
- }
-
- // First, check this helper itself.
- isValidType(type);
- JavaHelpers javaLangObject = getType(ITypeConstants.CLASSNAME_JAVA_LANG_OBJECT, bean);
- if(isSameType(type, javaLangObject)) {
- return;
- }
-
- // If this helper exists, and is not java.lang.Object, then check every supertype.
- JavaClass classType = type.getWrapper();
- if(classType == null) {
- Logger aLogger = getMsgLogger();
- if(aLogger.isLoggingLevel(Level.FINEST)) {
- LogEntry entry = getLogEntry();
- entry.setSourceID("ValidationRuleUtility.isValidTypeHierarchy"); //$NON-NLS-1$
- entry.setText("type.getWrapper() returns null; type is " + type.getJavaName()); //$NON-NLS-1$
- aLogger.write(Level.FINEST, entry);
- }
- throw new InvalidInputException();
- }
-
- // Check the superclass. Since type is not java.lang.Object, there is at least
- // the java.lang.Object superclass.
- if(!classType.isInterface()) {
- JavaClass superType = classType.getSupertype();
- isValidTypeHierarchy(bean, superType);
- }
-
- // Check the superinterfaces, if they exist.
- List superInterfaces = classType.getImplementsInterfaces();
- if(superInterfaces != null) {
- Iterator iterator = superInterfaces.iterator();
- while(iterator.hasNext()) {
- JavaClass superIntf = (JavaClass)iterator.next();
- isValidTypeHierarchy(bean, superIntf);
- }
- }
- }
-
- /**
- * RMI 1.3 page 6 section 2.4.1,
- * A remote method declaration must include the exception java.rmi.RemoteException (or one
- * of its upserclasses such as java.io.IOException or java.lang.Exception) in its throws
- * clause, in addition to any application-specific exceptions (note that application
- * specific exceptions do not have to extend java.rmi.RemoteException).
- */
- public static final boolean throwsRemoteExceptionOrParent(EnterpriseBean bean, Method method) throws InvalidInputException {
- return throwsExceptionOrParent(bean, method, ITypeConstants.CLASSNAME_JAVA_RMI_REMOTEEXCEPTION);
- }
-
- /**
- * Convenience method which checks if RemoteException (exactly, not Exception or IOException)
- * is in the method signature.
- */
- public static final boolean doesNotThrowRemoteException(EnterpriseBean bean, Method method) throws InvalidInputException {
- return !throwsException(bean, method, ITypeConstants.CLASSNAME_JAVA_RMI_REMOTEEXCEPTION);
- }
-
- public static final boolean throwsObjectNotFoundException(EnterpriseBean bean, Method method) throws InvalidInputException {
- return throwsException(bean, method, ITypeConstants.CLASSNAME_JAVAX_EJB_OBJECTNOTFOUNDEXCEPTION);
- }
-
- public static final boolean throwsFinderException(EnterpriseBean bean, Method method) throws InvalidInputException {
- return throwsException(bean, method, ITypeConstants.CLASSNAME_JAVAX_EJB_FINDEREXCEPTION);
- }
-
- public static final boolean throwsCreateException(EnterpriseBean bean, Method method) throws InvalidInputException {
- return throwsException(bean, method, ITypeConstants.CLASSNAME_JAVAX_EJB_CREATEEXCEPTION);
- }
-
- public static final boolean throwsApplicationException(Method method, EnterpriseBean bean) {
- List exceptions = method.getJavaExceptions();
- if(exceptions.size() == 0) {
- return false;
- }
-
- // CHKJ2419 = {0} must be a subclass of java.lang.Exception. Read section 18.1.1, 18.2.1 of the EJB 2.0 specification.
- Iterator iterator = exceptions.iterator();
- while(iterator.hasNext()) {
- JavaClass exception = (JavaClass)iterator.next();
-
- if(isApplicationException(exception, bean)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return true if the given method throws the named exception or a class which extends the named exception.
- */
- public static final boolean throwsException(EnterpriseBean bean, Method method, String exceptionName) throws InvalidInputException {
- if(method == null) {
- return false;
- }
-
- List exceptions = method.getJavaExceptions();
- Iterator iterator = exceptions.iterator();
- JavaClass exception = getType(exceptionName, bean).getWrapper();
- while(iterator.hasNext()) {
- JavaClass exc = (JavaClass)iterator.next();
- if(isAssignableFrom(exc, exception)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Return true if the method returns the named exception, an exception which extends the named exception, or one of the parents of the named exception (e.g. java.lang.Exception).
- * Use this method if it needs to be detected that an exception can be thrown either directly or through something generic like java.lang.Exception.
- */
- public static final boolean throwsExceptionOrParent(EnterpriseBean bean, Method method, String exceptionName) throws InvalidInputException {
- if(method == null) {
- return false;
- }
-
- JavaClass exception = getType(exceptionName, bean).getWrapper();
-
- List exceptions = method.getJavaExceptions();
- Iterator iterator = exceptions.iterator();
- while(iterator.hasNext()) {
- JavaClass exc = (JavaClass)iterator.next();
- if(isAssignableFrom(exc, exception)) {
- // Assignable from the named exception, e.g. RemoteException or a child of RemoteException
- return true;
- }
-
- if(isAssignableFrom(exception, exc)) {
- // The named exception is assignable from the method exception, e.g. java.lang.Exception
- return true;
- }
- }
-
- return false;
- }
-
- public static final boolean usesCollectionClass(EnterpriseBean bean, Method method) {
- if((bean == null) || (method == null)) {
- return false;
- }
-
- JavaParameter[] parms = method.listParametersWithoutReturn();
- if(parms != null) {
- for(int i=0; i<parms.length; i++) {
- JavaParameter parm = parms[i];
- try {
- if(isAssignableFromCollection(parm.getJavaType(), bean)) {
- return true;
- }
- }
- catch(InvalidInputException e) {
- // ignore and test next parm
- continue;
- }
- }
- }
-
- // Now check the return type
- try {
- if(isAssignableFromCollection(method.getReturnType(), bean)) {
- return true;
- }
- }
- catch(InvalidInputException e) {
- // ignore
- }
-
- return false;
- }
-
- public static final boolean usesLocalTypes(EnterpriseBean bean, Method method) {
- if((bean == null) || (method == null)) {
- return false;
- }
-
- JavaParameter[] parms = method.listParametersWithoutReturn();
- if(parms != null) {
- for(int i=0; i<parms.length; i++) {
- JavaParameter parm = parms[i];
- if(isLocalType(bean, parm.getJavaType())) {
- return true;
- }
- }
- }
-
- // Now check the return type
- if(isLocalType(bean, method.getReturnType())) {
- return true;
- }
-
- return false;
- }
-}
-
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/WARMessageConstants.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/WARMessageConstants.java
deleted file mode 100644
index d42c0054c..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/WARMessageConstants.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-
-
-
-/**
- * Message key constants for WAR validation.
- */
-public interface WARMessageConstants extends org.eclipse.jst.j2ee.model.internal.validation.J2EEMessageConstants {
- public static final String WAR_VALIDATOR_ID = "WAR_VALIDATOR"; //$NON-NLS-1$
- public static final String WAR_MODEL_NAME = "WAR_VALIDATION"; //$NON-NLS-1$
- public static final String ERROR_WAR_VALIDATION_FAILED = "ERROR_WAR_VALIDATION_FAILED"; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_SMALL_ICON = "MESSAGE_WAR_VALIDATION_SMALL_ICON"; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_LARGE_ICON = "MESSAGE_WAR_VALIDATION_LARGE_ICON"; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_BROKEN_SERVLET_MAPPING = "MESSAGE_WAR_VALIDATION_BROKEN_SERVLET_MAPPING"; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_MISSING_JSP = "MESSAGE_WAR_VALIDATION_MISSING_JSP"; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_MISSING_TLD = "MESSAGE_WAR_VALIDATION_MISSING_TLD"; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_MISSING_WELCOME_FILE = "MESSAGE_WAR_VALIDATION_MISSING_WELCOME_FILE"; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_NO_WELCOME_FILE = "MESSAGE_WAR_VALIDATION_NO_WELCOME_FILE"; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_INVALID_URL = "MESSAGE_WAR_VALIDATION_INVALID_URL" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_DUPLICATE_MAPPING = "MESSAGE_WAR_VALIDATION_DUPLICATE_MAPPING" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_DUPLICATE_SERVLET = "MESSAGE_WAR_VALIDATION_DUPLICATE_SERVLET" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_DUPLICATE_EJB_REF = "MESSAGE_WAR_VALIDATION_DUPLICATE_EJB_REF" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_SESSION_TIMEOUT = "MESSAGE_WAR_VALIDATION_SESSION_TIMEOUT" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_DUPLICATE_ENTRY = "MESSAGE_WAR_VALIDATION_DUPLICATE_ENTRY" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_EMPTY_ENTRY = "MESSAGE_WAR_VALIDATION_EMPTY_ENTRY" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_INVALID_SEC_ROLE = "MESSAGE_WAR_VALIDATION_INVALID_SEC_ROLE" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_INVALID_SEC_ROLE_NAME = "MESSAGE_WAR_VALIDATION_INVALID_SEC_ROLE_NAME" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_INVALID_HTTP_CMD = "MESSAGE_WAR_VALIDATION_INVALID_HTTP_CMD" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_INVALID_TRANSPORT = "MESSAGE_WAR_VALIDATION_INVALID_TRANSPORT" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_INVALID_JSPFILE_REF = "MESSAGE_WAR_VALIDATION_INVALID_JSPFILE_REF" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_INVALID_WELCOME_FILE = "MESSAGE_WAR_VALIDATION_INVALID_WELCOME_FILE" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_INVALID_ERROR_PAGE = "MESSAGE_WAR_VALIDATION_INVALID_ERROR_PAGE" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_INVALID_AUTH_METHOD = "MESSAGE_WAR_VALIDATION_INVALID_AUTH_METHOD" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_IGNORE_FORM_LOGIN = "MESSAGE_WAR_VALIDATION_IGNORE_FORM_LOGIN" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_RES_AUTH_REQUIRED_22 = "MESSAGE_WAR_VALIDATION_RES_AUTH_REQUIRED_22" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_RES_AUTH_REQUIRED_23 = "MESSAGE_WAR_VALIDATION_RES_AUTH_REQUIRED_23" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_RES_AUTH_INVALID_22 = "MESSAGE_WAR_VALIDATION_RES_AUTH_INVALID_22" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_RES_AUTH_INVALID_23 = "MESSAGE_WAR_VALIDATION_RES_AUTH_INVALID_23" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_DUPLICATE_FILTER = "MESSAGE_WAR_VALIDATION_DUPLICATE_FILTER" ; //$NON-NLS-1$
- public static final String MESSAGE_WAR_VALIDATION_BROKEN_FILTER_MAPPING = "MESSAGE_WAR_VALIDATION_BROKEN_FILTER_MAPPING" ; //$NON-NLS-1$
- public static final String ERROR_EAR_DUPLICATE_ROLES = "ERROR_EAR_DUPLICATE_ROLES"; //$NON-NLS-1$
- public static final String ERROR_EAR_UNCONTAINED_MODULE_FILE_EXCEPTION = "ERROR_EAR_UNCONTAINED_MODULE_FILE_EXCEPTION"; //$NON-NLS-1$
- public static final String ERROR_INVALID_WAR_FILE = "ERROR_INVALID_WAR_FILE"; //$NON-NLS-1$
- public static final String WAR_DD_PARSE_LINECOL = "WAR_DD_PARSE_LINECOL"; //$NON-NLS-1$
- public static final String WAR_DD_PARSE_LINE = "WAR_DD_PARSE_LINE"; //$NON-NLS-1$
- public static final String WAR_DD_CANNOT_OPEN_DD = "WAR_DD_CANNOT_OPEN_DD"; //$NON-NLS-1$
- public static final String WAR_DD_PARSE_NOINFO = "WAR_DD_PARSE_NOINFO"; //$NON-NLS-1$
- public static String ERROR_EAR_INVALID_CONTEXT_ROOT = "ERROR_EAR_INVALID_CONTEXT_ROOT"; //$NON-NLS-1$
- public static String MESSAGE_WAR_VALIDATION_INVALID_RES_SHARING_SCOPE = "MESSAGE_WAR_VALIDATION_INVALID_RES_SHARING_SCOPE"; //$NON-NLS-1$
- public static String MESSAGE_WAR_VALIDATION_INVALID_ENV_ENTRY = "MESSAGE_WAR_VALIDATION_INVALID_ENV_ENTRY"; //$NON-NLS-1$
- public static String MESSAGE_WAR_VALIDATION_INVALID_ERROR_CODE = "MESSAGE_WAR_VALIDATION_INVALID_ERROR_CODE"; //$NON-NLS-1$
- public static String MESSAGE_WAR_VALIDATION_MISSING_WLP_PROJECT = "MESSAGE_WAR_VALIDATION_MISSING_WLP_PROJECT"; //$NON-NLS-1$
- public static String MESSAGE_WAR_VALIDATION_INVALID_EXCEPTION_TYPE = "MESSAGE_WAR_VALIDATION_INVALID_EXCEPTION_TYPE"; //$NON-NLS-1$
- public static String MESSAGE_WAR_VALIDATION_CONFLICTING_WLP_PROJECT = "MESSAGE_WAR_VALIDATION_CONFLICTING_WLP_PROJECT"; //$NON-NLS-1$
- public static String MESSAGE_WAR_VALIDATION_INVALID_EJB_REF_TYPE = "MESSAGE_WAR_VALIDATION_INVALID_EJB_REF_TYPE"; //$NON-NLS-1$
- //J2EE 14 Messages
- public static String MESSAGE_URL_PATTERN_END_WITH_CARRAIGE_RETURN = "MESSAGE_URL_PATTERN_END_WITH_CARRAIGE_RETURN"; //$NON-NLS-1$
-
-
-
- }
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/WARValidationResourceHandler.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/WARValidationResourceHandler.java
deleted file mode 100644
index a549380d2..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/WARValidationResourceHandler.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class WARValidationResourceHandler extends NLS {
-
- private static final String BUNDLE_NAME = "warvalidation";//$NON-NLS-1$
-
- private WARValidationResourceHandler() {
- // Do not instantiate
- }
-
- public static String ERROR_WAR_VALIDATION_FAILED;
- public static String ERROR_EAR_DUPLICATE_ROLES;
- public static String MESSAGE_WAR_VALIDATION_MISSING_JSP;
- public static String MESSAGE_WAR_VALIDATION_SMALL_ICON;
- public static String MESSAGE_WAR_VALIDATION_LARGE_ICON;
- public static String MESSAGE_WAR_VALIDATION_BROKEN_SERVLET_MAPPING;
- public static String MESSAGE_WAR_VALIDATION_NO_WELCOME_FILE;
- public static String MESSAGE_WAR_VALIDATION_MISSING_WELCOME_FILE;
- public static String MESSAGE_WAR_VALIDATION_MISSING_TLD;
- public static String ERROR_INVALID_WAR_FILE;
- public static String MESSAGE_WAR_VALIDATION_BROKEN_FILTER_MAPPING;
- public static String MESSAGE_WAR_VALIDATION_INVALID_WELCOME_FILE;
- public static String WAR_DD_PARSE_LINECOL;
- public static String WAR_DD_PARSE_LINE;
- public static String WAR_DD_PARSE_NOINFO;
- public static String WAR_DD_CANNOT_OPEN_DD;
- public static String MESSAGE_WAR_VALIDATION_INVALID_URL;
- public static String MESSAGE_WAR_VALIDATION_INVALID_SEC_ROLE;
- public static String MESSAGE_WAR_VALIDATION_INVALID_HTTP_CMD;
- public static String MESSAGE_WAR_VALIDATION_INVALID_TRANSPORT;
- public static String MESSAGE_WAR_VALIDATION_INVALID_JSPFILE_REF;
- public static String ERROR_EAR_INVALID_CONTEXT_ROOT;
- public static String MESSAGE_WAR_VALIDATION_INVALID_ERROR_PAGE;
- public static String MESSAGE_WAR_VALIDATION_INVALID_SEC_ROLE_NAME;
- public static String MESSAGE_WAR_VALIDATION_INVALID_AUTH_METHOD;
- public static String MESSAGE_WAR_VALIDATION_IGNORE_FORM_LOGIN;
- public static String MESSAGE_WAR_VALIDATION_RES_AUTH_REQUIRED_22;
- public static String MESSAGE_WAR_VALIDATION_RES_AUTH_REQUIRED_23;
- public static String MESSAGE_WAR_VALIDATION_RES_AUTH_INVALID_22;
- public static String MESSAGE_WAR_VALIDATION_RES_AUTH_INVALID_23;
- public static String MESSAGE_WAR_VALIDATION_INVALID_EXCEPTION_TYPE;
- public static String MESSAGE_WAR_VALIDATION_DUPLICATE_MAPPING;
- public static String MESSAGE_WAR_VALIDATION_DUPLICATE_SERVLET;
- public static String MESSAGE_WAR_VALIDATION_SESSION_TIMEOUT;
- public static String MESSAGE_WAR_VALIDATION_DUPLICATE_ENTRY;
- public static String MESSAGE_WAR_VALIDATION_EMPTY_ENTRY;
- public static String MESSAGE_WAR_VALIDATION_DUPLICATE_FILTER;
- public static String MESSAGE_WAR_VALIDATION_DUPLICATE_EJB_REF;
- public static String ERROR_EAR_UNCONTAINED_MODULE_FILE_EXCEPTION;
- public static String MESSAGE_WAR_VALIDATION_INVALID_ERROR_CODE;
- public static String MESSAGE_WAR_VALIDATION_INVALID_RES_SHARING_SCOPE;
- public static String MESSAGE_WAR_VALIDATION_INVALID_ENV_ENTRY;
- public static String MESSAGE_WAR_VALIDATION_MISSING_WLP_PROJECT;
- public static String MESSAGE_WAR_VALIDATION_CONFLICTING_WLP_PROJECT;
- public static String MSG_SERVER_TARGET_MISMATCH;
- public static String MESSAGE_URL_PATTERN_END_WITH_CARRAIGE_RETURN;
- public static String MESSAGE_WAR_VALIDATION_INVALID_EJB_REF_TYPE;
- public static String ERROR_EAR_MISSING_EJB_ROLE;
- public static String of_Type_Security_Role_Name_6;
- public static String Web_Archive_Validator_8;
- public static String of_Type_Role_Name_19;
- public static String of_Type_Parameter_Name_25;
- public static String of_Type_Parameter_Value_26;
- public static String of_Type_Parameter_Name_32;
- public static String of_Type_Parameter_Value_33;
- public static String of_Type_Parameter_Name_39;
- public static String of_Type_Parameter_Value_40;
- public static String of_Type_ejb_ref_name_44;
- public static String of_Type_Error_Location_47;
- public static String of_Type_Error_Location_49;
- public static String of_Type_Mime_Extension_54;
- public static String of_Type_Mime_Type_55;
- public static String of_Type_Mime_Extension___56;
- public static String of_Type_Web_Resource_Collection_64;
- public static String of_Type_Filter_Name_66;
- public static String Invalid_URL_70;
- public static String Invalid_URL_75;
- public static String of_Type_Servlet_Name_77;
- public static String of_Type_Taglib_80;
- public static String of_Type_TagLib___81;
- public static String of_Type_Web_Resource_Name_84;
- public static String of_Type_Welcome_File_Name__87;
- public static String of_Type_Env_Entry_Name___88;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, WARValidationResourceHandler.class);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/WarValidator.java b/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/WarValidator.java
deleted file mode 100644
index 87c5025f4..000000000
--- a/plugins/org.eclipse.jst.j2ee.core/j2ee-validation/org/eclipse/jst/j2ee/model/internal/validation/WarValidator.java
+++ /dev/null
@@ -1,1420 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.j2ee.model.internal.validation;
-
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.jem.java.JavaClass;
-import org.eclipse.jem.java.JavaRefFactory;
-import org.eclipse.jst.j2ee.common.EnvEntry;
-import org.eclipse.jst.j2ee.common.SecurityRole;
-import org.eclipse.jst.j2ee.common.SecurityRoleRef;
-import org.eclipse.jst.j2ee.common.internal.impl.EJBLocalRefImpl;
-import org.eclipse.jst.j2ee.common.internal.impl.EjbRefImpl;
-import org.eclipse.jst.j2ee.common.internal.impl.ResourceRefImpl;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.EARFile;
-import org.eclipse.jst.j2ee.commonarchivecore.internal.WARFile;
-import org.eclipse.jst.j2ee.ejb.EnterpriseBean;
-import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
-import org.eclipse.jst.j2ee.webapplication.AuthConstraint;
-import org.eclipse.jst.j2ee.webapplication.ContextParam;
-import org.eclipse.jst.j2ee.webapplication.ErrorCodeErrorPage;
-import org.eclipse.jst.j2ee.webapplication.ErrorPage;
-import org.eclipse.jst.j2ee.webapplication.ExceptionTypeErrorPage;
-import org.eclipse.jst.j2ee.webapplication.Filter;
-import org.eclipse.jst.j2ee.webapplication.FilterMapping;
-import org.eclipse.jst.j2ee.webapplication.FormLoginConfig;
-import org.eclipse.jst.j2ee.webapplication.HTTPMethodType;
-import org.eclipse.jst.j2ee.webapplication.InitParam;
-import org.eclipse.jst.j2ee.webapplication.JSPType;
-import org.eclipse.jst.j2ee.webapplication.LoginConfig;
-import org.eclipse.jst.j2ee.webapplication.MimeMapping;
-import org.eclipse.jst.j2ee.webapplication.SecurityConstraint;
-import org.eclipse.jst.j2ee.webapplication.Servlet;
-import org.eclipse.jst.j2ee.webapplication.ServletMapping;
-import org.eclipse.jst.j2ee.webapplication.SessionConfig;
-import org.eclipse.jst.j2ee.webapplication.TagLibRef;
-import org.eclipse.jst.j2ee.webapplication.TransportGuaranteeType;
-import org.eclipse.jst.j2ee.webapplication.UserDataConstraint;
-import org.eclipse.jst.j2ee.webapplication.WebApp;
-import org.eclipse.jst.j2ee.webapplication.WebResourceCollection;
-import org.eclipse.jst.j2ee.webapplication.WelcomeFile;
-import org.eclipse.jst.j2ee.webapplication.WelcomeFileList;
-import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
-import org.eclipse.wst.validation.internal.ResourceConstants;
-import org.eclipse.wst.validation.internal.ResourceHandler;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-
-// import org.eclipse.jst.j2ee.internal.plugin.nls.ResourceHandler;
-
-public class WarValidator extends J2EEValidator implements WARMessageConstants {
- protected WARFile warFile;
- protected WebApp webDD;
- private Hashtable httpMethods = null;
-
- // Optional child validators
- // protected WebExtValidator webExtValidator;
- // protected WebBndValidator webBndValidator;
-
-
- /**
- * RelationshipMapValidator constructor comment.
- */
- public WarValidator() {
- super();
- }
-
- /**
- * Will construct a HashTable of roles, and check for duplicates and null entries
- *
- * @return java.util.Hashtable
- * @param roles
- * org.eclipse.emf.common.util.EList
- */
- public Hashtable getAndValidateSecurityRoles(EList roles) {
-
- Hashtable secRoles = new Hashtable();
- if (roles.isEmpty())
- return (secRoles);
-
- Iterator sRoles = roles.iterator();
-
- while (sRoles.hasNext()) {
-
- if( _reporter.isCancelled() ){
- String msg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED);
- status = WTPCommonPlugin.createCancelStatus(msg);
- }
-
- SecurityRole role = (SecurityRole) sRoles.next();
-
-
- String name = role.getRoleName();
- if (name != null)
- name = name.trim();
- if (name == null || name.equals("")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Security_Role_Name_6;
- addError(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, role);
- continue;
- }
- if (secRoles.get(name) != null) { // Check for dups
-
- String[] parms = new String[1];
- parms[0] = name;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_ENTRY, parms, role);
- continue;
- }
- secRoles.put(name, "Yea"); //$NON-NLS-1$
- }
-
-
- return secRoles;
- }
-
- /**
- * <p>
- * Answer the id of the resource bundle which is used by the receiver.
- * </p>
- */
- public String getBaseName() {
- return WAR_CATEGORY;
- }
-
- // Messaging helpers ...
-
- /**
- * Returns the name of the Validator, as it should be displayed in the UI.
- *
- * @see J2EEValidator#getName
- */
-
- public String getName() {
- return WARValidationResourceHandler.Web_Archive_Validator_8;
- }
-
- // Messaging helpers ...
-
- /**
- * Returns the name of the Validator, as it should be displayed in the UI.
- *
- * @see J2EEValidator#getName
- */
-
- public String getName(Locale locale) {
- return getMessage(null, "webArchiveValidator.name", locale); //$NON-NLS-1$
- }
-
- /**
- * This is a utility function used by the validateSecurityConstraints.
- *
- * @return boolean
- */
- protected boolean isHttpMethod(String method) {
-
-
- if (httpMethods == null) { // Need to construct the Hashtable, once
- String[] mList = {"GET", "PUT", "HEAD", "TRACE", "POST", "DELETE", "OPTIONS"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
-
- httpMethods = new Hashtable();
- for (int i = 0; i < mList.length; i++)
- httpMethods.put(mList[i], "bla"); //$NON-NLS-1$
- }
- String compare = method.trim();
- return (httpMethods.get(compare) != null);
- }
-
- /**
- * WAR validation is driven by 3 prong approach: o XML/DTD validation (this is now handled by
- * the XML Validator) o Consistent web.xml data entry validation beyond DTD e.g., duplicate
- * entries, null entries etc. This is also driven by this validator. o web.xml reference to
- * resources in the "file system". This will not be provided by this validator. In the workbench
- * this function is already provided by the link builder.
- *
- */
- public void validate() throws ValidationException {
- validateMimeMapping();
- validateContextParameters();
- validateTagLibs();
- validateServletMappings(webDD.getServletMappings());
- validateWelcomeFileList(webDD.getFileList());
- validateErrorPages(webDD.getErrorPages());
- validateSecurityAndServlets();
- validateFilters(webDD.getFilters());
- validateFilterMappings(webDD.getFilterMappings());
- validateRefs();
- validateLoginConfig(webDD.getLoginConfig());
- validateEnvironmentEntries(webDD.getEnvironmentProperties());
- validateOther();
- validate14();
- }
-
- /**
- *
- */
- private void validate14() {
- int versionId = webDD.getVersionID();
- if (versionId == J2EEVersionConstants.WEB_2_4_ID) {
- validateUrlPattern();
- }
- }
-
- /**
- *
- */
- private void validateUrlPattern() {
- List servletMappings = webDD.getServletMappings();
- for (int i = 0; i < servletMappings.size(); i++) {
- ServletMapping mapping = (ServletMapping) servletMappings.get(i);
- String urlPattern = mapping.getUrlPattern();
- int newLineChar = urlPattern.indexOf(Character.LINE_SEPARATOR);
- if (newLineChar != -1) {
- String[] parms = new String[2];
- parms[0] = urlPattern;
- parms[1] = mapping.getServlet().getDisplayName();
- addError(WAR_CATEGORY, MESSAGE_URL_PATTERN_END_WITH_CARRAIGE_RETURN, parms, mapping);
- }
- }
-
- }
-
- /**
- * This is the method which performs the validation on the MOF model. <br>
- * <br>
- * <code>helper</code> and <code>reporter</code> may not be null. <code>changedFiles</code>
- * may be null, if a full build is desired. <br>
- * <br>
- * <code>helper</code> loads a EObject. The EObject is the root of the MOF model about to be
- * validated. When this object is traversed, you can reach every element in the MOF model which
- * needs to be validated. <br>
- * <br>
- * <code>reporter</code> is an instance of an IReporter interface, which is used for
- * interaction with the user. <br>
- * <br>
- * <code>changedFiles</code> is an array of file names which have changed since the last
- * validation. If <code>changedFiles</code> is null, or if it is an empty array, then a full
- * build is performed. Otherwise, validation on just the files listed in the Vector is
- * performed.
- */
- public void validate(IValidationContext inHelper, IReporter inReporter) throws ValidationException {
- validateInJob(inHelper, inReporter);
- }
-
-
- public IStatus validateInJob(IValidationContext inHelper, IReporter inReporter) throws ValidationException {
- status = super.validateInJob(inHelper, inReporter);
-
-
- // First remove all previous msg. for this project
- _reporter.removeAllMessages(this, null); // Note the WarHelper will return web.xml with a
- // null object as well
-
- if( !_reporter.isCancelled()){
-
- warFile = (WARFile) _helper.loadModel(WAR_MODEL_NAME);
-
- try {
- if (warFile != null) {
- webDD = warFile.getDeploymentDescriptor();
- validate();
- } else {
- IMessage errorMsg = new Message(getBaseName(), IMessage.HIGH_SEVERITY, ERROR_INVALID_WAR_FILE);
- status = WTPCommonPlugin.createErrorStatus( errorMsg.getText( getClass().getClassLoader() ));
- throw new ValidationException(errorMsg);
- }
-
- } catch (ValidationException ex) {
- throw ex;
- } catch (Exception e) {
- String[] parms = new String[1];
- parms[0] = e.toString();
- IMessage errorMsg = new Message(getBaseName(), IMessage.HIGH_SEVERITY, ERROR_WAR_VALIDATION_FAILED, parms);
- status = WTPCommonPlugin.createErrorStatus(errorMsg.getText( getClass().getClassLoader() ));
- throw new ValidationException(errorMsg, e);
- }
- }else{
- String msg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED);
- status = WTPCommonPlugin.createCancelStatus(msg);
- }
- return status;
- }
-
- /**
- * This validator can be used for validation when the reporter and helper have been supplied via
- * the constructor.
- */
- public void validate(Object aWarFile) throws ValidationException {
-
- try {
- warFile = (WARFile) aWarFile;
- webDD = warFile.getDeploymentDescriptor();
-
- validate();
-
- } catch (Exception e) {
- e.printStackTrace();
- String[] parms = new String[1];
- parms[0] = e.toString();
- IMessage errorMsg = new Message(getBaseName(), IMessage.HIGH_SEVERITY, ERROR_WAR_VALIDATION_FAILED, parms);
- throw new ValidationException(errorMsg);
- }
- }
-
- /**
- * The auth-constraint element indicates the user roles that should be permitted access to this
- * resource collection. The role used here must appear in a security-role-ref element. <!ELEMENT
- * auth-constraint (description?, role-name*)> The role-name element contains the name of a
- * security role. <!ELEMENT role-name (#PCDATA)> Creation date: (7/6/2001 3:39:34 PM)
- *
- * @param authConstraint
- * org.eclipse.jst.j2ee.internal.webapplication.AuthConstraint
- */
- public void validateAuthConstraint(AuthConstraint authConstraint, Hashtable secRoles) {
-
- EList roleList = authConstraint.getRoles();
-
- if (roleList != null && !roleList.isEmpty()) {
- Iterator authRoles = roleList.iterator();
- Hashtable remember = new Hashtable();
- while (authRoles.hasNext()) {
- String role = (String) authRoles.next();
- if (role == null || role.trim().equals("")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Role_Name_19;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, authConstraint);
- continue;
- }
- if (remember.get(role.trim()) != null) {
- String[] parms = new String[1];
- parms[0] = role;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_ENTRY, parms, authConstraint);
- continue;
- }
- remember.put(role.trim(), "Yea"); //$NON-NLS-1$
- validateAuthSecRole("", role, secRoles, authConstraint); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Insert the method's description here. Creation date: (7/5/2001 2:20:02 PM)
- */
- public void validateContextParameters() {
-
- // we must verify that every param-name is unique;
- // param-name appears in context parameters, filter
- // and servlets. We must check each.
- Hashtable remember = new Hashtable();
-
- // check context parameters - each param-name should be unique within the web application
- Iterator cparams = webDD.getContexts().iterator();
- while (cparams.hasNext()) {
-
- if( _reporter.isCancelled() ){
- String msg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED);
- status = WTPCommonPlugin.createCancelStatus(msg);
- }
-
- ContextParam context = (ContextParam) cparams.next();
-
- String name = context.getParamName();
- if (name != null)
- name = name.trim();
-
- if (name == null || name.equals("")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Parameter_Name_25;
-
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, context);
- continue;
- }
- // if (remember.get(name + value) != null) { // Check for dups
- if (remember.get(name) != null) { // Check for dups
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Parameter_Name_25 + ": " + name; //$NON-NLS-1$
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_ENTRY, parms, context);
- continue;
- }
- // remember.put(name + value, "Yea");
- remember.put(name, "Yea"); //$NON-NLS-1$
- }
-
-
- // check servlet init-param - each param-name should be unique within a servlet
- Iterator servlets = webDD.getServlets().iterator();
- while (servlets.hasNext()) {
- Servlet nextServlet = (Servlet) servlets.next();
- Iterator params = nextServlet.getParams().iterator();
- remember.clear();
- while (params.hasNext()) {
- InitParam initParam = (InitParam) params.next();
- String name = initParam.getParamName();
-
- if (name != null)
- name = name.trim();
-
- if (name == null || name.equals("")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Parameter_Name_32;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, initParam);
- continue;
- }
- if (remember.get(name) != null) { // Check for dups
-
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Parameter_Name_25 + ": " + name; //$NON-NLS-1$
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_ENTRY, parms, initParam);
- continue;
- }
- remember.put(name, "Yea"); //$NON-NLS-1$
- }
- }
-
- // check filter init-param - each param-name should be unique within a filter
- Iterator filters = webDD.getFilters().iterator();
- while (filters.hasNext()) {
- Filter nextFilter = (Filter) filters.next();
- Iterator params = nextFilter.getInitParams().iterator();
- remember.clear();
- while (params.hasNext()) {
- InitParam initParam = (InitParam) params.next();
- String name = initParam.getParamName();
-
- if (name != null)
- name = name.trim();
-
- if (name == null || name.equals("")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Parameter_Name_39;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, initParam);
- continue;
- }
- if (remember.get(name) != null) { // Check for dups
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Parameter_Name_25 + ": " + name;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_ENTRY, parms, initParam);
- continue;
- }
- remember.put(name, "Yea"); //$NON-NLS-1$
- }
- }
-
- }
-
- /**
- * Validate EJB references.
- */
-
- public void validateEJBRefs(EjbRefImpl eref) {
- // try {
-
- EARFile earFile = warFile.getEARFile();
- EnterpriseBean eb = null;
-
- if (earFile != null)
- eb = earFile.getEnterpiseBeanFromRef(eref, warFile.getURI());
-
- if (!(eb == null)) {
- List ejbRefs = eb.getEjbRefs();
-
- int numRefs = ejbRefs.size();
-
- Set refSet = new HashSet(numRefs);
-
- for (int refNo = 0; refNo < numRefs; refNo++) {
- String nextName = ((EjbRefImpl) (ejbRefs.get(refNo))).getName();
-
- String[] parms = new String[1];
- parms[0] = eb.getName();
- if (!(refSet.add(nextName))) {
- addWarning(WAR_CATEGORY, ERROR_EAR_DUPLICATE_ROLES, parms, ejbRefs.get(refNo));
- }
- }
- }
-
- // } catch (UncontainedModuleFileException ue) {
- // String[] parms = new String[1];
- // parms[0] = warFile.getName();
- // addError(EREF_CATEGORY, ERROR_EAR_UNCONTAINED_MODULE_FILE_EXCEPTION, parms);
- // }
- }
-
- /**
- * validate for duplicates in EAR Roles
- */
-
- public void validateEJBRefs(List ejbRefs) {
- int numRefs = ejbRefs.size();
- Hashtable remember = new Hashtable();
- for (int refNo = 0; refNo < numRefs; refNo++) {
- EjbRefImpl eref = (EjbRefImpl) ejbRefs.get(refNo);
- if (eref.isSetType()) {
- String type = eref.getType().getName();
- if (type == null) {
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_EJB_REF_TYPE, null, eref); // Type
- // must
- // be
- // of
- // ENTITY
- // or
- // FOO
- }
- }
- if (eref.getName() != null) {
- String name = eref.getName();
- name = name.trim();
-
- if (name.equals("")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_ejb_ref_name_44;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, eref);
- continue;
- }
- if (remember.get(name) != null) { // check for duplicates
- String[] parms = new String[1];
- parms[0] = name;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_EJB_REF, parms, eref);
- continue;
- }
- remember.put(name, "Yea"); //$NON-NLS-1$
- } else {
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_ejb_ref_name_44;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, eref);
- continue;
- }
-
-
- validateEJBRefs(eref);
- validateEJBRefManadatoryElements(eref, webDD.getDisplayName());
- }
- }
-
-
- /**
- * validate for duplicates in EAR Roles
- */
-
- public void validateEJBLocalRefs(List ejbRefs) {
- int numRefs = ejbRefs.size();
- Hashtable remember = new Hashtable();
- for (int refNo = 0; refNo < numRefs; refNo++) {
- EJBLocalRefImpl eref = (EJBLocalRefImpl) ejbRefs.get(refNo);
- if (eref.isSetType()) {
- String type = eref.getType().getName();
- if (type == null) {
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_EJB_REF_TYPE, null, eref); // Type
- // must
- // be
- // of
- // ENTITY
- // or
- // FOO
- }
- }
- if (eref.getName() != null) {
- String name = eref.getName();
- name = name.trim();
-
- if (name.equals("")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_ejb_ref_name_44;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, eref);
- continue;
- }
- if (remember.get(name) != null) { // check for duplicates
- String[] parms = new String[1];
- parms[0] = name;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_EJB_REF, parms, eref);
- continue;
- }
- remember.put(name, "Yea"); //$NON-NLS-1$
- } else {
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_ejb_ref_name_44;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, eref);
- continue;
- }
-
-
- // validateEJBRefs(eref);
- // validateEJBRefManadatoryElements(eref, webDD.getDisplayName());
- }
- }
-
- /**
- * Link build should verify location of exception class
- */
-
- public void validateErrorPages(EList errorPageList) {
- Iterator errorPages = errorPageList.iterator();
-
- if (errorPageList == null || errorPageList.isEmpty())
- return;
-
- while (errorPages.hasNext()) {
-
- if( _reporter.isCancelled() ){
- String msg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED);
- status = WTPCommonPlugin.createCancelStatus(msg);
- }
-
- ErrorPage nextPage = (ErrorPage) errorPages.next();
- String location = nextPage.getLocation();
- if (location == null || location.equals("")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Error_Location_47;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, nextPage);
- }
- if (!location.startsWith("/")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Error_Location_49;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_ERROR_PAGE, parms, nextPage);
- }
-
-
- // check for valid HTTP error code - must be an Integer, 3 digits, and the starting
- // digit must be a 1,2,3,4, or 5.
- if (nextPage.isErrorCode()) {
- ErrorCodeErrorPage ecep = (ErrorCodeErrorPage) nextPage;
- String errorCode = ecep.getErrorCode();
-
- boolean valid = false;
- if (errorCode.length() == 3) {
- try {
- Integer tempInt = new Integer(errorCode);
- // ok, it's a valid 3-digit integer
- int code = tempInt.intValue();
- if (code >= 100 && code < 600) {
- // valid HTTP status code - starting digit must be between 1-5
- valid = true;
- }
- } catch (NumberFormatException exc) {
- // Ignore
- }
- }
- if (!valid) {
- String[] parms = new String[1];
- parms[0] = errorCode;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_ERROR_CODE, parms, ecep);
- }
-
- }
-
- // If exception-type... the specified class must be or inherit from java.lang.Throwable
- else if (nextPage.isExceptionType()) {
- ExceptionTypeErrorPage etep = (ExceptionTypeErrorPage) nextPage;
- JavaClass javaType = etep.getExceptionType();
- String exceptionType = "java.lang.Throwable";//$NON-NLS-1$
- String specifiedClassName = etep.getExceptionTypeName();
- if (javaType != null) {
- ResourceSet lookupSet = javaType.eResource().getResourceSet();
- if (lookupSet != null) {
- if (!javaType.inheritsFrom(JavaRefFactory.eINSTANCE.reflectType(exceptionType, lookupSet).getWrapper())) {
- String[] parms = new String[1];
- parms[0] = specifiedClassName;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_EXCEPTION_TYPE, parms, etep);
- }
- }
- } else {
- String[] parms = new String[1];
- parms[0] = "";//$NON-NLS-1$
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_EXCEPTION_TYPE, parms, etep);
- }
- // TBD
- } else { // Error Code
- // TBD
- }
-
- // TBD remember location/code/exception dups
- }
-
- }
-
- /**
- * Validate the loginConfig section is correct
- */
- public void validateLoginConfig(LoginConfig loginConfig) {
- // com.ibm.etools.validate.ValidatorManager.setResourceUtilClass(com.ibm.etools.validate.ui.UIResourceUtil.class);
-
- if (loginConfig != null) {
- String auth = loginConfig.getAuthMethod().getName();
-
- if (auth == null) {
- String[] parms = new String[0];
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_AUTH_METHOD, parms, loginConfig);
- }
- // Give a warning if form elements are supplied but FORM auth method is not used
- else if (!auth.equals("FORM")) { //$NON-NLS-1$
- FormLoginConfig cfg = loginConfig.getFormLoginConfig();
- if (cfg != null) {
- String[] parms = new String[1];
- parms[0] = auth;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_IGNORE_FORM_LOGIN, parms, loginConfig);
- }
- }
- }
- }
-
- /**
- * Validate the loginConfig section is correct
- */
- public void validateEnvironmentEntries(EList envEntries) {
- if (envEntries.isEmpty())
- return;
-
- // boolean isVersion22 = warFile.getDeploymentDescriptor().isVersion2_2Descriptor();
- Iterator entries = envEntries.iterator();
- Hashtable remember = new Hashtable();
-
- while (entries.hasNext()) {
- EnvEntry entry = (EnvEntry) entries.next();
- if (entry.getType().getName() == null) {
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_ENV_ENTRY, null, entry);
- }
-
- // check for duplicate env-entry-name's
- String name = entry.getName();
- if (name != null) {
- if (remember.get(name) != null) { // Check for dups
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Env_Entry_Name___88 + ": " + name;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_ENTRY, parms, entry);
- } else {
- remember.put(name, "Yea"); //$NON-NLS-1$
- }
- }
- }
-
- }
-
-
- /**
- * Insert the method's description here. Creation date: (7/5/2001 12:11:23 PM)
- */
- public void validateMimeMapping() {
-
- if (webDD.getMimeMappings().isEmpty())
- return;
-
- Iterator mimes = webDD.getMimeMappings().iterator();
- Hashtable remember = new Hashtable();
-
- while (mimes.hasNext()) {
-
- if( _reporter.isCancelled()){
- String msg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED);
- status = WTPCommonPlugin.createCancelStatus(msg);
- }
- MimeMapping mimeMap = (MimeMapping) mimes.next();
-
- String ext = mimeMap.getExtension();
- String mtype = mimeMap.getMimeType();
- if (ext != null)
- ext = ext.trim();
- if (mtype != null)
- mtype = mtype.trim();
-
- if (ext == null || ext.equals("") || mtype == null || mtype.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$
- String[] parms = new String[1];
- if (ext == null || ext.trim().equals("")) //$NON-NLS-1$
- parms[0] = WARValidationResourceHandler.of_Type_Mime_Extension_54;
- else
- parms[0] = WARValidationResourceHandler.of_Type_Mime_Type_55;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, mimeMap);
- continue;
- }
- if (remember.get(ext) != null) { // Check for dups
-
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Mime_Extension___56 + ": " + ext;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_ENTRY, parms, mimeMap);
- continue;
- }
- remember.put(ext, "Yea"); //$NON-NLS-1$
- }
- }
-
- /**
- * Insert the method's description here. Creation date: (7/5/2001 11:46:58 AM)
- */
- public void validateOther() {
-
- SessionConfig sessionCfg = webDD.getSessionConfig();
- if (sessionCfg != null) {
- int timeout = sessionCfg.getSessionTimeout();
- if (timeout == 0) {
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_SESSION_TIMEOUT, null, sessionCfg);
- }
- }
-
-
-
- }
-
- /**
- * validateRefs(WebApp) - validate EJB and resource references - details tbd
- */
-
- public void validateRefs() {
- EList ejbRefs = webDD.getEjbRefs();
-
- if (!ejbRefs.isEmpty())
- validateEJBRefs(ejbRefs);
-
-
- EList ejblocalRefs = webDD.getEjbLocalRefs();
-
- if (!ejblocalRefs.isEmpty())
- validateEJBLocalRefs(ejblocalRefs);
-
-
- EList resourceRefs = webDD.getResourceRefs();
-
- if (!resourceRefs.isEmpty()) {
- // validateResourceRefs(resourceRefs); // we want to do additional checks here
-
- int numRefs = resourceRefs.size();
- Set refSet = new HashSet(numRefs);
- boolean isVersion22 = warFile.getDeploymentDescriptor().getVersionID() <= J2EEVersionConstants.WEB_2_2_ID;
-
- for (int refNo = 0; refNo < numRefs; refNo++) {
-
- if( _reporter.isCancelled() ){
- String msg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED);
- status = WTPCommonPlugin.createCancelStatus(msg);
- }
-
- ResourceRefImpl ref = (ResourceRefImpl) (resourceRefs.get(refNo));
- String auth = ref.getAuth().getName();
-
- // Check: a res-auth element containing Container or Application must be supplied
- if (auth == null || !ref.isSetAuth()) {
- String[] parms = new String[1];
- parms[0] = ref.getName();
- String msgId = isVersion22 ? MESSAGE_WAR_VALIDATION_RES_AUTH_REQUIRED_22 : MESSAGE_WAR_VALIDATION_RES_AUTH_REQUIRED_23;
- addError(WAR_CATEGORY, msgId, parms, ref);
-
- } else if (isVersion22 && auth.equals("Application")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = ref.getName();
- addError(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_RES_AUTH_INVALID_22, parms, ref);
- } else if (!isVersion22 && auth.equals("SERVLET")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = ref.getName();
- addError(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_RES_AUTH_INVALID_23, parms, ref);
- }
-
- // validate res-sharing-scope is allowable value
- String sharingScope = ref.getResSharingScope().getName();
- if (!isVersion22) {
- if (sharingScope == null || !ref.isSetResSharingScope()) {
- String[] parms = new String[0];
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_RES_SHARING_SCOPE, parms, ref);
- }
- }
-
- String refName = ref.getName();
- String[] parms = new String[1];
- parms[0] = refName;
- if (!(refSet.add(refName))){
- addError(EREF_CATEGORY, ERROR_EAR_DUPLICATE_RESREF, parms, ref);
- }
- }
- }
-
- }
-
-
- /**
- * Insert the method's description here. Creation date: (7/6/2001 4:11:09 PM)
- *
- * @return boolean
- * @param role
- * java.lang.String
- * @param defineRoles
- * java.util.Hashtable
- *
- * The auth-constraint only needs to have role-name specified. <auth-constraint> <description></description>
- * <role-name>guest</role-name> </auth-constraint>
- *
- */
- protected void validateAuthSecRole(String link, String role, Hashtable definedRoles, EObject targetObject) {
- String rName = role;
- String lName = link;
- // boolean validRole = true;
- // boolean validLink = true;
-
- if (rName != null)
- rName = rName.trim();
- if (lName != null)
- lName = lName.trim();
-
- if (rName != null) {
- if (!rName.equals("*") && !rName.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$
- if (definedRoles.get(rName) == null && definedRoles.get(lName) == null) {
- String[] parms = new String[1];
- parms[0] = rName;
- addError(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_SEC_ROLE_NAME, parms, targetObject);
- }
- }
- }
- }
-
-
-
- /**
- * Insert the method's description here. Creation date: (7/6/2001 4:11:09 PM)
- *
- * @return boolean
- * @param role
- * java.lang.String
- * @param defineRoles
- * java.util.Hashtable
- *
- *
- * the security-role-ref must have a non-null role-name and the role-link must contain the name
- * of a role specified in the security-role section <security-role-ref> <role-name>MyName</role-name>
- * <role-link>ExistingRole</role-link> </security-role-ref>
- *
- *
- */
- protected void validateSecRole(String link, String role, Hashtable definedRoles, EObject targetObject) {
- String rName = role;
- String lName = link;
- // boolean validRole = true;
- // boolean validLink = true;
-
- if (rName != null)
- rName = rName.trim();
- if (lName != null)
- lName = lName.trim();
-
-
- // the security role-name cannot be null
- if ((rName == null || rName.equals(""))) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = rName;
- addError(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_SEC_ROLE_NAME, parms, targetObject);
- }
-
- if (rName == null || !rName.equals("*")) { //$NON-NLS-1$
- // check that security role-link matches a defines security role
- if (lName != null && definedRoles.get(lName) == null) {
-
- String[] parms = new String[1];
- parms[0] = lName;
- addError(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_SEC_ROLE, parms, targetObject);
- }
- }
- }
-
- /**
- * validateSecurity(WebApp) - validate security constraints, roles, and security role refs -
- * details tbd
- */
-
- public void validateSecurityAndServlets() {
-
-
- EList webRoles = webDD.getSecurityRoles();
-
- // Validate security roles
- Hashtable secRoles = getAndValidateSecurityRoles(webRoles);
-
- // Validate Servlets/JSPs and their role ref.
- validateServlets(webDD.getServlets(), secRoles);
-
- validateSecurityConstraints(webDD.getConstraints(), secRoles);
-
- // try {
- if (!(webRoles.isEmpty())) {
- EARFile module = warFile.getEARFile();
- if (module != null) {
- EList earRoleList = module.getDeploymentDescriptor().getSecurityRoles();
- validateWEBRolesWithEARRoles(earRoleList, webRoles);
- }
- }
- // } catch (UncontainedModuleFileException ue) {
- // String[] parms = new String[1];
- // parms[0] = warFile.getName();
- // addError(EREF_CATEGORY, ERROR_EAR_UNCONTAINED_MODULE_FILE_EXCEPTION, parms);
- // }
- }
-
- /**
- * The security-constraint element is used to associate security constraints with one or more
- * web resource collections <!ELEMENT security-constraint (web-resource-collection+,
- * auth-constraint?, user-data-constraint?)>
- *
- * @param constraints
- * org.eclipse.emf.common.util.EList
- */
- public void validateSecurityConstraints(EList constraints, Hashtable secRoles) {
-
- if (constraints.isEmpty())
- return;
-
- Iterator constList = constraints.iterator();
- while (constList.hasNext()) {
-
- if( _reporter.isCancelled() ){
- String msg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED);
- status = WTPCommonPlugin.createCancelStatus(msg);
- }
-
- SecurityConstraint constraint = (SecurityConstraint) constList.next();
-
- EList webResourceList = constraint.getWebResourceCollections();
- if (webResourceList == null || webResourceList.isEmpty()) {
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Web_Resource_Collection_64;
- addError(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, constraint);
- continue;
- }
- validateWebResourceCollections(webResourceList);
-
- AuthConstraint authConstraint = constraint.getAuthConstraint();
- if (authConstraint != null)
- validateAuthConstraint(authConstraint, secRoles);
-
- UserDataConstraint dataConstraint = constraint.getUserDataConstraint();
- if (dataConstraint != null && dataConstraint.getTransportGuarantee() != null) {
- // <!ELEMENT user-data-constraint (description?, transport-guarantee)>
- // The transport-guarantee element specifies that the communication
- // between client and server should be NONE, INTEGRAL, or
- // CONFIDENTIAL.
-
- // EEnumLiteral transport = dataConstraint.getTransportGuarantee();
- TransportGuaranteeType transport = dataConstraint.getTransportGuarantee();
- if (transport == null || !dataConstraint.isSetTransportGuarantee()) {
- addError(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_TRANSPORT, new String[0], dataConstraint);
- }
- }
- }
- }
-
- public void validateFilters(EList filterList) {
- if (filterList.isEmpty())
- return;
-
- Iterator filters = filterList.iterator();
-
- Hashtable remember = new Hashtable();
-
- while (filters.hasNext()) {
-
- if( _reporter.isCancelled() ){
- String msg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED);
- status = WTPCommonPlugin.createCancelStatus(msg);
- }
-
- Filter nextFilter = (Filter) filters.next();
- String name = nextFilter.getName();
- if (name != null)
- name = name.trim();
-
- if (name == null || name.equals("")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Filter_Name_66;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, nextFilter);
- continue;
- }
- if (remember.get(name) != null) { // check for duplicates
- String[] parms = new String[1];
- parms[0] = name;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_FILTER, parms, nextFilter);
- continue;
- }
- remember.put(name, "Yea"); //$NON-NLS-1$
- }
- }
-
- /**
- * validateFilterMappings(Elist(Filters's)) - for each filter mapping, make sure the named
- * filter exists
- */
- public void validateFilterMappings(EList filterMappingsList) {
-
- if (filterMappingsList.isEmpty())
- return;
-
- Iterator filterMappings = filterMappingsList.iterator();
- while (filterMappings.hasNext()) {
- FilterMapping nextMapping = (FilterMapping) filterMappings.next();
-
- // Mapping can be either servlet or url
- if (nextMapping.getUrlPattern() != null) {
- String[] parms = new String[1];
- String url = nextMapping.getUrlPattern();
- parms[0] = url;
- if (url == null) {
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_URL, parms, nextMapping);
- continue;
- }
- if (nextMapping.getFilter() == null || nextMapping.getFilter().equals("")) { //$NON-NLS-1$
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_BROKEN_FILTER_MAPPING, parms, nextMapping);
- continue;
- }
-
- // Is is a valid URI notation ?
- try {
- if (url.equals(""))
- throw new Exception(WARValidationResourceHandler.Invalid_URL_70);
- // You can't use com.ibm.webtools.URI here...
- // com.ibm.iwt.webtools.URI uri = new com.ibm.iwt.webtools.URI(url) ;
- } catch (Exception e) {
- parms = new String[1];
- parms[0] = nextMapping.getUrlPattern();
- addError(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_URL, parms, nextMapping);
- continue;
- }
- } else if (nextMapping.getServletName() != null) {
- String[] parms = new String[1];
- String servletName = nextMapping.getServletName();
- parms[0] = servletName;
- if (nextMapping.getServlet() == null) {
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_BROKEN_SERVLET_MAPPING, parms, nextMapping);
- continue;
- }
- if (nextMapping.getFilter() == null || nextMapping.getFilter().equals("")) { //$NON-NLS-1$
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_BROKEN_FILTER_MAPPING, parms, nextMapping);
- continue;
- }
- }
- // else {
- // // otherwise neither servlet-name or url-mapping is defined - this gets flagged by
- // the xml validator
- // // as this does not conform to the DTD
- //
- // }
-
-
- }
-
- }
-
-
-
- /**
- * validateServlets(Elist(Servlet's)) - for each servlet mapping, make sure the named servlet
- * exists
- */
-
- public void validateServletMappings(EList servletMappingsList) {
-
- if (servletMappingsList.isEmpty())
- return;
-
- Iterator servletMappings = servletMappingsList.iterator();
-
- Hashtable remember = new Hashtable();
- while (servletMappings.hasNext()) {
- if( _reporter.isCancelled() ){
- String msg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED);
- status = WTPCommonPlugin.createCancelStatus(msg);
- }
-
- ServletMapping nextMapping = (ServletMapping) servletMappings.next();
- String url = nextMapping.getUrlPattern();
-
- // Check for null servlet, if the name is right the reflection
- // has already resolved it.
-
- if (url != null) { // check for duplicate first, no need to repeat earlier error,
- url = url.trim();
- if (remember.get(url) != null) {
- String[] parms = new String[1];
- parms[0] = nextMapping.getUrlPattern();
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_MAPPING, parms, nextMapping);
- continue;
- }
- remember.put(nextMapping.getUrlPattern(), "Yea"); //$NON-NLS-1$
- }
-
-
- if (url == null || nextMapping.getServlet() == null || nextMapping.getServlet().equals("")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = url;
- if (url == null)
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_URL, parms, nextMapping);
- else
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_BROKEN_SERVLET_MAPPING, parms, nextMapping);
- continue;
- }
-
- // Is is a valid URI notation ?
- try {
- if (url.equals(""))
- throw new Exception(WARValidationResourceHandler.Invalid_URL_75);
-
- //
- // The spec does not prohibit whitespace in the url-patterns
- //
- // // check to see if the string is a valid URL- has no white space
- // char[] chars = url.toCharArray();
- // int len = chars.length;
- // for (int cnt = 0; cnt < chars.length; cnt++)
- // {
- // if (Character.isWhitespace(chars[cnt]))
- // throw new Exception("Invalid URL") ;
- // }
- // You can't use com.ibm.webtools.URI here...
- // com.ibm.iwt.webtools.URI uri = new com.ibm.iwt.webtools.URI(url) ;
- } catch (Exception e) {
- String[] parms = new String[1];
- parms[0] = nextMapping.getUrlPattern();
- addError(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_URL, parms, nextMapping);
- continue;
- }
- }
-
- }
-
- /**
- * validateServlets(Elist(Servlet's)) - if it's a JSP, verify the file exists - validate
- * optional security role refs for existence of the security role
- */
-
- public void validateServlets(EList servletList, Hashtable secRoles) {
- if (servletList.isEmpty())
- return;
-
- Iterator servlets = servletList.iterator();
-
- Hashtable remember = new Hashtable();
-
- while (servlets.hasNext()) {
- if( _reporter.isCancelled() ){
- String msg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED);
- status = WTPCommonPlugin.createCancelStatus(msg);
- }
-
- Servlet nextServlet = (Servlet) servlets.next();
- String name = nextServlet.getServletName();
- if (name != null)
- name = name.trim();
-
- if (name == null || name.equals("")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Servlet_Name_77;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, nextServlet);
- continue;
- }
- if (remember.get(name) != null) { // check for duplicates
- String[] parms = new String[1];
- parms[0] = name;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_SERVLET, parms, nextServlet);
- continue;
- }
- remember.put(name, "Yea"); //$NON-NLS-1$
-
- // Validate servlet roles
- EList rolesList = nextServlet.getSecurityRoleRefs();
- if (!rolesList.isEmpty()) {
- Iterator roles = rolesList.iterator();
- while (roles.hasNext()) {
- SecurityRoleRef role = (SecurityRoleRef) roles.next();
- validateSecRole(role.getLink(), role.getName(), secRoles, role);
- }
- }
-
- // if it's a JSP, the jsp-file attribute MUST be a full-path, according to the servlet
- // 2.2 spec
- if (nextServlet.getWebType() != null && nextServlet.getWebType().isJspType()) {
- JSPType jspType = (JSPType) (nextServlet.getWebType());
-
- String jspFileName = jspType.getJspFile();
- if (jspFileName == null || !(jspFileName.length() > 0)) {
- String[] parms = new String[2];
- parms[0] = jspFileName;
- parms[1] = name;
- addError(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_JSPFILE_REF, parms, nextServlet);
- }
- }
-
- /* No need to check for the existence of JSPs or Servlets. the LinkBuilder will do this */
-
- }
- }
-
- public void validateTagLibs() {
-
- if (webDD.getTagLibs().isEmpty())
- return;
-
- Iterator tags = webDD.getTagLibs().iterator();
- Hashtable remember = new Hashtable();
-
- while (tags.hasNext()) {
-
- if( _reporter.isCancelled() ){
- String msg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED);
- status = WTPCommonPlugin.createCancelStatus(msg);
- }
-
- TagLibRef taglib = (TagLibRef) tags.next(); // ClassCastException at runtime
- String uri = taglib.getTaglibURI();
-
- if (uri != null)
- uri = uri.trim();
-
- if (uri == null || uri.equals("")) { //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Taglib_80;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, taglib);
- continue;
- }
- if (remember.get(uri) != null) { // Check for dups
-
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_TagLib___81 + ": " + uri;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_ENTRY, parms, taglib);
- continue;
- }
- remember.put(uri, "Yea"); //$NON-NLS-1$
- }
- }
-
- public void validateWebResourceCollections(EList webResourceList) {
-
-
- Iterator resourceList = webResourceList.iterator();
- while (resourceList.hasNext()) { // Check the web resource collections
- WebResourceCollection resource = (WebResourceCollection) resourceList.next();
-
- String name = resource.getWebResourceName();
- if (name != null)
- name = name.trim();
- if (name == null || name.equals("")) { // should have a name //$NON-NLS-1$
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Web_Resource_Name_84;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_EMPTY_ENTRY, parms, resource);
- }
-
- // Check that the http methods, if any is correct
- EList httpList = resource.getHTTPs();
- if (!httpList.isEmpty()) {
- Iterator https = httpList.iterator();
- while (https.hasNext()) {
- HTTPMethodType httpMethod = (HTTPMethodType) https.next();
- String method = httpMethod.getHttpMethod();
-
- if (method == null || !isHttpMethod(method)) {
- String[] parms = new String[1];
- parms[0] = method;
- addError(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_HTTP_CMD, parms, httpMethod);
- }
-
-
- }
- }
- }
- }
-
- /**
- * validateWelcomeFileList(WelcomeFileList) - walk through the files and verify they exist
- */
-
- public void validateWelcomeFileList(WelcomeFileList fileList) {
- if (fileList == null)
- return;
-
- Iterator files = fileList.getFile().iterator();
-
- Hashtable remember = new Hashtable();
- while (files.hasNext()) {
-
- if( _reporter.isCancelled() ){
- String msg = ResourceHandler.getExternalizedMessage(ResourceConstants.VBF_STATUS_VALIDATOR_TERMINATED);
- status = WTPCommonPlugin.createCancelStatus(msg);
- }
-
- WelcomeFile nextFile = (WelcomeFile) files.next();
- String fileName = nextFile.getWelcomeFile();
-
- if ((fileName == null) || (fileName.length() == 0)) {
- String[] parms = new String[0];
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_NO_WELCOME_FILE, parms, nextFile);
- } else if ((fileName.startsWith("/")) || (fileName.endsWith("/"))) { //$NON-NLS-1$ //$NON-NLS-2$
- String[] parms = new String[0];
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_INVALID_WELCOME_FILE, parms, nextFile);
- }
- fileName = fileName.trim();
- if (remember.get(fileName) != null) {
- String[] parms = new String[1];
- parms[0] = WARValidationResourceHandler.of_Type_Welcome_File_Name__87 + ": " + fileName;
- addWarning(WAR_CATEGORY, MESSAGE_WAR_VALIDATION_DUPLICATE_ENTRY, parms, nextFile);
- continue;
- }
- remember.put(fileName, "Yea"); //$NON-NLS-1$
- }
- }
-
- public ISchedulingRule getSchedulingRule(IValidationContext helper) {
- _helper = helper;
- return null;
- }
-}

Back to the top