View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.config.spring.editors;
8   
9   import org.mule.MessageExchangePattern;
10  import org.mule.api.MuleContext;
11  import org.mule.api.context.MuleContextAware;
12  import org.mule.api.transport.Connector;
13  import org.mule.construct.SimpleService.Type;
14  import org.mule.endpoint.URIBuilder;
15  
16  import java.text.SimpleDateFormat;
17  import java.util.Date;
18  
19  import org.springframework.beans.PropertyEditorRegistrar;
20  import org.springframework.beans.PropertyEditorRegistry;
21  
22  /**
23   * The preferred way to configure property editors in Spring 2/3 is to implement a
24   * registrar
25   */
26  public class MulePropertyEditorRegistrar implements PropertyEditorRegistrar, MuleContextAware
27  {
28      private MuleContext muleContext;
29  
30      public void setMuleContext(MuleContext context)
31      {
32          muleContext = context;
33      }
34  
35      public void registerCustomEditors(PropertyEditorRegistry registry)
36      {
37          registry.registerCustomEditor(Connector.class, new ConnectorPropertyEditor(muleContext));
38          registry.registerCustomEditor(URIBuilder.class, new URIBuilderPropertyEditor(muleContext));
39          registry.registerCustomEditor(MessageExchangePattern.class,
40              new MessageExchangePatternPropertyEditor());
41          registry.registerCustomEditor(Type.class, new SimpleServiceTypePropertyEditor());
42          registry.registerCustomEditor(Date.class, new DatePropertyEditor(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"), new SimpleDateFormat("yyyy-MM-dd"), true));
43  
44      }
45  }