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