Author: pete.muir(a)jboss.org
Date: 2009-03-15 15:54:16 -0400 (Sun, 15 Mar 2009)
New Revision: 2015
Added:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/ShutdownManager.java
Removed:
extensions/trunk/se/src/test/resources/log4j.properties
Modified:
extensions/trunk/se/
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/AbstractScanner.java
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/URLScanner.java
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java
Log:
minor improvements
Property changes on: extensions/trunk/se
___________________________________________________________________
Name: svn:ignore
- nbactions.xml
target
.classpath
.project
.settings
temp-testng-customsuite.xml
+ nbactions.xml
target
.classpath
.project
.settings
temp-testng-customsuite.xml
test-output
Added:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/ShutdownManager.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/ShutdownManager.java
(rev 0)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/ShutdownManager.java 2009-03-15
19:54:16 UTC (rev 2015)
@@ -0,0 +1,52 @@
+package org.jboss.webbeans.environment.se;
+
+import javax.context.ApplicationScoped;
+import javax.event.Observes;
+import javax.inject.manager.Manager;
+
+import org.apache.log4j.Logger;
+import org.jboss.webbeans.bootstrap.api.Bootstrap;
+import org.jboss.webbeans.context.DependentContext;
+import org.jboss.webbeans.environment.se.events.Shutdown;
+
+@ApplicationScoped
+public class ShutdownManager
+{
+
+ private static Logger log = Logger.getLogger(ShutdownManager.class);
+
+ private boolean hasShutdownBeenCalled = false;
+
+ private Bootstrap bootstrap;
+
+ /**
+ * The observer of the optional shutdown request which will in turn fire the
+ * Shutdown event.
+ *
+ * @param shutdownRequest
+ */
+ public void shutdown(@Observes @Shutdown Manager shutdownRequest)
+ {
+ synchronized (this)
+ {
+
+ if (!hasShutdownBeenCalled)
+ {
+ hasShutdownBeenCalled = true;
+ bootstrap.shutdown();
+ DependentContext.INSTANCE.setActive(false);
+ }
+ else
+ {
+ log.debug("Skipping spurious call to shutdown");
+ log.trace(Thread.currentThread().getStackTrace());
+ }
+ }
+ }
+
+ public void setBootstrap(Bootstrap bootstrap)
+ {
+ this.bootstrap = bootstrap;
+ }
+
+}
Property changes on:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/ShutdownManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java 2009-03-15
19:45:58 UTC (rev 2014)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java 2009-03-15
19:54:16 UTC (rev 2015)
@@ -16,7 +16,6 @@
*/
package org.jboss.webbeans.environment.se;
-import javax.event.Observes;
import javax.inject.manager.Manager;
import org.jboss.webbeans.bootstrap.api.Bootstrap;
@@ -27,11 +26,9 @@
import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
import org.jboss.webbeans.environment.se.beans.ParametersFactory;
import org.jboss.webbeans.environment.se.discovery.SEWebBeanDiscovery;
-import org.jboss.webbeans.environment.se.events.Shutdown;
import org.jboss.webbeans.environment.se.resources.NoNamingContext;
import org.jboss.webbeans.environment.se.util.Reflections;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.manager.api.WebBeansManager;
import org.jboss.webbeans.resources.spi.NamingContext;
/**
@@ -51,9 +48,10 @@
private final Bootstrap bootstrap;
private final BeanStore applicationBeanStore;
private String[] args;
- private boolean hasShutdownBeenCalled = false;
- Log log = Logging.getLog(StartMain.class);
+ private WebBeansManager manager;
+
+
public StartMain(String[] commandLineArgs)
{
this.args = commandLineArgs;
@@ -76,8 +74,10 @@
bootstrap.setApplicationContext(applicationBeanStore);
bootstrap.initialize();
bootstrap.boot();
+ this.manager = bootstrap.getManager();
bootstrap.getManager().getInstanceByType(ParametersFactory.class).setArgs(args);
DependentContext.INSTANCE.setActive(true);
+
bootstrap.getManager().getInstanceByType(ShutdownManager.class).setBootstrap(bootstrap);
}
/**
@@ -89,31 +89,13 @@
*/
public static void main(String[] args)
{
- new StartMain(args).go();
+ new StartMain(args).main();
}
- /**
- * The observer of the optional shutdown request which will in turn fire the
- * Shutdown event.
- *
- * @param shutdownRequest
- */
- public void shutdown(@Observes @Shutdown Manager shutdownRequest)
+ public Manager main()
{
- synchronized (this)
- {
-
- if (!hasShutdownBeenCalled)
- {
- hasShutdownBeenCalled = true;
- bootstrap.shutdown();
- }
- else
- {
- log.debug("Skipping spurious call to shutdown");
- log.trace(Thread.currentThread().getStackTrace());
- }
- }
+ go();
+ return manager;
}
}
Modified:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/AbstractScanner.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/AbstractScanner.java 2009-03-15
19:45:58 UTC (rev 2014)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/AbstractScanner.java 2009-03-15
19:54:16 UTC (rev 2015)
@@ -18,8 +18,7 @@
import java.net.URL;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
+import org.apache.log4j.Logger;
/**
* Abstract base class for {@link Scanner} providing common functionality
@@ -32,7 +31,7 @@
public abstract class AbstractScanner implements Scanner
{
- private static final LogProvider log = Logging.getLogProvider(Scanner.class);
+ private static final Logger log = Logger.getLogger(Scanner.class);
private final ClassLoader classLoader;
private final SEWebBeanDiscovery webBeanDiscovery;
Modified:
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/URLScanner.java
===================================================================
---
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/URLScanner.java 2009-03-15
19:45:58 UTC (rev 2014)
+++
extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/URLScanner.java 2009-03-15
19:54:16 UTC (rev 2015)
@@ -29,8 +29,7 @@
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
+import org.apache.log4j.Logger;
/**
* Implementation of {@link Scanner} which can scan a {@link URLClassLoader}
@@ -43,7 +42,7 @@
*/
public class URLScanner extends AbstractScanner
{
- private static final LogProvider log = Logging.getLogProvider(URLScanner.class);
+ private static final Logger log = Logger.getLogger(URLScanner.class);
public URLScanner(ClassLoader classLoader, SEWebBeanDiscovery webBeanDiscovery)
{
Modified:
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java
===================================================================
---
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java 2009-03-15
19:45:58 UTC (rev 2014)
+++
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java 2009-03-15
19:54:16 UTC (rev 2015)
@@ -19,7 +19,6 @@
import javax.inject.AnnotationLiteral;
import javax.inject.manager.Manager;
-import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.environment.se.StartMain;
import org.jboss.webbeans.environment.se.events.Shutdown;
import org.jboss.webbeans.environment.se.test.beans.MainTestBean;
@@ -45,9 +44,8 @@
public void testMain()
{
String[] args = ARGS ;
- StartMain.main( args );
+ Manager manager = new StartMain(args).main();
- Manager manager = CurrentManager.rootManager();
MainTestBean mainTestBean = manager.getInstanceByType( MainTestBean.class );
Assert.assertNotNull( mainTestBean );
@@ -61,6 +59,16 @@
Assert.assertEquals( ARGS[2], paramsBean.getParam3() );
manager.fireEvent( manager, new AnnotationLiteral<Shutdown>() {} );
+ boolean contextNotActive = false;
+ try
+ {
+ assert manager.getInstanceByType(MainTestBean.class) == null;
+ }
+ catch (Exception e)
+ {
+ contextNotActive = true;
+ }
+ assert contextNotActive;
}
}
Deleted: extensions/trunk/se/src/test/resources/log4j.properties
===================================================================
--- extensions/trunk/se/src/test/resources/log4j.properties 2009-03-15 19:45:58 UTC (rev
2014)
+++ extensions/trunk/se/src/test/resources/log4j.properties 2009-03-15 19:54:16 UTC (rev
2015)
@@ -1,25 +0,0 @@
-#
-# JBoss, Home of Professional Open Source
-# Copyright 2008, Red Hat Middleware LLC, and individual contributors
-# by the @authors tag. See the copyright.txt in the distribution for a
-# full listing of individual contributors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
http://www.apache.org/licenses/LICENSE-2.0
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# Set root logger level to DEBUG and its only appender to A1.
-log4j.rootLogger=DEBUG, A1
-
-# A1 is set to be a ConsoleAppender.
-log4j.appender.A1=org.apache.log4j.ConsoleAppender
-
-# A1 uses PatternLayout.
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n