Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 241668
Collapse All | Expand All

(-)ejb_ui/org/eclipse/jst/ejb/ui/internal/wizard/NewSessionBeanClassWizardPage.java (-11 / +12 lines)
Lines 17-22 Link Here
17
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.STATE_TYPE;
17
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.STATE_TYPE;
18
import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.INTERFACES;
18
import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.INTERFACES;
19
19
20
import java.util.ArrayList;
21
import java.util.Arrays;
22
20
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.layout.GridData;
22
import org.eclipse.swt.layout.GridLayout;
25
import org.eclipse.swt.layout.GridLayout;
Lines 101-116 Link Here
101
104
102
	@Override
105
	@Override
103
	protected String[] getValidationPropertyNames() {
106
	protected String[] getValidationPropertyNames() {
104
		String[] retVal = null;
107
		ArrayList<String> names = new ArrayList<String>();
105
		String[] baseVals = super.getValidationPropertyNames();
108
		names.addAll(Arrays.asList(super.getValidationPropertyNames()));
106
		retVal = new String[baseVals.length + 2];
109
		
107
		for (int i = 0; i < baseVals.length; i++)
110
		names.add(STATE_TYPE);
108
		{
111
		names.add(INTERFACES);
109
			retVal[i] = baseVals[i];
112
		names.add(LOCAL_BUSINESS_INTERFACE);
110
		}
113
		names.add(REMOTE_BUSINESS_INTERFACE);
111
		retVal[baseVals.length] = LOCAL_BUSINESS_INTERFACE;
114
		
112
		retVal[baseVals.length + 1] = REMOTE_BUSINESS_INTERFACE;
115
		return names.toArray(new String[0]);
113
		retVal[baseVals.length + 1] = INTERFACES;
114
		return retVal;
115
	}
116
	}
116
}
117
}
(-)ejb/org/eclipse/jst/j2ee/ejb/internal/operations/INewEnterpriseBeanClassDataModelProperties.java (-5 / +5 lines)
Lines 25-37 Link Here
25
	 * Optional, String property of the EJB mapped name for the enterprise bean. 
25
	 * Optional, String property of the EJB mapped name for the enterprise bean. 
26
	 */
26
	 */
27
	public static final String MAPPED_NAME = "INewEnterpriseBeanClassDataModelProperties.MAPPED_NAME"; //$NON-NLS-1$
27
	public static final String MAPPED_NAME = "INewEnterpriseBeanClassDataModelProperties.MAPPED_NAME"; //$NON-NLS-1$
28
	
28
29
	/**
29
	/**
30
	 * Required, Integer property that determines the transaction type of the enterprise
30
	 * Required, String property that determines the transaction type of the
31
	 * bean.
31
	 * enterprise bean. Valid values are the string representation of the
32
	 * <code>TransactionType<code> enumeration.
32
	 * 
33
	 * 
33
	 * @see NewSessionBeanClassDataModelProvider#TRANSACTION_TYPE_CONTAINER_INDEX
34
	 * @see TransactionType
34
	 * @see NewSessionBeanClassDataModelProvider#TRANSACTION_TYPE_BEAN_INDEX
35
	 */
35
	 */
36
	public static final String TRANSACTION_TYPE = "INewEnterpriseBeanClassDataModelProperties.TRANSACTION_TYPE"; //$NON-NLS-1$
36
	public static final String TRANSACTION_TYPE = "INewEnterpriseBeanClassDataModelProperties.TRANSACTION_TYPE"; //$NON-NLS-1$
37
	
37
	
(-)ejb/org/eclipse/jst/j2ee/ejb/internal/operations/CreateSessionBeanTemplateModel.java (-6 / +14 lines)
Lines 31-36 Link Here
31
31
32
	public static final String QUALIFIED_STATELESS = "javax.ejb.Stateless"; //$NON-NLS-1$
32
	public static final String QUALIFIED_STATELESS = "javax.ejb.Stateless"; //$NON-NLS-1$
33
	public static final String QUALIFIED_STATEFUL = "javax.ejb.Stateful"; //$NON-NLS-1$
33
	public static final String QUALIFIED_STATEFUL = "javax.ejb.Stateful"; //$NON-NLS-1$
34
	public static final String QUALIFIED_SINGLETON = "javax.ejb.Singleton"; //$NON-NLS-1$
34
	public static final String QUALIFIED_LOCAL = "javax.ejb.Local"; //$NON-NLS-1$
35
	public static final String QUALIFIED_LOCAL = "javax.ejb.Local"; //$NON-NLS-1$
35
	public static final String QUALIFIED_REMOTE = "javax.ejb.Remote"; //$NON-NLS-1$
36
	public static final String QUALIFIED_REMOTE = "javax.ejb.Remote"; //$NON-NLS-1$
36
	public static final String QUALIFIED_REMOTE_HOME = "javax.ejb.RemoteHome"; //$NON-NLS-1$
37
	public static final String QUALIFIED_REMOTE_HOME = "javax.ejb.RemoteHome"; //$NON-NLS-1$
Lines 40-45 Link Here
40
	
41
	
41
	public static final String STATELESS_ANNOTATION = "@Stateless"; //$NON-NLS-1$
42
	public static final String STATELESS_ANNOTATION = "@Stateless"; //$NON-NLS-1$
42
	public static final String STATEFUL_ANNOTATION = "@Stateful"; //$NON-NLS-1$
43
	public static final String STATEFUL_ANNOTATION = "@Stateful"; //$NON-NLS-1$
44
	public static final String SINGLETON_ANNOTATION = "@Singleton"; //$NON-NLS-1$
43
45
44
	protected BusinessInterface currentBusinessInterface = null;
46
	protected BusinessInterface currentBusinessInterface = null;
45
	protected String localHomeClassName = null;
47
	protected String localHomeClassName = null;
Lines 56-67 Link Here
56
		Collection<String> collection = super.getImports();
58
		Collection<String> collection = super.getImports();
57
		
59
		
58
		String stateType = dataModel.getStringProperty(STATE_TYPE);
60
		String stateType = dataModel.getStringProperty(STATE_TYPE);
59
		if (stateType.equals(StateType.STATELESS.toString()))
61
		if (stateType.equals(StateType.STATELESS.toString())) {
60
			collection.add(QUALIFIED_STATELESS);
62
			collection.add(QUALIFIED_STATELESS);
61
		else if (stateType.equals(StateType.STATEFUL.toString()))
63
		} else if (stateType.equals(StateType.STATEFUL.toString())) {
62
			collection.add(QUALIFIED_STATEFUL);
64
			collection.add(QUALIFIED_STATEFUL);
63
		else
65
		} else if (stateType.equals(StateType.SINGLETON.toString())) {
66
			collection.add(QUALIFIED_SINGLETON);
67
		} else {
64
			throw new IllegalStateException("illegal state type: " + stateType); //$NON-NLS-1$
68
			throw new IllegalStateException("illegal state type: " + stateType); //$NON-NLS-1$
69
		}
65
		
70
		
66
		if (!isContainerType()) {
71
		if (!isContainerType()) {
67
			collection.add(QUALIFIED_TRANSACTION_MANAGEMENT);
72
			collection.add(QUALIFIED_TRANSACTION_MANAGEMENT);
Lines 106-117 Link Here
106
		String stateType = dataModel.getStringProperty(STATE_TYPE);
111
		String stateType = dataModel.getStringProperty(STATE_TYPE);
107
		
112
		
108
		String beanType;
113
		String beanType;
109
		if (stateType.equals(StateType.STATELESS.toString()))
114
		if (stateType.equals(StateType.STATELESS.toString())) {
110
			beanType = STATELESS_ANNOTATION;
115
			beanType = STATELESS_ANNOTATION;
111
		else if (stateType.equals(StateType.STATEFUL.toString()))
116
		} else if (stateType.equals(StateType.STATEFUL.toString())) {
112
			beanType = STATEFUL_ANNOTATION;
117
			beanType = STATEFUL_ANNOTATION;
113
		else 
118
		} else if (stateType.equals(StateType.SINGLETON.toString())) {
119
			beanType = SINGLETON_ANNOTATION;
120
		} else { 
114
			throw new IllegalStateException("illegal state type: " + stateType); //$NON-NLS-1$
121
			throw new IllegalStateException("illegal state type: " + stateType); //$NON-NLS-1$
122
		}
115
		
123
		
116
		return beanType;
124
		return beanType;
117
	}
125
	}
(-)ejb/org/eclipse/jst/j2ee/ejb/internal/operations/StateType.java (-2 / +15 lines)
Lines 12-28 Link Here
12
12
13
/**
13
/**
14
 * Enumerates the session state type values of a session bean. 
14
 * Enumerates the session state type values of a session bean. 
15
 * 
16
 * @since 3.0
15
 */
17
 */
16
public enum StateType {
18
public enum StateType {
17
19
18
	/**
20
	/**
19
	 * Represents the <code>Stateless</code> session state type. 
21
	 * Represents the <code>Stateless</code> session state type.
22
	 * 
23
	 * @since 3.0
20
	 */
24
	 */
21
	STATELESS,
25
	STATELESS,
22
	
26
	
23
	/**
27
	/**
24
	 * Represents the <code>Stateful</code> session state type.
28
	 * Represents the <code>Stateful</code> session state type.
29
	 * 
30
	 * @since 3.0
25
	 */
31
	 */
26
	STATEFUL;
32
	STATEFUL, 
33
	
34
	/**
35
	 * Represents the <code>Singleton</code> session state type.
36
	 * 
37
	 * @since 3.2
38
	 */
39
	SINGLETON;
27
40
28
}
41
}
(-)ejb/org/eclipse/jst/j2ee/ejb/internal/operations/INewSessionBeanClassDataModelProperties.java (-5 / +5 lines)
Lines 62-74 Link Here
62
	 * compatible remote home and components interfaces. The default is false.
62
	 * compatible remote home and components interfaces. The default is false.
63
	 */
63
	 */
64
	public static final String REMOTE_HOME = "INewSessionBeanClassDataModelProperties.REMOTE_HOME"; //$NON-NLS-1$
64
	public static final String REMOTE_HOME = "INewSessionBeanClassDataModelProperties.REMOTE_HOME"; //$NON-NLS-1$
65
	
65
66
	/**
66
	/**
67
	 * Required, Integer property that determines the state type of the session
67
	 * Required, String property that determines the state type of the session
68
	 * bean.
68
	 * bean. Valid values are the string representation of the
69
	 * <code>StateType<code> enumeration.
69
	 * 
70
	 * 
70
	 * @see NewSessionBeanClassDataModelProvider#STATE_TYPE_STATELESS_INDEX
71
	 * @see StateType
71
	 * @see NewSessionBeanClassDataModelProvider#STATE_TYPE_STATEFUL_INDEX
72
	 */
72
	 */
73
	public static final String STATE_TYPE = "INewSessionBeanClassDataModelProperties.STATE_TYPE"; //$NON-NLS-1$
73
	public static final String STATE_TYPE = "INewSessionBeanClassDataModelProperties.STATE_TYPE"; //$NON-NLS-1$
74
	
74
	
(-)ejb/org/eclipse/jst/j2ee/ejb/internal/operations/NewSessionBeanClassDataModelProvider.java (-9 / +29 lines)
Lines 46-53 Link Here
46
import org.eclipse.jst.j2ee.ejb.internal.operations.BusinessInterface.BusinessInterfaceType;
46
import org.eclipse.jst.j2ee.ejb.internal.operations.BusinessInterface.BusinessInterfaceType;
47
import org.eclipse.jst.j2ee.ejb.internal.plugin.EjbPlugin;
47
import org.eclipse.jst.j2ee.ejb.internal.plugin.EjbPlugin;
48
import org.eclipse.jst.j2ee.internal.common.J2EECommonMessages;
48
import org.eclipse.jst.j2ee.internal.common.J2EECommonMessages;
49
import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil;
49
import org.eclipse.jst.j2ee.internal.common.operations.NewJavaClassDataModelProvider;
50
import org.eclipse.jst.j2ee.internal.common.operations.NewJavaClassDataModelProvider;
50
import org.eclipse.jst.j2ee.internal.ejb.project.operations.EJBCreationResourceHandler;
51
import org.eclipse.jst.j2ee.internal.ejb.project.operations.EJBCreationResourceHandler;
52
import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
51
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
53
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
52
import org.eclipse.osgi.util.NLS;
54
import org.eclipse.osgi.util.NLS;
53
import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor;
55
import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor;
Lines 55-68 Link Here
55
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
57
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
56
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
58
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
57
import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
59
import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
60
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
58
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
61
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
59
62
60
public class NewSessionBeanClassDataModelProvider extends NewEnterpriseBeanClassDataModelProvider {
63
public class NewSessionBeanClassDataModelProvider extends NewEnterpriseBeanClassDataModelProvider {
61
64
62
63
	public static final int STATE_TYPE_STATELESS_INDEX = 0;
64
	public static final int STATE_TYPE_STATEFUL_INDEX = 1;
65
66
	private static final String LOCAL_SUFFIX = "Local"; //$NON-NLS-1$
65
	private static final String LOCAL_SUFFIX = "Local"; //$NON-NLS-1$
67
	private static final String REMOTE_SUFFIX = "Remote"; //$NON-NLS-1$
66
	private static final String REMOTE_SUFFIX = "Remote"; //$NON-NLS-1$
68
	private static final String LOCAL_HOME_SUFFIX = "LocalHome"; //$NON-NLS-1$
67
	private static final String LOCAL_HOME_SUFFIX = "LocalHome"; //$NON-NLS-1$
Lines 249-267 Link Here
249
	public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) {
248
	public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) {
250
		if (propertyName.equals(STATE_TYPE)) {
249
		if (propertyName.equals(STATE_TYPE)) {
251
			return DataModelPropertyDescriptor.createDescriptors(
250
			return DataModelPropertyDescriptor.createDescriptors(
252
					new String[] { 
251
					new String[] {
253
							StateType.STATELESS.toString(), 
252
							StateType.STATELESS.toString(), 
254
							StateType.STATEFUL.toString()
253
							StateType.STATEFUL.toString(), 
254
							StateType.SINGLETON.toString()
255
					}, 
255
					}, 
256
					new String[] {
256
					new String[] {
257
							EJBCreationResourceHandler.STATE_TYPE_STATELESS, 
257
							EJBCreationResourceHandler.STATE_TYPE_STATELESS, 
258
							EJBCreationResourceHandler.STATE_TYPE_STATEFUL
258
							EJBCreationResourceHandler.STATE_TYPE_STATEFUL, 
259
					});
259
							EJBCreationResourceHandler.STATE_TYPE_SINGLETON
260
					}
261
			);
260
		} 
262
		} 
261
		
263
		
262
		return super.getValidPropertyDescriptors(propertyName);
264
		return super.getValidPropertyDescriptors(propertyName);
263
	}
265
	}
264
266
267
	private boolean ejb31OrLater() {
268
		IProject project = getTargetProject();
269
		IProjectFacetVersion facetVersion = JavaEEProjectUtilities.getProjectFacetVersion(project, IJ2EEFacetConstants.EJB);
270
		int version = J2EEVersionUtil.convertVersionStringToInt(facetVersion.getVersionString());
271
		int ejb31version = J2EEVersionUtil.convertVersionStringToInt(IJ2EEFacetConstants.EJB_31.getVersionString());
272
		return version >= ejb31version;
273
	}
274
265
	private void updateBusinessInterfaces(String propertyName) {
275
	private void updateBusinessInterfaces(String propertyName) {
266
		List<BusinessInterface> list = (List<BusinessInterface>) getProperty(INTERFACES);
276
		List<BusinessInterface> list = (List<BusinessInterface>) getProperty(INTERFACES);
267
		if (propertyName.equals(REMOTE)) {
277
		if (propertyName.equals(REMOTE)) {
Lines 304-310 Link Here
304
314
305
	@Override
315
	@Override
306
	public IStatus validate(String propertyName) {
316
	public IStatus validate(String propertyName) {
307
		if (LOCAL_BUSINESS_INTERFACE.equals(propertyName)) {
317
		if (STATE_TYPE.equals(propertyName)) {
318
			return validateStateType();			
319
		} else if (LOCAL_BUSINESS_INTERFACE.equals(propertyName)) {
308
			if (getBooleanProperty(LOCAL)) {
320
			if (getBooleanProperty(LOCAL)) {
309
				return validateEjbInterface(getStringProperty(propertyName));
321
				return validateEjbInterface(getStringProperty(propertyName));
310
			}
322
			}
Lines 324-329 Link Here
324
		return super.validate(propertyName);
336
		return super.validate(propertyName);
325
	}
337
	}
326
338
339
	protected IStatus validateStateType() {
340
		String value = getStringProperty(STATE_TYPE);
341
		if (StateType.SINGLETON.toString().equals(value) && !ejb31OrLater()) {
342
			return WTPCommonPlugin.createErrorStatus(EJBCreationResourceHandler.ERR_SINGLETON_ALLOWED_ONLY_FOR_31_AND_LATER);
343
		}
344
		return Status.OK_STATUS;
345
	}
346
327
	protected IStatus validateEjbInterface(String fullyQualifiedName) {
347
	protected IStatus validateEjbInterface(String fullyQualifiedName) {
328
		IStatus status = validateJavaTypeName(fullyQualifiedName);
348
		IStatus status = validateJavaTypeName(fullyQualifiedName);
329
		if (status.getSeverity() != IStatus.ERROR) {
349
		if (status.getSeverity() != IStatus.ERROR) {
(-)property_files/ejbcreation.properties (-2 / +4 lines)
Lines 127-137 Link Here
127
remove_client_jar_client_binary=
127
remove_client_jar_client_binary=
128
EJB_Client_JAR_Creation_Error_=EJB client JAR Creation Error
128
EJB_Client_JAR_Creation_Error_=EJB client JAR Creation Error
129
Cannot_Be_Binary_Project_For_Client_=Cannot create a new EJB client JAR for a binary project.
129
Cannot_Be_Binary_Project_For_Client_=Cannot create a new EJB client JAR for a binary project.
130
Cannot_Be_StandAlone_Project_For_Client_=Cannont create a new EJB client JAR for a stand-alone project.
130
Cannot_Be_StandAlone_Project_For_Client_=Cannot create a new EJB client JAR for a stand-alone project.
131
TRANSACTION_TYPE_CONTAINER=Container
131
TRANSACTION_TYPE_CONTAINER=Container
132
TRANSACTION_TYPE_BEAN=Bean
132
TRANSACTION_TYPE_BEAN=Bean
133
STATE_TYPE_STATELESS=Stateless
133
STATE_TYPE_STATELESS=Stateless
134
STATE_TYPE_STATEFUL=Stateful
134
STATE_TYPE_STATEFUL=Stateful
135
STATE_TYPE_SINGLETON=Singleton
135
DESTINATION_TYPE_QUEUE=Queue
136
DESTINATION_TYPE_QUEUE=Queue
136
DESTINATION_TYPE_TOPIC=Topic
137
DESTINATION_TYPE_TOPIC=Topic
137
138
Lines 147-150 Link Here
147
ERR_REMOTE_HOME_NOT_INTERFACE=The specified Remote Home interface is not valid.
148
ERR_REMOTE_HOME_NOT_INTERFACE=The specified Remote Home interface is not valid.
148
ERR_BEAN_ALREADY_EXISTS=Enterprise bean with the same Ejb Name already exists.
149
ERR_BEAN_ALREADY_EXISTS=Enterprise bean with the same Ejb Name already exists.
149
WRN_BEAN_NAME_IS_EMPTY=Bean name is empty, the containter will use the name of the bean class.
150
WRN_BEAN_NAME_IS_EMPTY=Bean name is empty, the containter will use the name of the bean class.
150
WRN_NO_BUSINESS_INTERFACE=No business interface configured. Clients will not be able to access this bean. 
151
WRN_NO_BUSINESS_INTERFACE=No business interface configured. Clients will not be able to access this bean.
152
ERR_SINGLETON_ALLOWED_ONLY_FOR_31_AND_LATER=The 'Singleton' state type is allowed only for EJB projects with version 3.1 and later.  
(-)ejbcreation/org/eclipse/jst/j2ee/internal/ejb/project/operations/EJBCreationResourceHandler.java (+2 lines)
Lines 147-152 Link Here
147
	public static String TRANSACTION_TYPE_BEAN;
147
	public static String TRANSACTION_TYPE_BEAN;
148
	public static String STATE_TYPE_STATELESS;
148
	public static String STATE_TYPE_STATELESS;
149
	public static String STATE_TYPE_STATEFUL;
149
	public static String STATE_TYPE_STATEFUL;
150
	public static String STATE_TYPE_SINGLETON;
150
	public static String DESTINATION_TYPE_QUEUE;
151
	public static String DESTINATION_TYPE_QUEUE;
151
	public static String DESTINATION_TYPE_TOPIC;
152
	public static String DESTINATION_TYPE_TOPIC;
152
	
153
	
Lines 163-168 Link Here
163
	public static String ERR_NO_MESSAGE_LISTENER_INTERFACE;
164
	public static String ERR_NO_MESSAGE_LISTENER_INTERFACE;
164
	public static String WRN_BEAN_NAME_IS_EMPTY;
165
	public static String WRN_BEAN_NAME_IS_EMPTY;
165
	public static String WRN_NO_BUSINESS_INTERFACE;
166
	public static String WRN_NO_BUSINESS_INTERFACE;
167
	public static String ERR_SINGLETON_ALLOWED_ONLY_FOR_31_AND_LATER;
166
168
167
169
168
	static {
170
	static {

Return to bug 241668