01: // CvsModule.java
02: // $Id: CvsModule.java,v 1.3 2000/08/16 21:37:32 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1998.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.jigedit.cvs;
07:
08: import java.util.Hashtable;
09: import java.util.Properties;
10:
11: import java.io.File;
12:
13: import org.w3c.tools.resources.ResourceContext;
14:
15: import org.w3c.cvs.CvsDirectory;
16: import org.w3c.cvs.CvsException;
17:
18: /**
19: * @version $Revision: 1.3 $
20: * @author Benoît Mahé (bmahe@w3.org)
21: */
22: public class CvsModule {
23:
24: /**
25: * Name of the module
26: */
27: public static final String MODULE_NAME = "org.w3c.jigedit.cvsmodule";
28:
29: /**
30: * Name of the CVS Root value.
31: */
32: public static final String CVSROOT = "org.w3c.jigedit.cvsmodule.root";
33:
34: /**
35: * Set a value.
36: * @param ctxt the resource context
37: * @param name The value name.
38: * @param value The value to record.
39: * @return an Object.
40: */
41: public static void setValue(ResourceContext ctxt, String name,
42: Object value) {
43: Hashtable values = (Hashtable) ctxt.getModule(MODULE_NAME,
44: false);
45: if (values == null) {
46: values = new Hashtable(1);
47: ctxt.registerModule(MODULE_NAME, values);
48: }
49: values.put(name, value);
50: }
51:
52: /**
53: * Get a value.
54: * @param ctxt the resource context
55: * @param name The value name.
56: * @return an Object.
57: */
58: public static Object getValue(ResourceContext ctxt, String name) {
59: Hashtable values = (Hashtable) ctxt.getModule(MODULE_NAME);
60: if (values == null)
61: return null;
62: return values.get(name);
63: }
64:
65: public static synchronized CvsDirectory getCvsManager(
66: File directory, ResourceContext ctxt, Properties props)
67: throws CvsException {
68: CvsDirectory cvs = null;
69: String cvsroot = (String) getValue(ctxt, CVSROOT);
70: if (cvsroot != null)
71: cvs = CvsDirectory.getManager(directory, props, null,
72: cvsroot, null);
73: else
74: cvs = CvsDirectory.getManager(directory, props);
75: return cvs;
76: }
77:
78: private CvsModule() {
79: }
80:
81: }
|