Example usage for org.springframework.context.support ResourceBundleMessageSource ResourceBundleMessageSource

List of usage examples for org.springframework.context.support ResourceBundleMessageSource ResourceBundleMessageSource

Introduction

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

Prototype

public ResourceBundleMessageSource() 

Source Link

Usage

From source file:edu.duke.cabig.c3pr.domain.StudySubject.java

/**
 * Instantiates a new study subject.//from  ww w. j a va2  s  . c  o m
 */
public StudySubject() {
    ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
    resourceBundleMessageSource.setBasename("error_messages_multisite");
    ResourceBundleMessageSource resourceBundleMessageSource1 = new ResourceBundleMessageSource();
    resourceBundleMessageSource1.setBasename("error_messages_c3pr");
    resourceBundleMessageSource1.setParentMessageSource(resourceBundleMessageSource);
    this.c3prErrorMessages = resourceBundleMessageSource1;
    this.c3PRExceptionHelper = new C3PRExceptionHelper(c3prErrorMessages);
    lazyListHelper = new LazyListHelper();
    this.regDataEntryStatus = RegistrationDataEntryStatus.INCOMPLETE;
    this.regWorkflowStatus = RegistrationWorkFlowStatus.PENDING;
    lazyListHelper.add(OrganizationAssignedIdentifier.class,
            new ParameterizedInstantiateFactory<OrganizationAssignedIdentifier>(
                    OrganizationAssignedIdentifier.class));
    lazyListHelper.add(SystemAssignedIdentifier.class,
            new ParameterizedInstantiateFactory<SystemAssignedIdentifier>(SystemAssignedIdentifier.class));
    setIdentifiers(new ArrayList<Identifier>());
    lazyListHelper.add(CustomField.class,
            new ParameterizedBiDirectionalInstantiateFactory<CustomField>(CustomField.class, this));
    lazyListHelper.add(Correspondence.class,
            new ParameterizedInstantiateFactory<Correspondence>(Correspondence.class));

    // mandatory, so that the lazy-projected list is managed properly.
}

From source file:com.alliander.osgp.webdevicesimulator.application.config.ApplicationContext.java

/**
 * Method for creating the Message Source.
 *
 * @return MessageSource/*from  ww w. j a va 2 s  .  c o  m*/
 */
@Bean
public MessageSource messageSource() {
    final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();

    messageSource.setBasename(this.environment.getRequiredProperty(PROPERTY_NAME_MESSAGESOURCE_BASENAME));
    messageSource.setUseCodeAsDefaultMessage(Boolean.parseBoolean(
            this.environment.getRequiredProperty(PROPERTY_NAME_MESSAGESOURCE_USE_CODE_AS_DEFAULT_MESSAGE)));

    return messageSource;
}

From source file:net.solarnetwork.node.control.ping.HttpRequesterJob.java

@Override
public MessageSource getMessageSource() {
    if (MESSAGE_SOURCE == null) {
        ResourceBundleMessageSource source = new ResourceBundleMessageSource();
        source.setBundleClassLoader(getClass().getClassLoader());
        source.setBasename(getClass().getName());
        MESSAGE_SOURCE = source;// w  w w.j a v  a 2s  . c  o m
    }
    return MESSAGE_SOURCE;
}

From source file:net.solarnetwork.node.support.LocationDatumDataSource.java

@Override
public synchronized MessageSource getMessageSource() {
    if (messageSource == null) {
        MessageSource other = null;//  www.  j  a va2s .  c  o  m
        if (delegate instanceof SettingSpecifierProvider) {
            other = ((SettingSpecifierProvider) delegate).getMessageSource();
        }
        PrefixedMessageSource delegateSource = null;
        if (other != null) {
            delegateSource = new PrefixedMessageSource();
            delegateSource.setDelegate(other);
            delegateSource.setPrefix("delegate.");
        }

        ResourceBundleMessageSource proxySource = new ResourceBundleMessageSource();
        proxySource.setBundleClassLoader(getClass().getClassLoader());
        proxySource.setBasename(messageBundleBasename);
        if (delegateSource != null) {
            proxySource.setParentMessageSource(delegateSource);
        }

        messageSource = proxySource;
    }
    return messageSource;
}

From source file:com.all.login.LoginModule.java

public LoginModule() {
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasename("com.all.login.i18n.Messages");

    messages = new DefaultMessages(messageSource);
    ApplicationLanguage lang = ApplicationLanguage.getLanguage();
    messages.setLocale(lang.locale());/*from  w  w w.  j  a  v a  2s.  c  om*/
    createLoaderWindow(messages, null, null);
}

From source file:cu.uci.coj.restapi.controller.RestUserProfileController.java

private String ValidateUser(User user) {
    ResourceBundleMessageSource r = new ResourceBundleMessageSource();
    r.setBasename("messages_en");

    user.setDob(new Date(user.getYear() - 1900, user.getMonth() - 1, user.getDay()));

    if (user.getNick().length() == 0)
        return r.getMessage("judge.register.error.nick", null, new Locale("en"));

    if ((user.getNick().length()) > 15)
        return r.getMessage("judge.register.error.long25charact", null, new Locale("en"));

    if (user.getNick().length() < 3)
        return r.getMessage("judge.register.error.less3charact", null, new Locale("en"));

    if (user.getName().length() < 1)
        return r.getMessage("errormsg.7", null, new Locale("en"));

    if (user.getName().length() > 30)
        return r.getMessage("errormsg.6", null, new Locale("en"));

    if (!user.getName().matches("[a-zA-Z\\.\\-\\'\\s]+"))
        return r.getMessage("errormsg.8", null, new Locale("en"));

    if (user.getLastname().length() < 1)
        return r.getMessage("errormsg.10", null, new Locale("en"));

    if (user.getLastname().length() > 50)
        return r.getMessage("errormsg.9", null, new Locale("en"));

    if (!user.getLastname().matches("[a-zA-Z\\.\\-\\'\\s]+"))
        return r.getMessage("errormsg.11", null, new Locale("en"));

    // si el correo ha sido cambiado y esta en uso por otra persona en el
    // COJ//from  www .  j  a v a  2s  .  co  m
    if (user.getEmail().length() == 0)
        return r.getMessage("errormsg.51", null, new Locale("en"));

    if (!StringUtils.isEmpty(user.getEmail()) && userDAO.bool("email.changed", user.getEmail(), user.getUid())
            && userDAO.emailExistUpdate(user.getEmail().trim(), user.getUsername()))
        return r.getMessage("judge.register.error.emailexist", null, new Locale("en"));

    EmailValidator emailValidator = EmailValidator.getInstance(); //ver como inyectar este objeto
    if (!emailValidator.isValid(user.getEmail()))
        return r.getMessage("judge.register.error.bademail", null, new Locale("en"));

    if (user.getCountry_id() == 0)
        return r.getMessage("judge.register.error.country", null, new Locale("en"));

    if (user.getInstitution_id() == 0)
        return r.getMessage("judge.register.error.institution", null, new Locale("en"));

    if (user.getLid() == 0)
        return r.getMessage("judge.register.error.planguage", null, new Locale("en"));

    if (user.getLocale() == 0)
        return r.getMessage("judge.register.error.locale", null, new Locale("en"));

    if (user.getName().length() == 0)
        return r.getMessage("judge.register.error.name", null, new Locale("en"));

    if (user.getGender() == 0)
        return r.getMessage("judge.register.error.gender", null, new Locale("en"));

    return "0";
}

From source file:net.solarnetwork.node.centameter.CentameterSupport.java

public MessageSource getDefaultSettingsMessageSource() {
    synchronized (MONITOR) {
        if (MESSAGE_SOURCE == null) {
            ResourceBundleMessageSource serial = new ResourceBundleMessageSource();
            serial.setBundleClassLoader(SerialPortBeanParameters.class.getClassLoader());
            serial.setBasenames(new String[] { SerialPortBeanParameters.class.getName(),
                    DataCollectorSerialPortBeanParameters.class.getName() });

            PrefixedMessageSource serialSource = new PrefixedMessageSource();
            serialSource.setDelegate(serial);
            serialSource.setPrefix("serialParams.");

            ResourceBundleMessageSource source = new ResourceBundleMessageSource();
            source.setBundleClassLoader(CentameterSupport.class.getClassLoader());
            source.setBasename(CentameterSupport.class.getName());
            source.setParentMessageSource(serialSource);
            MESSAGE_SOURCE = source;/*from w ww .j a v a 2  s . c  o  m*/
        }
    }
    return MESSAGE_SOURCE;
}

From source file:net.solarnetwork.node.consumption.rfxcom.RFXCOMConsumptionDatumDataSource.java

@Override
public MessageSource getMessageSource() {
    synchronized (MONITOR) {
        if (MESSAGE_SOURCE == null) {
            ResourceBundleMessageSource serial = new ResourceBundleMessageSource();
            serial.setBundleClassLoader(SerialPortBeanParameters.class.getClassLoader());
            serial.setBasename(SerialPortBeanParameters.class.getName());

            PrefixedMessageSource serialSource = new PrefixedMessageSource();
            serialSource.setDelegate(serial);
            serialSource.setPrefix("serialParams.");

            ResourceBundleMessageSource source = new ResourceBundleMessageSource();
            source.setBundleClassLoader(RFXCOMConsumptionDatumDataSource.class.getClassLoader());
            source.setBasename(RFXCOMConsumptionDatumDataSource.class.getName());
            source.setParentMessageSource(serialSource);
            MESSAGE_SOURCE = source;//w w w .ja  v  a 2  s.c om
        }
    }
    return MESSAGE_SOURCE;
}

From source file:net.solarnetwork.node.power.impl.sma.sunnynet.SMASunnyNetPowerDatumDataSource.java

@Override
public MessageSource getMessageSource() {
    synchronized (MONITOR) {
        if (MESSAGE_SOURCE == null) {
            ResourceBundleMessageSource serial = new ResourceBundleMessageSource();
            serial.setBundleClassLoader(SerialPortBeanParameters.class.getClassLoader());
            serial.setBasename(SerialPortBeanParameters.class.getName());

            PrefixedMessageSource serialSource = new PrefixedMessageSource();
            serialSource.setDelegate(serial);
            serialSource.setPrefix("serialParams.");

            ResourceBundleMessageSource source = new ResourceBundleMessageSource();
            source.setBundleClassLoader(SMASunnyNetPowerDatumDataSource.class.getClassLoader());
            source.setBasename(SMASunnyNetPowerDatumDataSource.class.getName());
            source.setParentMessageSource(serialSource);
            MESSAGE_SOURCE = source;/*from ww  w  .j  a va2 s. co  m*/
        }
    }
    return MESSAGE_SOURCE;
}

From source file:org.hdiv.listener.InitListener.java

/**
 * Initialize ServletContext scoped objects.
 * /*from   ww  w .j  a va  2 s.co  m*/
 * @param servletContext
 *            ServletContext instance
 */
protected void initServletContext(ServletContext servletContext) {

    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);

    this.config = (HDIVConfig) wac.getBean("config");
    this.dataComposerFactory = (DataComposerFactory) wac.getBean("dataComposerFactory");
    this.stateUtil = (StateUtil) wac.getBean("stateUtil");
    this.session = (ISession) wac.getBean("sessionHDIV");

    // Init servlet context scoped objects
    HDIVUtil.setHDIVConfig(this.config, servletContext);

    IApplication application = (IApplication) wac.getBean("application");
    HDIVUtil.setApplication(application, servletContext);

    ISession session = (ISession) wac.getBean("sessionHDIV");
    HDIVUtil.setISession(session, servletContext);

    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBeanClassLoader(wac.getClassLoader());
    String messageSourcePath = (String) wac.getBean("messageSourcePath");
    messageSource.setBasename(messageSourcePath);
    HDIVUtil.setMessageSource(messageSource, servletContext);

    LinkUrlProcessor linkUrlProcessor = (LinkUrlProcessor) wac.getBean("linkUrlProcessor");
    HDIVUtil.setLinkUrlProcessor(linkUrlProcessor, servletContext);

    FormUrlProcessor formUrlProcessor = (FormUrlProcessor) wac.getBean("formUrlProcessor");
    HDIVUtil.setFormUrlProcessor(formUrlProcessor, servletContext);

    this.servletContextInitialized = true;
}