From b68c8b16ebef5d9f2c703ed32c2b4d77c42676a2 Mon Sep 17 00:00:00 2001 From: Ales Justin Date: Tue, 25 Oct 2011 16:49:05 +0200 Subject: [PATCH] [WELD-891]; fix shutdown order, adjust AS7 boot. --- .../jboss/weld/bootstrap/WeldBootstrap.java | 4 +- jboss-tck-runner/pom.xml | 4 +- .../lifecycle/BeforeShutdownExt.java | 38 +++++++++++++ .../lifecycle/BeforeShutdownExtTest.java | 57 +++++++++++++++++++ 4 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 tests-arquillian/src/test/java/org/jboss/weld/tests/extensions/lifecycle/BeforeShutdownExt.java create mode 100644 tests-arquillian/src/test/java/org/jboss/weld/tests/extensions/lifecycle/BeforeShutdownExtTest.java diff --git a/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java b/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java index c5c686b942e..5e8db3c1bf3 100644 --- a/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java +++ b/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java @@ -116,6 +116,7 @@ * detects and register beans * * @author Pete Muir + * @author Ales Justin */ public class WeldBootstrap implements Bootstrap { @@ -437,10 +438,9 @@ public void shutdown() { try { ApplicationContext applicationContext = deploymentManager.instance().select(ApplicationContext.class).get(); try { - applicationContext.invalidate(); BeforeShutdownImpl.fire(deploymentManager, beanDeployments); } finally { - + applicationContext.invalidate(); } } finally { Container.instance().setState(ContainerState.SHUTDOWN); diff --git a/jboss-tck-runner/pom.xml b/jboss-tck-runner/pom.xml index e2497583f93..2b41710de09 100644 --- a/jboss-tck-runner/pom.xml +++ b/jboss-tck-runner/pom.xml @@ -235,7 +235,7 @@ src/test/resources/tck-tests.xml - standalone-preview.xml + standalone.xml @@ -301,7 +301,7 @@ src/test/resources/tck-tests.xml - standalone-preview.xml + standalone.xml diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/extensions/lifecycle/BeforeShutdownExt.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/extensions/lifecycle/BeforeShutdownExt.java new file mode 100644 index 00000000000..06611258b29 --- /dev/null +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/extensions/lifecycle/BeforeShutdownExt.java @@ -0,0 +1,38 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2011, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.weld.tests.extensions.lifecycle; + +import javax.enterprise.event.Observes; +import javax.enterprise.inject.spi.BeanManager; +import javax.enterprise.inject.spi.BeforeShutdown; +import javax.enterprise.inject.spi.Extension; + +/** + * @author Aaron Anderson + * @author Ales Justin + */ +public class BeforeShutdownExt implements Extension { + public void beforeShutdown(@Observes BeforeShutdown bfs, BeanManager bm) { + System.out.format("BeforeShutdown \n"); + } +} diff --git a/tests-arquillian/src/test/java/org/jboss/weld/tests/extensions/lifecycle/BeforeShutdownExtTest.java b/tests-arquillian/src/test/java/org/jboss/weld/tests/extensions/lifecycle/BeforeShutdownExtTest.java new file mode 100644 index 00000000000..059ad92e397 --- /dev/null +++ b/tests-arquillian/src/test/java/org/jboss/weld/tests/extensions/lifecycle/BeforeShutdownExtTest.java @@ -0,0 +1,57 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2011, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.weld.tests.extensions.lifecycle; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.BeanArchive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; + +import javax.enterprise.inject.spi.BeanManager; +import javax.enterprise.inject.spi.Extension; + +/** + * @author Aaron Anderson + * @author Ales Justin + */ +@RunWith(Arquillian.class) +public class BeforeShutdownExtTest { + + @Deployment + public static Archive getDeployment() { + return ShrinkWrap.create(BeanArchive.class) + .addPackage(BeforeShutdownExt.class.getPackage()) + .addAsServiceProvider(Extension.class, BeforeShutdownExt.class); + } + + @Test + public void testExt(BeanManager bm) throws Exception { + System.err.println("----------- HERE -----------"); + Assert.assertNotNull(bm); + } + +}