01: /*
02: * $Id: UrlEndpointURIBuilder.java 10489 2008-01-23 17:53:38Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.endpoint;
12:
13: import org.mule.api.endpoint.MalformedEndpointException;
14: import org.mule.util.StringUtils;
15:
16: import java.net.URI;
17: import java.util.Properties;
18:
19: /**
20: * <code>UrlEndpointBuilder</code> is the default endpointUri strategy suitable for
21: * most connectors
22: */
23:
24: public class UrlEndpointURIBuilder extends AbstractEndpointURIBuilder {
25:
26: protected void setEndpoint(URI uri, Properties props)
27: throws MalformedEndpointException {
28: address = "";
29: if (uri.getHost() != null) {
30: // set the endpointUri to be a proper url if host and port are set
31: this .address = uri.getScheme() + "://" + uri.getHost();
32: if (uri.getPort() != -1) {
33: address += ":" + uri.getPort();
34: }
35: }
36: if (StringUtils.isNotBlank(uri.getPath())) {
37: address += uri.getPath();
38: }
39:
40: if (StringUtils.isNotBlank(uri.getQuery())) {
41: address += "?" + uri.getQuery();
42: }
43: }
44: }
|