Search in sources :

Example 31 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project solarnetwork-central by SolarNetwork.

the class DatumExportStandardServiceConfig method csvDatumExportOutputFormatService.

@Bean
public DatumExportOutputFormatService csvDatumExportOutputFormatService() {
    CsvDatumExportOutputFormatService service = new CsvDatumExportOutputFormatService();
    service.setTemporaryPath(temporaryDir);
    ResourceBundleMessageSource msgSource = new ResourceBundleMessageSource();
    msgSource.setBasenames(CsvDatumExportOutputFormatService.class.getName(), OutputConfiguration.class.getName());
    service.setMessageSource(msgSource);
    return service;
}
Also used : OutputConfiguration(net.solarnetwork.central.datum.export.domain.OutputConfiguration) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) CsvDatumExportOutputFormatService(net.solarnetwork.central.datum.export.standard.CsvDatumExportOutputFormatService) Bean(org.springframework.context.annotation.Bean)

Example 32 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project solarnetwork-central by SolarNetwork.

the class DaoUserEventHookBizTests method availableTopics_multipleProducers_overlapTopic.

@Test
public void availableTopics_multipleProducers_overlapTopic() {
    // GIVEN
    DatumAppEventProducer producer1 = EasyMock.createMock(DatumAppEventProducer.class);
    DatumAppEventProducer producer2 = EasyMock.createMock(DatumAppEventProducer.class);
    biz.setDatumEventProducers(asList(producer2, producer1));
    String topic = "topic/3";
    expect(producer2.getProducedDatumAppEventTopics()).andReturn(singleton(topic));
    expect(producer1.getProducedDatumAppEventTopics()).andReturn(singleton(topic));
    ResourceBundleMessageSource ms = new ResourceBundleMessageSource();
    ms.setBasename("net/solarnetwork/central/user/event/biz/dao/test/test-messages-03");
    expect(producer2.getMessageSource()).andReturn(ms);
    // WHEN
    replayAll(producer1, producer2);
    Iterable<LocalizedServiceInfo> itr = biz.availableDatumEventTopics(Locale.ENGLISH);
    // THEN
    assertThat("Service info iterable returned", itr, notNullValue());
    List<LocalizedServiceInfo> infos = StreamSupport.stream(itr.spliterator(), false).collect(toList());
    assertThat("Service info count", infos, hasSize(1));
    LocalizedServiceInfo info;
    info = infos.get(0);
    assertThat("Service info ID is topic", info.getId(), equalTo(topic));
    assertThat("Service name from i18n bundle", info.getLocalizedName(), equalTo("TOPIC-03-3"));
    assertThat("Service description from i18n bundle", info.getLocalizedDescription(), equalTo("DESC-03-3"));
}
Also used : DatumAppEventProducer(net.solarnetwork.central.datum.biz.DatumAppEventProducer) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) LocalizedServiceInfo(net.solarnetwork.domain.LocalizedServiceInfo) Test(org.junit.Test)

Example 33 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project solarnetwork-central by SolarNetwork.

the class UserEventHookBizConfig method userEventHookBiz.

@Bean
public UserEventHookBiz userEventHookBiz() {
    DaoUserEventHookBiz biz = new DaoUserEventHookBiz(userNodeEventHookConfiguationDao);
    biz.setDatumEventProducers(datumAppEventProducers);
    biz.setNodeEventHookServices(userNodeEventHookServices);
    ResourceBundleMessageSource msgSource = new ResourceBundleMessageSource();
    msgSource.setBasenames("net.solarnetwork.central.user.event.biz.UserEventHook");
    biz.setMessageSource(msgSource);
    return biz;
}
Also used : DaoUserEventHookBiz(net.solarnetwork.central.user.event.biz.dao.DaoUserEventHookBiz) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) Bean(org.springframework.context.annotation.Bean)

Example 34 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project solarnetwork-central by SolarNetwork.

the class UserEventServiceNoopConfig method noopUserNodeEventHookService.

@Bean
public UserNodeEventHookService noopUserNodeEventHookService() {
    NoopUserNodeEventHookService service = new NoopUserNodeEventHookService();
    ResourceBundleMessageSource msgSource = new ResourceBundleMessageSource();
    msgSource.setBasenames(NoopUserNodeEventHookService.class.getName());
    service.setMessageSource(msgSource);
    return service;
}
Also used : NoopUserNodeEventHookService(net.solarnetwork.central.user.event.noop.NoopUserNodeEventHookService) ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) Bean(org.springframework.context.annotation.Bean)

Example 35 with ResourceBundleMessageSource

use of org.springframework.context.support.ResourceBundleMessageSource in project study by bage2014.

the class WebAppConfig method messageSource.

@Bean
public ResourceBundleMessageSource messageSource() {
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    messageSource.setBasename("Messages");
    return messageSource;
}
Also used : ResourceBundleMessageSource(org.springframework.context.support.ResourceBundleMessageSource) Bean(org.springframework.context.annotation.Bean)

Aggregations

ResourceBundleMessageSource (org.springframework.context.support.ResourceBundleMessageSource)179 Bean (org.springframework.context.annotation.Bean)99 Before (org.junit.Before)16 MessageSourceAccessor (org.springframework.context.support.MessageSourceAccessor)13 LocalValidatorFactoryBean (org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)9 ValidatorFactory (javax.validation.ValidatorFactory)6 ResourceBundleMessageInterpolator (org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator)6 PlatformResourceBundleLocator (org.hibernate.validator.resourceloading.PlatformResourceBundleLocator)6 Test (org.junit.Test)6 Test (org.junit.jupiter.api.Test)6 IOException (java.io.IOException)5 List (java.util.List)5 Locale (java.util.Locale)5 ReaderFactoryByMap (net.n2oapp.framework.config.selective.reader.ReaderFactoryByMap)5 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)5 MessageSource (org.springframework.context.MessageSource)5 ArrayList (java.util.ArrayList)4 N2oApplicationBuilder (net.n2oapp.framework.config.N2oApplicationBuilder)4 N2oEnvironment (net.n2oapp.framework.config.compile.pipeline.N2oEnvironment)4 PersisterFactoryByMap (net.n2oapp.framework.config.selective.persister.PersisterFactoryByMap)4