1 package org.apache.turbine.util; 2 3 18 19 import java.lang.reflect.Method ; 20 21 import org.apache.turbine.services.pull.ApplicationTool; 22 23 34 public class ContentURI 35 extends DynamicURI 36 implements ApplicationTool 37 { 38 39 private String contextPath; 40 41 46 public ContentURI(RunData data) 47 { 48 super(data); 49 init(data); 50 } 51 52 55 public ContentURI() 56 { 57 } 58 59 65 public void init(Object data) 66 { 67 init((RunData) data); 70 } 71 72 75 public void refresh() 76 { 77 } 79 80 85 public void init(RunData data) 86 { 87 super.init(data); 88 try 89 { 90 Class runDataClass = RunData.class; 91 Method meth = runDataClass.getDeclaredMethod("getContextPath", null); 92 contextPath = (String ) meth.invoke(data, null); 93 } 94 catch (Exception e) 95 { 96 101 contextPath = ""; 102 } 103 } 104 105 111 public String getURI(String pathToContent) 112 { 113 StringBuffer sb = new StringBuffer (); 114 sb.append(getServerScheme()); sb.append("://"); 116 sb.append(getServerName()); sb.append(":"); 118 sb.append(getServerPort()); sb.append(contextPath); sb.append("/"); 122 sb.append(pathToContent); 123 return (sb.toString()); 124 } 125 } 126 | Popular Tags |