1   package com.atlassian.user.configuration;
2   
3   import com.atlassian.user.repository.RepositoryIdentifier;
4   
5   import java.util.Set;
6   
7   /**
8    * Represents the configuration of a single repository, with defaults taken from atlassian-user-defaults.xml
9    * and override settings coming from atlassian-user.xml.
10   * <p/>
11   * TODO: At the moment, properties like LDAP host names are retrieved via {@link #getComponent(String)} with a
12   * special constant (like {@link Configuration#HOST}). Instead, these properties should be retrieved by
13   * a getProperty(String) method on this object.
14   */
15  public interface RepositoryConfiguration
16  {
17      RepositoryIdentifier getIdentifier();
18  
19      void addComponent(String componentName, Object component);
20  
21      /**
22       * Returns the component specified by the name, or <tt>null</tt> if the
23       * component does not exist.
24       */
25      Object getComponent(String componentName);
26  
27      /**
28       * Returns the component specified by the name, or <tt>null</tt> if the
29       * component does not exist.
30       *
31       * @throws ClassCastException if the specified component can not be cast to a String
32       */
33      String getStringComponent(String componentName);
34  
35      /**
36       * Returns <tt>true</tt> if the component exists and is not <tt>null</tt>, otherwise <tt>false</tt>.
37       */
38      boolean hasComponent(String componentName);
39  
40      String getComponentClassName(String componentName);
41  
42      RepositoryAccessor configure() throws ConfigurationException;
43  
44      boolean hasClassForComponent(String componentName);
45  
46      /**
47       * @return an unmodifiable Set of the components specified by this configuration.
48       */
49      Set getComponentNames();
50  
51      /**
52       * Set the cache configuration to be used for this repository. If caching is to be
53       * disabled, you can pass a value of <tt>null</tt>. Caching is disabled by default.
54       */
55      void setCacheConfiguration(CacheConfiguration cacheConfiguration);
56  
57      /**
58       * Returns <tt>true</tt> if caching is enabled for this repository, or false
59       * if caching is disabled.
60       *
61       * @see #getCacheConfiguration()
62       * @see #setCacheConfiguration(CacheConfiguration)
63       */
64      boolean isCachingEnabled();
65  
66      /**
67       * Returns the cache configuration for this repository. If caching is disabled,
68       * returns <tt>null</tt>. You should use {@link #isCachingEnabled()} rather than
69       * checking explicitly for <tt>null</tt>.
70       *
71       * @see #isCachingEnabled()
72       */
73      CacheConfiguration getCacheConfiguration();
74  }