Update of
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21387/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb
Modified Files:
EjbUtils.java
Log Message:
Index: EjbUtils.java
===================================================================
RCS file:
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/EjbUtils.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** EjbUtils.java 26 Aug 2005 17:52:30 -0000 1.6
--- EjbUtils.java 30 Aug 2005 00:34:33 -0000 1.7
***************
*** 32,37 ****
--- 32,39 ----
import org.xdoclet.plugin.ejb.qtags.EjbEjbRefTag;
import org.xdoclet.plugin.ejb.qtags.EjbEjbServiceRef;
+ import org.xdoclet.plugin.ejb.qtags.EjbFinderTag;
import org.xdoclet.plugin.ejb.qtags.EjbPermissionTag;
import org.xdoclet.plugin.ejb.qtags.EjbPersistenceTag;
+ import org.xdoclet.plugin.ejb.qtags.EjbPkTag;
import org.xdoclet.plugin.ejb.qtags.EjbRelationTag;
import org.xdoclet.plugin.ejb.qtags.EjbResourceEnvRefTag;
***************
*** 97,101 ****
public static final String LOCAL_HOME_INTERFACE = "LocalHome";
public static final String SERVICE_END_POINT_INTERFACE =
"ServiceEndpoint";
-
/**
* Maps primitive types to their wrapper classes
--- 99,102 ----
***************
*** 176,180 ****
* @return Collection of [EMAIL PROTECTED]
com.thoughtworks.qdox.model.JavaMethod}
*/
! public Collection getInterfaceMethods(final JavaClass clazz, final String
desiredViewType) {
if (clazz == null || desiredViewType == null) {
throw new Error();
--- 177,182 ----
* @return Collection of [EMAIL PROTECTED]
com.thoughtworks.qdox.model.JavaMethod}
*/
! public Collection getInterfaceMethods(final JavaClass clazz, final int
anyMethodTypeFlag,
! final String desiredViewType) {
if (clazz == null || desiredViewType == null) {
throw new Error();
***************
*** 186,191 ****
JavaMethod method = (JavaMethod) object;
! if (!isInterfaceMethod(method)) {
! // TODO: Will this be enough ??!?
return false;
}
--- 188,192 ----
JavaMethod method = (JavaMethod) object;
! if ((getMethodType(method) & anyMethodTypeFlag) == 0) {
return false;
}
***************
*** 209,217 ****
}
! if (method.getTagByName("ejb.create-method") != null) {
retVal |= IFACE_METHOD_CREATE;
}
! if (method.getTagByName("ejb.home-method") != null) {
retVal |= IFACE_METHOD_HOME;
}
--- 210,218 ----
}
! if (method.getName().equals("ejbCreate") &&
(method.getTagByName("ejb.create-method") != null)) {
retVal |= IFACE_METHOD_CREATE;
}
! if (method.getName().startsWith("ejbHome") &&
(method.getTagByName("ejb.home-method") != null)) {
retVal |= IFACE_METHOD_HOME;
}
***************
*** 366,374 ****
}
- public String methodName(String finderSignature) {
- int idx = finderSignature.indexOf('(');
- return idx >= 0 ? finderSignature.substring(0, idx) : finderSignature;
- }
-
public boolean isViewType(JavaClass javaClass, String viewType) {
return hasFlag(getViewType(javaClass), getViewType(viewType));
--- 367,370 ----
***************
*** 1379,1386 ****
}
! public Collection getMethodPermissions(JavaClass javaClass) {
EjbVersion version = config.getVersion();
Collection retLst = new ArrayList();
- EjbPermissionTag permTag;
DocletTag[] tags = javaClass.getTagsByName("ejb.permission");
--- 1375,1381 ----
}
! public Collection getMethodPermissions(JavaClass javaClass) throws
ClassNotFoundException {
EjbVersion version = config.getVersion();
Collection retLst = new ArrayList();
DocletTag[] tags = javaClass.getTagsByName("ejb.permission");
***************
*** 1391,1395 ****
// Let dig into class level ejb.permission tags
for (int i = 0; i < tags.length; i++) {
! permTag = (EjbPermissionTag) tags[i];
int permType = getViewType(javaClass);
--- 1386,1390 ----
// Let dig into class level ejb.permission tags
for (int i = 0; i < tags.length; i++) {
! EjbPermissionTag permTag = (EjbPermissionTag) tags[i];
int permType = getViewType(javaClass);
***************
*** 1436,1440 ****
for (int k = 0; k < tags.length; k++) {
! permTag = (EjbPermissionTag) tags[k];
int methodType = getMethodType(method);
--- 1431,1435 ----
for (int k = 0; k < tags.length; k++) {
! EjbPermissionTag permTag = (EjbPermissionTag) tags[k];
int methodType = getMethodType(method);
***************
*** 1481,1484 ****
--- 1476,1565 ----
}
+ if (isEntityBean(javaClass) || isSessionBean(javaClass)) {
+ tags = javaClass.getTagsByName("ejb.finder");
+
+ // Let dig into class level ejb.finder tags
+ for (int i = 0; i < tags.length; i++) {
+ EjbFinderTag finderTag = (EjbFinderTag) tags[i];
+ int permType = getViewType(finderTag.getViewType()) &
(REMOTE_HOME| LOCAL_HOME);
+
+ // -------------------------------------------------------
+ // Let's "bitwise and" to get only the specied masks
+ // that are compatible with the bean
+ // HUMM: Is this valid ?
+ if (finderTag.getMethodIntf() != null) {
+ permType &= getInterfaceType(finderTag.getMethodIntf());
+ }
+
+ if (permType == 0) {
+ throw getErrorWithTagLocation(finderTag, "Couldn't
resolve a compatible interface type reference");
+ }
+
+ // -------------------------------------------------------
+ // We are generating an method permission if there is at least
+ // one role or unchecked is true
+ // NOTE: unchecked is only valid for EJB 2.0+
+ boolean canContinue = (finderTag.getRoleNames() != null &&
finderTag.getRoleNames().length > 0);
+
+ if (version.greaterOrEquals(EjbVersion.EJB_2_0)) {
+ canContinue |= finderTag.isUnchecked();
+ }
+
+ if (!canContinue) {
+ throw getErrorWithTagLocation(finderTag,
+ "Couldn't resolve role-names for method permission" +
+ (version.greaterOrEquals(EjbVersion.EJB_2_0) ? " or
unchecked is false" : ""));
+ }
+
+ // Lets expand by permission for interface type
+ retLst.addAll(MethodPermission.unroll(permType,
finderTag.getRoleNames(),
+ getMethodBySignature(finderTag.getSignature())));
+ }
+ }
+
+ if (isEntityBean(javaClass)) {
+ EjbPkTag pkTag = (EjbPkTag) javaClass.getTagByName("ejb.pk");
+
+ if (pkTag != null) {
+ // -------------------------------------------------------
+ // We are generating an method permission if there is at least
+ // one role or unchecked is true
+ // NOTE: unchecked is only valid for EJB 2.0+
+ boolean canContinue = (pkTag.getRoleNames() != null &&
pkTag.getRoleNames().length > 0);
+
+ if (version.greaterOrEquals(EjbVersion.EJB_2_0)) {
+ canContinue |= pkTag.isUnchecked();
+ }
+
+ // We'll not continue this if we do not have to check a
security method for
+ // "findByPrimaryKey"
+ if (canContinue) {
+ int permType = getViewType(javaClass) & (REMOTE_HOME|
LOCAL_HOME);
+
+ // -------------------------------------------------------
+ // Let's "bitwise and" to get only the specied masks
+ // that are compatible with the bean
+ // HUMM: Is this valid ?
+ if (pkTag.getMethodIntf() != null) {
+ permType &= getInterfaceType(pkTag.getMethodIntf());
+ }
+
+ if (permType == 0) {
+ throw getErrorWithTagLocation(pkTag, "Couldn't
resolve a compatible interface type reference");
+ }
+
+ // Lets expand by permission for interface type
+ String methodSignature =
EjbRuntime.getLocalHomeInterfacePlugin()
+
.getDestinationFullyQualifiedClassName(javaClass) +
+ " findByPrimaryKey()";
+
+ // Method signature should maybe be unrolled by permType,
but it's not really relevant
+ // the return type, soo..
+ retLst.addAll(MethodPermission.unroll(permType,
pkTag.getRoleNames(),
+ getMethodBySignature(methodSignature)));
+ }
+ }
+ }
+
return retLst;
}
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
xdoclet-plugins-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-commits