Java 类javax.validation.MessageInterpolator 实例源码

项目:lams    文件:CustomValidatorBean.java   
@Override
public void afterPropertiesSet() {
    if (this.validatorFactory == null) {
        this.validatorFactory = Validation.buildDefaultValidatorFactory();
    }

    ValidatorContext validatorContext = this.validatorFactory.usingContext();
    MessageInterpolator targetInterpolator = this.messageInterpolator;
    if (targetInterpolator == null) {
        targetInterpolator = this.validatorFactory.getMessageInterpolator();
    }
    validatorContext.messageInterpolator(new LocaleContextMessageInterpolator(targetInterpolator));
    if (this.traversableResolver != null) {
        validatorContext.traversableResolver(this.traversableResolver);
    }

    setTargetValidator(validatorContext.getValidator());
}
项目:spring4-understanding    文件:CustomValidatorBean.java   
@Override
public void afterPropertiesSet() {
    if (this.validatorFactory == null) {
        this.validatorFactory = Validation.buildDefaultValidatorFactory();
    }

    ValidatorContext validatorContext = this.validatorFactory.usingContext();
    MessageInterpolator targetInterpolator = this.messageInterpolator;
    if (targetInterpolator == null) {
        targetInterpolator = this.validatorFactory.getMessageInterpolator();
    }
    validatorContext.messageInterpolator(new LocaleContextMessageInterpolator(targetInterpolator));
    if (this.traversableResolver != null) {
        validatorContext.traversableResolver(this.traversableResolver);
    }

    setTargetValidator(validatorContext.getValidator());
}
项目:my-spring-cache-redis    文件:CustomValidatorBean.java   
@Override
public void afterPropertiesSet() {
    if (this.validatorFactory == null) {
        this.validatorFactory = Validation.buildDefaultValidatorFactory();
    }

    ValidatorContext validatorContext = this.validatorFactory.usingContext();
    MessageInterpolator targetInterpolator = this.messageInterpolator;
    if (targetInterpolator == null) {
        targetInterpolator = this.validatorFactory.getMessageInterpolator();
    }
    validatorContext.messageInterpolator(new LocaleContextMessageInterpolator(targetInterpolator));
    if (this.traversableResolver != null) {
        validatorContext.traversableResolver(this.traversableResolver);
    }

    setTargetValidator(validatorContext.getValidator());
}
项目:open-Autoscaler    文件:BeanValidation.java   
public static JsonNode parsePolicyEnable(String jsonString, HttpServletRequest httpServletRequest) throws JsonParseException, JsonMappingException, IOException{
     List<String> violation_message = new ArrayList<String>();
     ObjectNode result = new_mapper.createObjectNode();
     result.put("valid", false);
     PolicyEnbale policyEnable = new_mapper.readValue(jsonString, PolicyEnbale.class);
     ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
     Locale locale = LocaleUtil.getLocale(httpServletRequest);
     MessageInterpolator interpolator = new LocaleSpecificMessageInterpolator(vf.getMessageInterpolator(), locale);
     Validator validator = vf.usingContext().messageInterpolator(interpolator).getValidator();
     Set<ConstraintViolation<PolicyEnbale>> set = validator.validate(policyEnable);
     if (set.size() > 0 ){
         for (ConstraintViolation<PolicyEnbale> constraintViolation : set) {
             violation_message.add(constraintViolation.getMessage());
         }
         result.set("violation_message", new_mapper.valueToTree(violation_message));
         return result;
     }

     //additional data manipulation
     String new_json = policyEnable.transformInput();
     result.put("valid", true);
     result.put("new_json", new_json);
     return result;
}
项目:open-Autoscaler    文件:BeanValidation.java   
public static JsonNode parseScalingHistory(String jsonString, HttpServletRequest httpServletRequest) throws JsonParseException, JsonMappingException, IOException{
     List<String> violation_message = new ArrayList<String>();
     ObjectNode result = new_mapper.createObjectNode();
     result.put("valid", false);
     JavaType javaType = getCollectionType(ArrayList.class, ArrayList.class, HistoryData.class);
     new_mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
     List<HistoryData> scalinghistory = (List<HistoryData>)new_mapper.readValue(jsonString, javaType);
     ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
     Locale locale = LocaleUtil.getLocale(httpServletRequest);
     MessageInterpolator interpolator = new LocaleSpecificMessageInterpolator(vf.getMessageInterpolator(), locale);
     Validator validator = vf.usingContext().messageInterpolator(interpolator).getValidator();
     Set<ConstraintViolation<List<HistoryData>>> set = validator.validate(scalinghistory);
     if (set.size() > 0 ){
         for (ConstraintViolation<List<HistoryData>> constraintViolation : set) {
             violation_message.add(constraintViolation.getMessage());
         }
         result.set("violation_message", new_mapper.valueToTree(violation_message));
         return result;
     }

     //additional data manipulation
         String new_json = transformHistory(scalinghistory);
     result.put("valid", true);
     result.put("new_json", new_json);
     return result;
}
项目:spring    文件:CustomValidatorBean.java   
@Override
public void afterPropertiesSet() {
    if (this.validatorFactory == null) {
        this.validatorFactory = Validation.buildDefaultValidatorFactory();
    }

    ValidatorContext validatorContext = this.validatorFactory.usingContext();
    MessageInterpolator targetInterpolator = this.messageInterpolator;
    if (targetInterpolator == null) {
        targetInterpolator = this.validatorFactory.getMessageInterpolator();
    }
    validatorContext.messageInterpolator(new LocaleContextMessageInterpolator(targetInterpolator));
    if (this.traversableResolver != null) {
        validatorContext.traversableResolver(this.traversableResolver);
    }

    setTargetValidator(validatorContext.getValidator());
}
项目:opencucina    文件:BeanMessageInterpolatorTest.java   
/**
 * JAVADOC Method Level Comments
 */
@SuppressWarnings({"rawtypes", "unchecked"})
@Test
public void testInterpolateStringContext() {
    Context context = mock(Context.class);
    ConstraintDescriptor cd = mock(ConstraintDescriptor.class);
    Map<String, Object> atts = new HashMap<String, Object>();

    when(cd.getAttributes()).thenReturn(atts);
    when(context.getConstraintDescriptor()).thenReturn(cd);

    Foo foo = new Foo();

    when(context.getValidatedValue()).thenReturn(foo);

    MessageInterpolator delegate = mock(MessageInterpolator.class);

    when(delegate.interpolate("message", context)).thenReturn("MEssAGE");

    BeanMessageInterpolator interpolator = new BeanMessageInterpolator(delegate);

    interpolator.interpolate("message", context);
    assertEquals(foo, atts.get("0"));
}
项目:packagedrone    文件:OsgiMessageInterpolator.java   
protected String resolve ( final String key, final Context context, final Locale locale )
{
    for ( final Resolver resolver : this.tracker.getTracked ().values () )
    {
        final String result = resolver.resolve ( key, context, locale );
        if ( result != null )
        {
            return result;
        }
    }

    final MessageInterpolator fallback = this.fallback;

    if ( fallback == null )
    {
        return null;
    }
    return fallback.interpolate ( String.format ( "{%s}", key ), context, locale );
}
项目:gwt-bean-validators    文件:AbstractGwtSpecificValidator.java   
private <T, V, A extends Annotation> ConstraintViolation<T> createConstraintViolation(
    final GwtValidationContext<T> context, final G object, final V value,
    final ConstraintDescriptorImpl<A> constraintDescriptor, final MessageAndPath messageAndPath) {
  final MessageInterpolator messageInterpolator = context.getMessageInterpolator();
  final de.knightsoftnet.validators.client.impl.MessageInterpolatorContextImpl messageContext =
      new MessageInterpolatorContextImpl(constraintDescriptor, value);
  final String message =
      messageInterpolator.interpolate(messageAndPath.getMessage(), messageContext);
  return ConstraintViolationImpl.<T>builder() //
      .setConstraintDescriptor(constraintDescriptor) //
      .setInvalidValue(value) //
      .setLeafBean(object) //
      .setMessage(message) //
      .setMessageTemplate(messageAndPath.getMessage()) //
      .setPropertyPath(messageAndPath.getPath()) //
      .setRootBean(context.getRootBean()) //
      .setRootBeanClass(context.getRootBeanClass()) //
      .setElementType(constraintDescriptor.getElementType()) //
      .build();
}
项目:nest-old    文件:ValidatorFactoryImpl513.java   
/**
 * create validator
 * 
 * @param constraintValidatorFactory
 * @param messageInterpolator
 * @param traversableResolver
 * @param parameterNameProvider
 * @param failFast
 * @param validatedValueHandlers
 * @return
 */
protected Validator createValidator(ConstraintValidatorFactory constraintValidatorFactory,
        MessageInterpolator messageInterpolator, TraversableResolver traversableResolver,
        ParameterNameProvider parameterNameProvider, boolean failFast,
        List<ValidatedValueUnwrapper<?>> validatedValueHandlers) {
    BeanMetaDataManager513 beanMetaDataManager;
    if (!beanMetaDataManagerMap.containsKey(parameterNameProvider)) {
        beanMetaDataManager = new BeanMetaDataManager513(constraintHelper, executableHelper, parameterNameProvider,
                buildDataProviders(parameterNameProvider));
        beanMetaDataManagerMap.put(parameterNameProvider, beanMetaDataManager);
    } else {
        beanMetaDataManager = beanMetaDataManagerMap.get(parameterNameProvider);
    }

    return new ValidatorImpl(constraintValidatorFactory, messageInterpolator, traversableResolver,
            beanMetaDataManager, parameterNameProvider, typeResolutionHelper, validatedValueHandlers,
            constraintValidatorManager, failFast);
}
项目:class-guard    文件:CustomValidatorBean.java   
public void afterPropertiesSet() {
    if (this.validatorFactory == null) {
        this.validatorFactory = Validation.buildDefaultValidatorFactory();
    }

    ValidatorContext validatorContext = this.validatorFactory.usingContext();
    MessageInterpolator targetInterpolator = this.messageInterpolator;
    if (targetInterpolator == null) {
        targetInterpolator = this.validatorFactory.getMessageInterpolator();
    }
    validatorContext.messageInterpolator(new LocaleContextMessageInterpolator(targetInterpolator));
    if (this.traversableResolver != null) {
        validatorContext.traversableResolver(this.traversableResolver);
    }

    setTargetValidator(validatorContext.getValidator());
}
项目:package-drone    文件:OsgiMessageInterpolator.java   
protected String resolve ( final String key, final Context context, final Locale locale )
{
    for ( final Resolver resolver : this.tracker.getTracked ().values () )
    {
        final String result = resolver.resolve ( key, context, locale );
        if ( result != null )
        {
            return result;
        }
    }

    final MessageInterpolator fallback = this.fallback;

    if ( fallback == null )
    {
        return null;
    }
    return fallback.interpolate ( String.format ( "{%s}", key ), context, locale );
}
项目:vraptor4    文件:DefaultValidatorTest.java   
@Before
public void setup() {
    ResourceBundle bundle = new SafeResourceBundle(ResourceBundle.getBundle("messages"));

    ValidatorFactory validatorFactory = javax.validation.Validation.buildDefaultValidatorFactory();
    javax.validation.Validator bvalidator = validatorFactory.getValidator();
    MessageInterpolator interpolator = validatorFactory.getMessageInterpolator();

    Proxifier proxifier = new JavassistProxifier();
    Messages messages = new Messages();

    validator = new DefaultValidator(result, new DefaultValidationViewsFactory(result, proxifier, new DefaultReflectionProvider()), 
            outjector, proxifier, bundle, bvalidator, interpolator, Locale.ENGLISH, messages);
    when(result.use(LogicResult.class)).thenReturn(logicResult);
    when(result.use(PageResult.class)).thenReturn(pageResult);
    when(logicResult.forwardTo(MyComponent.class)).thenReturn(instance);
    when(pageResult.of(MyComponent.class)).thenReturn(instance);
}
项目:syndesis    文件:ValidatorContextResolver.java   
@Override
public GeneralValidator getContext(final Class<?> type) {
    final ResourceBundleLocator resourceBundleLocator = new PlatformResourceBundleLocator("messages");
    final MessageInterpolator messageInterpolator = new ResourceBundleMessageInterpolator(resourceBundleLocator);
    final Configuration<?> config = Validation.byDefaultProvider().configure()
        .messageInterpolator(messageInterpolator);
    final BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
    final boolean isExecutableValidationEnabled = bootstrapConfiguration.isExecutableValidationEnabled();
    final Set<ExecutableType> defaultValidatedExecutableTypes = bootstrapConfiguration
        .getDefaultValidatedExecutableTypes();

    return new GeneralValidatorImpl(validatorFactory, isExecutableValidationEnabled,
        defaultValidatedExecutableTypes);
}
项目:open-Autoscaler    文件:BeanValidation.java   
public static JsonNode parsePolicy(String jsonString, Map<String, String> service_info, HttpServletRequest httpServletRequest) throws JsonParseException, JsonMappingException, IOException{
     List<String> violation_message = new ArrayList<String>();
     ObjectNode result = new_mapper.createObjectNode();
     result.put("valid", false);
     logger.info("received policy : " + jsonString); //debug
     new_mapper.readValue(jsonString, Policy.class); //for syntax error check
     String transfered_json = TransferedPolicy.packServiceInfo(jsonString, service_info);
     logger.info("transfered policy after update with service_information : " + transfered_json); //debug
     TransferedPolicy policy = new_mapper.readValue(transfered_json, TransferedPolicy.class);
     logger.info("we get policy as " + (Obj2Map(policy)).toString());//debug
     //additional data manipulation and check again
     policy = policy.setMaxInstCount();
     HibernateValidatorConfiguration config = BeanValidation.getPolicyRange();
     ValidatorFactory vf = config.buildValidatorFactory();
     Locale locale = LocaleUtil.getLocale(httpServletRequest);
     MessageInterpolator interpolator = new LocaleSpecificMessageInterpolator(vf.getMessageInterpolator(), locale);
     Validator validator = vf.usingContext().messageInterpolator(interpolator).getValidator();
     Set<ConstraintViolation<TransferedPolicy>> set = validator.validate(policy);
     if (set.size() > 0 ){
         for (ConstraintViolation<TransferedPolicy> constraintViolation : set) {
             violation_message.add(constraintViolation.getMessage());
         }
         result.set("violation_message", new_mapper.valueToTree(violation_message));
         return result;
     }

     String new_json = policy.transformInput();
     logger.info("policy before trigger back : " + new_json); //debug
     new_json = TransferedPolicy.unpackServiceInfo(new_json, service_info);
     result.put("valid", true);
     logger.info("send out policy: " + new_json); //debug
     result.put("new_json", new_json);
     return result;
}
项目:open-Autoscaler    文件:BeanValidation.java   
public static JsonNode parsePolicyOutput(String jsonString, Map<String, String> supplyment, Map<String, String> service_info, HttpServletRequest httpServletRequest) throws JsonParseException, JsonMappingException, IOException{
     List<String> violation_message = new ArrayList<String>();
     ObjectNode result = new_mapper.createObjectNode();
     result.put("valid", false);
     logger.info("received json: " + jsonString); 
     String transfered_json = TransferedPolicy.packServiceInfo(jsonString, service_info);
     logger.info("transfered policy after update with service_information : " + transfered_json); //debug
     TransferedPolicy policy = new_mapper.readValue(transfered_json, TransferedPolicy.class);
     logger.info("we get policy as " + (Obj2Map(policy)).toString());//debug
     ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
     Locale locale = LocaleUtil.getLocale(httpServletRequest);
     MessageInterpolator interpolator = new LocaleSpecificMessageInterpolator(vf.getMessageInterpolator(), locale);
     Validator validator = vf.usingContext().messageInterpolator(interpolator).getValidator();
     Set<ConstraintViolation<TransferedPolicy>> set = validator.validate(policy);
     if (set.size() > 0 ){
         for (ConstraintViolation<TransferedPolicy> constraintViolation : set) {
             violation_message.add(constraintViolation.getMessage());
         }
         result.set("violation_message", new_mapper.valueToTree(violation_message));
         return result;
     }

     //additional data manipulation
     policy = policy.transformSchedules();
     String new_json = policy.transformOutput(supplyment, service_info);
     result.put("valid", true);
     result.put("new_json", new_json);
     return result;
}
项目:open-Autoscaler    文件:BeanValidation.java   
public static JsonNode parseMetrics(String jsonString, HttpServletRequest httpServletRequest) throws JsonParseException, JsonMappingException, IOException{
     List<String> violation_message = new ArrayList<String>();
     ObjectNode result = new_mapper.createObjectNode();
     result.put("valid", false);
     //JavaType javaType = getCollectionType(ArrayList.class, HistoryData.class);
     //new_mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
     logger.info("Received metrics: " + jsonString);
     Metrics metrics = new_mapper.readValue(jsonString, Metrics.class);

     ValidatorFactory vf = Validation.buildDefaultValidatorFactory();
     Locale locale = LocaleUtil.getLocale(httpServletRequest);
     MessageInterpolator interpolator = new LocaleSpecificMessageInterpolator(vf.getMessageInterpolator(), locale);
     Validator validator = vf.usingContext().messageInterpolator(interpolator).getValidator();
     Set<ConstraintViolation<Metrics>> set = validator.validate(metrics);
     if (set.size() > 0 ){
         for (ConstraintViolation<Metrics> constraintViolation : set) {
             violation_message.add(constraintViolation.getMessage());
         }
         result.set("violation_message", new_mapper.valueToTree(violation_message));
         return result;
     }


     //additional data manipulation
     String new_json = metrics.transformOutput();
     result.put("valid", true);
     result.put("new_json", new_json);
     return result;
}
项目:syndesis-rest    文件:ValidatorContextResolver.java   
@Override
public GeneralValidator getContext(final Class<?> type) {
    final ResourceBundleLocator resourceBundleLocator = new PlatformResourceBundleLocator("messages");
    final MessageInterpolator messageInterpolator = new ResourceBundleMessageInterpolator(resourceBundleLocator);
    final Configuration<?> config = Validation.byDefaultProvider().configure()
        .messageInterpolator(messageInterpolator);
    final BootstrapConfiguration bootstrapConfiguration = config.getBootstrapConfiguration();
    final boolean isExecutableValidationEnabled = bootstrapConfiguration.isExecutableValidationEnabled();
    final Set<ExecutableType> defaultValidatedExecutableTypes = bootstrapConfiguration
        .getDefaultValidatedExecutableTypes();

    return new GeneralValidatorImpl(validatorFactory, isExecutableValidationEnabled,
        defaultValidatedExecutableTypes);
}
项目:Camel    文件:ValidatorFactories.java   
public static ValidatorFactory buildValidatorFactory(boolean osgi,
                                                     ValidationProviderResolver validationProviderResolver,
                                                     MessageInterpolator messageInterpolator,
                                                     TraversableResolver traversableResolver,
                                                     ConstraintValidatorFactory constraintValidatorFactory) {

    ValidationProviderResolver resolvedValidationProviderResolver =
            resolveValidationProviderResolver(osgi, validationProviderResolver);

    GenericBootstrap bootstrap = Validation.byDefaultProvider();
    if (resolvedValidationProviderResolver != null) {
        bootstrap.providerResolver(resolvedValidationProviderResolver);
    }
    Configuration<?> configuration = bootstrap.configure();

    if (messageInterpolator != null) {
        configuration.messageInterpolator(messageInterpolator);
    }

    if (traversableResolver != null) {
        configuration.traversableResolver(traversableResolver);
    }

    if (constraintValidatorFactory != null) {
        configuration.constraintValidatorFactory(constraintValidatorFactory);
    }

    return configuration.buildValidatorFactory();
}
项目:opencucina    文件:BeanMessageInterpolatorTest.java   
/**
 * JAVADOC Method Level Comments
 */
@SuppressWarnings("unchecked")
@Test
public void testInterpolateStringContextLocale() {
    Context context = mock(Context.class);
    @SuppressWarnings("rawtypes")
    ConstraintDescriptor cd = mock(ConstraintDescriptor.class);
    Map<String, Object> atts = new HashMap<String, Object>();
    String[] properties = { "name", "value" };

    atts.put("properties", properties);

    when(cd.getAttributes()).thenReturn(atts);
    when(context.getConstraintDescriptor()).thenReturn(cd);

    Foo foo = new Foo();

    foo.setName("Name");
    foo.setValue(200);
    when(context.getValidatedValue()).thenReturn(foo);

    MessageInterpolator delegate = mock(MessageInterpolator.class);

    when(delegate.interpolate("message", context, Locale.getDefault())).thenReturn("MEssAGE");

    BeanMessageInterpolator interpolator = new BeanMessageInterpolator(delegate);

    interpolator.interpolate("message", context, Locale.getDefault());
    assertEquals("Name", atts.get("0"));
    assertEquals("200", atts.get("1"));
}
项目:rise    文件:CoreRestartableModule.java   
@Provides
@Singleton
protected MessageInterpolator messageInterpolator(RiseValidationMessageInterpolator interpolator) {
    return interpolator;
    // return new ResourceBundleMessageInterpolator(
    // resolver::getResourceBundle);
}
项目:gwt-bean-validators    文件:GwtValidationContext.java   
private GwtValidationContext(final Class<T> rootBeanClass, final T rootBean,
    final BeanDescriptor beanDescriptor, final MessageInterpolator messageInterpolator,
    final TraversableResolver traversableResolver, final AbstractGwtValidator validator,
    final Set<Object> validatedObjects) {
  this.rootBeanClass = rootBeanClass;
  this.rootBean = rootBean;
  this.beanDescriptor = beanDescriptor;
  this.messageInterpolator = messageInterpolator;
  this.traversableResolver = traversableResolver;
  this.validator = validator;
  this.validatedObjects = new HashSet<>(validatedObjects);
}
项目:viritin    文件:MBeanFieldGroup.java   
/**
 * A helper method that returns "bean level" validation errors, i.e. errors
 * that are not tied to a specific property/field.
 *
 * @return error messages from "bean level validation"
 */
public Collection<String> getBeanLevelValidationErrors() {
    Collection<String> errors = new ArrayList<>();
    if (getConstraintViolations() != null) {
        for (final ConstraintViolation<T> constraintViolation : getConstraintViolations()) {
            final MessageInterpolator.Context context = new MessageInterpolator.Context() {
                @Override
                public ConstraintDescriptor<?> getConstraintDescriptor() {
                    return constraintViolation.getConstraintDescriptor();
                }

                @Override
                public Object getValidatedValue() {
                    return constraintViolation.getInvalidValue();
                }

                @Override
                public <T> T unwrap(Class<T> type) {
                    throw new ValidationException();
                }
            };

            final String msg = getJavaxBeanValidatorFactory().getMessageInterpolator().interpolate(
                constraintViolation.getMessageTemplate(),
                context, getLocale());
            errors.add(msg);
        }
    }
    if (getBasicConstraintViolations() != null) {
        for (Validator.InvalidValueException cv : getBasicConstraintViolations()) {
            errors.add(cv.getMessage());
        }
    }
    return errors;
}
项目:cm_ext    文件:DefaultValidatorConfiguration.java   
/**
 * Creates the validator factory bean that Spring uses to
 * construct a Validator.
 *
 * @return a Validator Factory Bean
 */
@Bean
public LocalValidatorFactoryBean validatorFactoryBean() {
  BeanConstraintValidatorFactory validatorFactory = ctx.getBean(BeanConstraintValidatorFactory.class);
  MessageInterpolator messageInterpolator = ctx.getBean(MessageInterpolator.class);
  LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean();
  factoryBean.setMessageInterpolator(messageInterpolator);
  factoryBean.setConstraintValidatorFactory(validatorFactory);
  return factoryBean;
}
项目:hurraa    文件:CejugValidator.java   
@Inject
public CejugValidator(Result result, ValidationViewsFactory factory, Outjector outjector, Proxifier proxifier,
        ResourceBundle bundle, Validator validator, MessageInterpolator interpolator, Locale locale) {
    super(result, factory, outjector, proxifier, bundle,  validator, interpolator, locale);
    this.result = result;
    this.viewsFactory = factory;
    this.outjector = outjector;
    this.proxifier = proxifier;
}
项目:vraptor4    文件:DefaultValidator.java   
@Inject
public DefaultValidator(Result result, ValidationViewsFactory factory, Outjector outjector, Proxifier proxifier, 
        ResourceBundle bundle, javax.validation.Validator bvalidator, MessageInterpolator interpolator, Locale locale,
        Messages messages) {
    this.result = result;
    this.viewsFactory = factory;
    this.outjector = outjector;
    this.proxifier = proxifier;
    this.bundle = bundle;
    this.bvalidator = bvalidator;
    this.interpolator = interpolator;
    this.locale = locale;
    this.messages = messages;
}
项目:XPages-Scaffolding    文件:AbstractModelObject.java   
@Override
public String interpolate(final String message, final MessageInterpolator.Context context) {
    Locale locale;
    if(FrameworkUtils.isFaces()) {
        locale = XSPContext.getXSPContext(FacesContext.getCurrentInstance()).getLocale();
    } else {
        locale = Locale.getDefault();
    }
    return interpolate(message, context, locale);
}
项目:cas-5.1.0    文件:CasCoreUtilConfiguration.java   
@Bean
public MessageInterpolator messageInterpolator() {
    return new SpringAwareMessageMessageInterpolator();
}
项目:lams    文件:LocaleContextMessageInterpolator.java   
/**
 * Create a new LocaleContextMessageInterpolator, wrapping the given target interpolator.
 * @param targetInterpolator the target MessageInterpolator to wrap
 */
public LocaleContextMessageInterpolator(MessageInterpolator targetInterpolator) {
    Assert.notNull(targetInterpolator, "Target MessageInterpolator must not be null");
    this.targetInterpolator = targetInterpolator;
}
项目:lams    文件:CustomValidatorBean.java   
/**
 * Specify a custom MessageInterpolator to use for this Validator.
 */
public void setMessageInterpolator(MessageInterpolator messageInterpolator) {
    this.messageInterpolator = messageInterpolator;
}
项目:lams    文件:LocalValidatorFactoryBean.java   
@Override
public void afterPropertiesSet() {
    @SuppressWarnings({"rawtypes", "unchecked"})
    Configuration<?> configuration = (this.providerClass != null ?
            Validation.byProvider(this.providerClass).configure() :
            Validation.byDefaultProvider().configure());

    MessageInterpolator targetInterpolator = this.messageInterpolator;
    if (targetInterpolator == null) {
        targetInterpolator = configuration.getDefaultMessageInterpolator();
    }
    configuration.messageInterpolator(new LocaleContextMessageInterpolator(targetInterpolator));

    if (this.traversableResolver != null) {
        configuration.traversableResolver(this.traversableResolver);
    }

    ConstraintValidatorFactory targetConstraintValidatorFactory = this.constraintValidatorFactory;
    if (targetConstraintValidatorFactory == null && this.applicationContext != null) {
        targetConstraintValidatorFactory =
                new SpringConstraintValidatorFactory(this.applicationContext.getAutowireCapableBeanFactory());
    }
    if (targetConstraintValidatorFactory != null) {
        configuration.constraintValidatorFactory(targetConstraintValidatorFactory);
    }

    if (this.parameterNameDiscoverer != null) {
        configureParameterNameProviderIfPossible(configuration);
    }

    if (this.mappingLocations != null) {
        for (Resource location : this.mappingLocations) {
            try {
                configuration.addMapping(location.getInputStream());
            }
            catch (IOException ex) {
                throw new IllegalStateException("Cannot read mapping resource: " + location);
            }
        }
    }

    for (Map.Entry<String, String> entry : this.validationPropertyMap.entrySet()) {
        configuration.addProperty(entry.getKey(), entry.getValue());
    }

    // Allow for custom post-processing before we actually build the ValidatorFactory.
    postProcessConfiguration(configuration);

    this.validatorFactory = configuration.buildValidatorFactory();
    setTargetValidator(this.validatorFactory.getValidator());
}
项目:lams    文件:LocalValidatorFactoryBean.java   
@Override
public MessageInterpolator getMessageInterpolator() {
    Assert.notNull(this.validatorFactory, "No target ValidatorFactory set");
    return this.validatorFactory.getMessageInterpolator();
}
项目:lams    文件:LocalValidatorFactoryBean.java   
public static MessageInterpolator buildMessageInterpolator(MessageSource messageSource) {
    return new ResourceBundleMessageInterpolator(new MessageSourceResourceBundleLocator(messageSource));
}
项目:minijax    文件:MinijaxValidatorFactory.java   
@Override
public MessageInterpolator getMessageInterpolator() {
    throw new UnsupportedOperationException();
}
项目:minijax    文件:MinijaxValidationProvider.java   
@Override
public MinijaxValidationProvider messageInterpolator(final MessageInterpolator interpolator) {
    throw new UnsupportedOperationException();
}
项目:minijax    文件:MinijaxValidationProvider.java   
@Override
public MessageInterpolator getDefaultMessageInterpolator() {
    throw new UnsupportedOperationException();
}
项目:spring4-understanding    文件:LocaleContextMessageInterpolator.java   
/**
 * Create a new LocaleContextMessageInterpolator, wrapping the given target interpolator.
 * @param targetInterpolator the target MessageInterpolator to wrap
 */
public LocaleContextMessageInterpolator(MessageInterpolator targetInterpolator) {
    Assert.notNull(targetInterpolator, "Target MessageInterpolator must not be null");
    this.targetInterpolator = targetInterpolator;
}
项目:spring4-understanding    文件:CustomValidatorBean.java   
/**
 * Specify a custom MessageInterpolator to use for this Validator.
 */
public void setMessageInterpolator(MessageInterpolator messageInterpolator) {
    this.messageInterpolator = messageInterpolator;
}
项目:spring4-understanding    文件:LocalValidatorFactoryBean.java   
@Override
public MessageInterpolator getMessageInterpolator() {
    Assert.notNull(this.validatorFactory, "No target ValidatorFactory set");
    return this.validatorFactory.getMessageInterpolator();
}
项目:spring4-understanding    文件:LocalValidatorFactoryBean.java   
public static MessageInterpolator buildMessageInterpolator(MessageSource messageSource) {
    return new ResourceBundleMessageInterpolator(new MessageSourceResourceBundleLocator(messageSource));
}