Example usage for org.springframework.context ApplicationContextException ApplicationContextException

List of usage examples for org.springframework.context ApplicationContextException ApplicationContextException

Introduction

In this page you can find the example usage for org.springframework.context ApplicationContextException ApplicationContextException.

Prototype

public ApplicationContextException(String msg) 

Source Link

Document

Create a new ApplicationContextException with the specified detail message and no root cause.

Usage

From source file:ua.com.manometer.jasperreports.AbstractJasperReportsView.java

/**
 * Checks to see that a valid report file URL is supplied in the
 * configuration. Compiles the report file is necessary.
 * <p>Subclasses can add custom initialization logic by overriding
 * the {@link #onInit} method.//from ww w  .  j av  a  2  s.  c o m
 */
@Override
protected final void initApplicationContext() throws ApplicationContextException {
    this.report = loadReport();

    // Load sub reports if required, and check data source parameters.
    if (this.subReportUrls != null) {
        if (this.subReportDataKeys != null && this.subReportDataKeys.length > 0 && this.reportDataKey == null) {
            throw new ApplicationContextException(
                    "'reportDataKey' for main report is required when specifying a value for 'subReportDataKeys'");
        }
        this.subReports = new HashMap<String, JasperReport>(this.subReportUrls.size());
        for (Enumeration urls = this.subReportUrls.propertyNames(); urls.hasMoreElements();) {
            String key = (String) urls.nextElement();
            String path = this.subReportUrls.getProperty(key);
            Resource resource = getApplicationContext().getResource(path);
            this.subReports.put(key, loadReport(resource));
        }
    }

    // Convert user-supplied exporterParameters.
    convertExporterParameters();

    if (this.headers == null) {
        this.headers = new Properties();
    }
    if (!this.headers.containsKey(HEADER_CONTENT_DISPOSITION)) {
        this.headers.setProperty(HEADER_CONTENT_DISPOSITION, CONTENT_DISPOSITION_INLINE);
    }

    onInit();
}

From source file:com.dhcc.framework.web.context.DhccContextLoader.java

/**
 * Instantiate the root WebApplicationContext for this loader, either the
 * default context class or a custom context class if specified.
 * <p>This implementation expects custom contexts to implement the
 * {@link ConfigurableWebApplicationContext} interface.
 * Can be overridden in subclasses./*from ww w . j ava2 s .  c om*/
 * <p>In addition, {@link #customizeContext} gets called prior to refreshing the
 * context, allowing subclasses to perform custom modifications to the context.
 * @param sc current servlet context
 * @return the root WebApplicationContext
 * @see ConfigurableWebApplicationContext
 */
protected WebApplicationContext createWebApplicationContext(ServletContext sc) {
    Class<?> contextClass = determineContextClass(sc);
    if (!ConfigurableWebApplicationContext.class.isAssignableFrom(contextClass)) {
        throw new ApplicationContextException("Custom context class [" + contextClass.getName()
                + "] is not of type [" + ConfigurableWebApplicationContext.class.getName() + "]");
    }
    return (ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass);
}

From source file:com.cisco.dvbu.ps.deploytool.services.VCSManagerImpl.java

private static void setVCSConnectionProperties(String vcsConnectionId, String pathToVcsXML) {
    // Set the global variable that indicates that a VCS Version 2 method is invoking this procedure.
    // Original VCS methods do not invoke this method
    vcsV2Method = true;/*from  w  ww  .  ja  va 2  s .  c  o  m*/
    boolean vcsConnectionFound = false;
    String prefix = "setVCSConnectionProperties";
    String propValue = null;
    String oldProp = null;

    // validate incoming arguments
    if (vcsConnectionId == null || vcsConnectionId.trim().length() == 0 || pathToVcsXML == null
            || pathToVcsXML.trim().length() == 0) {
        throw new ValidationException("Invalid Arguments");
    }

    // Extract variables for the vcsConnectionId
    vcsConnectionId = CommonUtils.extractVariable(prefix, vcsConnectionId, propertyFile, true);

    if (logger.isDebugEnabled())
        logger.debug("VCSManagerImpl.setVCSConnectionProperties() : " + " vcsConnectionId: " + vcsConnectionId
                + ", pathToVcsXML: " + pathToVcsXML + ", propertyFile=" + propertyFile);

    try {
        //using jaxb convert xml to corresponding java objects
        VCSModule vcsModuleType = (VCSModule) XMLUtils.getModuleTypeFromXML(pathToVcsXML);

        if (vcsModuleType != null && vcsModuleType.getVcsConnections() != null
                && !vcsModuleType.getVcsConnections().getVcsConnection().isEmpty()) {

            if (vcsModuleType.getVcsConnections().getVcsConnection().size() > 0) {
                List<VCSConnectionType> vcsConnectionList = vcsModuleType.getVcsConnections()
                        .getVcsConnection();

                for (VCSConnectionType vcsConnection : vcsConnectionList) {

                    // Get the identifier and convert any $VARIABLES
                    String identifier = CommonUtils.extractVariable(prefix, vcsConnection.getId(), propertyFile,
                            true);

                    /**
                     * Possible values for archives 
                     * 1. csv string like import1,import2 (we process only resource names which are passed in)
                     * 2. '*' or what ever is configured to indicate all resources (we process all resources in this case)
                     * 3. csv string with '-' or what ever is configured to indicate exclude resources as prefix 
                     *      like -import1,import3 (we ignore passed in resources and process rest of the in the input xml
                     */
                    // Determine if the XML entry is in the list of vcsConnectionId passed in
                    if (DeployUtil.canProcessResource(vcsConnectionId, identifier)) {

                        // Set the vcs connection found flag
                        vcsConnectionFound = true;

                        // VCS_TYPE
                        String vcsType = vcsConnection.getVCSTYPE();
                        if (vcsType == null || vcsType.isEmpty()) {
                            throw new ValidationException("VCSModule XML Connection=" + vcsConnectionId
                                    + ": VCS_TYPE cannot be emtpy.");
                        }
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSTYPE(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_TYPE", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : " + " VCS_TYPE: "
                                    + propValue);

                        // VCS_BASE_TYPE
                        String vcsBaseType = vcsConnection.getVCSBASETYPE();
                        if (vcsBaseType == null || vcsBaseType.isEmpty()) {
                            // If the VCS_BASE_TYPE does not exist then use the VCS_TYPE value.
                            propValue = vcsType;
                            oldProp = System.setProperty("VCS_BASE_TYPE", propValue);
                        } else {
                            propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSBASETYPE(),
                                    propertyFile, true);
                            oldProp = System.setProperty("VCS_BASE_TYPE", propValue);
                        }
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : " + " VCS_BASE_TYPE: "
                                    + propValue);

                        // VCS_HOME
                        if (vcsConnection.getVCSHOME() == null || vcsConnection.getVCSHOME().isEmpty()) {
                            throw new ValidationException("VCSModule XML Connection=" + vcsConnectionId
                                    + ": VCS_HOME cannot be emtpy.");
                        }
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSHOME(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_HOME", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : " + " VCS_HOME: "
                                    + propValue);

                        // VCS_COMMAND
                        if (vcsConnection.getVCSCOMMAND() == null || vcsConnection.getVCSCOMMAND().isEmpty()) {
                            throw new ValidationException("VCSModule XML Connection=" + vcsConnectionId
                                    + ": VCS_COMMAND cannot be emtpy.");
                        }
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSCOMMAND(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_COMMAND", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : " + " VCS_COMMAND: "
                                    + propValue);

                        // VCS_EXEC_FULL_PATH
                        if (vcsConnection.getVCSEXECFULLPATH() == null
                                || vcsConnection.getVCSEXECFULLPATH().isEmpty()) {
                            throw new ValidationException("VCSModule XML Connection=" + vcsConnectionId
                                    + ": VCS_EXEC_FULL_PATH cannot be emtpy.");
                        }
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSEXECFULLPATH(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_EXEC_FULL_PATH", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                    + " VCS_EXEC_FULL_PATH: " + propValue);

                        // VCS_REPOSITORY_URL
                        if (vcsConnection.getVCSREPOSITORYURL() == null
                                || vcsConnection.getVCSREPOSITORYURL().isEmpty()) {
                            throw new ValidationException("VCSModule XML Connection=" + vcsConnectionId
                                    + ": VCS_REPOSITORY_URL cannot be emtpy.");
                        }
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSREPOSITORYURL(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_REPOSITORY_URL", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                    + " VCS_REPOSITORY_URL: " + propValue);

                        // VCS_PROJECT_ROOT
                        if (vcsConnection.getVCSPROJECTROOT() == null
                                || vcsConnection.getVCSPROJECTROOT().isEmpty()) {
                            throw new ValidationException("VCSModule XML Connection=" + vcsConnectionId
                                    + ": VCS_PROJECT_ROOT cannot be emtpy.");
                        }
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSPROJECTROOT(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_PROJECT_ROOT", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                    + " VCS_PROJECT_ROOT: " + propValue);

                        // VCS_WORKSPACE_HOME
                        if (vcsConnection.getVCSWORKSPACEHOME() == null
                                || vcsConnection.getVCSWORKSPACEHOME().isEmpty()) {
                            throw new ValidationException("VCSModule XML Connection=" + vcsConnectionId
                                    + ": VCS_WORKSPACE_HOME cannot be emtpy.");
                        }
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSWORKSPACEHOME(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_WORKSPACE_HOME", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                    + " VCS_WORKSPACE_HOME: " + propValue);

                        // VCS_WORKSPACE_NAME
                        if (vcsConnection.getVCSWORKSPACENAME() == null
                                || vcsConnection.getVCSWORKSPACENAME().isEmpty()) {
                            throw new ValidationException("VCSModule XML Connection=" + vcsConnectionId
                                    + ": VCS_WORKSPACE_NAME cannot be emtpy.");
                        }
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSWORKSPACENAME(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_WORKSPACE_NAME", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                    + " VCS_WORKSPACE_NAME: " + propValue);

                        // VCS_WORKSPACE_DIR
                        if (vcsConnection.getVCSWORKSPACEDIR() == null
                                || vcsConnection.getVCSWORKSPACEDIR().isEmpty()) {
                            throw new ValidationException("VCSModule XML Connection=" + vcsConnectionId
                                    + ": VCS_WORKSPACE_DIR cannot be emtpy.");
                        }
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSWORKSPACEDIR(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_WORKSPACE_DIR", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                    + " VCS_WORKSPACE_DIR: " + propValue);

                        // VCS_TEMP_DIR
                        if (vcsConnection.getVCSTEMPDIR() == null || vcsConnection.getVCSTEMPDIR().isEmpty()) {
                            throw new ValidationException("VCSModule XML Connection=" + vcsConnectionId
                                    + ": VCS_TEMP_DIR cannot be emtpy.");
                        }
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSTEMPDIR(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_TEMP_DIR", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : " + " VCS_TEMP_DIR: "
                                    + propValue);

                        // VCS_OPTIONS
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSOPTIONS(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_OPTIONS", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : " + " VCS_OPTIONS: "
                                    + propValue);

                        // VCS_WORKSPACE_INIT_NEW_OPTIONS
                        if (vcsConnection.getVCSWORKSPACEINITNEWOPTIONS() != null) {
                            propValue = CommonUtils.extractVariable(prefix,
                                    vcsConnection.getVCSWORKSPACEINITNEWOPTIONS(), propertyFile, true);
                            oldProp = System.setProperty("VCS_WORKSPACE_INIT_NEW_OPTIONS", propValue);
                            if (logger.isDebugEnabled())
                                logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                        + " VCS_WORKSPACE_INIT_NEW_OPTIONS: " + propValue);
                        }

                        // VCS_WORKSPACE_INIT_LINK_OPTIONS
                        if (vcsConnection.getVCSWORKSPACEINITLINKOPTIONS() != null) {
                            propValue = CommonUtils.extractVariable(prefix,
                                    vcsConnection.getVCSWORKSPACEINITLINKOPTIONS(), propertyFile, true);
                            oldProp = System.setProperty("VCS_WORKSPACE_INIT_LINK_OPTIONS", propValue);
                            if (logger.isDebugEnabled())
                                logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                        + " VCS_WORKSPACE_INIT_LINK_OPTIONS: " + propValue);
                        }

                        // VCS_WORKSPACE_INIT_GET_OPTIONS
                        if (vcsConnection.getVCSWORKSPACEINITGETOPTIONS() != null) {
                            propValue = CommonUtils.extractVariable(prefix,
                                    vcsConnection.getVCSWORKSPACEINITGETOPTIONS(), propertyFile, true);
                            oldProp = System.setProperty("VCS_WORKSPACE_INIT_GET_OPTIONS", propValue);
                            if (logger.isDebugEnabled())
                                logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                        + " VCS_WORKSPACE_INIT_GET_OPTIONS: " + propValue);
                        }

                        // VCS_BASE_FOLDER_INIT_ADD
                        if (vcsConnection.getVCSBASEFOLDERINITADD() != null) {
                            propValue = CommonUtils.extractVariable(prefix,
                                    vcsConnection.getVCSBASEFOLDERINITADD(), propertyFile, true);
                            oldProp = System.setProperty("VCS_BASE_FOLDER_INIT_ADD", propValue);
                            if (logger.isDebugEnabled())
                                logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                        + " VCS_BASE_FOLDER_INIT_ADD: " + propValue);
                        }

                        // VCS_CHECKIN_OPTIONS
                        if (vcsConnection.getVCSCHECKINOPTIONS() != null) {
                            propValue = CommonUtils.extractVariable(prefix,
                                    vcsConnection.getVCSCHECKINOPTIONS(), propertyFile, true);
                            oldProp = System.setProperty("VCS_CHECKIN_OPTIONS", propValue);
                            if (logger.isDebugEnabled())
                                logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                        + " VCS_CHECKIN_OPTIONS: " + propValue);
                        }

                        // VCS_CHECKIN_OPTIONS_REQUIRED
                        if (vcsConnection.getVCSCHECKINOPTIONSREQUIRED() != null) {
                            propValue = CommonUtils.extractVariable(prefix,
                                    vcsConnection.getVCSCHECKINOPTIONSREQUIRED(), propertyFile, true);
                            oldProp = System.setProperty("VCS_CHECKIN_OPTIONS_REQUIRED", propValue);
                            if (logger.isDebugEnabled())
                                logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                        + " VCS_CHECKIN_OPTIONS_REQUIRED: " + propValue);
                        }

                        // VCS_CHECKOUT_OPTIONS
                        if (vcsConnection.getVCSCHECKOUTOPTIONS() != null) {
                            propValue = CommonUtils.extractVariable(prefix,
                                    vcsConnection.getVCSCHECKOUTOPTIONS(), propertyFile, true);
                            oldProp = System.setProperty("VCS_CHECKOUT_OPTIONS", propValue);
                            if (logger.isDebugEnabled())
                                logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                        + " VCS_CHECKOUT_OPTIONS: " + propValue);
                        }

                        // VCS_CHECKOUT_OPTIONS_REQUIRED
                        if (vcsConnection.getVCSCHECKOUTOPTIONSREQUIRED() != null) {
                            propValue = CommonUtils.extractVariable(prefix,
                                    vcsConnection.getVCSCHECKOUTOPTIONSREQUIRED(), propertyFile, true);
                            oldProp = System.setProperty("VCS_CHECKOUT_OPTIONS_REQUIRED", propValue);
                            if (logger.isDebugEnabled())
                                logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                        + " VCS_CHECKOUT_OPTIONS_REQUIRED: " + propValue);
                        }

                        // VCS_CIS_IMPORT_OPTIONS
                        if (vcsConnection.getVCSCISIMPORTOPTIONS() != null) {
                            propValue = CommonUtils.extractVariable(prefix,
                                    vcsConnection.getVCSCISIMPORTOPTIONS(), propertyFile, true);
                            oldProp = System.setProperty("VCS_CIS_IMPORT_OPTIONS", propValue);
                            if (logger.isDebugEnabled())
                                logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                        + " VCS_CIS_IMPORT_OPTIONS: " + propValue);
                        }

                        // VCS_CIS_EXPORT_OPTIONS
                        if (vcsConnection.getVCSCISEXPORTOPTIONS() != null) {
                            propValue = CommonUtils.extractVariable(prefix,
                                    vcsConnection.getVCSCISEXPORTOPTIONS(), propertyFile, true);
                            oldProp = System.setProperty("VCS_CIS_EXPORT_OPTIONS", propValue);
                            if (logger.isDebugEnabled())
                                logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                        + " VCS_CIS_EXPORT_OPTIONS: " + propValue);
                        }

                        // VCS_USERNAME
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSUSERNAME(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_USERNAME", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : " + " VCS_USERNAME: "
                                    + propValue);

                        // VCS_PASSWORD
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSPASSWORD(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_PASSWORD", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : " + " VCS_PASSWORD: "
                                    + propValue);

                        // VCS_IGNORE_MESSAGES
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSIGNOREMESSAGES(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_IGNORE_MESSAGES", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                    + " VCS_IGNORE_MESSAGES: " + propValue);

                        // VCS_MESSAGE_PREPEND
                        propValue = CommonUtils.extractVariable(prefix, vcsConnection.getVCSMESSAGEPREPEND(),
                                propertyFile, true);
                        oldProp = System.setProperty("VCS_MESSAGE_PREPEND", propValue);
                        if (logger.isDebugEnabled())
                            logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                    + " VCS_MESSAGE_PREPEND: " + propValue);

                        // VCS_MESSAGE_MANDATORY
                        /* 3-7-2012: may not need       
                        //oldProp = System.setProperty("VCS_MESSAGE_MANDATORY", vcsConnection.getVCSMESSAGEMANDATORY());
                        */
                        // Extract the user defined name value pairs P4_ENV, CVS_ENV, SVN_ENV, TFS_ENV, or GIT_ENV
                        if (vcsConnection.getVcsSpecificEnvVars() != null
                                && !vcsConnection.getVcsSpecificEnvVars().getEnvVar().isEmpty()) {

                            String envList = "";
                            List<VCSConnectionEnvNameValuePairType> nameValuePairList = vcsConnection
                                    .getVcsSpecificEnvVars().getEnvVar();

                            // Loop through the user-defined property list and concatenate them to an environment list
                            // This is similar to how they are handled in the deploy.properties or studio.properties file
                            for (VCSConnectionEnvNameValuePairType nameValue : nameValuePairList) {

                                String envName = nameValue.getEnvName();
                                String envValue = CommonUtils.extractVariable(prefix, nameValue.getEnvValue(),
                                        propertyFile, true);
                                if (vcsType.equalsIgnoreCase("P4") && envName.equalsIgnoreCase("P4PASSWD")) {
                                    envValue = CommonUtils.decrypt(envValue);
                                }
                                oldProp = System.setProperty(envName, envValue);
                                if (envList.length() > 0) {
                                    envList = envList + ",";
                                }
                                envList = envList + envName;
                            }
                            // Set then JVM property for the VCS type being used [SVN, P4, CVS, TFS2005, TFS2010, TFS2012, TFS2013, etc]
                            if (envList.length() > 0) {
                                if (vcsType.equalsIgnoreCase("P4")) {
                                    oldProp = System.setProperty("P4_ENV", envList);
                                    if (logger.isDebugEnabled())
                                        logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                                + " P4_ENV: " + envList);
                                }
                                if (vcsType.equalsIgnoreCase("CVS")) {
                                    oldProp = System.setProperty("CVS_ENV", envList);
                                    if (logger.isDebugEnabled())
                                        logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                                + " CVS_ENV: " + envList);
                                }
                                if (vcsType.equalsIgnoreCase("SVN")) {
                                    oldProp = System.setProperty("SVN_ENV", envList);
                                    if (logger.isDebugEnabled())
                                        logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                                + " SVN_ENV: " + envList);
                                }

                                if (vcsType.equalsIgnoreCase("TFS2005") || vcsType.equalsIgnoreCase("TFS2010")
                                        || vcsType.equalsIgnoreCase("TFS2012")
                                        || vcsType.equalsIgnoreCase("TFS2013")) {
                                    // set TFS_ENV
                                    oldProp = System.setProperty("TFS_ENV", envList);
                                    if (logger.isDebugEnabled())
                                        logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                                + " TFS_ENV: " + envList);
                                }
                                if (vcsType.equalsIgnoreCase("GIT")) {
                                    oldProp = System.setProperty("GIT_ENV", envList);
                                    if (logger.isDebugEnabled())
                                        logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                                + " GIT_ENV: " + envList);
                                }
                                if (vcsType.equalsIgnoreCase("CLC")) {
                                    oldProp = System.setProperty("CLC_ENV", envList);
                                    if (logger.isDebugEnabled())
                                        logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                                + " CLC_ENV: " + envList);
                                }
                                //--------------------------------------------------------------
                                // setVCSConnectionProperties: New VCS Type (new) specific settings
                                //--------------------------------------------------------------
                                if (vcsType.equalsIgnoreCase("ABC")) {
                                    oldProp = System.setProperty("ABC_ENV", envList);
                                    if (logger.isDebugEnabled())
                                        logger.debug("VCSManagerImpl.setVCSConnectionProperties() : "
                                                + " ABC_ENV: " + envList);
                                }
                            }
                        }
                    }
                }
            }
        }

        if (!vcsConnectionFound)
            throw new ApplicationContextException("The selected VCS Connection Id (VCONN) \"" + vcsConnectionId
                    + "\" was not found in the file " + pathToVcsXML);

    } catch (CompositeException e) {
        String errorMessage = DeployUtil.constructMessage(DeployUtil.MessageType.ERROR.name(),
                "Parse VCSModule XML", "setVCSConnectionProperties", pathToVcsXML, null);

        logger.error(errorMessage, e);
        throw new ApplicationContextException(errorMessage, e);
    }
}

From source file:com.workingmouse.webservice.axis.SpringAxisServlet.java

/**
 * Instantiate the WebApplicationContext for the SpringAxisServlet, either a default
 * XmlWebApplicationContext or a custom context class if set. This implementation
 * expects custom contexts to implement ConfigurableWebApplicationContext.
 * Can be overridden in subclasses.//from w w w.  j  a v a  2 s.c  o  m
 *
 * @throws org.springframework.beans.BeansException
 *      if the context couldn't be initialized
 *
 * @see #setContextClass
 *
 * @see org.springframework.web.context.support.XmlWebApplicationContext
 */
protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent)
        throws BeansException {

    if (LOG.isDebugEnabled()) {
        LOG.debug("Servlet with name '" + getServletName()
                + "' will try to create custom WebApplicationContext context of class '"
                + getContextClass().getName() + "'" + " using parent context [" + parent + "]");
    }
    if (!ConfigurableWebApplicationContext.class.isAssignableFrom(getContextClass())) {
        throw new ApplicationContextException("Fatal initialization error in servlet with name '"
                + getServletName() + "': custom WebApplicationContext class [" + getContextClass().getName()
                + "] is not of type ConfigurableWebApplicationContext");
    }

    ConfigurableWebApplicationContext wac = createContextInstance();
    wac.setParent(parent);
    wac.setServletContext(getServletContext());
    wac.setNamespace(getNamespace());

    if (this.contextConfigLocation != null) {
        wac.setConfigLocations(StringUtils.tokenizeToStringArray(this.contextConfigLocation,
                ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS, true, true));
    }
    wac.refresh();
    return wac;
}

From source file:net.sf.sail.webapp.spring.impl.CustomContextLoader.java

/**
 * The behaviour of this method is the same as the superclass except for
 * setting of the config locations.// w  ww.  ja va2  s  . c  om
 * 
 * @throws ClassNotFoundException
 * 
 * @see org.springframework.web.context.ContextLoader#createWebApplicationContext(javax.servlet.ServletContext,
 *      org.springframework.context.ApplicationContext)
 */
@Override
protected WebApplicationContext createWebApplicationContext(ServletContext servletContext,
        ApplicationContext parent) throws BeansException {

    Class<?> contextClass = determineContextClass(servletContext);
    if (!ConfigurableWebApplicationContext.class.isAssignableFrom(contextClass)) {
        throw new ApplicationContextException("Custom context class [" + contextClass.getName()
                + "] is not of type ConfigurableWebApplicationContext");
    }

    ConfigurableWebApplicationContext webApplicationContext = (ConfigurableWebApplicationContext) BeanUtils
            .instantiateClass(contextClass);
    webApplicationContext.setParent(parent);
    webApplicationContext.setServletContext(servletContext);

    String configClass = servletContext.getInitParameter(CONFIG_CLASS_PARAM);
    if (configClass != null) {
        try {
            SpringConfiguration springConfig = (SpringConfiguration) BeanUtils
                    .instantiateClass(Class.forName(configClass));
            webApplicationContext.setConfigLocations(springConfig.getRootApplicationContextConfigLocations());
        } catch (ClassNotFoundException e) {
            if (LOGGER.isErrorEnabled()) {
                LOGGER.error(CONFIG_CLASS_PARAM + " <" + configClass + "> not found.", e);
            }
            throw new InvalidParameterException("ClassNotFoundException: " + configClass);
        }
    } else {
        throw new InvalidParameterException("No value defined for the required: " + CONFIG_CLASS_PARAM);
    }

    webApplicationContext.refresh();
    return webApplicationContext;
}

From source file:org.codehaus.enunciate.modules.rest.RESTResourceExporter.java

@Override
protected void initApplicationContext() throws BeansException {
    super.initApplicationContext();

    if (resource == null) {
        throw new ApplicationContextException("A REST resource must be provided.");
    }/*  w  w  w  . ja v a2s.co m*/

    if (contentTypeSupport == null) {
        throw new ApplicationContextException("No content type support was supplied.");
    }

    if (this.multipartRequestHandler == null) {
        this.multipartRequestHandler = new DefaultMultipartRequestHandler();
        Map beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(getApplicationContext(),
                AutowiredAnnotationBeanPostProcessor.class);
        if (!beans.isEmpty()) {
            AutowiredAnnotationBeanPostProcessor processor = (AutowiredAnnotationBeanPostProcessor) beans
                    .values().iterator().next();
            processor.processInjection(this.multipartRequestHandler);
        }
    }
}

From source file:org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.java

/**
 * Cancel waiting due to timeout./* w ww.j a va2  s .  c  o  m*/
 */
private void timeout() {
    ApplicationContextException e;
    List<OsgiServiceDependencyEvent> events = null;
    String filterAsString = null;

    synchronized (monitor) {
        // deregister listener to get an accurate snapshot of the
        // unsatisfied dependencies.

        if (dependencyDetector != null) {
            dependencyDetector.deregister();
            events = dependencyDetector.getUnsatisfiedDependenciesAsEvents();
            filterAsString = dependencyDetector.createUnsatisfiedDependencyFilter();
        }
    }

    Filter filter = (filterAsString != null ? OsgiFilterUtils.createFilter(filterAsString) : null);

    log.warn("Timeout occurred before finding service dependencies for [" + delegateContext.getDisplayName()
            + "]");

    String bundleName = null;
    if (System.getSecurityManager() != null) {
        bundleName = AccessController.doPrivileged(new PrivilegedAction<String>() {
            public String run() {
                return OsgiStringUtils.nullSafeSymbolicName(getBundle());
            }
        });
    } else {
        bundleName = OsgiStringUtils.nullSafeSymbolicName(getBundle());
    }

    // generate exception
    e = new ApplicationContextException("Application context " + "initialization for '" + bundleName
            + "' has timed out waiting for " + filterAsString);
    e.fillInStackTrace();

    // send notification
    delegatedMulticaster.multicastEvent(new BootstrappingDependenciesFailedEvent(delegateContext,
            delegateContext.getBundle(), e, events, filter));

    fail(e, true);
}

From source file:org.jsecurity.spring.SpringIniWebConfiguration.java

protected SecurityManager getOrCreateSecurityManager(ApplicationContext appCtx,
        Map<String, Map<String, String>> sections) {
    String beanName = getSecurityManagerBeanName();

    SecurityManager securityManager = null;
    if (beanName != null) {
        securityManager = (SecurityManager) appCtx.getBean(beanName, SecurityManager.class);
    }//from  w  w w  .j  a  va 2s . com

    if (securityManager == null) {
        securityManager = getSecurityManagerByType(appCtx);
    }

    if (securityManager == null) {
        securityManager = createDefaultSecurityManagerFromRealms(appCtx, sections);
    }

    if (securityManager == null) {
        String msg = "Unable to locate a " + SecurityManager.class.getName() + " instance in the "
                + "Spring WebApplicationContext.  You can 1) simply just define the securityManager as a bean ("
                + "it will be automatically located based on type) or "
                + "2) explicitly specifify which bean is retrieved by setting this filter's "
                + "'securityManagerBeanName' init-param or 3) define one or more " + Realm.class.getName()
                + " instances and a default SecurityManager using those realms will be created automatically.";
        throw new ApplicationContextException(msg);
    }
    return securityManager;
}

From source file:org.jsecurity.spring.SpringIniWebConfiguration.java

@SuppressWarnings("unchecked")
protected SecurityManager getSecurityManagerByType(ApplicationContext appCtx) {

    SecurityManager securityManager = null;

    Map<String, SecurityManager> securityManagers = appCtx.getBeansOfType(SecurityManager.class);
    if (securityManagers == null || securityManagers.isEmpty()) {
        return null;
    }//from   w  w  w .j a va 2  s.c om

    if (securityManagers.size() > 1) {

        // If more than one are declared, see if one is named "securityManager"
        securityManager = securityManagers.get(DEFAULT_SECURITY_MANAGER_BEAN_ID);

        if (securityManager == null) {
            String msg = "There is more than one bean of type " + SecurityManager.class.getName()
                    + " available in the "
                    + "Spring WebApplicationContext.  Please specify which bean should be used by "
                    + "setting this filter's 'securityManagerBeanName' init-param or by naming one of the "
                    + "security managers '" + DEFAULT_SECURITY_MANAGER_BEAN_ID + "'.";
            throw new ApplicationContextException(msg);
        }

    } else if (securityManagers.size() == 1) {

        securityManager = securityManagers.values().iterator().next();
    }

    return securityManager;
}

From source file:org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.java

/**
 * Returns the {@link EmbeddedServletContainerFactory} that should be used to create
 * the embedded servlet container. By default this method searches for a suitable bean
 * in the context itself./* ww  w .  j  av a  2 s  .  co  m*/
 * @return a {@link EmbeddedServletContainerFactory} (never {@code null})
 */
protected EmbeddedServletContainerFactory getEmbeddedServletContainerFactory() {
    // Use bean names so that we don't consider the hierarchy
    String[] beanNames = getBeanFactory().getBeanNamesForType(EmbeddedServletContainerFactory.class);
    if (beanNames.length == 0) {
        throw new ApplicationContextException("Unable to start EmbeddedWebApplicationContext due to missing "
                + "EmbeddedServletContainerFactory bean.");
    }
    if (beanNames.length > 1) {
        throw new ApplicationContextException("Unable to start EmbeddedWebApplicationContext due to multiple "
                + "EmbeddedServletContainerFactory beans : "
                + StringUtils.arrayToCommaDelimitedString(beanNames));
    }
    return getBeanFactory().getBean(beanNames[0], EmbeddedServletContainerFactory.class);
}