View Javadoc

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