1 16 17 package org.apache.jetspeed.services.rundata; 19 20 import java.util.Collections ; 22 import java.util.HashMap ; 23 import java.util.Map ; 24 import javax.servlet.ServletConfig ; 25 import javax.servlet.http.HttpServletRequest ; 26 import javax.servlet.http.HttpServletResponse ; 27 28 import org.apache.turbine.services.rundata.TurbineRunDataService; 30 import org.apache.turbine.services.InitializationException; 31 import org.apache.turbine.util.RunData; 32 import org.apache.turbine.util.TurbineException; 33 import org.apache.turbine.services.TurbineServices; 34 35 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService; 37 import org.apache.jetspeed.services.logging.JetspeedLogger; 38 import org.apache.jetspeed.services.rundata.JetspeedRunData; 39 import org.apache.jetspeed.services.statemanager.StateManagerService; 40 41 53 public class JetspeedRunDataService 54 extends TurbineRunDataService 55 { 56 59 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(JetspeedRunDataService.class.getName()); 60 61 62 private Map m_runDataStore = null; 63 64 67 68 73 public void init() 74 throws InitializationException 75 { 76 super.init(); 77 78 m_runDataStore = Collections.synchronizedMap(new HashMap ()); 80 81 } 83 86 87 98 public RunData getRunData(String key, 99 HttpServletRequest req, 100 HttpServletResponse res, 101 ServletConfig config) 102 throws TurbineException, IllegalArgumentException 103 { 104 JetspeedRunData r = (JetspeedRunData)super.getRunData(key, req, res, config); 106 107 m_runDataStore.put(Thread.currentThread(), r); 109 110 StateManagerService stateManager = (StateManagerService)TurbineServices 112 .getInstance().getService(StateManagerService.SERVICE_NAME); 113 if (stateManager != null) 114 { 115 stateManager.setCurrentContext(req.getSession(true)); 116 } 117 118 if (logger.isDebugEnabled()) 119 logger.debug("JetspeedRunDataService: storing rundata " + r 120 + " for thread: " + Thread.currentThread()); 121 122 return r; 123 124 } 126 132 public boolean putRunData(RunData data) 133 { 134 StateManagerService stateManager = (StateManagerService)TurbineServices 136 .getInstance().getService(StateManagerService.SERVICE_NAME); 137 if (stateManager != null) 138 { 139 stateManager.clearCurrentContext(); 140 } 141 142 m_runDataStore.remove(Thread.currentThread()); 144 145 if (logger.isDebugEnabled()) 146 logger.debug("JetspeedRunDataService: releasing rundata for thread: " 147 + Thread.currentThread()); 148 149 return super.putRunData(data); 151 152 } 154 158 public JetspeedRunData getCurrentRunData() 159 { 160 if (logger.isDebugEnabled()) 161 logger.debug("JetspeedRunDataService: accessing rundata " 162 + m_runDataStore.get(Thread.currentThread()) 163 + " for thread: " + Thread.currentThread()); 164 165 return (JetspeedRunData) m_runDataStore.get(Thread.currentThread()); 166 167 } 169 } 171 176 177 | Popular Tags |