|
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) { |