PageRenderTime 4193ms CodeModel.GetById 32ms RepoModel.GetById 3ms app.codeStats 0ms

/arquillian/container-embedded/src/main/java/org/jboss/as/arquillian/container/embedded/EmbeddedDeployableContainer.java

https://bitbucket.org/cprenzberg/wildfly
Java | 72 lines | 37 code | 7 blank | 28 comment | 2 complexity | b4bc50daebfceb9152b5dd09320cfb18 MD5 | raw file
  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2012, 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.as.arquillian.container.embedded;
  18. import org.jboss.arquillian.container.spi.client.container.LifecycleException;
  19. import org.jboss.as.arquillian.container.CommonDeployableContainer;
  20. import org.jboss.as.embedded.EmbeddedServerFactory;
  21. import org.jboss.as.embedded.EmbeddedStandAloneServerFactory;
  22. import org.jboss.as.embedded.StandaloneServer;
  23. /**
  24. * {@link org.jboss.arquillian.container.spi.client.container.DeployableContainer} implementation to bootstrap JBoss Logging (installing the LogManager if possible), use the JBoss
  25. * Modules modular ClassLoading Environment to create a new server instance, and handle lifecycle of the Application Server in
  26. * the currently-running environment.
  27. *
  28. * @author <a href="mailto:alr@jboss.org">Andrew Lee Rubinger</a>
  29. * @author <a href="mailto:mmatloka@gmail.com">Michal Matloka</a>
  30. * @author Thomas.Diesler@jboss.com
  31. */
  32. public final class EmbeddedDeployableContainer extends CommonDeployableContainer<EmbeddedContainerConfiguration> {
  33. /**
  34. * Hook to the server; used in start/stop, created by setup
  35. */
  36. private StandaloneServer server;
  37. @Override
  38. public void setup(final EmbeddedContainerConfiguration config) {
  39. super.setup(config);
  40. if (config.getCleanServerBaseDir() != null) {
  41. SecurityActions.setSystemProperty(EmbeddedStandAloneServerFactory.JBOSS_EMBEDDED_ROOT, config.getCleanServerBaseDir());
  42. }
  43. server = EmbeddedServerFactory.create(config.getJbossHome(), config.getModulePath(), config.getBundlePath());
  44. }
  45. @Override
  46. public Class<EmbeddedContainerConfiguration> getConfigurationClass() {
  47. return EmbeddedContainerConfiguration.class;
  48. }
  49. @Override
  50. protected void startInternal() throws LifecycleException {
  51. try {
  52. server.start();
  53. } catch (Throwable e) {
  54. throw new LifecycleException("Could not invoke start on: " + server, e);
  55. }
  56. }
  57. @Override
  58. protected void stopInternal() throws LifecycleException {
  59. try {
  60. server.stop();
  61. } catch (Throwable e) {
  62. throw new LifecycleException("Could not invoke stop on: " + server, e);
  63. }
  64. }
  65. }