<commit_before>/*
 * Copyright 2002-2004 the original author or authors.
 *
 * 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.
 */
package org.springframework.richclient.application.config;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.richclient.application.Application;
import org.springframework.richclient.application.ApplicationServices;
import org.springframework.richclient.application.ApplicationServicesLocator;
import org.springframework.richclient.application.ApplicationWindow;
import org.springframework.richclient.application.support.ApplicationWindowCommandManager;
import org.springframework.richclient.command.CommandGroup;
import org.springframework.richclient.exceptionhandling.DefaultRegisterableExceptionHandler;
import org.springframework.richclient.exceptionhandling.RegisterableExceptionHandler;
import org.springframework.richclient.progress.StatusBarCommandGroup;
import org.springframework.util.Assert;

/**
 * @author <NAME>
 * @author <NAME>
 */
public abstract class ApplicationLifecycleAdvisor implements InitializingBean {
    private static final String EXCEPTION_HANDLER_KEY = "sun.awt.exception.handler";

    private Application application;

    private ApplicationWindow openingWindow;

    private String startingPageId;

    private RegisterableExceptionHandler registerableExceptionHandler;

    /**
     * This is used to allow the ViewDescriptor to be lazily created when the
     * ApplicationWindow is opened. Useful when the ApplicationAdvisor needs to
     * do things before ViewDescriptor should be created, such as setting up a
     * security context.
     * 
     * @param startingViewDescriptorBeanName the name of the bean to create
     * 
     * @see #getStartingViewDescriptor()
     */
    public void setStartingPageId(String pageDescriptorId) {
        this.startingPageId = pageDescriptorId;
    }

    /**
     * Sets the exception handler which will be registered upon initialization to handle uncaught throwables.
     *
     * By default this is a DefaultRegisterableExceptionHandler,
     * which is inferiour to a well configured DelegatingExceptionHandler (java 1.5 only).
     *
     * @param registerableExceptionHandler the exception handler which will handle uncaught throwables
     */
    public void setRegisterableExceptionHandler(RegisterableExceptionHandler registerableExceptionHandler) {
        this.registerableExceptionHandler = registerableExceptionHandler;
    }

    public void afterPropertiesSet() throws Exception {
        getRegisterableExceptionHandler().registerExceptionHandler();
        Assert.state(startingPageId != null,
                "startingPageId must be set: it must point to a page descriptor, or a view descriptor for a single view per page");<commit_msg>Fixed minor typo in javadoc<commit_after>/*
 * Copyright 2002-2004 the original author or authors.
 *
 * 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.
 */
package org.springframework.richclient.application.config;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.richclient.application.Application;
import org.springframework.richclient.application.ApplicationServices;
import org.springframework.richclient.application.ApplicationServicesLocator;
import org.springframework.richclient.application.ApplicationWindow;
import org.springframework.richclient.application.support.ApplicationWindowCommandManager;
import org.springframework.richclient.command.CommandGroup;
import org.springframework.richclient.exceptionhandling.DefaultRegisterableExceptionHandler;
import org.springframework.richclient.exceptionhandling.RegisterableExceptionHandler;
import org.springframework.richclient.progress.StatusBarCommandGroup;
import org.springframework.util.Assert;

/**
 * @author <NAME>
 * @author <NAME>
 */
public abstract class ApplicationLifecycleAdvisor implements InitializingBean {
    private static final String EXCEPTION_HANDLER_KEY = "sun.awt.exception.handler";

    private Application application;

    private ApplicationWindow openingWindow;

    private String startingPageId;

    private RegisterableExceptionHandler registerableExceptionHandler;

    /**
     * This is used to allow the ViewDescriptor to be lazily created when the
     * ApplicationWindow is opened. Useful when the ApplicationAdvisor needs to
     * do things before ViewDescriptor should be created, such as setting up a
     * security context.
     * 
     * @param startingViewDescriptorBeanName the name of the bean to create
     * 
     * @see #getStartingViewDescriptor()
     */
    public void setStartingPageId(String pageDescriptorId) {
        this.startingPageId = pageDescriptorId;
    }

    /**
     * Sets the exception handler which will be registered upon initialization to handle uncaught throwables.
     *
     * By default this is a DefaultRegisterableExceptionHandler,
     * which is inferior to a well configured DelegatingExceptionHandler (java 1.5 only).
     *
     * @param registerableExceptionHandler the exception handler which will handle uncaught throwables
     */
    public void setRegisterableExceptionHandler(RegisterableExceptionHandler registerableExceptionHandler) {
        this.registerableExceptionHandler = registerableExceptionHandler;
    }

    public void afterPropertiesSet() throws Exception {
        getRegisterableExceptionHandler().registerExceptionHandler();
        Assert.state(startingPageId != null,
                "startingPageId must be set: it must point to a page descriptor, or a view descriptor for a single view per page");
{'fraction_non_alphanumeric': 0.06162211146352515, 'fraction_numerical': 0.004228968433771334, 'mean_word_length': 4.513738551207327, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3026732', 'n_tokens_mistral': 1542, 'n_tokens_neox': 1487, 'n_words': 537}