View Javadoc

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