comparison src/org/tmatesoft/hg/internal/BasicSessionContext.java @ 295:981f9f50bb6c

Issue 11: Error log facility. SessionContext to share common facilities
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 16 Sep 2011 05:35:32 +0200
parents
children 3cfa4d908fc9
comparison
equal deleted inserted replaced
294:32890bab7209 295:981f9f50bb6c
1 /*
2 * Copyright (c) 2011 TMate Software Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * For information on how to redistribute this software under
14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com
16 */
17 package org.tmatesoft.hg.internal;
18
19 import org.tmatesoft.hg.core.SessionContext;
20 import org.tmatesoft.hg.util.LogFacility;
21 import org.tmatesoft.hg.util.PathPool;
22 import org.tmatesoft.hg.util.PathRewrite;
23
24 /**
25 *
26 * @author Artem Tikhomirov
27 * @author TMate Software Ltd.
28 */
29 public class BasicSessionContext implements SessionContext {
30
31 private PathPool pathPool;
32 private final LogFacility logFacility;
33
34 public BasicSessionContext(PathPool pathFactory, LogFacility log) {
35 pathPool = pathFactory;
36 logFacility = log != null ? log : new StreamLogFacility(true, true, true, System.out);
37 }
38
39 public PathPool getPathPool() {
40 if (pathPool == null) {
41 pathPool = new PathPool(new PathRewrite.Empty());
42 }
43 return pathPool;
44 }
45
46 public LogFacility getLog() {
47 // e.g. for exceptions that we can't handle but log (e.g. FileNotFoundException when we've checked beforehand file.canRead()
48 return logFacility;
49 }
50
51 }