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.api.MuleContext;
10  import org.mule.api.endpoint.EndpointException;
11  import org.mule.endpoint.MuleEndpointURI;
12  
13  import java.beans.PropertyEditorSupport;
14  
15  /**
16   * Translates a connector name property into the corresponding {@link org.mule.api.transport.Connector}
17   * instance.
18   */
19  public class EndpointURIPropertyEditor extends PropertyEditorSupport
20  {
21      private MuleContext muleContext;
22  
23      public EndpointURIPropertyEditor(MuleContext muleContext)
24      {
25          this.muleContext = muleContext;
26      }
27  
28      public void setAsText(String text)
29      {
30          try
31          {
32              setValue(new MuleEndpointURI(text, muleContext));
33          }
34          catch (EndpointException e)
35          {
36              throw new IllegalArgumentException(e.getMessage());
37          }
38      }
39  
40  }