Author: snicoll
Date: Wed May 30 19:24:18 2007
New Revision: 543023

URL: http://svn.apache.org/viewvc?view=rev&rev=543023
Log:
MEAR-50: Added simple loader repository support
Submitted by: Maurice Zeijen
Reviewed by: Stephane Nicoll

Added:
    
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/
    
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/expected-META-INF/
    
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/expected-META-INF/application.xml
    
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/expected-META-INF/jboss-app.xml
    
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/pom.xml
Modified:
    
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java
    
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossAppXmlWriter.java
    
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossConfiguration.java
    
maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/generating-jboss-app.apt
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt
    
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java

Modified: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java?view=diff&rev=543023&r1=543022&r2=543023
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java
 Wed May 30 19:24:18 2007
@@ -289,10 +289,11 @@
                 final String securityDomain = jboss.getChild( 
JbossConfiguration.SECURITY_DOMAIN ).getValue();
                 final String unauthenticatedPrincipal =
                     jboss.getChild( 
JbossConfiguration.UNAUHTHENTICTED_PRINCIPAL ).getValue();
+                final String loaderRepository = jboss.getChild( 
JbossConfiguration.LOADER_REPOSITORY ).getValue();
                 final String jmxName = jboss.getChild( 
JbossConfiguration.JMX_NAME ).getValue();
 
                 jbossConfiguration =
-                    new JbossConfiguration( version, securityDomain, 
unauthenticatedPrincipal, jmxName );
+                    new JbossConfiguration( version, securityDomain, 
unauthenticatedPrincipal, jmxName, loaderRepository );
             }
             catch ( PlexusConfigurationException e )
             {

Modified: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossAppXmlWriter.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossAppXmlWriter.java?view=diff&rev=543023&r1=543022&r2=543023
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossAppXmlWriter.java
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossAppXmlWriter.java
 Wed May 30 19:24:18 2007
@@ -58,7 +58,7 @@
         final Writer w = initializeWriter( destinationFile );
 
         XMLWriter writer = null;
-        if ( jbossConfiguration.isJbossThreeDot2() )
+        if ( jbossConfiguration.isJbossThreeDotTwo() )
         {
             writer = initializeXmlWriter( w, DOCTYPE_3_2 );
         }
@@ -83,6 +83,14 @@
                 writer.writeText( 
jbossConfiguration.getUnauthenticatedPrincipal() );
                 writer.endElement();
             }
+        }
+
+        // classloader repository
+        if ( jbossConfiguration.getLoaderRepository() != null )
+        {
+            writer.startElement( JbossConfiguration.LOADER_REPOSITORY );
+            writer.writeText( jbossConfiguration.getLoaderRepository() );
+            writer.endElement();
         }
 
         // jmx name

Modified: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossConfiguration.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossConfiguration.java?view=diff&rev=543023&r1=543022&r2=543023
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossConfiguration.java
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossConfiguration.java
 Wed May 30 19:24:18 2007
@@ -41,10 +41,12 @@
 
     static final String JMX_NAME = "jmx-name";
 
+    static final String LOADER_REPOSITORY = "loader-repository";
+
 
     private final String version;
 
-    private boolean jbossThreeDot2;
+    private boolean jbossThreeDotTwo;
 
     private boolean jbossFour;
 
@@ -54,8 +56,11 @@
 
     private final String jmxName;
 
+    private final String loaderRepository;
+
 
-    public JbossConfiguration( String version, String securityDomain, String 
unauthenticatedPrincipal, String jmxName )
+    public JbossConfiguration( String version, String securityDomain, String 
unauthenticatedPrincipal, String jmxName,
+                               String loaderRepository )
         throws EarPluginException
     {
         if ( version == null )
@@ -67,7 +72,7 @@
             this.version = version;
             if ( version.equals( JbossConfiguration.VERSION_3_2 ) )
             {
-                this.jbossThreeDot2 = true;
+                this.jbossThreeDotTwo = true;
             }
             else if ( version.equals( JbossConfiguration.VERSION_4 ) )
             {
@@ -81,6 +86,7 @@
             this.securityDomain = securityDomain;
             this.unauthenticatedPrincipal = unauthenticatedPrincipal;
             this.jmxName = jmxName;
+            this.loaderRepository = loaderRepository;
         }
     }
 
@@ -99,9 +105,9 @@
      *
      * @return if the targeted version is 3.2
      */
-    public boolean isJbossThreeDot2()
+    public boolean isJbossThreeDotTwo()
     {
-        return jbossThreeDot2;
+        return jbossThreeDotTwo;
     }
 
     /**
@@ -160,4 +166,18 @@
         return jmxName;
     }
 
+    /**
+     * The loader-repository specifies the name of the UnifiedLoaderRepository
+     * MBean to use for the ear to provide ear level scoping of classes 
deployed
+     * in the ear. It is a unique JMX ObjectName string.
+     * <p/>
+     * <P>Example:</P>
+     * 
<loader-repository>jboss.test:loader=cts-cmp2v1-sar.ear</loader-repository>
+     *
+     * @return the object name of the ear mbean
+     */
+    public String getLoaderRepository()
+    {
+        return loaderRepository;
+    }
 }

Modified: 
maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/generating-jboss-app.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/generating-jboss-app.apt?view=diff&rev=543023&r1=543022&r2=543023
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/generating-jboss-app.apt
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/generating-jboss-app.apt
 Wed May 30 19:24:18 2007
@@ -27,7 +27,7 @@
 Generating the JBoss deployment descriptor file
 
   To trigger the generation of the jboss-app.xml file you need to configure 
the 'jboss' element. For instance
-  to target version 4 of JBoss with a 'guest' unauthenticated principal:
+  to target version 4 of JBoss with a 'guest' unauthenticated principal and a 
scoped classloader:
 
 +--------
   <build>
@@ -40,6 +40,7 @@
            <jboss>
              <version>4</version>
              <unauthenticated-principal>guest</unauthenticated-principal>
+             
<loader-repository>com.foo:loader=foo-application-1.0.ear</loader-repository>
            </jboss>
         </configuration>
       </plugin>

Modified: maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt?view=diff&rev=543023&r1=543022&r2=543023
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt Wed May 30 
19:24:18 2007
@@ -106,5 +106,6 @@
 
   * project-038: builds an EAR and make sure that a non-classified dependency 
with mutiple candidates is detected when specifying the mainArtifactId as 
classifier
   
+  * project-039: builds an EAR with a Jboss 4 configuration specifying the 
loader repository to use
 
    

Modified: maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt?view=diff&rev=543023&r1=543022&r2=543023
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt Wed May 30 
19:24:18 2007
@@ -122,7 +122,10 @@
 
    * <<unauthenticated-principal>>: the unauthenticated principal (JBoss 4 
only)
 
+   * <<loader-repository>>: the name of the UnifiedLoaderRepository MBean to 
use for the ear to provide ear level scoping of classes deployed in the ear 
+   
    * <<jmx-name>>: the object name of the ear mbean.
+  
 
   Hibernate archives (HAR) and Service archives (SAR) will be recognized 
automatically
   and added the the jboss-app.xml file.

Modified: 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java?view=diff&rev=543023&r1=543022&r2=543023
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java
 (original)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java
 Wed May 30 19:24:18 2007
@@ -412,4 +412,13 @@
                        new boolean[]{false, true} );
     }
 
+    /**
+     * Builds an EAR with a Jboss 4 configuration specifying specifying the 
loader repository to use.
+     */
+    public void testProject039()
+        throws Exception
+    {
+        doTestProject( "project-039", new String[]{"ejb-sample-one-1.0.jar", 
"ejb-sample-two-1.0.jar"} );
+    }
+
 }

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/expected-META-INF/application.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/expected-META-INF/application.xml?view=auto&rev=543023
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/expected-META-INF/application.xml
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/expected-META-INF/application.xml
 Wed May 30 19:24:18 2007
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<!DOCTYPE application PUBLIC
+       "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+       "http://java.sun.com/dtd/application_1_3.dtd";>
+<application>
+  <display-name>maven-ear-plugin-test-project-039</display-name>
+  <module>
+    <ejb>ejb-sample-two-1.0.jar</ejb>
+  </module>
+  <module>
+    <ejb>ejb-sample-one-1.0.jar</ejb>
+  </module>
+</application>

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/expected-META-INF/jboss-app.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/expected-META-INF/jboss-app.xml?view=auto&rev=543023
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/expected-META-INF/jboss-app.xml
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/expected-META-INF/jboss-app.xml
 Wed May 30 19:24:18 2007
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<!DOCTYPE jboss-app PUBLIC
+       "-//JBoss//DTD J2EE Application 1.4//EN"
+       "http://www.jboss.org/j2ee/dtd/jboss-app_4_0.dtd";>
+<jboss-app>
+  <loader-repository>com.foo:loader=foo-application-1.0.ear</loader-repository>
+</jboss-app>
\ No newline at end of file

Added: 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/pom.xml?view=auto&rev=543023
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-039/pom.xml
 Wed May 30 19:24:18 2007
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>ear</groupId>
+  <artifactId>maven-ear-plugin-test-project-039</artifactId>
+  <version>99.0</version>
+  <name>Maven</name>
+  <packaging>ear</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>ejb-sample-one</artifactId>
+      <version>1.0</version>
+      <type>ejb</type>
+    </dependency>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>ejb-sample-two</artifactId>
+      <version>1.0</version>
+      <type>ejb</type>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <configuration>
+          <jboss>
+            <version>4</version>
+            
<loader-repository>com.foo:loader=foo-application-1.0.ear</loader-repository>
+          </jboss>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>


Reply via email to