code: public void undeployManaged(@Observes UnDeployManagedDeployments event) throws Exception {
          forEachDeployedDeployment(new Operation<Container, Deployment>() {
              @Inject
              private Event<DeploymentEvent> event;
  
              @Override
              public void perform(Container container, Deployment deployment) throws Exception {
                  if (container.getState().equals(Container.State.STARTED) && deployment.isDeployed()) {
                      event.fire(new UnDeployDeployment(container, deployment));
                  }
              }
          });
      }
docs: Undeploy all deployments marked as managed, and all manually deployed.
  
  @throws Exception