Hi DM<div><br></div><div>Well my suggestion would be to adopt a IOC/dependency injection. Perhaps a "config provider" object can be inserted into those places that need access to those statics. We can somehow insert a default provider with default config if no user config provider is found.</div>
<div><br></div><div>The JSword code would ask the config provider for the various settings. JSword could also alter the config provider on any changes. </div><div><br></div><div>If the provider is defined as an interface, it gives the people the option to write their own Configuration Provider mechanism, and inject/set it at runtime. Some might want to carry state and persist it elsewhere, some might want it geared towards concurrency usage, etc. </div>
<div><br></div><div>I guess if we were to do that we would want to provide a default provider that people don't need to worry about, but also later provide some that are geared towards different needs as people write them. </div>
<div><br></div><div>If we were already using Guice or Spring, I'd suggest adding it to that, but in the meantime we can just provide a setter and encapsulate our statics into this config object.</div><div><br></div><div>
I'm guessing the interface would have to provide the concept of settings/user, which imply some refactoring, since as a developer I'd want to be able to query this. I can see two ways of doing this. </div><div>1- Threading through and overloading the method signatures with the username/id as a parameter for a method.</div>
<div>2- Somehow making a request to JSword "transactional" or having a "request scope" Any part of JSword could query the current scope for the current user, etc. That provides us perhaps with more flexibility going forward. Perhaps this is achievable with AOP/annotations. Perhaps again Guice can help <a href="http://code.google.com/p/google-guice/wiki/Scopes">http://code.google.com/p/google-guice/wiki/Scopes</a> being a small library with a small footprint (according to me!)</div>
<div><br></div><div>Some suggestions.</div><div>Sorry about the mailing list (feel free to copy this back the sword-devel to keep the flow)</div><div>Chris</div><div><br></div><div><br></div><div><br></div><div><br><br><div class="gmail_quote">
On 16 July 2010 19:24, DM Smith <span dir="ltr"><<a href="mailto:dmsmith@crosswire.org">dmsmith@crosswire.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 07/16/2010 12:41 PM, Chris Burrell wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all<br>
<br>
The documentation of Key.getName() suggests that getName() will return the short name, such as Mat 1:1 but in fact, when I was just using it out of the box, I got Matthew 1:1 instead!<br>
<br>
Books.installed().getBook(version).getKey(reference).getName();<br>
</blockquote></div>
Well, the documentation doesn't match. That's a bug either in the docs or in the implementation. But you saw that :-P<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
But I've found, that we have to set BibleInfo.setFullBookName(false); first, for this to end up in short names.<br>
</blockquote></div>
The other setting that gets in the way is PassageUtil.setPersistentNaming(boolean persistentNaming), which will preserve whatever the verse was parsed from.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Not being completely familiar with the whole JSword framework, does this have other implications given this is a static assignment? In particular for concurrency/multi user environment for example?<br>
</blockquote></div>
You are right that global statics are generally an issue for concurrency/multi-user code.<br>
<br>
JSword and BibleDesktop have a bunch of global statics. These are part of the preferences mechanism. They are exposed in BibleDesktop under Options (Preferences on the Mac).<br>
<br>
Those that are part of the jsword.jar or the jsword-common.jar may be problematic for you. BibleDesktop has some that won't bother you.<br>
<br>
It probably would be good to figure out a better mechanism to handle preferences or to avoid statics.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Does this affect the passage lookup mechanism too? for the title tag for example? or is taken straight from the Sword module, and therefore this wouldn't affect it...?<br>
</blockquote>
<br></div>
It affects the title tag that the filters and xslt generates. Some of the book names are taken straight from the Sword module and are left as is.<br>
<br>
Can you suggest a better mechanism?<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Just wondering...<br>
<br>
The interface in question is Key.java.<br>
</blockquote>
<br></div>
By the way sword-devel is not the appropriate place to discuss JSword. jsword-devel is. :)<br>
<br>
In Him,<br><font color="#888888">
DM<br>
</font></blockquote></div><br></div>