bean.setTransactionType(TransactionType.CONTAINER);
break;
}
}
AssemblyDescriptor assemblyDescriptor = ejbModule.getEjbJar().getAssemblyDescriptor();
if (assemblyDescriptor == null) {
assemblyDescriptor = new AssemblyDescriptor();
ejbModule.getEjbJar().setAssemblyDescriptor(assemblyDescriptor);
}
if (bean.getTransactionType() == TransactionType.CONTAINER) {
Map<String, List<MethodTransaction>> methodTransactions = assemblyDescriptor.getMethodTransactions(ejbName);
// SET THE DEFAULT
if (!methodTransactions.containsKey("*")) {
TransactionAttribute attribute = clazz.getAnnotation(TransactionAttribute.class);
if (attribute != null) {
ContainerTransaction ctx = new ContainerTransaction(cast(attribute.value()), ejbName, "*");
assemblyDescriptor.getContainerTransaction().add(ctx);
}
}
List<Method> methods = classFinder.findAnnotatedMethods(TransactionAttribute.class);
for (Method method : methods) {
TransactionAttribute attribute = method.getAnnotation(TransactionAttribute.class);
if (!methodTransactions.containsKey(method.getName())) {
// no method with this name in descriptor
addContainerTransaction(attribute, ejbName, method, assemblyDescriptor);
} else {
// method name already declared
List<MethodTransaction> list = methodTransactions.get(method.getName());
for (MethodTransaction mtx : list) {
MethodParams methodParams = mtx.getMethodParams();
if (methodParams == null) {
// params not specified, so this is more specific
addContainerTransaction(attribute, ejbName, method, assemblyDescriptor);
} else {
List<String> params1 = methodParams.getMethodParam();
String[] params2 = asStrings(method.getParameterTypes());
if (params1.size() != params2.length) {
// params not the same
addContainerTransaction(attribute, ejbName, method, assemblyDescriptor);
} else {
for (int i = 0; i < params1.size(); i++) {
String a = params1.get(i);
String b = params2[i];
if (!a.equals(b)) {
// params not the same
addContainerTransaction(attribute, ejbName, method, assemblyDescriptor);
break;
}
}
}
}
}
}
}
}
RolesAllowed rolesAllowed = clazz.getAnnotation(RolesAllowed.class);
if (rolesAllowed != null) {
MethodPermission methodPermission = new MethodPermission();
methodPermission.getRoleName().addAll(Arrays.asList(rolesAllowed.value()));
methodPermission.getMethod().add(new org.apache.openejb.jee.Method(ejbName, "*"));
assemblyDescriptor.getMethodPermission().add(methodPermission);
}
for (Method method : classFinder.findAnnotatedMethods(RolesAllowed.class)) {
rolesAllowed = method.getAnnotation(RolesAllowed.class);
MethodPermission methodPermission = new MethodPermission();
methodPermission.getRoleName().addAll(Arrays.asList(rolesAllowed.value()));
methodPermission.getMethod().add(new org.apache.openejb.jee.Method(ejbName, method));
assemblyDescriptor.getMethodPermission().add(methodPermission);
}
PermitAll permitAll = clazz.getAnnotation(PermitAll.class);
if (permitAll != null) {
MethodPermission methodPermission = new MethodPermission();
methodPermission.setUnchecked(true);
methodPermission.getMethod().add(new org.apache.openejb.jee.Method(ejbName, "*"));
assemblyDescriptor.getMethodPermission().add(methodPermission);
}
for (Method method : classFinder.findAnnotatedMethods(PermitAll.class)) {
MethodPermission methodPermission = new MethodPermission();
methodPermission.setUnchecked(true);
methodPermission.getMethod().add(new org.apache.openejb.jee.Method(ejbName, method));
assemblyDescriptor.getMethodPermission().add(methodPermission);
}
for (Method method : classFinder.findAnnotatedMethods(DenyAll.class)) {
ExcludeList excludeList = assemblyDescriptor.getExcludeList();
excludeList.addMethod(new org.apache.openejb.jee.Method(ejbName, method));
}
RunAs runAs = clazz.getAnnotation(RunAs.class);
if (runAs != null && bean.getSecurityIdentity() == null) {
SecurityIdentity securityIdentity = new SecurityIdentity();
securityIdentity.setRunAs(runAs.value());
bean.setSecurityIdentity(securityIdentity);
}
DeclareRoles declareRoles = clazz.getAnnotation(DeclareRoles.class);
if (declareRoles != null && bean instanceof RemoteBean){
RemoteBean remoteBean = (RemoteBean) bean;
List<SecurityRoleRef> securityRoleRefs = remoteBean.getSecurityRoleRef();
for (String role : declareRoles.value()) {
securityRoleRefs.add(new SecurityRoleRef(role));
}
}
Interceptors interceptors = clazz.getAnnotation(Interceptors.class);
if (interceptors != null) {
EjbJar ejbJar = ejbModule.getEjbJar();
for (Class interceptor : interceptors.value()) {
if (ejbJar.getInterceptor(interceptor.getName()) == null) {
ejbJar.addInterceptor(new Interceptor(interceptor.getName()));
}
}
InterceptorBinding binding = new InterceptorBinding(bean);
assemblyDescriptor.getInterceptorBinding().add(0, binding);
for (Class interceptor : interceptors.value()) {
binding.getInterceptorClass().add(interceptor.getName());
}
}
for (Method method : classFinder.findAnnotatedMethods(Interceptors.class)) {
interceptors = method.getAnnotation(Interceptors.class);
if (interceptors != null) {
EjbJar ejbJar = ejbModule.getEjbJar();
for (Class interceptor : interceptors.value()) {
if (ejbJar.getInterceptor(interceptor.getName()) == null) {
ejbJar.addInterceptor(new Interceptor(interceptor.getName()));
}
}
InterceptorBinding binding = new InterceptorBinding(bean);
assemblyDescriptor.getInterceptorBinding().add(0, binding);
for (Class interceptor : interceptors.value()) {
binding.getInterceptorClass().add(interceptor.getName());
}
binding.setMethod(new NamedMethod(method));
}
}
ExcludeDefaultInterceptors excludeDefaultInterceptors = clazz.getAnnotation(ExcludeDefaultInterceptors.class);
if (excludeDefaultInterceptors != null) {
InterceptorBinding binding = assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(bean));
binding.setExcludeDefaultInterceptors(true);
}
for (Method method : classFinder.findAnnotatedMethods(ExcludeDefaultInterceptors.class)) {
InterceptorBinding binding = assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(bean));
binding.setExcludeDefaultInterceptors(true);
binding.setMethod(new NamedMethod(method));
}
ExcludeClassInterceptors excludeClassInterceptors = clazz.getAnnotation(ExcludeClassInterceptors.class);
if (excludeClassInterceptors != null) {
InterceptorBinding binding = assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(bean));
binding.setExcludeClassInterceptors(true);
}
for (Method method : classFinder.findAnnotatedMethods(ExcludeClassInterceptors.class)) {
InterceptorBinding binding = assemblyDescriptor.addInterceptorBinding(new InterceptorBinding(bean));
binding.setExcludeClassInterceptors(true);
binding.setMethod(new NamedMethod(method));
}
if (bean instanceof RemoteBean) {