1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package no.feide.moria.directory.backend;
21
22 import no.feide.moria.directory.DirectoryManagerConfigurationException;
23
24 import org.jdom.Element;
25
26 /***
27 * Factory class for dummy backends.
28 */
29 public class DummyBackendFactory
30 implements DirectoryManagerBackendFactory {
31
32 /*** Holds the dummy backend configuration. */
33 private Element myConfig;
34
35
36 /***
37 * Configures use of the dummy backends. May be called repeatedly to update
38 * used configuration. <br>
39 * <br>
40 * Note that much of the parsing of the configuration element is done in the
41 * <code>DummyBackend</code> class.
42 * @param config
43 * The new or updated configuration for the dummy backend. Cannot
44 * be <code>null</code>.
45 * @throws IllegalArgumentException
46 * If <code>config</code> is <code>null</code>.
47 * @throws DirectoryManagerConfigurationException
48 * If <code>config</code> is not a <code>Backend</code>
49 * element.
50 * @see DirectoryManagerBackendFactory#setConfig(Element)
51 */
52 public final void setConfig(final Element config) {
53
54
55 if (config == null)
56 throw new IllegalArgumentException("Backend configuration element cannot be NULL");
57 if (!config.getName().equalsIgnoreCase("Backend"))
58 throw new DirectoryManagerConfigurationException("Cannot find backend configuration element");
59
60 myConfig = (Element) config.clone();
61
62 }
63
64
65 /***
66 * Creates a new <code>DummyBackend</code> instance.
67 * @param sessionTicket
68 * Ignored for instances of <code>DummyBackend</code>.
69 * @see no.feide.moria.directory.backend.DirectoryManagerBackendFactory#createBackend
70 * @return The new DummyBackend.
71 * @see DummyBackend
72 */
73 public final DirectoryManagerBackend createBackend(final String sessionTicket) {
74
75 DummyBackend newBackend = new DummyBackend(myConfig);
76 return newBackend;
77
78 }
79
80 }