View Javadoc

1   /*
2    * PersistanceManager.java
3    *
4    * Created on June 3, 2004, 4:46 PM
5    */
6   
7   package gov.bnl.gums.persistence;
8   
9   import gov.bnl.gums.configuration.Configuration;
10  import gov.bnl.gums.db.AccountPoolMapperDB;
11  import gov.bnl.gums.db.ManualAccountMapperDB;
12  import gov.bnl.gums.db.ManualUserGroupDB;
13  import gov.bnl.gums.db.UserGroupDB;
14  
15  import java.util.Iterator;
16  import java.util.Properties;
17  
18  /** Represent a factory for all the classes that take care of the persistance of
19   * the AccountMappers, the UserGroups or any other components.
20   * <p>
21   * Implementing a new PersistanceManager class allows to complete redefined how
22   * the user, group and accounting information is stored. This will allow to keep
23   * the information integrated in the site accounting system, being it any RDBMS,
24   * LDAP, or even a combination of these.
25   * <p>
26   * It also allow to use different mapping technologies, allowing to use either
27   * entity beans, simple JDBC, Hibernate or any other favourite technology.
28   *
29   * @author Gabriele Carcassi, Jay Packard
30   */
31  public abstract class PersistenceFactory {
32      /**
33       * @return user friendly string representation of the property type called statically 
34       */
35      static public String getTypeStatic() {
36  		return "abstract";
37  	}
38      
39      private String name = "";
40  	private String description = "";
41      private Properties properties;
42      private Configuration configuration;
43      
44  	/**
45  	 * Create a persistence factory. This empty constructor is needed by the XML Digestor.
46  	 */
47  	public PersistenceFactory() {
48  	}
49      
50  	/**
51  	 * Create a persistence factory with a configuration.
52  	 * 
53  	 * @param configuration
54  	 */
55  	public PersistenceFactory(Configuration configuration) {
56  		this.configuration = configuration;
57  	}	
58      
59  	/**
60  	 * Create a persistence factory with a configuration and a name.
61  	 * 
62  	 * @param configuration
63  	 * @param name
64  	 */
65  	public PersistenceFactory(Configuration configuration, String name) {
66  		this.name = name;
67  		this.configuration = configuration;
68  	}
69  	
70  	/**
71  	 * Create a clone of itself
72  	 * 
73  	 * @param configuration
74  	 * @return
75  	 */
76  	public abstract PersistenceFactory clone(Configuration configuration);
77  
78  	/**
79       * Getter for property configuration.
80       * 
81       * @return Value of property configuration.
82       */
83  	public Configuration getConfiguration() {
84  		return configuration;
85  	}
86  	
87      /**
88       * Getter for property description.
89       * 
90       * @return Value of property description.
91       */
92  	public String getDescription() {
93  		return description;
94  	}
95  
96      /**
97       * Getter for property name.
98       * 
99       * @return Value of property name.
100      */
101 	public String getName() {
102 		return name;
103 	}
104 	
105     /**
106      * Getter for the list of properties for the particular technology
107      * deployed by the inhereted classes.
108      * 
109      * @return properties.
110      */
111 	public Properties getProperties() {
112 		return properties;
113 	}
114 
115 	/**
116 	 * @return string representation of type of persistence factory
117 	 */
118 	public String getType() {
119 		return "abstract";
120 	}
121 
122 	public abstract AccountPoolMapperDB retrieveAccountPoolMapperDB(String name);
123 	
124 	public abstract ManualAccountMapperDB retrieveManualAccountMapperDB(String name);
125 	
126 	public abstract ManualUserGroupDB retrieveManualUserGroupDB(String name);
127 	
128 	public abstract UserGroupDB retrieveUserGroupDB(String name);
129 	
130 	/**
131      * Setter for property configuration.
132      * 
133      * @param configuration.
134      */
135 	public void setConfiguration(Configuration configuration) {
136 		this.configuration = configuration;
137 	}
138 	
139     /**
140      * Setter for property description.
141      * 
142      * @param description.
143      */
144     public void setDescription(String description) {
145     	this.description = description;
146     }
147 	
148     /**
149      * Setter for property name.
150      * 
151      * @param name.
152      */
153 	public void setName(String name) {
154 		this.name = name;
155 	}
156 
157     /**
158      * Setter for the list of properties for the particular technology
159      * deployed by the inhereted classes.
160      * 
161      * @param properties.
162      */
163 	public void setProperties(Properties properties) {
164 		this.properties = properties;
165 	}
166 	
167     /**
168      * Get XML representation of this object for writing to gums.config
169      * 
170      * @return xml as string
171      */
172 	public abstract String toXML();
173 }