org.springframework.context.support.MessageSourceAccessor类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中org.springframework.context.support.MessageSourceAccessor类的一些代码示例,展示了MessageSourceAccessor类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MessageSourceAccessor类的具体详情如下:
包路径:org.springframework.context.support.MessageSourceAccessor
类名称:MessageSourceAccessor

MessageSourceAccessor介绍

[英]Helper class for easy access to messages from a MessageSource, providing various overloaded getMessage methods.

Available from ApplicationObjectSupport, but also reusable as a standalone helper to delegate to in application objects.
[中]Helper类,用于轻松访问来自MessageSource的消息,提供了各种重载的getMessage方法。
可从ApplicationObjectSupport获得,但也可作为独立的帮助程序重用,以委托给应用程序中的对象。

代码示例

代码示例来源:origin: spring-projects/spring-security

private BadCredentialsException badCredentials() {
  return new BadCredentialsException(messages.getMessage(
      "LdapAuthenticationProvider.badCredentials", "Bad credentials"));
}

代码示例来源:origin: spring-projects/spring-security-oauth

/**
 * Set the message source.
 *
 * @param messageSource The message source.
 */
public void setMessageSource(MessageSource messageSource) {
  this.messages = new MessageSourceAccessor(messageSource);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the message for the given code and the default Locale.
 * @param code code of the message
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getMessage(String code) throws NoSuchMessageException {
  return this.messageSource.getMessage(code, null, getDefaultLocale());
}

代码示例来源:origin: spring-projects/spring-framework

MessageSourceAccessor accessor = new MessageSourceAccessor(ac);
LocaleContextHolder.setLocale(new Locale("DE", "at"));
try {
  assertEquals("nochricht2", accessor.getMessage("code2"));

代码示例来源:origin: nz.co.senanque/madura-objects

/**
 * @param message
 */
public LocaleAwareRuntimeException(String message, Object[] args, MessageSource messageSource)
{
  super(message);
  MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(messageSource);
  m_localisedMessage = messageSourceAccessor.getMessage(message,args);
}

代码示例来源:origin: spring-projects/spring-security-oauth

/**
 * Logic to be performed on a new timestamp.  The default behavior expects that the timestamp should not be new.
 *
 * @throws org.springframework.security.core.AuthenticationException
 *          If the timestamp shouldn't be new.
 */
protected void onNewTimestamp() throws AuthenticationException {
 throw new InvalidOAuthParametersException(messages.getMessage("OAuthProcessingFilter.timestampNotNew", "A new timestamp should not be used in a request for an access token."));
}

代码示例来源:origin: spring-projects/spring-security-oauth

/**
 * Set the message source.
 *
 * @param messageSource The message source.
 */
public void setMessageSource(MessageSource messageSource) {
 this.messages = new MessageSourceAccessor(messageSource);
}

代码示例来源:origin: nz.co.senanque/madura-vaadinsupport

public Button getButtonField(String name, MessageSource messageSource) {
    MessageSourceAccessor messageSourceAccessor = new MessageSourceAccessor(messageSource);
    Button ret = new Button(messageSourceAccessor.getMessage(name,null,name));
    return ret;
  }
//    public void setMessageSource(MessageSource messageSource) {

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance)
 * in the default Locale.
 * @param resolvable the MessageSourceResolvable
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getMessage(MessageSourceResolvable resolvable) throws NoSuchMessageException {
  return this.messageSource.getMessage(resolvable, getDefaultLocale());
}

代码示例来源:origin: spring-projects/spring-security

public Authentication authenticate(Authentication authentication)
    throws AuthenticationException {
  RunAsUserToken token = (RunAsUserToken) authentication;
  if (token.getKeyHash() == key.hashCode()) {
    return authentication;
  }
  else {
    throw new BadCredentialsException(messages.getMessage(
        "RunAsImplAuthenticationProvider.incorrectKey",
        "The presented RunAsUserToken does not contain the expected key"));
  }
}

代码示例来源:origin: spring-projects/spring-security-oauth

/**
 * Set the message source.
 *
 * @param messageSource The message source.
 */
public void setMessageSource(MessageSource messageSource) {
 this.messages = new MessageSourceAccessor(messageSource);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the message for the given code and the default Locale.
 * @param code code of the message
 * @param defaultMessage the String to return if the lookup fails
 * @return the message
 */
public String getMessage(String code, String defaultMessage) {
  String msg = this.messageSource.getMessage(code, null, defaultMessage, getDefaultLocale());
  return (msg != null ? msg : "");
}

代码示例来源:origin: spring-projects/spring-security-oauth

@Override
protected void onNewTimestamp() throws AuthenticationException {
 throw new InvalidOAuthParametersException(messages.getMessage("AccessTokenProcessingFilter.timestampNotNew", "A new timestamp should not be used in a request for an access token."));
}

代码示例来源:origin: spring-projects/spring-security

public void setMessageSource(MessageSource messageSource) {
  this.messages = new MessageSourceAccessor(messageSource);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the message for the given code and the default Locale.
 * @param code code of the message
 * @param args arguments for the message, or {@code null} if none
 * @param defaultMessage the String to return if the lookup fails
 * @return the message
 */
public String getMessage(String code, @Nullable Object[] args, String defaultMessage) {
  String msg = this.messageSource.getMessage(code, args, defaultMessage, getDefaultLocale());
  return (msg != null ? msg : "");
}

代码示例来源:origin: org.springframework.security/spring-security-core

public Authentication authenticate(Authentication authentication)
    throws AuthenticationException {
  RunAsUserToken token = (RunAsUserToken) authentication;
  if (token.getKeyHash() == key.hashCode()) {
    return authentication;
  }
  else {
    throw new BadCredentialsException(messages.getMessage(
        "RunAsImplAuthenticationProvider.incorrectKey",
        "The presented RunAsUserToken does not contain the expected key"));
  }
}

代码示例来源:origin: spring-projects/spring-security

public void setMessageSource(final MessageSource messageSource) {
  this.messages = new MessageSourceAccessor(messageSource);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the message for the given code and the default Locale.
 * @param code code of the message
 * @param args arguments for the message, or {@code null} if none
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getMessage(String code, @Nullable Object[] args) throws NoSuchMessageException {
  return this.messageSource.getMessage(code, args, getDefaultLocale());
}

代码示例来源:origin: spring-projects/spring-security

public Authentication authenticate(Authentication authentication)
    throws AuthenticationException {
  if (!supports(authentication.getClass())) {
    return null;
  }
  if (this.key.hashCode() != ((RememberMeAuthenticationToken) authentication)
      .getKeyHash()) {
    throw new BadCredentialsException(
        messages.getMessage("RememberMeAuthenticationProvider.incorrectKey",
            "The presented RememberMeAuthenticationToken does not contain the expected key"));
  }
  return authentication;
}

代码示例来源:origin: spring-projects/spring-security

public void setMessageSource(MessageSource messageSource) {
  this.messages = new MessageSourceAccessor(messageSource);
}

相关文章

微信公众号

最新文章

更多