2 Replies Latest reply on Jul 13, 2016 10:04 AM by Bartosz Majsak

    Arquillian: listen for Deploy events

    Luis Fernandes Newbie

      Hi all.


      Is there any chance to listen for Deploy events?

      I need to execute some code after deploy finishes.



        • 1. Re: Arquillian: listen for Deploy events
          Bartosz Majsak Master

          I believe you can do that through your custom extension. But it really depends on what kind of code you would like to execute. The solution below will work on the client side (so if you run your test in the container this is not a valid approach)


          You will need following bits


          Listener itself:


          public class DeploymentListener {
              void observeDeployment(@Observes(precedence = xxx) EventContext<DeployManagedDeployments> eventContext) {
                  // do something before
                  // or after
          void observeUndeploy(@Observes(precedence = yyy) EventContext<UnDeployManagedDeployments> eventContext) {
                  // do something before
                  // or after


          The precedence is arbitrary number which let's you hook in before or after other event listneres of the same type. In your case it should probably be a positive number (but cannot really tell you if 100 or 1000 or anything else - would need to investigate in the core itself for the exact answer, but I belive this is not really necessary).


          Registering the listener:

          import org.jboss.arquillian.core.spi.LoadableExtension;
          import org.jboss.arquillian.test.impl.enricher.resource.ArquillianResourceTestEnricher;
          import org.jboss.arquillian.test.spi.TestEnricher;
          public class DeploymentListenerExtension implements LoadableExtension {
              public void register(final ExtensionBuilder builder) {


          Making Arquillian aware of the extension, so that it will be loaded automatically by the framework. You should register your loadable extension through SPI in resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension file with following content



          More sample extensions, which can help you getting familiar with the topic, can be found here:



          And obviously I'm around to help further.




          • 2. Re: Arquillian: listen for Deploy events
            Bartosz Majsak Master

            Moved to general Arquillian space.

            Can we assume this thread is closed? Or is there anything else you would like to know?