Java 类org.springframework.context.support.MessageSourceAccessor 实例源码

项目:credhub    文件:AuditOAuth2AccessDeniedHandler.java   
@Autowired
public AuditOAuth2AccessDeniedHandler(
    TokenStore tokenStore,
    RequestAuditRecordDataService requestAuditRecordDataService,
    SecurityEventsLogService securityEventsLogService,
    UserContextFactory userContextFactory,
    WebResponseExceptionTranslator exceptionTranslator,
    AuditLogFactory auditLogFactory,
    MessageSourceAccessor messageSourceAccessor
) {
  this.userContextFactory = userContextFactory;
  this.tokenStore = tokenStore;
  this.requestAuditRecordDataService = requestAuditRecordDataService;
  this.securityEventsLogService = securityEventsLogService;
  this.exceptionTranslator = exceptionTranslator;
  this.auditLogFactory = auditLogFactory;
  this.messageSourceAccessor = messageSourceAccessor;
}
项目:openmrs-module-legacyui    文件:ModuleListController.java   
@Override
protected Map<String, Object> referenceData(HttpServletRequest request) throws Exception {
    Map<String, Object> map = new HashMap<String, Object>();
    MessageSourceAccessor msa = getMessageSourceAccessor();

    map.put("allowAdmin", ModuleUtil.allowAdmin().toString());
    map.put("disallowUploads", msa.getMessage("Module.disallowUploads",
        new String[] { ModuleConstants.RUNTIMEPROPERTY_ALLOW_ADMIN }));

    map.put("openmrsVersion", OpenmrsConstants.OPENMRS_VERSION_SHORT);
    map.put("moduleRepositoryURL", WebConstants.MODULE_REPOSITORY_URL);

    map.put("loadedModules", ModuleFactory.getLoadedModules());

    return map;
}
项目:spring-rich-client    文件:DefaultRegisterableExceptionHandler.java   
public void uncaughtException(Thread thread, Throwable throwable) {
    LogFactory.getLog(ApplicationLifecycleAdvisor.class).error(throwable.getMessage(), throwable);
    String exceptionMessage;
    if (throwable instanceof MessageSourceResolvable) {
        exceptionMessage = ((MessageSourceAccessor) ApplicationServicesLocator.services()
                .getService(MessageSourceAccessor.class))
                .getMessage((MessageSourceResolvable) throwable);
    } else {
        exceptionMessage = throwable.getLocalizedMessage();
    }
    if (!StringUtils.hasText(exceptionMessage)) {
        String defaultMessage = "An application exception occurred.\nPlease contact your administrator.";
        exceptionMessage = ((MessageSourceAccessor) ApplicationServicesLocator.services()
                .getService(MessageSourceAccessor.class))
                .getMessage("applicationDialog.defaultException", defaultMessage);
    }

    Message message = new DefaultMessage(exceptionMessage, Severity.ERROR);
    ApplicationWindow activeWindow = Application.instance().getActiveWindow();
    JFrame parentFrame = (activeWindow == null) ? null : activeWindow.getControl();
    JOptionPane.showMessageDialog(parentFrame, message.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
项目:spring-rich-client    文件:DefaultBindingErrorMessageProviderTests.java   
public void testGetErrorMessage() {
    DefaultBindingErrorMessageProvider provider = new DefaultBindingErrorMessageProvider();

    TestAbstractFormModel formModel = new TestAbstractFormModel(new Object()) {
        public FieldFace getFieldFace(String field) {
            return new DefaultFieldFace("Some Property", "", "", new LabelInfo("Some Property"), null);
        }
    };
    formModel.add("someProperty", new ValueHolder("value"));

    StaticMessageSource messageSource = new StaticMessageSource();
    messageSource.addMessage("typeMismatch", Locale.getDefault(), "{0} has an invalid format \"{1}\"");
    MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(messageSource);
    provider.setMessageSourceAccessor(messageSourceAccessor);

    ValidationMessage message = provider.getErrorMessage(formModel, "someProperty", "new value",
            new IllegalArgumentException());

    assertNotNull(message);
    assertEquals("someProperty", message.getProperty());
    assertEquals("Some Property has an invalid format \"new value\"", message.getMessage());
}
项目:gocd    文件:LocalizerTest.java   
@Test
public void shouldReturnTheFormattedLocalizedMessage() {
    CurrentLocale locale = new CurrentLocale();
    ReloadableResourceBundleMessageSource source = new ReloadableResourceBundleMessageSource();
    source.setBasename("test_message");
    MessageSourceAccessor accessor = new MessageSourceAccessor(source);
    Localizer localizer = new Localizer(accessor, locale);

    assertThat(localizer.localize("hello_world"), is("Hello World"));

    locale.setLocaleString(Localizer.LOCALE_ENGLISH_US);
    assertThat(localizer.localize("MY_HOME", "San Francisco"), is("My home is San Francisco"));

    locale.setLocaleString(Localizer.LOCALE_KANNADA);
    assertThat(localizer.localize("MY_HOME", "ಬೆಂಗಳೂರು"), is("ನಮ್ಮ ಊರು ಬೆಂಗಳೂರು"));

    locale.setLocaleString(Localizer.LOCALE_KANNADA);
    assertThat(localizer.localize("MY_BIRTHDAY", new DateTime(1984, 12, 23, 14, 0, 0, 0, DateTimeZone.UTC).toDate()), is("ನನ್ನ ಹುಟ್ಟು ಹಬ್ಬ 12/23/84"));

    locale.setLocaleString(Localizer.LOCALE_ENGLISH_US);
    assertThat(localizer.localize("MY_BIRTHDAY", new DateTime(1984, 12, 23, 14, 0, 0, 0, DateTimeZone.UTC).toDate()), is("My birthday is 12/23/84"));

}
项目:spring-richclient    文件:DefaultRegisterableExceptionHandler.java   
public void uncaughtException(Thread thread, Throwable throwable) {
    LogFactory.getLog(ApplicationLifecycleAdvisor.class).error(throwable.getMessage(), throwable);
    String exceptionMessage;
    if (throwable instanceof MessageSourceResolvable) {
        exceptionMessage = ((MessageSourceAccessor) ApplicationServicesLocator.services()
                .getService(MessageSourceAccessor.class))
                .getMessage((MessageSourceResolvable) throwable);
    } else {
        exceptionMessage = throwable.getLocalizedMessage();
    }
    if (!StringUtils.hasText(exceptionMessage)) {
        String defaultMessage = "An application exception occurred.\nPlease contact your administrator.";
        exceptionMessage = ((MessageSourceAccessor) ApplicationServicesLocator.services()
                .getService(MessageSourceAccessor.class))
                .getMessage("applicationDialog.defaultException", defaultMessage);
    }

    Message message = new DefaultMessage(exceptionMessage, Severity.ERROR);
    ApplicationWindow activeWindow = Application.instance().getActiveWindow();
    JFrame parentFrame = (activeWindow == null) ? null : activeWindow.getControl();
    JOptionPane.showMessageDialog(parentFrame, message.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
项目:spring-richclient    文件:DefaultBindingErrorMessageProviderTests.java   
public void testGetErrorMessage() {
    DefaultBindingErrorMessageProvider provider = new DefaultBindingErrorMessageProvider();

    TestAbstractFormModel formModel = new TestAbstractFormModel(new Object()) {
        public FieldFace getFieldFace(String field) {
            return new DefaultFieldFace("Some Property", "", "", new LabelInfo("Some Property"), null);
        }
    };
    formModel.add("someProperty", new ValueHolder("value"));

    StaticMessageSource messageSource = new StaticMessageSource();
    messageSource.addMessage("typeMismatch", Locale.getDefault(), "{0} has an invalid format \"{1}\"");
    MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(messageSource);
    provider.setMessageSourceAccessor(messageSourceAccessor);

    ValidationMessage message = provider.getErrorMessage(formModel, "someProperty", "new value",
            new IllegalArgumentException());

    assertNotNull(message);
    assertEquals("someProperty", message.getProperty());
    assertEquals("Some Property has an invalid format \"new value\"", message.getMessage());
}
项目:spring-data-rest-android    文件:Jackson2HalModule.java   
public HalLinkListSerializer(BeanProperty property, CurieProvider curieProvider, EmbeddedMapper mapper,
                             MessageSourceAccessor messageSource) {

    super(List.class, false);
    this.property = property;
    this.curieProvider = curieProvider;
    this.mapper = mapper;
    this.messageSource = messageSource;
}
项目:spring-data-rest-android    文件:Jackson2HalModule.java   
public HalHandlerInstantiator(RelProvider resolver, CurieProvider curieProvider,
                              MessageSourceAccessor messageSource, boolean enforceEmbeddedCollections) {

    EmbeddedMapper mapper = new EmbeddedMapper(resolver, curieProvider, enforceEmbeddedCollections);

    Assert.notNull(resolver, "RelProvider must not be null!");
    this.instanceMap.put(HalResourcesSerializer.class, new HalResourcesSerializer(mapper));
    this.instanceMap.put(HalLinkListSerializer.class,
            new HalLinkListSerializer(curieProvider, mapper, messageSource));
}
项目:credhub    文件:X509AuthenticationFailureHandler.java   
@Autowired
X509AuthenticationFailureHandler(
    MessageSourceAccessor messageSourceAccessor,
    ObjectMapper objectMapper
) {
  this.objectMapper = objectMapper;
  this.messageSourceAccessor = messageSourceAccessor;
}
项目:credhub    文件:AuditOAuth2AuthenticationExceptionHandler.java   
@Autowired
AuditOAuth2AuthenticationExceptionHandler(
    CurrentTimeProvider currentTimeProvider,
    AuthFailureAuditRecordDataService authFailureAuditRecordDataService,
    MessageSourceAccessor messageSourceAccessor,
    AuditLogFactory auditLogFactory
) {
  this.currentTimeProvider = currentTimeProvider;
  this.authFailureAuditRecordDataService = authFailureAuditRecordDataService;
  this.auditLogFactory = auditLogFactory;
  this.objectMapper = JsonParserFactory.create();
  this.messageSourceAccessor = messageSourceAccessor;
}
项目:credhub    文件:OAuth2ExtraValidationFilter.java   
@Autowired
OAuth2ExtraValidationFilter(
    OAuth2IssuerService oAuth2IssuerService,
    TokenStore tokenStore,
    AuditOAuth2AuthenticationExceptionHandler oAuth2AuthenticationExceptionHandler,
    MessageSourceAccessor messageSourceAccessor,
    AuthenticationEventPublisher eventPublisher
) {
  this.oAuth2IssuerService = oAuth2IssuerService;
  this.tokenStore = tokenStore;
  this.oAuth2AuthenticationExceptionHandler = oAuth2AuthenticationExceptionHandler;
  this.eventPublisher = eventPublisher;
  this.tokenExtractor = new BearerTokenExtractor();
  this.messageSourceAccessor = messageSourceAccessor;
}
项目:openmrs-module-legacyui    文件:ConceptDatatypeListController.java   
/**
 * The onSubmit function receives the form/command object that was modified by the input form
 * and saves it to the db
 *
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 */
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
        BindException errors) throws Exception {

    HttpSession httpSession = request.getSession();

    String view = getFormView();
    if (Context.isAuthenticated()) {

        String[] cdList = request.getParameterValues("conceptDatatypeId");
        ConceptService cs = Context.getConceptService();

        StringBuilder success = new StringBuilder("");
        StringBuilder error = new StringBuilder();

        MessageSourceAccessor msa = getMessageSourceAccessor();
        String deleted = msa.getMessage("general.deleted");
        String notDeleted = msa.getMessage("general.cannot.delete");
        if (cdList.length != 0) {
            log.warn("Deleting concept datatype is not supported");
            if (!"".equals(error.toString())) {
                error.append("<br/>");
            }
            error.append("ConceptDatatype").append(" ").append(notDeleted);
        }

        view = getSuccessView();
        if (!"".equals(success.toString())) {
            httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success.toString());
        }
        if (!"".equals(error.toString())) {
            httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error.toString());
        }
    }

    return new ModelAndView(new RedirectView(view));
}
项目:openmrs-module-legacyui    文件:PersonFormController.java   
/**
 * @see org.springframework.web.servlet.mvc.AbstractFormController#processFormSubmission(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 */
protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object obj,
        BindException errors) throws Exception {
    if (!Context.isAuthenticated()) {
        errors.reject("auth.invalid");
    }

    if (errors.hasErrors()) {
        return showForm(request, response, errors);
    }

    Person person = (Person) obj;

    MessageSourceAccessor msa = getMessageSourceAccessor();
    String action = request.getParameter("action");

    if (action.equals(msa.getMessage("Person.save"))) {
        updatePersonAddresses(request, person, errors);

        updatePersonNames(request, person);

        updatePersonAttributes(request, errors, person);
    }

    if (errors.hasErrors()) {
        return showForm(request, response, errors);
    }

    return super.processFormSubmission(request, response, person, errors);
}
项目:openmrs-module-legacyui    文件:ModulePropertiesFormController.java   
@Override
protected Map<String, String> referenceData(HttpServletRequest request) throws Exception {

    Map<String, String> map = new HashMap<String, String>();
    MessageSourceAccessor msa = getMessageSourceAccessor();

    map.put("allowUpload", ModuleUtil.allowAdmin().toString());
    map.put("disallowUploads", msa.getMessage("Module.disallowUploads",
        new String[] { ModuleConstants.RUNTIMEPROPERTY_ALLOW_UPLOAD }));

    return map;
}
项目:openmrs-module-legacyui    文件:SchedulerListController.java   
@SuppressWarnings("unchecked")
@Override
protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception {

    Map<String, Object> map = new HashMap<String, Object>();

    Collection<TaskDefinition> tasks = (Collection<TaskDefinition>) command;
    Map<TaskDefinition, String> intervals = new HashMap<TaskDefinition, String>();
    MessageSourceAccessor msa = getMessageSourceAccessor();

    for (TaskDefinition task : tasks) {

        Long interval = task.getRepeatInterval();

        if (interval < 60) {
            intervals.put(task, interval + " " + msa.getMessage("Scheduler.scheduleForm.repeatInterval.units.seconds"));
        } else if (interval < 3600) {
            intervals.put(task, interval / 60 + " "
                    + msa.getMessage("Scheduler.scheduleForm.repeatInterval.units.minutes"));
        } else if (interval < 86400) {
            intervals.put(task, interval / 3600 + " "
                    + msa.getMessage("Scheduler.scheduleForm.repeatInterval.units.hours"));
        } else {
            intervals.put(task, interval / 86400 + " "
                    + msa.getMessage("Scheduler.scheduleForm.repeatInterval.units.days"));
        }
    }
    map.put("intervals", intervals);

    return map;
}
项目:openmrs-module-legacyui    文件:AlertListController.java   
/**
 * The onSubmit function receives the form/command object that was modified by the input form
 * and saves it to the db
 *
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 */
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
        BindException errors) throws Exception {

    HttpSession httpSession = request.getSession();

    Locale locale = Context.getLocale();

    if (Context.isAuthenticated()) {
        AlertService as = Context.getAlertService();

        MessageSourceAccessor msa = getMessageSourceAccessor();
        String msg = "";

        // expire the selected alerts
        String[] alertIds = request.getParameterValues("alertId");
        if (alertIds != null) {
            for (String alertIdString : alertIds) {
                Integer alertId = Integer.parseInt(alertIdString);
                Alert a = as.getAlert(alertId);
                a.setDateToExpire(new Date());
                as.saveAlert(a);
            }

            msg = msa.getMessage("Alert.expired", new Object[] { alertIds.length }, locale);
        } else {
            msg = msa.getMessage("Alert.select");
        }

        httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, msg);
        return new ModelAndView(new RedirectView(getSuccessView()));
    }

    // The user isn't authenticated or their session has expired
    return showForm(request, response, errors);
}
项目:psi-probe    文件:ListSessionsController.java   
/**
 * Populate search messages.
 *
 * @param searchInfo the search info
 */
private void populateSearchMessages(SessionSearchInfo searchInfo) {
  MessageSourceAccessor msa = getMessageSourceAccessor();

  searchInfo.getErrorMessages().clear();

  if (searchInfo.isEmpty()) {
    searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.empty"));
  } else if (searchInfo.isValid()) {
    searchInfo.setInfoMessage(msa.getMessage("probe.src.sessions.search.results.empty"));
  } else {
    if (!searchInfo.isSessionIdValid()) {
      searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.invalid.sessionId",
          new Object[] {searchInfo.getSessionIdMsg()}));
    }
    if (!searchInfo.isAttrNameValid()) {
      for (String message : searchInfo.getAttrNameMsgs()) {
        searchInfo.addErrorMessage(
            msa.getMessage("probe.src.sessions.search.invalid.attrName", new Object[] {message}));
      }
    }
    if (!searchInfo.isAgeFromValid()) {
      searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.invalid.ageFrom"));
    }
    if (!searchInfo.isAgeToValid()) {
      searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.invalid.ageTo"));
    }
    if (!searchInfo.isIdleTimeFromValid()) {
      searchInfo
          .addErrorMessage(msa.getMessage("probe.src.sessions.search.invalid.idleTimeFrom"));
    }
    if (!searchInfo.isIdleTimeToValid()) {
      searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.invalid.idleTimeTo"));
    }
    if (searchInfo.getErrorMessages().isEmpty()) {
      searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.invalid"));
    }
  }
}
项目:jpublish    文件:SpringI18nSupport.java   
/**
 * Execute the action using the given context.
 *
 * @param context       The current context
 * @param configuration The configuration
 * @throws Exception Any error
 */
public void execute(JPublishContext context, Configuration configuration) throws Exception {
    HttpServletRequest request = (HttpServletRequest) context.get("request");
    HttpServletResponse response = (HttpServletResponse) context.get("response");
    Page page = ((Page) context.get("page"));

    if (page != null) {
        Locale locale = page.getLocale();

        ApplicationContext applicationContext = getApplicationContext(context);
        context.put(SPRING, applicationContext);
        HandlerInterceptor localeChangeInterceptor = (HandlerInterceptor)
                applicationContext.getBean("localeChangeInterceptor");

        if (localeChangeInterceptor != null) {
            try {
                LocaleResolver localeResolver = (LocaleResolver) applicationContext.getBean("localeResolver");
                if (localeResolver != null) {
                    request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, localeResolver);
                    localeChangeInterceptor.preHandle(request, response, null);
                    locale = localeResolver.resolveLocale(request);
                    MessageSource messageSource = (MessageSource) applicationContext.getBean("messageSource");
                    if (messageSource != null) {
                        context.put(I18N, new MessageSourceAccessor(messageSource, locale));
                    } else {
                        log.error("There is no 'messageSource' defined in your application context." +
                                " Please define one.");
                    }
                } else {
                    log.error("please define a 'localeResolver' bean in your Application context");
                }
            } catch (Exception e) {
                e.printStackTrace();
                log.error("Cannot handle the locale change event");
            }
        }
        page.setLocale(locale);
    }
}
项目:spring-struts-forwardport    文件:DispatchActionSupport.java   
/**
 * Initialize the WebApplicationContext for this Action.
 * Invokes onInit after successful initialization of the context.
 * @see #initWebApplicationContext
 * @see #onInit
 */
@Override
public void setServlet(ActionServlet actionServlet) {
    super.setServlet(actionServlet);
    if (actionServlet != null) {
        this.webApplicationContext = initWebApplicationContext(actionServlet);
        this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
        onInit();
    }
    else {
        onDestroy();
    }
}
项目:spring-struts-forwardport    文件:ActionSupport.java   
/**
 * Initialize the WebApplicationContext for this Action.
 * Invokes onInit after successful initialization of the context.
 * @see #initWebApplicationContext
 * @see #onInit
 */
@Override
public void setServlet(ActionServlet actionServlet) {
    super.setServlet(actionServlet);
    if (actionServlet != null) {
        this.webApplicationContext = initWebApplicationContext(actionServlet);
        this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
        onInit();
    }
    else {
        onDestroy();
    }
}
项目:spring-struts-forwardport    文件:MappingDispatchActionSupport.java   
/**
 * Initialize the WebApplicationContext for this Action.
 * Invokes onInit after successful initialization of the context.
 * @see #initWebApplicationContext
 * @see #onInit
 */
@Override
public void setServlet(ActionServlet actionServlet) {
    super.setServlet(actionServlet);
    if (actionServlet != null) {
        this.webApplicationContext = initWebApplicationContext(actionServlet);
        this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
        onInit();
    }
    else {
        onDestroy();
    }
}
项目:spring-struts-forwardport    文件:LookupDispatchActionSupport.java   
/**
 * Initialize the WebApplicationContext for this Action.
 * Invokes onInit after successful initialization of the context.
 * @see #initWebApplicationContext
 * @see #onInit
 */
@Override
public void setServlet(ActionServlet actionServlet) {
    super.setServlet(actionServlet);
    if (actionServlet != null) {
        this.webApplicationContext = initWebApplicationContext(actionServlet);
        this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
        onInit();
    }
    else {
        onDestroy();
    }
}
项目:grassroot-platform    文件:GroupFetchController.java   
public GroupFetchController(GroupFetchBroker groupFetchBroker, JwtService jwtService,
                            UserManagementService userManagementService, PdfGeneratingService generatingService,
                            MemberDataExportBroker memberDataExportBroker, UrlShortener urlShortener,
                            MessageSourceAccessor messageSourceAccessor, GroupBroker groupBroker) {
    super(jwtService, userManagementService);
    this.groupFetchBroker = groupFetchBroker;
    this.generatingService = generatingService;
    this.memberDataExportBroker = memberDataExportBroker;
    this.urlShortener = urlShortener;
    this.messageSourceAccessor = messageSourceAccessor;
    this.groupBroker = groupBroker;
}
项目:grassroot-platform    文件:UserController.java   
public UserController(MediaFileBroker mediaFileBroker, StorageBroker storageBroker,
                      UserManagementService userService, JwtService jwtService,
                      PasswordTokenService passwordService, MessagingServiceBroker messagingBroker,
                      @Qualifier("messageSourceAccessor") MessageSourceAccessor messageSource) {
    super(jwtService, userService);
    this.mediaFileBroker = mediaFileBroker;
    this.storageBroker = storageBroker;
    this.userService = userService;
    this.passwordService = passwordService;
    this.messagingBroker = messagingBroker;
    this.messageSource = messageSource;
}
项目:grassroot-platform    文件:PermissionDTO.java   
public PermissionDTO(Permission permission, Group group, String roleName, Set<Permission> enabledSet, MessageSourceAccessor messageSourceAccessor) {
    this.permission = permission;
    this.groupUid = group.getUid();
    this.forRole = roleName;
    this.permissionName = permission.getName();
    this.permissionLabel = messageSourceAccessor.getMessage("rest.permission." + permission.getName(), Locale.getDefault());
    this.permissionDesc = messageSourceAccessor.getMessage("rest.permission.desc." + permission.getName(), Locale.getDefault());
    this.permissionEnabled = enabledSet.contains(permission);
    this.position = displayedPermissionsSorted.get(permission);
}
项目:grassroot-platform    文件:LiveWireSendingBrokerImpl.java   
@Autowired
public LiveWireSendingBrokerImpl(LiveWireAlertRepository alertRepository,
                                 DataSubscriberRepository subscriberRepository,
                                 LiveWirePushBroker liveWirePushBroker,
                                 @Qualifier("servicesMessageSourceAccessor") MessageSourceAccessor messageSource,
                                 @Qualifier("emailTemplateEngine") TemplateEngine templateEngine,
                                 StorageBroker storageBroker) {
    this.alertRepository = alertRepository;
    this.subscriberRepository = subscriberRepository;
    this.liveWirePushBroker = liveWirePushBroker;
    this.messageSource = messageSource;
    this.templateEngine = templateEngine;
    this.storageBroker = storageBroker;
}
项目:springfield    文件:BaseMessageConfiguration.java   
@Bean
public MessageSourceAccessor messageSourceAccessor()  throws Exception{
    MessageSourceAccessor bean = new MessageSourceAccessor(messageSource(), 
            environment.getProperty(
                    "springfield.baseLocale", 
                    Locale.class, 
                    Locale.KOREA
                )
    );
    return bean;
}
项目:springfield    文件:ContextWebmvcBase.java   
@Bean
public MessageSourceAccessor messageSourceAccessor()  throws Exception{
    MessageSourceAccessor bean = new MessageSourceAccessor(messageSource(), 
            StringUtils.parseLocaleString(configurer.getProperty(Configurer.BASE_LOCALE))
            );
    return bean;
}
项目:class-guard    文件:ServletEndpointSupport.java   
/**
 * Initialize this JAX-RPC servlet endpoint.
 * Calls onInit after successful context initialization.
 * @param context ServletEndpointContext
 * @throws ServiceException if the context is not a ServletEndpointContext
 * @see #onInit
 */
public final void init(Object context) throws ServiceException {
    if (!(context instanceof ServletEndpointContext)) {
        throw new ServiceException("ServletEndpointSupport needs ServletEndpointContext, not [" + context + "]");
    }
    this.servletEndpointContext = (ServletEndpointContext) context;
    ServletContext servletContext = this.servletEndpointContext.getServletContext();
    this.webApplicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
    onInit();
}
项目:class-guard    文件:ComponentControllerSupport.java   
/**
 * This implementation delegates to {@code doPerform},
 * lazy-initializing the application context reference if necessary.
 * <p>This is the preferred execution method in Struts 1.2.
 * When running with Struts 1.1, it will be called by {@code perform}.
 * @see #perform
 * @see #doPerform
 */
@Override
public final void execute(
        ComponentContext componentContext, HttpServletRequest request,
        HttpServletResponse response, ServletContext servletContext)
    throws Exception {

    synchronized (this) {
        if (this.webApplicationContext == null) {
            this.webApplicationContext = RequestContextUtils.getWebApplicationContext(request, servletContext);
            this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
        }
    }
    doPerform(componentContext, request, response);
}
项目:class-guard    文件:DispatchActionSupport.java   
/**
 * Initialize the WebApplicationContext for this Action.
 * Invokes onInit after successful initialization of the context.
 * @see #initWebApplicationContext
 * @see #onInit
 */
@Override
public void setServlet(ActionServlet actionServlet) {
    super.setServlet(actionServlet);
    if (actionServlet != null) {
        this.webApplicationContext = initWebApplicationContext(actionServlet);
        this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
        onInit();
    }
    else {
        onDestroy();
    }
}
项目:class-guard    文件:ActionSupport.java   
/**
 * Initialize the WebApplicationContext for this Action.
 * Invokes onInit after successful initialization of the context.
 * @see #initWebApplicationContext
 * @see #onInit
 */
@Override
public void setServlet(ActionServlet actionServlet) {
    super.setServlet(actionServlet);
    if (actionServlet != null) {
        this.webApplicationContext = initWebApplicationContext(actionServlet);
        this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
        onInit();
    }
    else {
        onDestroy();
    }
}
项目:class-guard    文件:MappingDispatchActionSupport.java   
/**
 * Initialize the WebApplicationContext for this Action.
 * Invokes onInit after successful initialization of the context.
 * @see #initWebApplicationContext
 * @see #onInit
 */
@Override
public void setServlet(ActionServlet actionServlet) {
    super.setServlet(actionServlet);
    if (actionServlet != null) {
        this.webApplicationContext = initWebApplicationContext(actionServlet);
        this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
        onInit();
    }
    else {
        onDestroy();
    }
}
项目:class-guard    文件:LookupDispatchActionSupport.java   
/**
 * Initialize the WebApplicationContext for this Action.
 * Invokes onInit after successful initialization of the context.
 * @see #initWebApplicationContext
 * @see #onInit
 */
@Override
public void setServlet(ActionServlet actionServlet) {
    super.setServlet(actionServlet);
    if (actionServlet != null) {
        this.webApplicationContext = initWebApplicationContext(actionServlet);
        this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext);
        onInit();
    }
    else {
        onDestroy();
    }
}
项目:flash-messages    文件:MessageSourceMessageResolverAdapter.java   
/**
 * @param messageSource
 */
public MessageSourceMessageResolverAdapter(MessageSource messageSource) {

    if (messageSource == null) {
        throw new NullPointerException("MessageSource can't be null");
    }
    this.messageSourceAccessor = new MessageSourceAccessor(messageSource);
}
项目:psi-probe-plus    文件:ListSessionsController.java   
private void populateSearchMessages(SessionSearchInfo searchInfo) {
    MessageSourceAccessor msa = getMessageSourceAccessor();

    searchInfo.getErrorMessages().clear();

    if (searchInfo.isEmpty()) {
        searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.empty"));
    } else if (searchInfo.isValid()) {
        searchInfo.setInfoMessage(msa.getMessage("probe.src.sessions.search.results.empty"));
    } else {
        if (!searchInfo.isSessionIdValid()) {
            searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.invalid.sessionId", new Object[] {searchInfo.getSessionIdMsg()}));
        }
        if (!searchInfo.isAttrNameValid()) {
            for (Iterator i = searchInfo.getAttrNameMsgs().iterator(); i.hasNext();) {
                String m = (String) i.next();
                searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.invalid.attrName", new Object[] {m}));
            }
        }
        if (!searchInfo.isAgeFromValid()) {
            searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.invalid.ageFrom"));
        }
        if (!searchInfo.isAgeToValid()) {
            searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.invalid.ageTo"));
        }
        if (!searchInfo.isIdleTimeFromValid()) {
            searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.invalid.idleTimeFrom"));
        }
        if (!searchInfo.isIdleTimeToValid()) {
            searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.invalid.idleTimeTo"));
        }
        if (searchInfo.getErrorMessages().isEmpty()) {
            searchInfo.addErrorMessage(msa.getMessage("probe.src.sessions.search.invalid"));
        }
    }
}
项目:spring-rich-client    文件:EnumComboBoxBinder.java   
protected AbstractListBinding createListBinding(JComponent control, FormModel formModel, String formPropertyPath) {
    ComboBoxBinding binding = (ComboBoxBinding) super.createListBinding(control, formModel, formPropertyPath);
    binding.setSelectableItems(createEnumSelectableItems(formModel, formPropertyPath));
    MessageSourceAccessor messageSourceAccessor = getMessages();
    binding.setRenderer(new EnumListRenderer(messageSourceAccessor));
    binding.setEditor(new EnumComboBoxEditor(messageSourceAccessor, binding.getEditor()));
    return binding;
}
项目:spring-rich-client    文件:BeanTableModel.java   
public void setMessageSource(MessageSource messages) {
    if (messages != null) {
        this.messages = new MessageSourceAccessor(messages);
        createColumnInfo();
    }
    else {
        this.messages = null;
    }
}
项目:spring-rich-client    文件:EnumTableCellRendererTests.java   
public void testGetTableCellRendererComponent() {
    StaticMessageSource messageSource = new StaticMessageSource();
    messageSource.addMessage("org.springframework.richclient.table.renderer.EnumTableCellRendererTests$Numbers.ONE", Locale.getDefault(), "one");
    messageSource.addMessage("org.springframework.richclient.table.renderer.EnumTableCellRendererTests$Numbers.TWO", Locale.getDefault(), "two");
    messageSource.addMessage("org.springframework.richclient.table.renderer.EnumTableCellRendererTests$Numbers.THREE", Locale.getDefault(), "three");
    messageSource.addMessage("org.springframework.richclient.table.renderer.EnumTableCellRendererTests$Numbers.FOUR", Locale.getDefault(), "four");
    messageSource.addMessage("org.springframework.richclient.table.renderer.EnumTableCellRendererTests$Numbers.FIVE", Locale.getDefault(), "five");
    messageSource.addMessage("org.springframework.richclient.table.renderer.EnumTableCellRendererTests$Numbers.SIX", Locale.getDefault(), "six");
    messageSource.addMessage("org.springframework.richclient.table.renderer.EnumTableCellRendererTests$Numbers.SEVEN", Locale.getDefault(), "seven");
    messageSource.addMessage("org.springframework.richclient.table.renderer.EnumTableCellRendererTests$Numbers.EIGHT", Locale.getDefault(), "eight");
    messageSource.addMessage("org.springframework.richclient.table.renderer.EnumTableCellRendererTests$Numbers.NINE", Locale.getDefault(), "nine");
    messageSource.addMessage("org.springframework.richclient.table.renderer.EnumTableCellRendererTests$Numbers.TEN", Locale.getDefault(), "ten");
    MessageSourceAccessor msa = new MessageSourceAccessor(messageSource);
    tetcr = new EnumTableCellRenderer(msa);
    Object[][] rowData = { 
            { Numbers.ONE },
            { Numbers.TWO },
            { Numbers.THREE },
            { Numbers.FOUR },
            { Numbers.FIVE },
            { Numbers.SIX },
            { Numbers.SEVEN },
            { Numbers.EIGHT },
            { Numbers.NINE },
            { Numbers.TEN }
            };
    Object[] columnNames = { "Numbers" };
    JTable table = new JTable(rowData, columnNames);
    TableColumnModel tcm = table.getColumnModel();
    tcm.getColumn(0).setCellRenderer(tetcr);
    tetcr.getTableCellRendererComponent(table, Numbers.SEVEN, false, false, 6, 0);
    Component component = tetcr.getTableCellRendererComponent(table, Numbers.SEVEN, false, false, 6, 0);
    assertTrue(component instanceof EnumTableCellRenderer);
}