1 package br.com.ibnetwork.guara.pull.tools;
2
3 import org.apache.avalon.framework.configuration.Configurable;
4 import org.apache.avalon.framework.configuration.Configuration;
5 import org.apache.avalon.framework.configuration.ConfigurationException;
6
7 import br.com.ibnetwork.guara.pull.impl.ApplicationToolSupport;
8
9 /***
10 * @author leandro
11 */
12 public class ContentTool
13 extends ApplicationToolSupport
14 implements Configurable
15 {
16 String baseAddress;
17
18 String contextName;
19
20 public void configure(Configuration conf)
21 throws ConfigurationException
22 {
23 Configuration addr = conf.getChild("baseAddress");
24 String protocol = addr.getAttribute("protocol","http");
25 String hostName = addr.getAttribute("hostName","localhost");
26 String port = addr.getAttribute("port",null);
27 port = port == null || "80".equals(port) ? "" : ":" + port;
28 contextName = addr.getAttribute("contextName","/");
29 baseAddress = protocol
30 + "://"
31 + hostName
32 + port
33 + contextName;
34 }
35
36 public String getURI(String resourceName)
37 {
38 return baseAddress + resourceName;
39 }
40
41 public String getContextName()
42 {
43 return contextName;
44 }
45
46 }