Mercurial > jhg
annotate src/org/tmatesoft/hg/core/SessionContext.java @ 631:8a5cdcb27b8f
AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 30 May 2013 15:24:17 +0200 |
parents | e4ee4bf4c7d0 |
children | fba85bc1dfb8 |
rev | line source |
---|---|
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
571
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
2 * Copyright (c) 2011-2013 TMate Software Ltd |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.core; |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import org.tmatesoft.hg.util.LogFacility; |
571
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
20 import org.tmatesoft.hg.util.Path; |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 /** |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
23 * Access to objects that might need to be shared between various distinct operations ran during the same working session |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
24 * (i.e. caches, log, etc.). It's unspecified whether session context is per repository or can span multiple repositories |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 * |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
26 * <p>Note, API is likely to be extended in future versions, adding more object to share. |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 * |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 * @author Artem Tikhomirov |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 * @author TMate Software Ltd. |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 */ |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
31 public abstract class SessionContext { |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
32 // abstract class to facilitate adding more functionality without API break |
338
3cfa4d908fc9
Add options to control DataAccessProvider, allow to turn off use of file memory mapping in particular to solve potential sharing violation (os file handle gets released on MappedByteByffer being GC'd, not on FileChannel.close())
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
33 |
3cfa4d908fc9
Add options to control DataAccessProvider, allow to turn off use of file memory mapping in particular to solve potential sharing violation (os file handle gets released on MappedByteByffer being GC'd, not on FileChannel.close())
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
34 /** |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
35 * Access wrapper for a system log facility. |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
36 * @return facility to direct dumps to, never <code>null</code> |
338
3cfa4d908fc9
Add options to control DataAccessProvider, allow to turn off use of file memory mapping in particular to solve potential sharing violation (os file handle gets released on MappedByteByffer being GC'd, not on FileChannel.close())
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
295
diff
changeset
|
37 */ |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
38 public abstract LogFacility getLog(); |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
39 |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
40 /** |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
41 * Access configuration parameters of the session. |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
42 * @param name name of the session configuration parameter |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
43 * @param defaultValue value to return if parameter is not configured |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
44 * @return value of the session parameter, defaultValue if none found |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
45 */ |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
46 public abstract Object getConfigurationProperty(String name, Object defaultValue); |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
47 // perhaps, later may add Configuration object, with PropertyMarshal's helpers |
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
338
diff
changeset
|
48 // e.g. when there's standalone Caches and WritableSessionProperties objects |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
49 |
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
50 /** |
571
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
51 * Provide a factory to create {@link Path} objects. |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
52 * |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
53 * Occasionally, there's a need to construct a {@link Path} object from a string/byte data |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
54 * kept in mercurial control files. Generally, default implementation (with {@link Path#create(CharSequence)} |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
55 * is enough, however, if there's a need to control number of string objects in memory (i.e. prevent duplicates), |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
56 * default implementation might need to be replaced with more sophisticated (e.g. using weak references or |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
57 * just a huge hash set). |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
58 * |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
59 * @return factory to construct Path objects, never <code>null</code> |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
60 */ |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
61 public Path.Source getPathFactory() { |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
62 return new Path.Source() { |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
63 public Path path(CharSequence p) { |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
64 return Path.create(p); |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
65 } |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
66 }; |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
67 } |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
68 |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
69 /** |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
70 * Providers of the context may implement |
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
71 */ |
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
72 public interface Source { |
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
73 SessionContext getSessionContext(); |
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
74 } |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
75 } |