001    /*
002     * Copyright 2002-2004 the original author or authors.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005     * use this file except in compliance with the License. You may obtain a copy of
006     * the License at
007     * 
008     * http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012     * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013     * License for the specific language governing permissions and limitations under
014     * the License.
015     */
016    package org.springframework.richclient.samples.simple.app;
017    
018    import org.apache.commons.logging.Log;
019    import org.apache.commons.logging.LogFactory;
020    import org.springframework.richclient.application.ApplicationLauncher;
021    
022    /**
023     * This application provides a very simple introduction to the Spring Richclient platform. It is intended to highlight
024     * the common models for working with the platform (including configuration and runtime access to platform services) and
025     * how to organize the basic pieces of an application using the platform.
026     * <p>
027     * This sample provides an implementation of a&nbsp;<em>trivial</em> address book. Trust me when I say trivial :-) It
028     * has no persistence, no security, and no complex business logic. The focus of the sample is how to work with the
029     * Spring Rich platform, not about how to build a great address book.
030     * <p>
031     * Other samples will introduce more complex topics like user management (security), alternate page/view layouts,
032     * complex data binding, remoting, etc.
033     * <p>
034     * The Spring Rich platform relies on the <a href="http://www.springframework.org/">Spring</a> project to manage the
035     * application context with all the associated benefits it offers.
036     * <p>
037     * A start at the Spring Rich Client documentation can be found on the <a
038     * href="http://opensource.atlassian.com/confluence/spring/display/RCP/Home">wiki</a>.
039     * </p>
040     * @author Larry Streepy
041     * @see The <a href="http://www.springframework.org/">Spring project</a>
042     * @see The <a href="http://opensource.atlassian.com/confluence/spring/display/RCP/Home">Spring Rich Wiki</a>
043     */
044    public class SimpleApp {
045    
046            private static final Log logger = LogFactory.getLog(SimpleApp.class);
047    
048            /**
049             * Main routine for the simple sample application.
050             * @param args
051             */
052            public static void main(String[] args) {
053                    logger.info("SimpleApp starting up");
054    
055                    // In order to launch the platform, we have to construct an
056                    // application context that defines the beans (services) and
057                    // wiring. This is pretty much straight Spring.
058                    //
059                    // Part of this configuration will indicate the initial page to be
060                    // displayed.
061    
062                    String rootContextDirectoryClassPath = "/org/springframework/richclient/samples/simple/ctx";
063    
064                    // The startup context defines elements that should be available
065                    // quickly such as a splash screen image.
066    
067                    String startupContextPath = rootContextDirectoryClassPath + "/richclient-startup-context.xml";
068    
069                    String richclientApplicationContextPath = rootContextDirectoryClassPath + "/richclient-application-context.xml";
070    
071                    // The ApplicationLauncher is responsible for loading the contexts,
072                    // presenting the splash screen, initializing the Application
073                    // singleton instance, creating the application window to display
074                    // the initial page.
075    
076                    try {
077                            new ApplicationLauncher(startupContextPath, new String[] { richclientApplicationContextPath });
078                    }
079                    catch (RuntimeException e) {
080                            logger.error("RuntimeException during startup", e);
081                    }
082            }
083    
084    }