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

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

Introduction

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

Prototype

public void setBundleClassLoader(ClassLoader classLoader) 

Source Link

Document

Set the ClassLoader to load resource bundles with.

Usage

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;/*  w  w w. j ava2 s .  co  m*/
        }
    }
    return MESSAGE_SOURCE;
}

From source file:com.evolveum.midpoint.common.LocalizationServiceImpl.java

private ResourceBundleMessageSource buildSource(String basename, ClassLoader classLoader) {
    ResourceBundleMessageSource source = new CachedResourceBundleMessageSource();
    source.setDefaultEncoding(StandardCharsets.UTF_8.name());
    source.setFallbackToSystemLocale(false);
    source.setBasename(basename);/*from  w  w w  .j a va2  s. c o m*/

    if (classLoader == null) {
        classLoader = LocalizationServiceImpl.class.getClassLoader();
    }
    source.setBundleClassLoader(classLoader);

    return source;
}

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

@Override
public synchronized MessageSource getMessageSource() {
    if (messageSource == null) {
        MessageSource other = null;/*w  ww. ja  va2 s . co  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: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;//from w  w  w.  j a  v a2  s .  c o  m
        }
    }
    return MESSAGE_SOURCE;
}

From source file:net.solarnetwork.node.dao.jdbc.AbstractJdbcDao.java

/**
 * Initialize this class after properties are set.
 *//*from   w  w w .  j  av a 2  s .  c  o  m*/
public void init() {
    // verify database table exists, and if not create it
    verifyDatabaseExists(this.schemaName, this.tableName, this.initSqlResource);

    // now veryify database tables version is up-to-date
    try {
        upgradeTablesVersion();
    } catch (IOException e) {
        throw new RuntimeException("Unable to upgrade tables to version " + getTablesVersion(), e);
    }

    if (messageSource == null) {
        ResourceBundleMessageSource ms = new ResourceBundleMessageSource();
        ms.setBasename(getClass().getName());
        ms.setBundleClassLoader(getClass().getClassLoader());
        setMessageSource(ms);
    }
}

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;//  w  w w.j a v a2s . c  om
        }
    }
    return MESSAGE_SOURCE;
}