View Javadoc

1   package net.sf.cantina.datasource;
2   
3   import net.sf.cantina.Realm;
4   import org.apache.log4j.Logger;
5   
6   import java.util.Locale;
7   
8   /***
9    * 
10   * @author Stephane JAIS
11   * @hibernate.class
12   *   table="realms"
13   * @hibernate.query
14   *   name="net.sf.cantina.system.realm.Realm.find.all"
15   *   query="from Realm as realm"
16   */
17  
18  public class PersistentRealm
19  extends Realm
20  {
21    private static final Logger logger = Logger.getLogger(PersistentRealm.class);
22  
23    public PersistentRealm() {}
24    public PersistentRealm(String name)
25    {
26      setName(name);
27    }
28    private String name;
29    private Locale defaultLocale;
30  
31    /***
32      * The name of the realm is its unique identifier.
33      * 
34      * @hibernate.id
35      *   generator-class="assigned"
36      *   column="realm_name"
37      */
38  
39    public String getName() { return this.name; }
40    /*** Sets the name of this realm */
41    public void setName(String name) { this.name = name; }
42  
43    /***
44      * The default locale for a realm is its preferred language.
45      *
46      * @hibernate.property
47      *   column="default_locale"
48      *   type="java.util.Locale"
49      */
50  
51    public Locale getDefaultLocale() {return this.defaultLocale;}
52    /*** Sets the default locale of this realm */
53    public void setDefaultLocale(Locale l) {this.defaultLocale = l;}
54  
55    /***
56     * A wrapper for getName() to implement persistable
57     * @return The name of the realm
58     */
59  
60    public String getId()
61    { return getName(); }
62  
63    /***
64     * A wrapper for setName(), to implement persistable
65     * @param id The name of the realm
66     */
67  
68    public void setId(String id)
69    { setName(id); }
70  
71    public boolean equals(Object o)
72    {
73      if (!(o instanceof PersistentRealm))
74        return false;
75      PersistentRealm realm = (PersistentRealm)o;
76      return realm.getId().equals(this.getId());
77  
78    }
79  }
80  
81