Revision: 1437
          http://svn.sourceforge.net/spring-rich-c/?rev=1437&view=rev
Author:   ge0ffrey
Date:     2006-09-22 08:09:20 -0700 (Fri, 22 Sep 2006)

Log Message:
-----------
RCP-404 clean up useless wrapping and double logging

Modified Paths:
--------------
    
trunk/spring-richclient/archetype/src/main/resources/archetype-resources/src/main/java/SimpleApp.java
    
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ctx/common/richclient-startup-context.xml
    
trunk/spring-richclient/samples/petclinic/standalone/src/main/java/org/springframework/richclient/samples/petclinic/PetClinicStandalone.java
    
trunk/spring-richclient/samples/simple/src/main/java/org/springframework/richclient/samples/simple/app/SimpleApp.java
    trunk/spring-richclient/src/site/apt/user/upgrading/upgradingTo0.3.x.apt
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationLauncher.java

Modified: 
trunk/spring-richclient/archetype/src/main/resources/archetype-resources/src/main/java/SimpleApp.java
===================================================================
--- 
trunk/spring-richclient/archetype/src/main/resources/archetype-resources/src/main/java/SimpleApp.java
       2006-09-22 14:27:55 UTC (rev 1436)
+++ 
trunk/spring-richclient/archetype/src/main/resources/archetype-resources/src/main/java/SimpleApp.java
       2006-09-22 15:09:20 UTC (rev 1437)
@@ -46,35 +46,33 @@
      * @param args
      */
     public static void main( String[] args ) {
-        try {
-            _logger.info("SimpleApp starting up");
+        _logger.info("SimpleApp starting up");
 
-            // In order to launch the platform, we have to construct an
-            // application context that defines the beans (services) and
-            // wiring. This is pretty much straight Spring.
-            //
-            // Part of this configuration will indicate the initial page to be
-            // displayed.
+        // In order to launch the platform, we have to construct an
+        // application context that defines the beans (services) and
+        // wiring. This is pretty much straight Spring.
+        //
+        // Part of this configuration will indicate the initial page to be
+        // displayed.
 
-            String rootContextDirectoryClassPath = "/ctx";
+        String rootContextDirectoryClassPath = "/ctx";
 
-            // The startup context defines elements that should be available
-            // quickly such as a splash screen image.
+        // The startup context defines elements that should be available
+        // quickly such as a splash screen image.
 
-            String startupContextPath = rootContextDirectoryClassPath + 
"/richclient-startup-context.xml";
+        String startupContextPath = rootContextDirectoryClassPath + 
"/richclient-startup-context.xml";
 
-            String richclientApplicationContextPath = 
rootContextDirectoryClassPath
-                    + "/richclient-application-context.xml";
+        String richclientApplicationContextPath = rootContextDirectoryClassPath
+                + "/richclient-application-context.xml";
 
-            // The ApplicationLauncher is responsible for loading the contexts,
-            // presenting the splash screen, initializing the Application
-            // singleton instance, creating the application window to display
-            // the initial page.
-
+        // The ApplicationLauncher is responsible for loading the contexts,
+        // presenting the splash screen, initializing the Application
+        // singleton instance, creating the application window to display
+        // the initial page.
+        try {
             new ApplicationLauncher(startupContextPath, new String[] { 
richclientApplicationContextPath });
-
-        } catch( Exception e ) {
-            System.exit(1);
+        } catch (RuntimeException e) {
+            _logger.error("RuntimeException during startup", e);
         }
     }
 

Modified: 
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ctx/common/richclient-startup-context.xml
===================================================================
--- 
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ctx/common/richclient-startup-context.xml
 2006-09-22 14:27:55 UTC (rev 1436)
+++ 
trunk/spring-richclient/samples/petclinic/gui/src/main/resources/org/springframework/richclient/samples/petclinic/ctx/common/richclient-startup-context.xml
 2006-09-22 15:09:20 UTC (rev 1437)
@@ -3,7 +3,7 @@
        "http://www.springframework.org/dtd/spring-beans.dtd";>
 <!-- $Id$ -->
 <beans>
-       <bean id="splashScreen" 
+       <bean id="splashScreen"
                class="org.springframework.richclient.application.SplashScreen" 
                singleton="false">
                <property name="imageResourcePath">

Modified: 
trunk/spring-richclient/samples/petclinic/standalone/src/main/java/org/springframework/richclient/samples/petclinic/PetClinicStandalone.java
===================================================================
--- 
trunk/spring-richclient/samples/petclinic/standalone/src/main/java/org/springframework/richclient/samples/petclinic/PetClinicStandalone.java
        2006-09-22 14:27:55 UTC (rev 1436)
+++ 
trunk/spring-richclient/samples/petclinic/standalone/src/main/java/org/springframework/richclient/samples/petclinic/PetClinicStandalone.java
        2006-09-22 15:09:20 UTC (rev 1437)
@@ -16,6 +16,7 @@
 package org.springframework.richclient.samples.petclinic;
 
 import org.springframework.richclient.application.ApplicationLauncher;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Main driver that starts the pet clinic rich client sample application.
@@ -34,8 +35,12 @@
 
         String securityContextPath = rootContextDirectoryClassPath + 
"/standalone/security-context.xml";
 
-        new ApplicationLauncher(startupContextPath, new String[] { 
richclientApplicationContextPath,
-                businessLayerContextPath, securityContextPath });
+        try {
+            new ApplicationLauncher(startupContextPath, new String[] { 
richclientApplicationContextPath,
+                    businessLayerContextPath, securityContextPath });
+        } catch (RuntimeException e) {
+            
LogFactory.getLog(PetClinicStandalone.class).error("RuntimeException during 
startup", e);
+        }
     }
-    
+
 }
\ No newline at end of file

Modified: 
trunk/spring-richclient/samples/simple/src/main/java/org/springframework/richclient/samples/simple/app/SimpleApp.java
===================================================================
--- 
trunk/spring-richclient/samples/simple/src/main/java/org/springframework/richclient/samples/simple/app/SimpleApp.java
       2006-09-22 14:27:55 UTC (rev 1436)
+++ 
trunk/spring-richclient/samples/simple/src/main/java/org/springframework/richclient/samples/simple/app/SimpleApp.java
       2006-09-22 15:09:20 UTC (rev 1437)
@@ -57,35 +57,34 @@
      * @param args
      */
     public static void main( String[] args ) {
-        try {
-            _logger.info("SimpleApp starting up");
+        _logger.info("SimpleApp starting up");
 
-            // In order to launch the platform, we have to construct an
-            // application context that defines the beans (services) and
-            // wiring. This is pretty much straight Spring.
-            //
-            // Part of this configuration will indicate the initial page to be
-            // displayed.
+        // In order to launch the platform, we have to construct an
+        // application context that defines the beans (services) and
+        // wiring. This is pretty much straight Spring.
+        //
+        // Part of this configuration will indicate the initial page to be
+        // displayed.
 
-            String rootContextDirectoryClassPath = 
"/org/springframework/richclient/samples/simple/ctx";
+        String rootContextDirectoryClassPath = 
"/org/springframework/richclient/samples/simple/ctx";
 
-            // The startup context defines elements that should be available
-            // quickly such as a splash screen image.
+        // The startup context defines elements that should be available
+        // quickly such as a splash screen image.
 
-            String startupContextPath = rootContextDirectoryClassPath + 
"/richclient-startup-context.xml";
+        String startupContextPath = rootContextDirectoryClassPath + 
"/richclient-startup-context.xml";
 
-            String richclientApplicationContextPath = 
rootContextDirectoryClassPath
-                    + "/richclient-application-context.xml";
+        String richclientApplicationContextPath = rootContextDirectoryClassPath
+                + "/richclient-application-context.xml";
 
-            // The ApplicationLauncher is responsible for loading the contexts,
-            // presenting the splash screen, initializing the Application
-            // singleton instance, creating the application window to display
-            // the initial page.
+        // The ApplicationLauncher is responsible for loading the contexts,
+        // presenting the splash screen, initializing the Application
+        // singleton instance, creating the application window to display
+        // the initial page.
 
+        try {
             new ApplicationLauncher(startupContextPath, new String[] { 
richclientApplicationContextPath });
-
-        } catch( Exception e ) {
-            System.exit(1);
+        } catch (RuntimeException e) {
+            _logger.error("RuntimeException during startup", e);
         }
     }
 

Modified: 
trunk/spring-richclient/src/site/apt/user/upgrading/upgradingTo0.3.x.apt
===================================================================
--- trunk/spring-richclient/src/site/apt/user/upgrading/upgradingTo0.3.x.apt    
2006-09-22 14:27:55 UTC (rev 1436)
+++ trunk/spring-richclient/src/site/apt/user/upgrading/upgradingTo0.3.x.apt    
2006-09-22 15:09:20 UTC (rev 1437)
@@ -27,5 +27,21 @@
 
     Instead there is the much finer grained system, by injecting a 
registerableExceptionHandler.
 
-    * Exception catching improvements in ApplicationLauncher TODO
+    * Exception catching improvements in ApplicationLauncher
+
+    ApplicationLauncher no longer wraps it's runtime exceptions in an 
<<<ApplicationException>>>
+    and it no longer logs them either before throwing.
+    This is to avoid double logging when both logging and throwing - the 
thrown will probably be logged too.
+
+    So you might want to try-catch your ApplicationLauncher startup:
+
++--
+try {
+    new ApplicationLauncher(...);
+} catch (RuntimeException e) {
+    logger.error("RuntimeException during startup", e);
+}
++--
+
+    Or you could initialize an <<<LoggingExceptionHandler>>> on your main 
thread before using ApplicationLauncher.
     
\ No newline at end of file

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationLauncher.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationLauncher.java
   2006-09-22 14:27:55 UTC (rev 1436)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationLauncher.java
   2006-09-22 15:09:20 UTC (rev 1437)
@@ -99,8 +99,12 @@
         if (startupContext != null) {
             displaySplashScreen(startupContext);
         }
-        setRootApplicationContext(loadRootApplicationContext(rootContextPath));
-        launchMyRichClient();
+        try {
+            
setRootApplicationContext(loadRootApplicationContext(rootContextPath));
+            launchMyRichClient();
+        } finally {
+            destroySplashScreen();
+        }
     }
 
     /**
@@ -122,8 +126,12 @@
         if (startupContext != null) {
             displaySplashScreen(startupContext);
         }
-        setRootApplicationContext(rootApplicationContext);
-        launchMyRichClient();
+        try {
+            setRootApplicationContext(rootApplicationContext);
+            launchMyRichClient();
+        } finally {
+            destroySplashScreen();
+        }
     }
 
     private ApplicationContext loadStartupContext(String startupContextPath) {
@@ -136,59 +144,51 @@
     }
 
     private ApplicationContext loadRootApplicationContext(String[] 
contextPaths) {
-        try {
-            final ClassPathXmlApplicationContext applicationContext = new 
ClassPathXmlApplicationContext(contextPaths,
-                    false);
+        final ClassPathXmlApplicationContext applicationContext = new 
ClassPathXmlApplicationContext(contextPaths,
+                false);
 
-            final ProgressMonitor tracker = splashScreen.getProgressMonitor();
+        final ProgressMonitor tracker = splashScreen.getProgressMonitor();
 
-            applicationContext.addBeanFactoryPostProcessor(new 
BeanFactoryPostProcessor() {
-                public void 
postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws 
BeansException {
-                    beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
-                        private int max = -1;
+        applicationContext.addBeanFactoryPostProcessor(new 
BeanFactoryPostProcessor() {
+            public void postProcessBeanFactory(ConfigurableListableBeanFactory 
beanFactory) throws BeansException {
+                beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
+                    private int max = -1;
 
-                        public Object postProcessBeforeInitialization(Object 
bean, String beanName)
-                                throws BeansException {
-                            if (max == -1) {
-                                max = 0;
-                                ConfigurableListableBeanFactory 
configurableListBeanFactory = applicationContext.getBeanFactory();
-                                String[] beanNames = 
applicationContext.getBeanDefinitionNames();
-                                for (int i = 0; i < beanNames.length; i++) {
-                                    // using beanDefinition to check singleton 
property because when accessing through
-                                    // context 
(applicationContext.isSingleton(beanName)), bean will be created already,
-                                    // possibly bypassing other 
BeanFactoryPostProcessors
-                                    if 
(configurableListBeanFactory.getBeanDefinition(beanNames[i]).isSingleton())
-                                        max++;
-                                }
-                                tracker.taskStarted("Loading Application 
Context ...", max);
+                    public Object postProcessBeforeInitialization(Object bean, 
String beanName)
+                            throws BeansException {
+                        if (max == -1) {
+                            max = 0;
+                            ConfigurableListableBeanFactory 
configurableListBeanFactory = applicationContext.getBeanFactory();
+                            String[] beanNames = 
applicationContext.getBeanDefinitionNames();
+                            for (int i = 0; i < beanNames.length; i++) {
+                                // using beanDefinition to check singleton 
property because when accessing through
+                                // context 
(applicationContext.isSingleton(beanName)), bean will be created already,
+                                // possibly bypassing other 
BeanFactoryPostProcessors
+                                if 
(configurableListBeanFactory.getBeanDefinition(beanNames[i]).isSingleton())
+                                    max++;
                             }
-
-                            if 
(applicationContext.containsLocalBean(beanName)) {
-                                tracker.subTaskStarted("Loading " + beanName + 
" ...");
-                                tracker.worked(1);
-                            }
-
-                            return bean;
+                            tracker.taskStarted("Loading Application Context 
...", max);
                         }
 
-                        public Object postProcessAfterInitialization(Object 
bean, String beanName)
-                                throws BeansException {
-                            return bean;
+                        if (applicationContext.containsLocalBean(beanName)) {
+                            tracker.subTaskStarted("Loading " + beanName + " 
...");
+                            tracker.worked(1);
                         }
-                    });
-                }
-            });
 
-            applicationContext.refresh();
+                        return bean;
+                    }
 
-            return applicationContext;
-        }
-        catch (RuntimeException e) {
-            logger.warn("Exception occured initializing application startup 
context.", e);
-            destroySplashScreen(); // when app context fails to load, destroy
-            // splashscreen
-            throw new ApplicationException("Unable to start rich client 
application", e);
-        }
+                    public Object postProcessAfterInitialization(Object bean, 
String beanName)
+                            throws BeansException {
+                        return bean;
+                    }
+                });
+            }
+        });
+
+        applicationContext.refresh();
+
+        return applicationContext;
     }
 
     private void setRootApplicationContext(ApplicationContext context) {
@@ -212,40 +212,27 @@
             displaySplashScreen(rootApplicationContext);
         }
 
+        Application application;
         try {
-            Application application = 
(Application)rootApplicationContext.getBean(APPLICATION_BEAN_ID,
-                    Application.class);
-            application.start();
+            application = 
(Application)rootApplicationContext.getBean(APPLICATION_BEAN_ID, 
Application.class);
         }
         catch (NoSuchBeanDefinitionException e) {
-            logger.error("A single org.springframework.richclient.Application 
bean definition must be defined "
+            throw new IllegalArgumentException(
+                    "A single org.springframework.richclient.Application bean 
definition must be defined "
                     + "in the main application context", e);
-            throw e;
         }
-        catch (RuntimeException e) {
-            logger.error("Exception occured initializing Application bean", e);
-            throw new ApplicationException("Unable to start rich client 
application", e);
-        }
-        finally {
-            destroySplashScreen();
-            logger.debug("Launcher thread exiting...");
-        }
+        application.start();
+        logger.debug("Launcher thread exiting...");
     }
 
     private void displaySplashScreen(BeanFactory beanFactory) {
-        try {
-            if (beanFactory.containsBean(SPLASH_SCREEN_BEAN_ID)) {
-                this.splashScreen = 
(SplashScreen)beanFactory.getBean(SPLASH_SCREEN_BEAN_ID, SplashScreen.class);
-                logger.info("Displaying application splash screen...");
-                this.splashScreen.splash();
-            }
-            else {
-                logger.info("No splash screen bean found to 
display--continuing...");
-            }
+        if (beanFactory.containsBean(SPLASH_SCREEN_BEAN_ID)) {
+            this.splashScreen = 
(SplashScreen)beanFactory.getBean(SPLASH_SCREEN_BEAN_ID, SplashScreen.class);
+            logger.debug("Displaying application splash screen...");
+            this.splashScreen.splash();
+        } else {
+            logger.info("No splash screen bean found to display. 
Continuing...");
         }
-        catch (RuntimeException e) {
-            logger.warn("Unable to load and display startup splash screen.", 
e);
-        }
     }
 
     private void destroySplashScreen() {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
spring-rich-c-cvs mailing list
spring-rich-c-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to