/jbossas-managed-4.2/src/main/java/org/jboss/arquillian/container/jbossas/managed_4_2/JBossASConfiguration.java

https://github.com/charleswmiller/arquillian-container-jbossas · Java · 227 lines · 117 code · 36 blank · 74 comment · 2 complexity · 0312ccada2766ca570bcd9ff160ba9a5 MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2009, Red Hat Middleware LLC, and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.jboss.arquillian.container.jbossas.managed_4_2;
  18. import java.io.File;
  19. import org.jboss.arquillian.container.spi.ConfigurationException;
  20. import org.jboss.arquillian.container.spi.client.container.ContainerConfiguration;
  21. import org.jboss.arquillian.container.spi.client.deployment.Validate;
  22. /**
  23. * A {@link org.jboss.arquillian.spi.client.container.ContainerConfiguration} implementation for
  24. * the JBoss AS container.
  25. *
  26. * @author <a href="mailto:german.escobarc@gmail.com">German Escobar</a>
  27. * @version $Revision: $
  28. */
  29. public class JBossASConfiguration implements ContainerConfiguration
  30. {
  31. private String bindAddress = "localhost";
  32. private int httpPort = 8080;
  33. private int rmiPort = 1099;
  34. private String profileName = "default";
  35. private boolean useRmiPortForAliveCheck = false;
  36. private String jbossHome = System.getenv("JBOSS_HOME");
  37. private String javaHome = System.getenv("JAVA_HOME");
  38. private String javaVmArguments = "-Xmx512m -XX:MaxPermSize=128m";
  39. private int startupTimeoutInSeconds = 120;
  40. private int shutdownTimeoutInSeconds = 45;
  41. private String urlPkgPrefix = "org.jboss.naming:org.jnp.interfaces";
  42. /* (non-Javadoc)
  43. * @see org.jboss.arquillian.spi.client.container.ContainerConfiguration#validate()
  44. */
  45. @Override
  46. public void validate() throws ConfigurationException
  47. {
  48. Validate.configurationDirectoryExists(jbossHome, "Either JBOSS_HOME environment variable or jbossHome property in Arquillian configuration must be set and point to a valid directory");
  49. Validate.configurationDirectoryExists(javaHome, "Either JAVA_HOME environment variable or javaHome property in Arquillian configuration must be set and point to a valid directory");
  50. }
  51. public String getBindAddress()
  52. {
  53. return bindAddress;
  54. }
  55. public void setBindAddress(String bindAddress)
  56. {
  57. this.bindAddress = bindAddress;
  58. }
  59. public int getHttpPort()
  60. {
  61. return httpPort;
  62. }
  63. /**
  64. * Set the HTTP Connect port. <br/>
  65. * This is not the JBoss AS HTTP Bind port, bind port must be set in the JBoss XML configuration.<br/>
  66. * <b>Only set this if default http port is changed in JBoss AS!</b>
  67. *
  68. * @param httpPort HTTP Connect port
  69. */
  70. public void setHttpPort(int httpPort)
  71. {
  72. this.httpPort = httpPort;
  73. }
  74. /**
  75. * @return the rmiPort
  76. */
  77. public int getRmiPort()
  78. {
  79. return rmiPort;
  80. }
  81. /**
  82. * Set the RMI Connect port. <br/>
  83. * This is not the JBoss AS RMI Bind port, bind port must be set in the JBoss XML configuration.<br/>
  84. * <b>Only set this if default RMI port is changed in JBoss AS!</b>
  85. *
  86. * @param rmiPort the rmiPort to set
  87. */
  88. public void setRmiPort(int rmiPort)
  89. {
  90. this.rmiPort = rmiPort;
  91. }
  92. public String getProfileName()
  93. {
  94. return profileName;
  95. }
  96. public void setProfileName(String profileName)
  97. {
  98. this.profileName = profileName;
  99. }
  100. /**
  101. * If true, RMI port and not HTTP port is used to see if the Server is running.
  102. *
  103. * @param checkAliveUsingRmiPort the checkAliveUsingRmiPort to set
  104. */
  105. public void setUseRmiPortForAliveCheck(boolean checkAliveUsingRmiPort)
  106. {
  107. this.useRmiPortForAliveCheck = checkAliveUsingRmiPort;
  108. }
  109. /**
  110. * @return the checkAliveUsingRmiPort
  111. */
  112. public boolean isUseRmiPortForAliveCheck()
  113. {
  114. return useRmiPortForAliveCheck;
  115. }
  116. public void setJbossHome(String jbossHome)
  117. {
  118. this.jbossHome = jbossHome;
  119. }
  120. public String getJbossHome()
  121. {
  122. if(jbossHome != null)
  123. {
  124. return new File(jbossHome).getAbsolutePath();
  125. }
  126. return jbossHome;
  127. }
  128. public void setJavaHome(String javaHome)
  129. {
  130. this.javaHome = javaHome;
  131. }
  132. public String getJavaHome()
  133. {
  134. return javaHome;
  135. }
  136. /**
  137. * This will override the default ("-Xmx512m -XX:MaxPermSize=128m") startup JVM arguments.
  138. *
  139. * @param javaVmArguments use as start up arguments
  140. */
  141. public void setJavaVmArguments(String javaVmArguments)
  142. {
  143. this.javaVmArguments = javaVmArguments;
  144. }
  145. public String getJavaVmArguments()
  146. {
  147. return javaVmArguments;
  148. }
  149. /**
  150. * @return the startupTimeoutInSeconds
  151. */
  152. public int getStartupTimeoutInSeconds()
  153. {
  154. return startupTimeoutInSeconds;
  155. }
  156. /**
  157. * @param startupTimeoutInSeconds the startupTimeoutInSeconds to set
  158. */
  159. public void setStartupTimeoutInSeconds(int startupTimeoutInSeconds)
  160. {
  161. this.startupTimeoutInSeconds = startupTimeoutInSeconds;
  162. }
  163. /**
  164. * @return the shutdownTimeoutInSeconds
  165. */
  166. public int getShutdownTimeoutInSeconds()
  167. {
  168. return shutdownTimeoutInSeconds;
  169. }
  170. /**
  171. * @param shutdownTimeoutInSeconds the shutdownTimeoutInSeconds to set
  172. */
  173. public void setShutdownTimeoutInSeconds(int shutdownTimeoutInSeconds)
  174. {
  175. this.shutdownTimeoutInSeconds = shutdownTimeoutInSeconds;
  176. }
  177. /**
  178. * @param urlPkgPrefix the urlPkgPrefix to set
  179. */
  180. public void setUrlPkgPrefix(String urlPkgPrefix)
  181. {
  182. this.urlPkgPrefix = urlPkgPrefix;
  183. }
  184. /**
  185. * @return the urlPkgPrefix
  186. */
  187. public String getUrlPkgPrefix()
  188. {
  189. return urlPkgPrefix;
  190. }
  191. }