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.transport.jms;
8   
9   import org.mule.endpoint.ResourceNameEndpointURIBuilder;
10  import org.mule.api.endpoint.MalformedEndpointException;
11  
12  import java.util.Properties;
13  import java.net.URI;
14  import java.net.URISyntaxException;
15  
16  /**
17   * TODO
18   */
19  public class JmsEndpointURIBuilder extends ResourceNameEndpointURIBuilder
20  {
21      @Override
22      protected void setEndpoint(URI uri, Properties props) throws MalformedEndpointException
23      {
24          super.setEndpoint(uri, props);
25  
26          String newUri = null;
27          if (uri.getScheme().equals("topic"))
28          {
29              props.setProperty(RESOURCE_INFO_PROPERTY, "topic");
30              newUri = uri.toString().replace("topic://", "jms://");
31          }
32          else if (uri.getScheme().equals("queue"))
33          {
34              newUri = uri.toString().replace("queue://", "jms://");
35          }
36  
37          try
38          {
39              if (newUri != null)
40              {
41                  rewriteURI(new URI(newUri));
42              }
43          }
44          catch (URISyntaxException e)
45          {
46              throw new MalformedEndpointException(e);
47          }
48  
49      }
50  }