On Tuesday 23 September 2008 12:10, [EMAIL PROTECTED] wrote: > Author: xor > Date: 2008-09-23 11:10:49 +0000 (Tue, 23 Sep 2008) > New Revision: 22761 > > Modified: > trunk/plugins/WoT/Config.java > trunk/plugins/WoT/WoT.java > Log: > Change the Config class so that it does not store a reference to a db4o ObjectContainer. This is not its job.
Make sure you store when you change something. Setting cascading updates on
Config may be the easiest way to ensure that the HashMap is properly saved to
the database, assuming Config doesn't reference the rest of the WoT plugin.
>
> Modified: trunk/plugins/WoT/Config.java
> ===================================================================
> --- trunk/plugins/WoT/Config.java 2008-09-23 11:10:42 UTC (rev 22760)
> +++ trunk/plugins/WoT/Config.java 2008-09-23 11:10:49 UTC (rev 22761)
> @@ -19,19 +19,14 @@
> */
> public class Config {
>
> - private ObjectContainer db;
> private HashMap<String, String> params = null;
>
> /**
> *
> * @param db The database where the configuration is stored.
> */
> - public Config(ObjectContainer db) {
> + public Config() {
>
> - // TODO Refactor this : the database shouldn't try to store its
> own
reference
> - // The ObjectContainer should be passed to set/get/... methodes
> -
> - this.db = db;
> if(params == null) {
> params = new HashMap<String, String>();
> initDefault(false);
> @@ -46,7 +41,6 @@
> */
> public synchronized void set(String key, String value) {
> params.put(key, value);
> - db.store(params);
> }
>
> /**
> @@ -95,7 +89,5 @@
> public void initDefault(boolean overwrite) {
> if (!contains("delayBetweenInserts") || overwrite)
> set("delayBetweenInserts", "30");
> -
> - db.store(this);
> }
> }
>
> Modified: trunk/plugins/WoT/WoT.java
> ===================================================================
> --- trunk/plugins/WoT/WoT.java 2008-09-23 11:10:42 UTC (rev 22760)
> +++ trunk/plugins/WoT/WoT.java 2008-09-23 11:10:49 UTC (rev 22761)
> @@ -89,7 +89,7 @@
> ObjectSet<Config> result =
> db.queryByExample(Config.class);
> if(result.size() == 0) {
> Logger.debug(this, "Created new config");
> - config = new Config(db);
> + config = new Config();
> db.store(config);
> }
> else {
>
> _______________________________________________
> cvs mailing list
> [EMAIL PROTECTED]
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>
>
pgp4jwK8iQ285.pgp
Description: PGP signature
_______________________________________________ Devl mailing list [email protected] http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
