KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > impl > endpoint > SocketEndpointBuilder


1 /*
2  * $Id: SocketEndpointBuilder.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.impl.endpoint;
12
13 import org.mule.umo.endpoint.MalformedEndpointException;
14
15 import java.net.URI JavaDoc;
16 import java.util.Properties JavaDoc;
17
18 /**
19  * <code>SocketEndpointBuilder</code> builds an endpointUri based on host and port
20  * only
21  *
22  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
23  * @version $Revision: 3798 $
24  */

25 public class SocketEndpointBuilder extends AbstractEndpointBuilder
26 {
27     protected void setEndpoint(URI JavaDoc uri, Properties JavaDoc props) throws MalformedEndpointException
28     {
29         // set the endpointUri to be a proper url if host and port are set
30
if (uri.getPort() == -1)
31         {
32             // try the form tcp://6666
33
try
34             {
35                 int port = Integer.parseInt(uri.getHost());
36                 this.address = uri.getScheme() + "://localhost:" + port;
37             }
38             catch (NumberFormatException JavaDoc e)
39             {
40                 // ignore
41
}
42         }
43
44         if (address == null)
45         {
46             this.address = uri.getScheme() + "://" + uri.getHost();
47             if (uri.getPort() != -1)
48             {
49                 this.address += ":" + uri.getPort();
50             }
51         }
52     }
53 }
54
Popular Tags