// Let dig into class level ejb.permission tags
tags = javaClass.getTagsByName(TagLibrary.EJB_PERMISSION);
for (int i = 0; i < tags.length; i++) {
EjbPermissionTag permTag = (EjbPermissionTag) tags[i];
int permType = getViewType(javaClass);
// -------------------------------------------------------
// Let's "bitwise and" to get only the specied masks
// that are compatible with the bean
// HUMM: Is this valid ?
if (permTag.getViewType() != null) {
permType &= getViewType(permTag.getViewType());
} else if (permTag.getMethodIntf() != null) {
permType &= getInterfaceType(permTag.getMethodIntf());
}
if (permType == 0) {
throw getErrorWithTagLocation(permTag,
"Couldn't resolve a compatible interface type reference. Maybe bean/view-type/version doesn't support it!");
}
// -------------------------------------------------------
// 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 = (permTag.getRoleNames() != null && permTag.getRoleNames().length > 0);
if (version.greaterOrEquals(EjbVersion.EJB_2_0)) {
canContinue |= permTag.isUnchecked();
}
if (!canContinue) {
throw getErrorWithTagLocation(permTag,
"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, permTag.getRoleNames()));
}
// Now let's dig into method level ejb.permission tags
JavaMethod[] methods = javaClass.getMethods();
JavaMethod method;
for (int j = 0; j < methods.length; j++) {
tags = (method = methods[j]).getTagsByName(TagLibrary.EJB_PERMISSION);
for (int k = 0; k < tags.length; k++) {
EjbPermissionTag permTag = (EjbPermissionTag) tags[k];
int methodType = getMethodType(method);
if ((methodType != IFACE_METHOD_CREATE) && (methodType != IFACE_METHOD_COMPONENT)) {
throw getErrorWithTagLocation(permTag,
"Can't mark a method permission on a non interface or create method");
}
int permType = getViewType(method, javaClass);
// -------------------------------------------------------
// Let's "bitwise and" to get only the specied masks
// that are compatible with the bean
// HUMM: Is this valid ?
if (permTag.getViewType() != null) {
permType &= getViewType(permTag.getViewType());
} else if (permTag.getMethodIntf() != null) {
permType &= getInterfaceType(permTag.getMethodIntf());
}
if (permType == 0) {
throw getErrorWithTagLocation(permTag,
"Couldn't resolve a compatible interface type reference. Maybe bean/view-type/version doesn't support it!");
}
// -------------------------------------------------------
// 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 = (permTag.getRoleNames() != null && permTag.getRoleNames().length > 0);
if (version.greaterOrEquals(EjbVersion.EJB_2_0)) {
canContinue |= permTag.isUnchecked();
}
if (!canContinue) {
throw getErrorWithTagLocation(permTag,
"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, externalizeMethodName(method), permTag.getRoleNames()));
}
}
if (isEntityBean(javaClass)) {
tags = javaClass.getTagsByName(TagLibrary.EJB_FINDER);