[jboss-cvs] JBossAS SVN: r102036 - in projects/metadata/common/trunk/src: main/java/org/jboss/metadata/javaee/support and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Mar 7 10:17:02 EST 2010


Author: bstansberry at jboss.com
Date: 2010-03-07 10:17:01 -0500 (Sun, 07 Mar 2010)
New Revision: 102036

Added:
   projects/metadata/common/trunk/src/main/java/org/jboss/metadata/javaee/jboss/NamedModule.java
   projects/metadata/common/trunk/src/main/java/org/jboss/metadata/javaee/support/NamedModuleImpl.java
   projects/metadata/common/trunk/src/test/java/org/jboss/test/metadata/javaee/NamedModuleImplUnitTestCase.java
Log:
[JBMETA-260] Add common support for EE 6 module-name concept

Added: projects/metadata/common/trunk/src/main/java/org/jboss/metadata/javaee/jboss/NamedModule.java
===================================================================
--- projects/metadata/common/trunk/src/main/java/org/jboss/metadata/javaee/jboss/NamedModule.java	                        (rev 0)
+++ projects/metadata/common/trunk/src/main/java/org/jboss/metadata/javaee/jboss/NamedModule.java	2010-03-07 15:17:01 UTC (rev 102036)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.metadata.javaee.jboss;
+
+/**
+ * Information about an EE module's name as discussed in EE 6 Section EE.8.1.1.
+ *
+ * @author Brian Stansberry
+ * 
+ * @version $Revision$
+ */
+public interface NamedModule
+{
+   /**
+    * Gets the name of the module as configured in its deployment descriptor.
+    * 
+    * @return the name, or <code>null</code> if no module name was configured
+    *         in the deployment descriptor
+    */
+   String getModuleName();
+   
+   /**
+    * Sets the name of the module as configured in its deployment descriptor.
+    * 
+    * param moduleName the name as configured in the deployment descriptor
+    */
+   void setModuleName(String moduleName);
+}

Added: projects/metadata/common/trunk/src/main/java/org/jboss/metadata/javaee/support/NamedModuleImpl.java
===================================================================
--- projects/metadata/common/trunk/src/main/java/org/jboss/metadata/javaee/support/NamedModuleImpl.java	                        (rev 0)
+++ projects/metadata/common/trunk/src/main/java/org/jboss/metadata/javaee/support/NamedModuleImpl.java	2010-03-07 15:17:01 UTC (rev 102036)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.metadata.javaee.support;
+
+import org.jboss.metadata.javaee.jboss.NamedModule;
+
+/**
+ * Base class for metadata classes that include both a module name and a
+ * description group.
+ *
+ * @author Brian Stansberry
+ * 
+ * @version $Revision$
+ */
+public abstract class NamedModuleImpl extends IdMetaDataImplWithDescriptionGroup implements NamedModule
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 6848308773842846138L;
+   
+   private String moduleName;
+
+   public String getModuleName()
+   {
+      return moduleName;
+   }
+
+   public void setModuleName(String moduleName)
+   {
+      this.moduleName = moduleName;
+   }  
+
+   public void merge(NamedModuleImpl override,
+         NamedModuleImpl original)
+   {
+      super.merge(override, original);   
+      mergeModuleName(override, original);
+   }
+   
+   public void mergeModuleName(NamedModule override, NamedModule original)
+   {
+      if(override != null && override.getModuleName() != null)
+         setModuleName(override.getModuleName());
+      else if(original != null && original.getModuleName() != null)
+         setModuleName(original.getModuleName());
+   }
+
+}

Added: projects/metadata/common/trunk/src/test/java/org/jboss/test/metadata/javaee/NamedModuleImplUnitTestCase.java
===================================================================
--- projects/metadata/common/trunk/src/test/java/org/jboss/test/metadata/javaee/NamedModuleImplUnitTestCase.java	                        (rev 0)
+++ projects/metadata/common/trunk/src/test/java/org/jboss/test/metadata/javaee/NamedModuleImplUnitTestCase.java	2010-03-07 15:17:01 UTC (rev 102036)
@@ -0,0 +1,83 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat, Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.metadata.javaee;
+
+import junit.framework.TestCase;
+
+import org.jboss.metadata.javaee.spec.DescriptionGroupMetaData;
+import org.jboss.metadata.javaee.spec.DisplayNameImpl;
+import org.jboss.metadata.javaee.spec.DisplayNamesImpl;
+import org.jboss.metadata.javaee.support.NamedModuleImpl;
+
+
+/**
+ * Unit tests of NamedModuleImpl.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision: 1.1 $
+ */
+public class NamedModuleImplUnitTestCase extends TestCase
+{
+   private static class ConcreteNamedModule extends NamedModuleImpl
+   {
+      private ConcreteNamedModule()
+      {         
+      }
+      
+      private ConcreteNamedModule(String name)
+      {
+         setModuleName(name);
+         setId(name);
+         DisplayNameImpl dm = new DisplayNameImpl();
+         dm.setDisplayName(name);
+         DisplayNamesImpl names = new DisplayNamesImpl();
+         names.add(dm);
+         DescriptionGroupMetaData dgm = new DescriptionGroupMetaData();
+         dgm.setDisplayNames(names);
+         setDescriptionGroup(dgm);
+      }
+   }
+   
+   private static final ConcreteNamedModule A = new ConcreteNamedModule("A");
+   private static final ConcreteNamedModule B = new ConcreteNamedModule("B");
+   
+   public void testMerge()
+   {
+      ConcreteNamedModule testee = new ConcreteNamedModule();
+      testee.merge(A, B);
+      checkValues(testee, "A");
+      
+      testee = new ConcreteNamedModule();
+      testee.merge(B, A);
+      checkValues(testee, "B");      
+   }
+
+   private void checkValues(ConcreteNamedModule testee, String expected)
+   {
+      assertEquals(expected, testee.getModuleName());
+      assertEquals(expected, testee.getId());
+      assertNotNull(testee.getDescriptionGroup());
+      assertEquals(expected, testee.getDescriptionGroup().getDisplayName());
+   }
+   
+   
+}




More information about the jboss-cvs-commits mailing list