Examples of ConversionService


Examples of org.springframework.binding.convert.ConversionService

    // targetClass is the correct one
    if ((sourceClass == null) || (sourceClass == targetClass)) {
      return sourceValueModel;
    }

    final ConversionService conversionService = getConversionService();
    ConversionExecutor convertTo = null;
    ConversionExecutor convertFrom = null;

    // Check for locally registered property converters
    if (propertyConversionServices.containsKey(formProperty)) {
      // TODO - extract ConfigurableConversionService interface...
      final GenericConversionService propertyConversionService = (GenericConversionService) propertyConversionServices
          .get(formProperty);

      if (propertyConversionService != null) {
        convertTo = propertyConversionService.getConversionExecutor(sourceClass, targetClass);
        convertFrom = propertyConversionService.getConversionExecutor(targetClass, sourceClass);
      }
    }

    // If we have nothing from the property level, then try the conversion
    // service
    if (convertTo == null) {
      convertTo = conversionService.getConversionExecutor(sourceClass, targetClass);
    }
    Assert.notNull(convertTo, "conversionService returned null ConversionExecutor");

    if (convertFrom == null) {
      convertFrom = conversionService.getConversionExecutor(targetClass, sourceClass);
    }
    Assert.notNull(convertFrom, "conversionService returned null ConversionExecutor");

    ValueModel convertingValueModel = preProcessNewConvertingValueModel(formProperty, targetClass,
        new TypeConverter(sourceValueModel, convertTo, convertFrom));
View Full Code Here

Examples of org.springframework.core.convert.ConversionService

  static class CustomConversionServiceFactoryBean extends ConversionServiceFactoryBean {

    @Override
    public ConversionService getObject() {
      ConversionService service = super.getObject();
      if (service instanceof GenericConversionService) {
        ((GenericConversionService) service).removeConvertible(Object.class, Object.class);
      }
      return service;
    }
View Full Code Here

Examples of org.springframework.core.convert.ConversionService

  static class CustomConversionServiceFactoryBean extends ConversionServiceFactoryBean {

    @Override
    public ConversionService getObject() {
      ConversionService service = super.getObject();
      if (service instanceof GenericConversionService) {
        ((GenericConversionService) service).removeConvertible(Object.class, Object.class);
      }
      return service;
    }
View Full Code Here

Examples of org.springframework.core.convert.ConversionService

   */
  static class CustomConversionServiceFactoryBean extends ConversionServiceFactoryBean {

    @Override
    public ConversionService getObject() {
      ConversionService service = super.getObject();
      if (service instanceof GenericConversionService) {
        ((GenericConversionService) service).removeConvertible(Object.class, Object.class);
      }
      return service;
    }
View Full Code Here

Examples of org.springframework.core.convert.ConversionService

public class DefaultMindAppmasterServiceClient extends MindAppmasterServiceClient {

  @Override
  protected BaseResponseObject getBaseResponseObject(RpcMessage<?> rpcMessage) {
    MindRpcMessageHolder holder = (MindRpcMessageHolder) rpcMessage.getBody();
    ConversionService conversionService = getConversionService();
    if(conversionService != null) {
      return (BaseResponseObject) conversionService.convert(holder, BaseObject.class);
    }
    return null;
  }
View Full Code Here

Examples of org.springframework.core.convert.ConversionService

    this.beanFactory = beanFactory;
  }

  public void afterPropertiesSet() throws Exception {
    Assert.notNull(beanFactory, "BeanFactory is required");
    ConversionService conversionService = IntegrationContextUtils.getConversionService(beanFactory);
    if (conversionService instanceof GenericConversionService) {
      ConversionServiceFactory.registerConverters(converters, (GenericConversionService) conversionService);
    } else {
      Assert.notNull(conversionService, "Failed to locate '"
          + IntegrationContextUtils.YARN_INTEGRATION_CONVERSION_SERVICE_BEAN_NAME + "'");
View Full Code Here

Examples of org.springframework.core.convert.ConversionService

  public MindRpcMessageHolder getPayload(RpcMessage<?> message) {
    Object body = message.getBody();
    if(body instanceof MindRpcMessageHolder) {
      return (MindRpcMessageHolder)body;
    }
    ConversionService conversionService = getConversionService();
    if(conversionService != null) {
      return conversionService.convert(body, MindRpcMessageHolder.class);
    }
    return null;
  }
View Full Code Here

Examples of org.springframework.core.convert.ConversionService

public class TestService extends MindAppmasterService {

  @Override
  protected MindRpcMessageHolder handleMindMessageInternal(MindRpcMessageHolder message) {

    ConversionService conversionService = getConversionService();
    SimpleTestRequest request = (SimpleTestRequest) conversionService.convert(message, BaseObject.class);

    SimpleTestResponse response = new SimpleTestResponse();
    response.stringField = "echo:" + request.stringField;

    MindRpcMessageHolder holder = conversionService.convert(response, MindRpcMessageHolder.class);
    return holder;

  }
View Full Code Here

Examples of org.springframework.core.convert.ConversionService

         sec.addPropertyAccessor(new BeanExpressionContextAccessor());
         sec.addPropertyAccessor(new BeanFactoryAccessor());
         sec.addPropertyAccessor(new MapAccessor());
         sec.setBeanResolver(new BeanFactoryResolver(beanEvaluationContext.getBeanFactory()));
         sec.setTypeLocator(new StandardTypeLocator(beanEvaluationContext.getBeanFactory().getBeanClassLoader()));
         ConversionService conversionService = beanEvaluationContext.getBeanFactory().getConversionService();
         if (conversionService != null) {
            sec.setTypeConverter(new StandardTypeConverter(conversionService));
         }

         _evaluationContext = sec;
View Full Code Here

Examples of org.springframework.core.convert.ConversionService

        // For compatibility with AbstractTemplateView
        addRequestContextAsVariable(mergedModel, AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE, requestContext);


        // Expose Thymeleaf's own evaluation context as a model variable
        final ConversionService conversionService =
                (ConversionService) request.getAttribute(ConversionService.class.getName()); // might be null!
        final ThymeleafEvaluationContext evaluationContext =
                new ThymeleafEvaluationContext(applicationContext, conversionService);
        mergedModel.put(ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME, evaluationContext);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.