View Javadoc

1   /*
2    * $Id: JmsEndpointURIBuilder.java 22291 2011-06-28 20:48:42Z eugene.berman $
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 oldUri = uri.toString();
30  
31          String newUri = null;
32          if (uri.getScheme().equals("topic"))
33          {
34              props.setProperty(RESOURCE_INFO_PROPERTY, "topic");
35              newUri = uri.toString().replace("topic://", "jms://");
36          }
37          else if (uri.getScheme().equals("queue"))
38          {
39              newUri = uri.toString().replace("queue://", "jms://");
40          }//Added by Eugene - dynamic endpoints were resolved to jms://queue:// etc
41  		else if (oldUri.startsWith("jms://queue://"))
42  		{
43  			newUri = uri.toString().replace("jms://queue://", "jms://queue:");
44  		}
45  		else if (oldUri.startsWith("jms://temp-queue://"))
46  		{
47  			newUri = uri.toString().replace("jms://temp-queue://", "jms://temp-queue:");
48  		}
49  		else if (oldUri.startsWith("jms://topic://"))
50  		{
51  			props.setProperty(RESOURCE_INFO_PROPERTY, "topic");
52  			newUri = uri.toString().replace("jms://topic://", "jms://topic:");
53  		}
54  
55          try
56          {
57              if (newUri != null)
58              {
59                  rewriteURI(new URI(newUri));
60              }
61          }
62          catch (URISyntaxException e)
63          {
64              throw new MalformedEndpointException(e);
65          }
66      }
67  }