use of org.apache.openejb.jee.Method in project tomee by apache.
the class EjbJarInfoBuilder method copyConcurrentMethods.
private void copyConcurrentMethods(final SessionBean bean, final EjbJarInfo ejbJarInfo, final Map ejbds) {
for (final ConcurrentMethod method : bean.getConcurrentMethod()) {
final MethodConcurrencyInfo info = new MethodConcurrencyInfo();
if (method.getLock() != null) {
info.concurrencyAttribute = method.getLock().toString();
}
info.accessTimeout = toInfo(method.getAccessTimeout());
final Method m = new Method(bean.getEjbName(), null, method.getMethod().getMethodName());
m.setMethodParams(method.getMethod().getMethodParams());
info.methods.add(getMethodInfo(m, ejbds));
ejbJarInfo.methodConcurrency.add(info);
}
}
use of org.apache.openejb.jee.Method in project tomee by apache.
the class DebuggableVmHackery method deploy.
public AppModule deploy(final AppModule appModule) throws OpenEJBException {
for (final EjbModule ejbModule : appModule.getEjbModules()) {
final EjbJar ejbJar = ejbModule.getEjbJar();
final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName();
ejbJar.setRelationships(null);
final List<String> removed = new ArrayList<>();
for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
final String ejbName = bean.getEjbName();
final EjbDeployment ejbDeployment = deployments.get(ejbName);
pruneRefs(bean, ejbDeployment);
// }
if (!(bean instanceof MessageDrivenBean) && !(bean instanceof EntityBean)) {
continue;
}
ejbJar.removeEnterpriseBean(ejbName);
openejbJar.removeEjbDeployment(ejbDeployment);
removed.add(ejbName);
final AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
if (assemblyDescriptor != null) {
for (final MethodPermission permission : copy(assemblyDescriptor.getMethodPermission())) {
for (final Method method : copy(permission.getMethod())) {
if (method.getEjbName().equals(ejbName)) {
permission.getMethod().remove(method);
}
}
if (permission.getMethod().size() == 0) {
assemblyDescriptor.getMethodPermission().remove(permission);
}
}
for (final ContainerTransaction transaction : copy(assemblyDescriptor.getContainerTransaction())) {
for (final Method method : copy(transaction.getMethod())) {
if (method.getEjbName().equals(ejbName)) {
transaction.getMethod().remove(method);
}
}
if (transaction.getMethod().size() == 0) {
assemblyDescriptor.getContainerTransaction().remove(transaction);
}
}
for (final InterceptorBinding binding : copy(assemblyDescriptor.getInterceptorBinding())) {
if (binding.getEjbName().equals(ejbName)) {
assemblyDescriptor.getInterceptorBinding().remove(binding);
}
}
}
}
// Drop any ejb ref to with an ejb-link to a removed ejb
for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
bean.getEjbLocalRefMap().keySet().removeAll(removed);
bean.getEjbRefMap().keySet().removeAll(removed);
}
for (final Interceptor interceptor : ejbJar.getInterceptors()) {
pruneRefs(interceptor, new EjbDeployment());
}
}
return appModule;
}
use of org.apache.openejb.jee.Method in project tomee by apache.
the class EjbJarInfoBuilder method getMethodInfos.
private List<MethodInfo> getMethodInfos(final List<Method> ms, final Map ejbds) {
if (ms == null) {
return Collections.emptyList();
}
final List<MethodInfo> mi = new ArrayList<>(ms.size());
for (final Method method : ms) {
final MethodInfo methodInfo = getMethodInfo(method, ejbds);
mi.add(methodInfo);
}
return mi;
}
use of org.apache.openejb.jee.Method in project tomee by apache.
the class RemoveWebServices method deploy.
public AppModule deploy(final AppModule appModule) throws OpenEJBException {
for (final EjbModule ejbModule : appModule.getEjbModules()) {
final EjbJar ejbJar = ejbModule.getEjbJar();
final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName();
for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
final String ejbName = bean.getEjbName();
final EjbDeployment ejbDeployment = deployments.get(ejbName);
// Clear any <service-ref> references from ejbs
bean.getServiceRef().clear();
if (!(bean instanceof SessionBean)) {
continue;
}
final SessionBean sessionBean = (SessionBean) bean;
if (sessionBean.getServiceEndpoint() == null) {
continue;
}
sessionBean.setServiceEndpoint(null);
// if not, then we should just delete it
if (sessionBean.getHome() != null) {
continue;
}
if (sessionBean.getLocalHome() != null) {
continue;
}
if (sessionBean.getBusinessLocal().size() > 0) {
continue;
}
if (sessionBean.getBusinessRemote().size() > 0) {
continue;
}
// Ok, delete away...
ejbJar.removeEnterpriseBean(ejbName);
openejbJar.removeEjbDeployment(ejbDeployment);
// As well, let's get rid of any transaction or security attributes
// associated with the bean we just deleted.
final AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
if (assemblyDescriptor != null) {
for (final MethodPermission permission : copy(assemblyDescriptor.getMethodPermission())) {
for (final Method method : copy(permission.getMethod())) {
if (method.getEjbName().equals(ejbName)) {
permission.getMethod().remove(method);
}
}
if (permission.getMethod().size() == 0) {
assemblyDescriptor.getMethodPermission().remove(permission);
}
}
for (final ContainerTransaction transaction : copy(assemblyDescriptor.getContainerTransaction())) {
for (final Method method : copy(transaction.getMethod())) {
if (method.getEjbName().equals(ejbName)) {
transaction.getMethod().remove(method);
}
}
if (transaction.getMethod().size() == 0) {
assemblyDescriptor.getContainerTransaction().remove(transaction);
}
}
for (final InterceptorBinding binding : copy(assemblyDescriptor.getInterceptorBinding())) {
if (binding.getEjbName().equals(ejbName)) {
assemblyDescriptor.getInterceptorBinding().remove(binding);
}
}
}
}
// Clear any <service-ref> references from interceptors
for (final Interceptor interceptor : ejbJar.getInterceptors()) {
interceptor.getServiceRef().clear();
}
}
return appModule;
}
use of org.apache.openejb.jee.Method in project tomee by apache.
the class CheckAssemblyBindings method validate.
public void validate(final EjbModule ejbModule) {
checkUnusedInterceptors(ejbModule);
final Map<String, EnterpriseBean> ejbsByName = ejbModule.getEjbJar().getEnterpriseBeansByEjbName();
final AssemblyDescriptor assembly = ejbModule.getEjbJar().getAssemblyDescriptor();
if (assembly == null) {
return;
}
for (final InterceptorBinding binding : assembly.getInterceptorBinding()) {
final List<String> interceptorClasses = binding.getInterceptorClass();
if (binding.getInterceptorOrder() != null) {
interceptorClasses.addAll(binding.getInterceptorOrder().getInterceptorClass());
}
if (binding.getEjbName() != null && !binding.getEjbName().equals("*") && !ejbsByName.containsKey(binding.getEjbName())) {
fail("InterceptorBinding", "interceptorBinding.noSuchEjbName", binding.getEjbName(), join(",", interceptorClasses));
}
if (binding.getMethod() != null) {
if (binding.getEjbName() == null) {
fail("InterceptorBinding", "interceptorBinding.ejbNameRequiredWithMethod", binding.getMethod().getMethodName(), join(",", interceptorClasses));
}
}
}
for (final MethodPermission permission : assembly.getMethodPermission()) {
for (final Method method : permission.getMethod()) {
if (method.getEjbName() == null) {
fail("MethodPermission", "methodPermission.ejbNameRequired", method.getMethodName(), join(",", permission.getRoleName()));
} else if (method.getEjbName().equals("*")) {
// NOPMD
// no-op. Just continue the loop.
} else if (!ejbsByName.containsKey(method.getEjbName())) {
fail("MethodPermission", "methodPermission.noSuchEjbName", method.getEjbName(), method.getMethodName(), join(",", permission.getRoleName()));
}
}
}
for (final ContainerTransaction transaction : assembly.getContainerTransaction()) {
for (final Method method : transaction.getMethod()) {
if (method.getEjbName() == null) {
fail("ContainerTransaction", "containerTransaction.ejbNameRequired", method.getMethodName(), transaction.getTransAttribute());
} else if (method.getEjbName().equals("*")) {
// NOPMD
// no-op. Just continue the loop.
} else if (!ejbsByName.containsKey(method.getEjbName())) {
fail("ContainerTransaction", "containerTransaction.noSuchEjbName", method.getEjbName(), method.getMethodName(), transaction.getTransAttribute());
}
}
}
}
Aggregations