[368506] Allow to change the default package for interfaces when creating new session EJBs
diff --git a/plugins/org.eclipse.jst.j2ee.ejb/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.j2ee.ejb/META-INF/MANIFEST.MF
index 33993dd..fdc1490 100644
--- a/plugins/org.eclipse.jst.j2ee.ejb/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jst.j2ee.ejb/META-INF/MANIFEST.MF
@@ -41,7 +41,7 @@
org.eclipse.jem.util;bundle-version="[2.0.0,3.0.0)",
org.eclipse.wst.common.project.facet.core;bundle-version="[1.1.0,2.0.0)",
org.eclipse.jst.common.project.facet.core;bundle-version="[1.1.0,2.0.0)",
- org.eclipse.wst.web;bundle-version="[1.1.0,1.2.0)",
+ org.eclipse.wst.web;bundle-version="[1.1.500,1.2.0)",
org.eclipse.emf.codegen;bundle-version="[2.4.0,3.0.0)",
org.eclipse.jst.jee;bundle-version="[1.0.0,1.1.0)"
Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.jst.j2ee.ejb/ejb/org/eclipse/jst/j2ee/ejb/internal/operations/NewSessionBeanClassDataModelProvider.java b/plugins/org.eclipse.jst.j2ee.ejb/ejb/org/eclipse/jst/j2ee/ejb/internal/operations/NewSessionBeanClassDataModelProvider.java
index fb0eca8..00fed1b 100644
--- a/plugins/org.eclipse.jst.j2ee.ejb/ejb/org/eclipse/jst/j2ee/ejb/internal/operations/NewSessionBeanClassDataModelProvider.java
+++ b/plugins/org.eclipse.jst.j2ee.ejb/ejb/org/eclipse/jst/j2ee/ejb/internal/operations/NewSessionBeanClassDataModelProvider.java
@@ -8,6 +8,7 @@
* Contributors:
* Kaloyan Raev, kaloyan.raev@sap.com - initial API and implementation
* Roberto Sanchez, rsanchez@mx1.ibm.com - Add remote and local annotations to bean class
+ * Roberto Sanchez, rsanchez@mx1.ibm.com - Allow adopter to change default value of package for interfaces
*******************************************************************************/
package org.eclipse.jst.j2ee.ejb.internal.operations;
@@ -144,33 +145,39 @@
}
return listResult;
}
- else if (REMOTE_BUSINESS_INTERFACE.equals(propertyName)) {
- String className = getStringProperty(QUALIFIED_CLASS_NAME);
- return className + ((className != null && className.length() > 0) ? REMOTE_SUFFIX : ""); //$NON-NLS-1$
- }
+ else if (REMOTE_BUSINESS_INTERFACE.equals(propertyName)) {
+ String className = getStringProperty(QUALIFIED_CLASS_NAME);
+ String packageSuffix = J2EEPlugin.getDefault().getJ2EEPreferences().getString(IProductConstants.EJB_INTERFACE_PACKAGE_SUFFIX);
+ return buildInterfaceName(className, REMOTE_SUFFIX, packageSuffix);
+ }
else if (LOCAL_BUSINESS_INTERFACE.equals(propertyName)) {
String className = getStringProperty(QUALIFIED_CLASS_NAME);
- return className + ((className != null && className.length() > 0) ? LOCAL_SUFFIX : ""); //$NON-NLS-1$
+ String packageSuffix = J2EEPlugin.getDefault().getJ2EEPreferences().getString(IProductConstants.EJB_INTERFACE_PACKAGE_SUFFIX);
+ return buildInterfaceName(className, LOCAL_SUFFIX, packageSuffix);
}
else if (REMOTE_HOME_INTERFACE.equals(propertyName))
{
String className = getStringProperty(QUALIFIED_CLASS_NAME);
- return className + REMOTE_HOME_SUFFIX;
+ String packageSuffix = J2EEPlugin.getDefault().getJ2EEPreferences().getString(IProductConstants.EJB_INTERFACE_PACKAGE_SUFFIX);
+ return buildInterfaceName(className, REMOTE_HOME_SUFFIX, packageSuffix);
}
else if (LOCAL_HOME_INTERFACE.equals(propertyName))
{
String className = getStringProperty(QUALIFIED_CLASS_NAME);
- return className + LOCAL_HOME_SUFFIX;
+ String packageSuffix = J2EEPlugin.getDefault().getJ2EEPreferences().getString(IProductConstants.EJB_INTERFACE_PACKAGE_SUFFIX);
+ return buildInterfaceName(className, LOCAL_HOME_SUFFIX, packageSuffix);
}
else if (LOCAL_COMPONENT_INTERFACE.equals(propertyName))
{
String className = getStringProperty(QUALIFIED_CLASS_NAME);
- return className + LOCAL_COMPONENT_SUFFIX;
+ String packageSuffix = J2EEPlugin.getDefault().getJ2EEPreferences().getString(IProductConstants.EJB_INTERFACE_PACKAGE_SUFFIX);
+ return buildInterfaceName(className, LOCAL_COMPONENT_SUFFIX, packageSuffix);
}
else if (REMOTE_COMPONENT_INTERFACE.equals(propertyName))
{
String className = getStringProperty(QUALIFIED_CLASS_NAME);
- return className + REMOTE_COMPONENT_SUFFIX;
+ String packageSuffix = J2EEPlugin.getDefault().getJ2EEPreferences().getString(IProductConstants.EJB_INTERFACE_PACKAGE_SUFFIX);
+ return buildInterfaceName(className, REMOTE_COMPONENT_SUFFIX, packageSuffix);
}
else if (BUSINESS_INTERFACE_ANNOTATION_LOCATION.equals(propertyName))
{
@@ -189,6 +196,27 @@
return super.getDefaultProperty(propertyName);
}
+
+ private String buildInterfaceName(final String qualifiedBeanClassName, final String interfaceSuffix,
+ final String interfacePackageSuffix) {
+
+ boolean usePackageSuffix = (interfacePackageSuffix != null && interfacePackageSuffix.length() > 0);
+ String interfaceName = qualifiedBeanClassName + ((qualifiedBeanClassName != null && qualifiedBeanClassName.length() > 0) ? interfaceSuffix : ""); //$NON-NLS-1$
+
+ if (!usePackageSuffix || interfaceName.equals("")){ //$NON-NLS-1$
+ return interfaceName;
+ }
+ StringBuffer buf = new StringBuffer(interfaceName);
+
+ int index = buf.lastIndexOf("."); //$NON-NLS-1$
+ if (index == -1){
+ return buf.insert(0, interfacePackageSuffix + ".").toString(); //$NON-NLS-1$
+ }
+ return buf.insert(index, "." + interfacePackageSuffix).toString(); //$NON-NLS-1$
+ }
+
+
+
/**
* Subclasses may extend this method to add their own specific behavior when a certain property
* in the data model hierarchy is set. This method does not accept null for the property name,