| 194 | |
| 195 | |
| 196 | @Override |
| 197 | public Session load(String id) throws ClassNotFoundException, IOException { |
| 198 | // Open an input stream to the specified pathname, if any |
| 199 | File file = file(id); |
| 200 | if (file == null) { |
| 201 | return null; |
| 202 | } |
| 203 | |
| 204 | Context context = getManager().getContext(); |
| 205 | Log contextLog = context.getLogger(); |
| 206 | |
| 207 | if (contextLog.isTraceEnabled()) { |
| 208 | contextLog.trace(sm.getString(getStoreName() + ".loading", id, file.getAbsolutePath())); |
| 209 | } |
| 210 | |
| 211 | ClassLoader oldThreadContextCL = context.bind(null); |
| 212 | try { |
| 213 | Lock readLock = sessionLocksById.getLock(id).readLock(); |
| 214 | readLock.lock(); |
| 215 | try { |
| 216 | if (!file.exists()) { |
| 217 | return null; |
| 218 | } |
| 219 | try (FileInputStream fis = new FileInputStream(file.getAbsolutePath()); |
| 220 | ObjectInputStream ois = getObjectInputStream(fis)) { |
| 221 | StandardSession session = (StandardSession) manager.createEmptySession(); |
| 222 | session.readObjectData(ois); |
| 223 | session.setManager(manager); |
| 224 | return session; |
| 225 | } catch (FileNotFoundException e) { |
| 226 | if (contextLog.isDebugEnabled()) { |
| 227 | contextLog.debug(sm.getString("fileStore.noFile", id, file.getAbsolutePath()), e); |
| 228 | } |
| 229 | return null; |
| 230 | } |
| 231 | } finally { |
| 232 | readLock.unlock(); |
| 233 | } |
| 234 | } finally { |
| 235 | context.unbind(oldThreadContextCL); |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | |
| 240 | @Override |