tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1291379 - /openejb/trunk/maven-plugins/dd-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/dd/merger/EjbJarMerger.java
Date Mon, 20 Feb 2012 17:14:53 GMT
Author: rmannibucau
Date: Mon Feb 20 17:14:53 2012
New Revision: 1291379

URL: http://svn.apache.org/viewvc?rev=1291379&view=rev
Log:
more ejb-jar merging

Modified:
    openejb/trunk/maven-plugins/dd-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/dd/merger/EjbJarMerger.java

Modified: openejb/trunk/maven-plugins/dd-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/dd/merger/EjbJarMerger.java
URL: http://svn.apache.org/viewvc/openejb/trunk/maven-plugins/dd-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/dd/merger/EjbJarMerger.java?rev=1291379&r1=1291378&r2=1291379&view=diff
==============================================================================
--- openejb/trunk/maven-plugins/dd-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/dd/merger/EjbJarMerger.java
(original)
+++ openejb/trunk/maven-plugins/dd-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/dd/merger/EjbJarMerger.java
Mon Feb 20 17:14:53 2012
@@ -1,11 +1,18 @@
 package org.apache.openejb.maven.plugin.dd.merger;
 
 import org.apache.maven.plugin.logging.Log;
+import org.apache.openejb.jee.ApplicationException;
 import org.apache.openejb.jee.AssemblyDescriptor;
+import org.apache.openejb.jee.ContainerConcurrency;
+import org.apache.openejb.jee.ContainerTransaction;
 import org.apache.openejb.jee.EjbJar;
 import org.apache.openejb.jee.EnterpriseBean;
 import org.apache.openejb.jee.Interceptor;
+import org.apache.openejb.jee.InterceptorBinding;
 import org.apache.openejb.jee.JaxbJavaee;
+import org.apache.openejb.jee.MessageDestination;
+import org.apache.openejb.jee.MethodPermission;
+import org.apache.openejb.jee.SecurityRole;
 import org.apache.openejb.maven.plugin.dd.Merger;
 
 import java.io.BufferedInputStream;
@@ -43,8 +50,109 @@ public class EjbJarMerger extends Merger
         return reference;
     }
 
-    private static void mergeAssemblyDescriptor(final AssemblyDescriptor assemblyDescriptor,
final AssemblyDescriptor descriptor) {
-        // TODO
+    // TODO: merge it in a better way
+    private void mergeAssemblyDescriptor(final AssemblyDescriptor reference, final AssemblyDescriptor
descriptor) {
+        for (SecurityRole role : descriptor.getSecurityRole()) {
+            boolean found = false;
+            for (SecurityRole refRole : reference.getSecurityRole()) {
+                if (refRole.getRoleName().equals(role.getRoleName())) {
+                    found = true;
+                    break;
+                }
+            }
+            if (found) {
+                log.warn("role " + role.getRoleName() + " already defined");
+            } else {
+                reference.getSecurityRole().add(role);
+            }
+        }
+
+        for (MethodPermission perm : descriptor.getMethodPermission()) {
+            boolean found = false;
+            for (MethodPermission refPerm : reference.getMethodPermission()) {
+                if (refPerm.getRoleName().equals(perm.getRoleName())) {
+                    found  = true;
+                    break;
+                }
+            }
+            if (found) {
+                log.warn("method permission " + perm.getId() + " already defined");
+            } else {
+                reference.getMethodPermission().add(perm);
+            }
+        }
+
+        for (ContainerTransaction tx : descriptor.getContainerTransaction()) {
+            boolean found = false;
+            for (ContainerTransaction refTx : reference.getContainerTransaction()) {
+                if (refTx.getId().equals(tx.getId())) { // is id the good test?
+                    found = true;
+                    break;
+                }
+            }
+            if (found) {
+                log.warn("container transaction " + tx.getId() + " already defined");
+            } else {
+                reference.getContainerTransaction().add(tx);
+            }
+        }
+
+        for (ContainerConcurrency concurrency : descriptor.getContainerConcurrency()) {
+            boolean found = false;
+            for (ContainerConcurrency refConcurrency : reference.getContainerConcurrency())
{
+                if (refConcurrency.getId().equals(concurrency.getId())) { // is id the good
test?
+                    found = true;
+                    break;
+                }
+            }
+            if (found) {
+                log.warn("container concurrency " + concurrency.getId() + " already defined");
+            } else {
+                reference.getContainerConcurrency().add(concurrency);
+            }
+        }
+
+        for (InterceptorBinding interceptorBinding : descriptor.getInterceptorBinding())
{
+            boolean found = false;
+            for (InterceptorBinding refInterceptorBinding : reference.getInterceptorBinding())
{
+                if (refInterceptorBinding.getEjbName().equals(interceptorBinding.getEjbName()))
{
+                    for (String interceptor : interceptorBinding.getInterceptorClass()) {
+                        if (refInterceptorBinding.getInterceptorClass().contains(interceptor))
{
+                            found = true;
+                            break;
+                        }
+                    }
+                }
+            }
+            if (found) {
+                log.warn("interceptor binding " + interceptorBinding.getId() + " already
defined");
+            } else {
+                reference.getInterceptorBinding().add(interceptorBinding);
+            }
+        }
+
+        for (MessageDestination destination : descriptor.getMessageDestination()) {
+            boolean found = false;
+            for (MessageDestination refDestination : reference.getMessageDestination()) {
+                if (refDestination.getMessageDestinationName().equals(destination.getMessageDestinationName()))
{ // is id the good test?
+                    found = true;
+                    break;
+                }
+            }
+            if (found) {
+                log.warn("message destination " + destination.getMessageDestinationName()
+ " already defined");
+            } else {
+                reference.getMessageDestination().add(destination);
+            }
+        }
+
+        for (ApplicationException exception : descriptor.getApplicationException()) {
+            if (reference.getApplicationExceptionMap().containsKey(exception.getKey())) {
+                log.warn("application exception " + exception.getKey() + " already defined");
+            } else {
+                reference.getApplicationException().add(exception);
+            }
+        }
     }
 
     @Override



Mime
View raw message