Example usage for org.springframework.web.context.support WebApplicationContextUtils getWebApplicationContext

List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getWebApplicationContext

Introduction

In this page you can find the example usage for org.springframework.web.context.support WebApplicationContextUtils getWebApplicationContext.

Prototype

@Nullable
public static WebApplicationContext getWebApplicationContext(ServletContext sc) 

Source Link

Document

Find the root WebApplicationContext for this web app, typically loaded via org.springframework.web.context.ContextLoaderListener .

Usage

From source file:org.openmeetings.servlet.outputhandler.LangExport.java

public Sessionmanagement getSessionManagement() {
    try {//from w ww  . ja v  a2  s. c  om
        if (ScopeApplicationAdapter.initComplete) {
            ApplicationContext context = WebApplicationContextUtils
                    .getWebApplicationContext(getServletContext());
            return context.getBean("sessionManagement", Sessionmanagement.class);
        }
    } catch (Exception err) {
        log.error("[getSessionManagement]", err);
    }
    return null;
}

From source file:it.cilea.osd.common.validation.BaseValidator.java

/**
 * Get the FieldError validation message from the underlying MessageSource for the given fieldName.
 *
 * @param errors The validation errors./*from  w w w  . j av  a2s .  c o m*/
 * @param fieldName The fieldName to retrieve the error message from.
 * @return The validation message or an empty String.
 */
protected String getValidationMessage(Errors errors, String fieldName) {
    String message = "";
    FieldError fieldError = errors.getFieldError(fieldName);
    if (fieldError != null) {
        WebContext ctx = WebContextFactory.get();
        MessageSource messageSource = WebApplicationContextUtils
                .getWebApplicationContext(ctx.getServletContext());
        String errore = fieldError.getCode();
        //il messaggio deve essere ripescato dal resource bundle
        ResourceBundle resourceBundle = ResourceBundle.getBundle(Constants.BUNDLE_KEY,
                ctx.getHttpServletRequest().getLocale());
        message = resourceBundle.getString(errore);
    }
    return message;
}

From source file:eu.earthobservatory.org.StrabonEndpoint.BrowseBean.java

public void init(ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);

    // get the context of the servlet
    context = getServletContext();// w  w w .j  a  v a 2s.  co  m

    // get the context of the application
    WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);

    // the the strabon wrapper
    strabonWrapper = (StrabonBeanWrapper) applicationContext.getBean("strabonBean");

}

From source file:org.openmeetings.servlet.outputhandler.ScreenRequestHandler.java

public Sessionmanagement getSessionManagement() {
    try {/*from  ww w . j  a va 2 s.co m*/
        if (ScopeApplicationAdapter.initComplete) {
            ApplicationContext context = WebApplicationContextUtils
                    .getWebApplicationContext(getServletContext());
            return context.getBean(Sessionmanagement.class);
        }
    } catch (Exception err) {
        log.error("[getSessionManagement]", err);
    }
    return null;
}

From source file:com.pararede.alfresco.security.AlfrescoContainerSecurityFilter.java

public void init(FilterConfig config) throws ServletException {
    this.context = WebApplicationContextUtils.getWebApplicationContext(config.getServletContext());
    this.registry = (ServiceRegistry) this.context.getBean("ServiceRegistry");
}

From source file:gov.nih.nci.system.web.struts.action.RestQuery.java

public void init() throws Exception {

    ServletContext context = ServletActionContext.getServletContext();
    ctx = WebApplicationContextUtils.getWebApplicationContext(context);
    classCache = (ClassCache) ctx.getBean("ClassCache");
    Properties systemProperties = (Properties) ctx.getBean("WebSystemProperties");

    String securityEnabled = (String) systemProperties.getProperty("securityEnabled");
    secured = "yes".equalsIgnoreCase(securityEnabled) || "true".equalsIgnoreCase(securityEnabled);
    String isoEnabledStr = (String) systemProperties.getProperty("enableISO21090DataTypes");
    isoEnabled = "yes".equalsIgnoreCase(isoEnabledStr) || "true".equalsIgnoreCase(isoEnabledStr);

    String metadataEnabled = (String) systemProperties.getProperty("caDSRMetadataEnabled");
    metadata = "yes".equalsIgnoreCase(metadataEnabled) || "true".equalsIgnoreCase(metadataEnabled);
}

From source file:com.redip.servlet.nonconformity.NonConformityUpdateTable.java

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, JSONException {
    PrintWriter out = response.getWriter();

    String id = request.getParameter("id");
    int login = Integer.parseInt(id);
    int columnPosition = Integer.parseInt(request.getParameter("columnPosition"));

    String value = request.getParameter("value");
    String columnName = request.getParameter("columnName");

    Logger.log("NonConformityUpdate", Level.INFO,
            "id:" + login + ";value:" + value + ";columnName:" + columnName);

    ApplicationContext appContext = WebApplicationContextUtils
            .getWebApplicationContext(this.getServletContext());
    IQualityNonconformitiesService nonconformitiesService = appContext
            .getBean(IQualityNonconformitiesService.class);
    IEmailService emailService = appContext.getBean(IEmailService.class);
    IFactoryQualityNonconformities factoryQNC = appContext.getBean(IFactoryQualityNonconformities.class);

    QualityNonconformities nonconformities = nonconformitiesService.getOneNonconformities(login);

    String str = nonconformitiesService.updateNonconformity(login, columnName, value);

    emailService.sendEmailEvent("update" + columnName, nonconformities, columnName, value);

    out.print(value);/*from   w  ww . jav a  2  s .  co m*/
}

From source file:org.workingonit.gwtbridge.GwtBridgeServlet.java

protected RemoteService findRemoteService(String url) {
    WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
    GwtServicesRegistrar registrar = context.getBean(GwtServicesRegistrar.class);
    if (registrar == null) {
        throw new RuntimeException("No bean of class GwtServicesRegistrar defined in the Spring context!");
    }/*w  w  w . j a  va  2  s.  c o m*/

    String serviceName = url.substring(url.lastIndexOf("/") + 1);
    return registrar.retrieveGwtService(serviceName);
}

From source file:org.cerberus.servlet.publi.ExecuteNextInQueue.java

@Override
public void init() throws ServletException {
    ApplicationContext appContext = WebApplicationContextUtils
            .getWebApplicationContext(this.getServletContext());
    inQueueService = appContext.getBean(ITestCaseExecutionInQueueService.class);
}

From source file:it.geosolutions.geofence.gui.server.gwt.ConfigurationRemoteImpl.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());

    ApplicationContextUtil.getInstance().setSpringContext(context);

    this.startupService = (IStartupService) ApplicationContextUtil.getInstance().getBean("startupService");

    logger.info("SPRING CONTEXT INITIALIZED" + this.startupService);
}