1 18 21 package org.apache.roller.ui; 22 import java.io.File ; 23 24 import javax.servlet.ServletContext ; 25 import javax.servlet.ServletContextEvent ; 26 import javax.servlet.http.HttpServletRequest ; 27 28 import org.apache.commons.logging.Log; 29 import org.apache.commons.logging.LogFactory; 30 import org.apache.roller.RollerException; 31 import org.apache.roller.ui.core.*; 32 33 36 public class MockRollerContext extends RollerContext { 37 private static Log mLogger = 38 LogFactory.getFactory().getInstance(MockRollerContext.class); 39 40 private static ServletContext mContext = null; 41 42 public void init(ServletContext sc) { 43 mLogger.debug("MockRollerContext initializing"); 44 45 super.contextInitialized(new ServletContextEvent (sc)); 47 48 mContext = sc; 50 mContext.setAttribute(ROLLER_CONTEXT, this); 51 mContext.setAttribute("org.apache.roller.absoluteContextURL", "/"); 52 } 53 56 public static RollerContext getRollerContext() { 57 return (RollerContext) mContext.getAttribute(ROLLER_CONTEXT); 59 } 60 63 public static ServletContext getServletContext() { 64 return mContext; 65 } 66 67 70 public String getRollerVersion() { 71 return super.getRollerVersion(); 72 } 73 76 public String getRollerBuildTime() { 77 return super.getRollerBuildTime(); 78 } 79 82 public String getRollerBuildUser() { 83 return super.getRollerBuildUser(); 84 } 85 86 89 public String getAbsoluteContextUrl() { 90 return ""; 91 } 92 95 public String getAbsoluteContextUrl(HttpServletRequest request) { 96 return "http://localhost:8080/roller"; 97 } 98 101 107 public String getConfigPath() { 109 String root = System.getProperty("ro.build"); 110 String configPath = 111 root 112 + File.separator 113 + "roller" 114 + File.separator 115 + "WEB-INF" 116 + File.separator 117 + "roller-config.xml"; 118 return configPath; 119 } 120 protected void upgradeDatabaseIfNeeded() throws RollerException { 121 } 123 124 } 125 126 | Popular Tags |