|
Lines 15-20
Link Here
|
| 15 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.LOCAL_COMPONENT_INTERFACE; |
15 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.LOCAL_COMPONENT_INTERFACE; |
| 16 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.LOCAL_HOME; |
16 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.LOCAL_HOME; |
| 17 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.LOCAL_HOME_INTERFACE; |
17 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.LOCAL_HOME_INTERFACE; |
|
|
18 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.NO_INTERFACE; |
| 18 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.REMOTE; |
19 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.REMOTE; |
| 19 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.REMOTE_BUSINESS_INTERFACE; |
20 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.REMOTE_BUSINESS_INTERFACE; |
| 20 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.REMOTE_COMPONENT_INTERFACE; |
21 |
import static org.eclipse.jst.j2ee.ejb.internal.operations.INewSessionBeanClassDataModelProperties.REMOTE_COMPONENT_INTERFACE; |
|
Lines 32-38
Link Here
|
| 32 |
|
33 |
|
| 33 |
import org.eclipse.core.resources.IProject; |
34 |
import org.eclipse.core.resources.IProject; |
| 34 |
import org.eclipse.core.resources.ResourcesPlugin; |
35 |
import org.eclipse.core.resources.ResourcesPlugin; |
| 35 |
import org.eclipse.core.runtime.CoreException; |
|
|
| 36 |
import org.eclipse.core.runtime.IStatus; |
36 |
import org.eclipse.core.runtime.IStatus; |
| 37 |
import org.eclipse.core.runtime.Status; |
37 |
import org.eclipse.core.runtime.Status; |
| 38 |
import org.eclipse.jdt.core.IJavaProject; |
38 |
import org.eclipse.jdt.core.IJavaProject; |
|
Lines 57-63
Link Here
|
| 57 |
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; |
57 |
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider; |
| 58 |
import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; |
58 |
import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; |
| 59 |
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; |
59 |
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; |
| 60 |
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; |
|
|
| 61 |
|
60 |
|
| 62 |
public class NewSessionBeanClassDataModelProvider extends NewEnterpriseBeanClassDataModelProvider { |
61 |
public class NewSessionBeanClassDataModelProvider extends NewEnterpriseBeanClassDataModelProvider { |
| 63 |
|
62 |
|
|
Lines 89-94
Link Here
|
| 89 |
propertyNames.add(LOCAL_BUSINESS_INTERFACE); |
88 |
propertyNames.add(LOCAL_BUSINESS_INTERFACE); |
| 90 |
propertyNames.add(REMOTE); |
89 |
propertyNames.add(REMOTE); |
| 91 |
propertyNames.add(LOCAL); |
90 |
propertyNames.add(LOCAL); |
|
|
91 |
propertyNames.add(NO_INTERFACE); |
| 92 |
propertyNames.add(STATE_TYPE); |
92 |
propertyNames.add(STATE_TYPE); |
| 93 |
propertyNames.add(REMOTE_HOME); |
93 |
propertyNames.add(REMOTE_HOME); |
| 94 |
propertyNames.add(LOCAL_HOME); |
94 |
propertyNames.add(LOCAL_HOME); |
|
Lines 120-136
Link Here
|
| 120 |
else if (propertyName.equals(REMOTE)) |
120 |
else if (propertyName.equals(REMOTE)) |
| 121 |
return Boolean.FALSE; |
121 |
return Boolean.FALSE; |
| 122 |
else if (propertyName.equals(LOCAL)) |
122 |
else if (propertyName.equals(LOCAL)) |
| 123 |
return Boolean.TRUE; |
123 |
return new Boolean(!ejb31OrLater()); |
|
|
124 |
else if (propertyName.equals(NO_INTERFACE)) |
| 125 |
return new Boolean(ejb31OrLater()); |
| 124 |
else if (propertyName.equals(STATE_TYPE)) |
126 |
else if (propertyName.equals(STATE_TYPE)) |
| 125 |
return StateType.STATELESS.toString(); |
127 |
return StateType.STATELESS.toString(); |
| 126 |
else if (propertyName.equals(INTERFACES)) { |
128 |
else if (propertyName.equals(INTERFACES)) { |
| 127 |
List<BusinessInterface> listResult = new ArrayList<BusinessInterface>(); |
129 |
List<BusinessInterface> listResult = new ArrayList<BusinessInterface>(); |
| 128 |
String className = getStringProperty(QUALIFIED_CLASS_NAME); |
130 |
String className = getStringProperty(QUALIFIED_CLASS_NAME); |
| 129 |
if ((Boolean) getProperty(REMOTE) && className.length() > 0) { |
131 |
if (getBooleanProperty(REMOTE) && className.length() > 0) { |
| 130 |
BusinessInterface remoteInterface = new BusinessInterface(getStringProperty(REMOTE_BUSINESS_INTERFACE), BusinessInterfaceType.REMOTE); |
132 |
BusinessInterface remoteInterface = new BusinessInterface(getStringProperty(REMOTE_BUSINESS_INTERFACE), BusinessInterfaceType.REMOTE); |
| 131 |
listResult.add(remoteInterface); |
133 |
listResult.add(remoteInterface); |
| 132 |
} |
134 |
} |
| 133 |
if ((Boolean) getProperty(LOCAL) && className.length() > 0) { |
135 |
if (getBooleanProperty(LOCAL) && className.length() > 0) { |
| 134 |
BusinessInterface localInterface = new BusinessInterface(getStringProperty(LOCAL_BUSINESS_INTERFACE), BusinessInterfaceType.LOCAL); |
136 |
BusinessInterface localInterface = new BusinessInterface(getStringProperty(LOCAL_BUSINESS_INTERFACE), BusinessInterfaceType.LOCAL); |
| 135 |
listResult.add(localInterface); |
137 |
listResult.add(localInterface); |
| 136 |
} |
138 |
} |
|
Lines 188-194
Link Here
|
| 188 |
// Call super to set the property on the data model |
190 |
// Call super to set the property on the data model |
| 189 |
boolean result = super.propertySet(propertyName, propertyValue); |
191 |
boolean result = super.propertySet(propertyName, propertyValue); |
| 190 |
|
192 |
|
| 191 |
if (propertyName.equals(REMOTE)) { |
193 |
if (PROJECT_NAME.equals(propertyName)) { |
|
|
194 |
IDataModel dataModel = getDataModel(); |
| 195 |
dataModel.notifyPropertyChange(REMOTE, IDataModel.DEFAULT_CHG); |
| 196 |
dataModel.notifyPropertyChange(LOCAL, IDataModel.DEFAULT_CHG); |
| 197 |
dataModel.notifyPropertyChange(NO_INTERFACE, IDataModel.DEFAULT_CHG); |
| 198 |
dataModel.notifyPropertyChange(REMOTE_BUSINESS_INTERFACE, IDataModel.DEFAULT_CHG); |
| 199 |
dataModel.notifyPropertyChange(LOCAL_BUSINESS_INTERFACE, IDataModel.DEFAULT_CHG); |
| 200 |
} else if (CLASS_NAME.equals(propertyName) || JAVA_PACKAGE.equals(propertyName)) { |
| 201 |
IDataModel dataModel = getDataModel(); |
| 202 |
dataModel.notifyPropertyChange(REMOTE_BUSINESS_INTERFACE, IDataModel.DEFAULT_CHG); |
| 203 |
dataModel.notifyPropertyChange(LOCAL_BUSINESS_INTERFACE, IDataModel.DEFAULT_CHG); |
| 204 |
dataModel.notifyPropertyChange(REMOTE_HOME_INTERFACE, IDataModel.DEFAULT_CHG); |
| 205 |
dataModel.notifyPropertyChange(LOCAL_HOME_INTERFACE, IDataModel.DEFAULT_CHG); |
| 206 |
dataModel.notifyPropertyChange(REMOTE_COMPONENT_INTERFACE, IDataModel.DEFAULT_CHG); |
| 207 |
dataModel.notifyPropertyChange(LOCAL_COMPONENT_INTERFACE, IDataModel.DEFAULT_CHG); |
| 208 |
} else if (propertyName.equals(REMOTE)) { |
| 192 |
if (!getDataModel().isPropertySet(INTERFACES)) { |
209 |
if (!getDataModel().isPropertySet(INTERFACES)) { |
| 193 |
getDataModel().notifyPropertyChange(INTERFACES, IDataModel.DEFAULT_CHG); |
210 |
getDataModel().notifyPropertyChange(INTERFACES, IDataModel.DEFAULT_CHG); |
| 194 |
} else { |
211 |
} else { |
|
Lines 196-232
Link Here
|
| 196 |
} |
213 |
} |
| 197 |
getDataModel().notifyPropertyChange(REMOTE_BUSINESS_INTERFACE, IDataModel.ENABLE_CHG); |
214 |
getDataModel().notifyPropertyChange(REMOTE_BUSINESS_INTERFACE, IDataModel.ENABLE_CHG); |
| 198 |
|
215 |
|
| 199 |
} |
216 |
} else if (propertyName.equals(LOCAL)) { |
| 200 |
if (propertyName.equals(LOCAL)) { |
|
|
| 201 |
if (!getDataModel().isPropertySet(INTERFACES)) { |
217 |
if (!getDataModel().isPropertySet(INTERFACES)) { |
| 202 |
getDataModel().notifyPropertyChange(INTERFACES, IDataModel.DEFAULT_CHG); |
218 |
getDataModel().notifyPropertyChange(INTERFACES, IDataModel.DEFAULT_CHG); |
| 203 |
} else { |
219 |
} else { |
| 204 |
updateBusinessInterfaces(LOCAL); |
220 |
updateBusinessInterfaces(LOCAL); |
| 205 |
} |
221 |
} |
| 206 |
getDataModel().notifyPropertyChange(LOCAL_BUSINESS_INTERFACE, IDataModel.ENABLE_CHG); |
222 |
getDataModel().notifyPropertyChange(LOCAL_BUSINESS_INTERFACE, IDataModel.ENABLE_CHG); |
| 207 |
} |
223 |
} else if (REMOTE_BUSINESS_INTERFACE.equals(propertyName)) { |
| 208 |
if (REMOTE_BUSINESS_INTERFACE.equals(propertyName)) |
|
|
| 209 |
{ |
| 210 |
if(getRemoteProperty() != null){ |
224 |
if(getRemoteProperty() != null){ |
| 211 |
getRemoteProperty().setFullyQualifiedName(propertyValue.toString()); |
225 |
getRemoteProperty().setFullyQualifiedName(propertyValue.toString()); |
| 212 |
} |
226 |
} |
| 213 |
} |
227 |
} else if (LOCAL_BUSINESS_INTERFACE.equals(propertyName)) { |
| 214 |
else if (LOCAL_BUSINESS_INTERFACE.equals(propertyName)) |
|
|
| 215 |
{ |
| 216 |
if(getLocalProperty() != null){ |
228 |
if(getLocalProperty() != null){ |
| 217 |
getLocalProperty().setFullyQualifiedName(propertyValue.toString()); |
229 |
getLocalProperty().setFullyQualifiedName(propertyValue.toString()); |
| 218 |
} |
230 |
} |
| 219 |
} |
231 |
} |
| 220 |
else if (CLASS_NAME.equals(propertyName) || JAVA_PACKAGE.equals(propertyName)) |
|
|
| 221 |
{ |
| 222 |
IDataModel dataModel = getDataModel(); |
| 223 |
dataModel.notifyPropertyChange(REMOTE_BUSINESS_INTERFACE, IDataModel.DEFAULT_CHG); |
| 224 |
dataModel.notifyPropertyChange(LOCAL_BUSINESS_INTERFACE, IDataModel.DEFAULT_CHG); |
| 225 |
dataModel.notifyPropertyChange(REMOTE_HOME_INTERFACE, IDataModel.DEFAULT_CHG); |
| 226 |
dataModel.notifyPropertyChange(LOCAL_HOME_INTERFACE, IDataModel.DEFAULT_CHG); |
| 227 |
dataModel.notifyPropertyChange(REMOTE_COMPONENT_INTERFACE, IDataModel.DEFAULT_CHG); |
| 228 |
dataModel.notifyPropertyChange(LOCAL_COMPONENT_INTERFACE, IDataModel.DEFAULT_CHG); |
| 229 |
} |
| 230 |
|
232 |
|
| 231 |
return result; |
233 |
return result; |
| 232 |
} |
234 |
} |
|
Lines 262-275
Link Here
|
| 262 |
return super.getValidPropertyDescriptors(propertyName); |
264 |
return super.getValidPropertyDescriptors(propertyName); |
| 263 |
} |
265 |
} |
| 264 |
|
266 |
|
| 265 |
private boolean ejb31OrLater() { |
|
|
| 266 |
IProject project = getTargetProject(); |
| 267 |
IProjectFacetVersion facetVersion = JavaEEProjectUtilities.getProjectFacetVersion(project, IJ2EEFacetConstants.EJB); |
| 268 |
int version = J2EEVersionUtil.convertVersionStringToInt(facetVersion.getVersionString()); |
| 269 |
int ejb31version = J2EEVersionUtil.convertVersionStringToInt(IJ2EEFacetConstants.EJB_31.getVersionString()); |
| 270 |
return version >= ejb31version; |
| 271 |
} |
| 272 |
|
| 273 |
private void updateBusinessInterfaces(String propertyName) { |
267 |
private void updateBusinessInterfaces(String propertyName) { |
| 274 |
List<BusinessInterface> list = (List<BusinessInterface>) getProperty(INTERFACES); |
268 |
List<BusinessInterface> list = (List<BusinessInterface>) getProperty(INTERFACES); |
| 275 |
if (propertyName.equals(REMOTE)) { |
269 |
if (propertyName.equals(REMOTE)) { |
|
Lines 314-319
Link Here
|
| 314 |
public IStatus validate(String propertyName) { |
308 |
public IStatus validate(String propertyName) { |
| 315 |
if (STATE_TYPE.equals(propertyName)) { |
309 |
if (STATE_TYPE.equals(propertyName)) { |
| 316 |
return validateStateType(); |
310 |
return validateStateType(); |
|
|
311 |
} else if (NO_INTERFACE.equals(propertyName)) { |
| 312 |
if (getBooleanProperty(NO_INTERFACE)) { |
| 313 |
return validateNoInterface(); |
| 314 |
} |
| 317 |
} else if (LOCAL_BUSINESS_INTERFACE.equals(propertyName)) { |
315 |
} else if (LOCAL_BUSINESS_INTERFACE.equals(propertyName)) { |
| 318 |
if (getBooleanProperty(LOCAL)) { |
316 |
if (getBooleanProperty(LOCAL)) { |
| 319 |
return validateEjbInterface(getStringProperty(propertyName)); |
317 |
return validateEjbInterface(getStringProperty(propertyName)); |
|
Lines 337-343
Link Here
|
| 337 |
protected IStatus validateStateType() { |
335 |
protected IStatus validateStateType() { |
| 338 |
String value = getStringProperty(STATE_TYPE); |
336 |
String value = getStringProperty(STATE_TYPE); |
| 339 |
if (StateType.SINGLETON.toString().equals(value) && !ejb31OrLater()) { |
337 |
if (StateType.SINGLETON.toString().equals(value) && !ejb31OrLater()) { |
| 340 |
return WTPCommonPlugin.createErrorStatus(EJBCreationResourceHandler.ERR_SINGLETON_ALLOWED_ONLY_FOR_31_AND_LATER); |
338 |
return WTPCommonPlugin.createErrorStatus(EJBCreationResourceHandler.ERR_SINGLETON_NOT_ALLOWED); |
|
|
339 |
} |
| 340 |
return Status.OK_STATUS; |
| 341 |
} |
| 342 |
|
| 343 |
protected IStatus validateNoInterface() { |
| 344 |
if (!ejb31OrLater()) { |
| 345 |
return WTPCommonPlugin.createErrorStatus(EJBCreationResourceHandler.ERR_NO_INTERFACE_NOT_ALLOWED); |
| 341 |
} |
346 |
} |
| 342 |
return Status.OK_STATUS; |
347 |
return Status.OK_STATUS; |
| 343 |
} |
348 |
} |
|
Lines 448-455
Link Here
|
| 448 |
|
453 |
|
| 449 |
protected IStatus validateInterfacesList() { |
454 |
protected IStatus validateInterfacesList() { |
| 450 |
List<BusinessInterface> list = (List<BusinessInterface>) getProperty(INTERFACES); |
455 |
List<BusinessInterface> list = (List<BusinessInterface>) getProperty(INTERFACES); |
| 451 |
if (list.isEmpty() && isEJB30Project()) { |
456 |
if (list.isEmpty() && !ejb31OrLater()) { |
| 452 |
return new Status(IStatus.WARNING, EjbPlugin.PLUGIN_ID, EJBCreationResourceHandler.WRN_NO_BUSINESS_INTERFACE); |
457 |
return new Status(IStatus.WARNING, EjbPlugin.PLUGIN_ID, EJBCreationResourceHandler.WRN_NO_CLIENT_VIEW); |
| 453 |
} |
458 |
} |
| 454 |
return Status.OK_STATUS; |
459 |
return Status.OK_STATUS; |
| 455 |
} |
460 |
} |
|
Lines 493-505
Link Here
|
| 493 |
} |
498 |
} |
| 494 |
return WTPCommonPlugin.OK_STATUS; |
499 |
return WTPCommonPlugin.OK_STATUS; |
| 495 |
} |
500 |
} |
| 496 |
|
|
|
| 497 |
private boolean isEJB30Project() { |
| 498 |
try { |
| 499 |
return ProjectFacetsManager.create(getTargetProject()).hasProjectFacet(IJ2EEFacetConstants.EJB_30); |
| 500 |
} catch (CoreException e) { |
| 501 |
return false; |
| 502 |
} |
| 503 |
} |
| 504 |
|
501 |
|
|
|
502 |
private boolean ejb31OrLater() { |
| 503 |
IProject project = getTargetProject(); |
| 504 |
IProjectFacetVersion facetVersion = JavaEEProjectUtilities.getProjectFacetVersion(project, IJ2EEFacetConstants.EJB); |
| 505 |
int version = J2EEVersionUtil.convertVersionStringToInt(facetVersion.getVersionString()); |
| 506 |
int ejb31version = J2EEVersionUtil.convertVersionStringToInt(IJ2EEFacetConstants.EJB_31.getVersionString()); |
| 507 |
return version >= ejb31version; |
| 508 |
} |
| 509 |
|
| 505 |
} |
510 |
} |