KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > jdbc > JdbcEndpointBuilder


1 /*
2  * $Id: JdbcEndpointBuilder.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.providers.jdbc;
12
13 import java.net.URI JavaDoc;
14 import java.util.Properties JavaDoc;
15
16 import org.mule.impl.endpoint.AbstractEndpointBuilder;
17 import org.mule.umo.endpoint.MalformedEndpointException;
18
19 /**
20  * Parses a JDBC style endpoint to a MuleEndpointURI
21  */

22 public class JdbcEndpointBuilder extends AbstractEndpointBuilder
23 {
24
25     protected void setEndpoint(URI JavaDoc uri, Properties JavaDoc props) throws MalformedEndpointException
26     {
27         if (uri.getHost() != null && !"localhost".equals(uri.getHost()))
28         {
29             endpointName = uri.getHost();
30         }
31         int i = uri.getPath().indexOf("/", 1);
32         if (i > 0)
33         {
34             endpointName = uri.getPath().substring(1, i);
35             address = uri.getPath().substring(i + 1);
36         }
37         else if (uri.getPath() != null && uri.getPath().length() != 0)
38         {
39             address = uri.getPath().substring(1);
40         }
41         else
42         {
43             address = uri.getAuthority();
44         }
45         // JDBC endpoints can just have a param string, hence te address is left
46
// null, but the address
47
// should always be a non-null value
48
if (address == null)
49         {
50             address = uri.getScheme();
51         }
52     }
53 }
54
Popular Tags