1 4 package org.roller.presentation; 5 import java.io.File ; 6 import javax.servlet.ServletContext ; 7 import javax.servlet.ServletContextEvent ; 8 import javax.servlet.http.HttpServletRequest ; 9 import org.apache.commons.logging.Log; 10 import org.apache.commons.logging.LogFactory; 11 import org.roller.RollerException; 12 13 16 public class MockRollerContext extends RollerContext 17 { 18 private static Log mLogger = 19 LogFactory.getFactory().getInstance(MockRollerContext.class); 20 private static ServletContext mContext = null; 21 public void init(ServletContext sc) 22 { 23 mLogger.debug("MockRollerContext initializing"); 24 25 super.contextInitialized(new ServletContextEvent (sc)); 27 28 mContext = sc; 30 mContext.setAttribute(ROLLER_CONTEXT, this); 31 mContext.setAttribute("org.roller.absoluteContextURL", "/"); 32 } 33 36 public static RollerContext getRollerContext(ServletContext sc) 37 { 38 return (RollerContext) mContext.getAttribute(ROLLER_CONTEXT); 40 } 41 44 public static ServletContext getServletContext() 45 { 46 return mContext; 47 } 48 49 52 public String getRollerVersion() 53 { 54 return super.getRollerVersion(); 55 } 56 59 public String getRollerBuildTime() 60 { 61 return super.getRollerBuildTime(); 62 } 63 66 public String getRollerBuildUser() 67 { 68 return super.getRollerBuildUser(); 69 } 70 71 74 public String getAbsoluteContextUrl() 75 { 76 return ""; 77 } 78 81 public String getAbsoluteContextUrl(HttpServletRequest request) 82 { 83 return request.getScheme() +"://" + request.getServerName() + ""; 84 } 85 88 94 public String getConfigPath() 96 { 97 String root = System.getProperty("ro.build"); 98 String configPath = 99 root 100 + File.separator 101 + "roller" 102 + File.separator 103 + "WEB-INF" 104 + File.separator 105 + "roller-config.xml"; 106 return configPath; 107 } 108 protected void upgradeDatabaseIfNeeded() throws RollerException 109 { 110 } 112 113 } 114 115 | Popular Tags |