Coverage Report - org.apache.maven.plugin.ear.JbossConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
JbossConfiguration
0%
0/41
0%
0/20
1,556
 
 1  
 package org.apache.maven.plugin.ear;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *  http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.util.List;
 23  
 
 24  
 /**
 25  
  * The JBoss specific configuration, used to generate the jboss-app.xml
 26  
  * deployment descriptor file
 27  
  *
 28  
  * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
 29  
  * @version $Id: JbossConfiguration.java 1228837 2012-01-08 13:19:38Z rfscholte $
 30  
  */
 31  
 class JbossConfiguration
 32  
 {
 33  
     static final String VERSION_3_2 = "3.2";
 34  
 
 35  
     static final String VERSION_4 = "4";
 36  
 
 37  
     static final String VERSION_4_2 = "4.2";
 38  
 
 39  
     static final String VERSION_5 = "5";
 40  
 
 41  
     static final String VERSION = "version";
 42  
 
 43  
     static final String SECURITY_DOMAIN = "security-domain";
 44  
 
 45  
     static final String UNAUHTHENTICTED_PRINCIPAL = "unauthenticated-principal";
 46  
 
 47  
     static final String JMX_NAME = "jmx-name";
 48  
 
 49  
     static final String LOADER_REPOSITORY = "loader-repository";
 50  
 
 51  
     static final String LOADER_REPOSITORY_CLASS_ATTRIBUTE = "loaderRepositoryClass";
 52  
 
 53  
     static final String LOADER_REPOSITORY_CONFIG = "loader-repository-config";
 54  
 
 55  
     static final String CONFIG_PARSER_CLASS_ATTRIBUTE = "configParserClass";
 56  
 
 57  
     static final String MODULE_ORDER = "module-order";
 58  
 
 59  
     static final String DATASOURCES = "data-sources";
 60  
 
 61  
     static final String DATASOURCE = "data-source";
 62  
 
 63  
     static final String LIBRARY_DIRECTORY = "library-directory";
 64  
 
 65  
     private final String version;
 66  
 
 67  
     private boolean jbossThreeDotTwo;
 68  
 
 69  
     private boolean jbossFour;
 70  
 
 71  
     private boolean jbossFourDotTwo;
 72  
 
 73  
     private boolean jbossFive;
 74  
 
 75  
     private final String securityDomain;
 76  
 
 77  
     private final String unauthenticatedPrincipal;
 78  
 
 79  
     private final String jmxName;
 80  
 
 81  
     private final String loaderRepository;
 82  
 
 83  
     private final String loaderRepositoryConfig;
 84  
 
 85  
     private final String loaderRepositoryClass;
 86  
 
 87  
     private final String configParserClass;
 88  
 
 89  
     private final String moduleOrder;
 90  
 
 91  
     private final List<String> dataSources;
 92  
 
 93  
     private final String libraryDirectory;
 94  
 
 95  
     public JbossConfiguration( String version, String securityDomain, String unauthenticatedPrincipal, String jmxName,
 96  
                                String loaderRepository, String moduleOrder, List<String> dataSources, String libraryDirectory,
 97  
                                String loaderRepositoryConfig, String loaderRepositoryClass, String configParserClass )
 98  
         throws EarPluginException
 99  0
     {
 100  0
         if ( version == null )
 101  
         {
 102  0
             throw new EarPluginException( "jboss version could not be null." );
 103  
         }
 104  
         else
 105  
         {
 106  0
             this.version = version;
 107  0
             if ( version.equals( JbossConfiguration.VERSION_3_2 ) )
 108  
             {
 109  0
                 this.jbossThreeDotTwo = true;
 110  
             }
 111  0
             else if ( version.equals( JbossConfiguration.VERSION_4 ) )
 112  
             {
 113  0
                 this.jbossFour = true;
 114  
             }
 115  0
             else if ( version.equals( JbossConfiguration.VERSION_4_2 ) )
 116  
             {
 117  0
                 this.jbossFourDotTwo = true;
 118  
             }
 119  0
             else if ( version.equals( JbossConfiguration.VERSION_5 ) )
 120  
             {
 121  0
                 this.jbossFive = true;
 122  
             }
 123  
             else
 124  
             {
 125  0
                 throw new EarPluginException(
 126  
                     "Invalid JBoss configuration, version[" + version + "] is not supported." );
 127  
             }
 128  0
             this.securityDomain = securityDomain;
 129  0
             this.unauthenticatedPrincipal = unauthenticatedPrincipal;
 130  0
             this.jmxName = jmxName;
 131  0
             this.loaderRepository = loaderRepository;
 132  0
             this.moduleOrder = moduleOrder;
 133  0
             this.dataSources = dataSources;
 134  0
             this.libraryDirectory = libraryDirectory;
 135  0
             this.loaderRepositoryConfig = loaderRepositoryConfig;
 136  0
             this.loaderRepositoryClass = loaderRepositoryClass;
 137  0
             this.configParserClass = configParserClass;
 138  
         }
 139  0
     }
 140  
 
 141  
     /**
 142  
      * Returns the targeted version of JBoss.
 143  
      *
 144  
      * @return the jboss version
 145  
      */
 146  
     public String getVersion()
 147  
     {
 148  0
         return version;
 149  
     }
 150  
 
 151  
     /**
 152  
      * Returns true if the targeted JBoss version is 3.2.
 153  
      *
 154  
      * @return if the targeted version is 3.2
 155  
      */
 156  
     public boolean isJbossThreeDotTwo()
 157  
     {
 158  0
         return jbossThreeDotTwo;
 159  
     }
 160  
 
 161  
     /**
 162  
      * Returns true if the targeted JBoss version is 4.
 163  
      *
 164  
      * @return if the targeted version is 4
 165  
      */
 166  
     public boolean isJbossFour()
 167  
     {
 168  0
         return jbossFour;
 169  
     }
 170  
 
 171  
     /**
 172  
      * Returns true if the targeted JBoss version if 4 or higher (that is
 173  
      * 4, 4.2 or 5).
 174  
      *
 175  
      * @return true if the targeted version is 4+
 176  
      */
 177  
     public boolean isJbossFourOrHigher()
 178  
     {
 179  0
         return jbossFour || jbossFourDotTwo || jbossFive;
 180  
     }
 181  
 
 182  
 
 183  
     /**
 184  
      * Returns true if the targeted JBoss version is 4.2.
 185  
      *
 186  
      * @return if the targeted version is 4.2
 187  
      */
 188  
     public boolean isJbossFourDotTwo()
 189  
     {
 190  0
         return jbossFourDotTwo;
 191  
     }
 192  
 
 193  
     /**
 194  
      * Returns true if the targeted JBoss version if 4.2 or higher (that is
 195  
      * 4.2 or 5).
 196  
      *
 197  
      * @return true if the targeted version is 4.2+
 198  
      */
 199  
     public boolean isJbossFourDotTwoOrHigher()
 200  
     {
 201  0
         return jbossFourDotTwo || jbossFive;
 202  
     }
 203  
 
 204  
 
 205  
     /**
 206  
      * Returns true if the targeted JBoss version is 5.
 207  
      *
 208  
      * @return if the targeted version is 5
 209  
      */
 210  
     public boolean isJbossFive()
 211  
     {
 212  0
         return jbossFive;
 213  
     }
 214  
 
 215  
     /**
 216  
      * The security-domain element specifies the JNDI name of the security
 217  
      * manager that implements the EJBSecurityManager and RealmMapping for
 218  
      * the domain. When specified at the jboss level it specifies the security
 219  
      * domain for all j2ee components in the deployment unit.
 220  
      * <p/>
 221  
      * One can override the global security-domain at the container
 222  
      * level using the security-domain element at the container-configuration
 223  
      * level.
 224  
      * <p/>
 225  
      * Only available as from JBoss 4.
 226  
      *
 227  
      * @return the JNDI name of the security manager
 228  
      */
 229  
     public String getSecurityDomain()
 230  
     {
 231  0
         return securityDomain;
 232  
     }
 233  
 
 234  
     /**
 235  
      * The unauthenticated-principal element specifies the name of the principal
 236  
      * that will be returned by the EJBContext.getCallerPrincipal() method if there
 237  
      * is no authenticated user. This Principal has no roles or privileges to call
 238  
      * any other beans.
 239  
      * <p/>
 240  
      * Only available as from JBoss 4.
 241  
      *
 242  
      * @return the unauthenticated principal
 243  
      */
 244  
     public String getUnauthenticatedPrincipal()
 245  
     {
 246  0
         return unauthenticatedPrincipal;
 247  
     }
 248  
 
 249  
     /**
 250  
      * The jmx-name element allows one to specify the JMX ObjectName to use
 251  
      * for the MBean associated with the ear module. This must be a unique
 252  
      * name and valid JMX ObjectName string.
 253  
      *
 254  
      * @return the object name of the ear mbean
 255  
      */
 256  
     public String getJmxName()
 257  
     {
 258  0
         return jmxName;
 259  
     }
 260  
 
 261  
     /**
 262  
      * The loader-repository specifies the name of the UnifiedLoaderRepository
 263  
      * MBean to use for the ear to provide ear level scoping of classes deployed
 264  
      * in the ear. It is a unique JMX ObjectName string.
 265  
      * <p/>
 266  
      * <P>Example:</P>
 267  
      * &lt;loader-repository>jboss.test:loader=cts-cmp2v1-sar.ear&lt;/loader-repository>
 268  
      *
 269  
      * @return the object name of the ear mbean
 270  
      */
 271  
     public String getLoaderRepository()
 272  
     {
 273  0
         return loaderRepository;
 274  
     }
 275  
 
 276  
     /**
 277  
      * The module-order specifies the order in which the modules specified
 278  
      * in the application.xml file gets loaded. Allowed values are:
 279  
      * <p/>
 280  
      * <module-order>strict</module-order>
 281  
      * The strict value indicates that the deployments of the modules will
 282  
      * be done in the order that would be specified in the application.xml
 283  
      * and jboss-app.xml file.
 284  
      * <p/>
 285  
      * <module-order>implicit</module-order>
 286  
      * The implicit value indicates the deployment would follow the order
 287  
      * which would be specified in the DeploymentSorter.
 288  
      * <p/>
 289  
      * Returns <tt>null</tt> if no module order is set.
 290  
      * <p/>
 291  
      * Only available in JBoss 4.2 and 4.3. Has no effect in JBoss 5 and is
 292  
      * not added when mentioned version is used.
 293  
      *
 294  
      * @return the module order
 295  
      */
 296  
     public String getModuleOrder()
 297  
     {
 298  0
         return moduleOrder;
 299  
     }
 300  
 
 301  
     /**
 302  
      * Returns the list of datasources to include in the <tt>jboss-app.xml</tt>
 303  
      * file as services. Each element of the list is the relative path to the
 304  
      * datasource file contained in the EAR archive.
 305  
      *
 306  
      * @return the list of datasources paths
 307  
      */
 308  
     public List<String> getDataSources()
 309  
     {
 310  0
         return dataSources;
 311  
     }
 312  
 
 313  
     /**
 314  
      * Returns the library directory to include in the <tt>jboss-app.xml</tt> file.
 315  
      * It tells JBoss where to find non-Java EE libraries included in the EAR.
 316  
      *
 317  
      * @return the library directory
 318  
      */
 319  
     public String getLibraryDirectory()
 320  
     {
 321  0
         return libraryDirectory;
 322  
     }
 323  
 
 324  
     /**
 325  
      * Returns the class loader repository configuration to include in the <tt>jboss-app.xml</tt> file.
 326  
      * The content of this element is handed to the class loader, thereby altering it's default behaviour.
 327  
      * <p/>
 328  
      * This element is added as a child to the <tt>loader-repository</tt> element. If the element is not
 329  
      * present in the configuration, it will be added.
 330  
      * <p/>
 331  
      * Example: &lt;loader-repository-config>java2ParentDelegaton=true&lt;/loader-repository-config>
 332  
      *
 333  
      * @return the class loader repository configuration
 334  
      */
 335  
     public String getLoaderRepositoryConfig()
 336  
     {
 337  0
         return loaderRepositoryConfig;
 338  
     }
 339  
 
 340  
     /**
 341  
      * Returns the class loader repository class to include in the <tt>jboss-app.xml</tt> file.
 342  
      * It tells JBoss which loader repository implementation to use.
 343  
      * <p/>
 344  
      * This element is added as an attribute to the <tt>loader-repository</tt> element, therefore it is
 345  
      * not added if no such element configuration is present.
 346  
      * <p/>
 347  
      * Example: &lt;loader-repository-class>org.mindbug.jboss.AlternateLoaderRepository&lt;/loader-repository-class>
 348  
      *
 349  
      * @return the class loader repository class
 350  
      */
 351  
     public String getLoaderRepositoryClass()
 352  
     {
 353  0
         return loaderRepositoryClass;
 354  
     }
 355  
 
 356  
     /**
 357  
      * Returns the class loader's configuration parser class to include in the <tt>jboss-app.xml</tt> file.
 358  
      * It tells JBoss how to parse the configuration given in the <tt>loader-repository-config</tt> element.
 359  
      * <p/>
 360  
      * This element is added as an attribute to the <tt>loader-repository-config</tt> element, therefore it is
 361  
      * not added if no such element configuration is present.
 362  
      * <p/>
 363  
      * Example: &lt;config-parser-class>org.mindbug.jboss.AlternateLoaderRepositoryConfigParser&lt;/config-parser-class>
 364  
      *
 365  
      * @return the class loader's configuration parser class
 366  
      */
 367  
     public String getConfigParserClass()
 368  
     {
 369  0
         return configParserClass;
 370  
     }
 371  
 }