[MOBY-dev] RegistryCache
Ola Spjuth
ola.spjuth at farmbio.uu.se
Wed Oct 31 10:22:18 UTC 2007
Hi Paul,
Thank you for the answers. I think I have found a bug in jMoby, but
please correct me if I'm wrong.
The following call with reg being my custom Regsitry:
MobyDataComposite comp = new MobyDataComposite("DNASequence", reg);
calls
public MobyDataComposite(String typeName, Registry r){
this(MobyDataType.getDataType(typeName, r));
}
calls
public MobyDataComposite(MobyDataType type){
this(type, "");
}
calls
public MobyDataComposite(MobyDataType type, String name){
this(type, name, "", "");
}
calls
public MobyDataComposite(MobyDataType type, String name, String
namespace, String id){
super(namespace, id);
setName(name);
setDataType(type);
members = new ConcurrentHashMap<String, MobyDataObject>();
}
where super calls
public MobyDataObject(String namespace, String id){
this(namespace, id, null);
}
calls
public MobyDataObject(String namespace, String id, Registry
registry){
super("");
thus having registry=null. This means I will always use the default
registry and not my custom registry that I inputted. This prevents me
from using my cached registry which you explained below.
A second question: When defining my own registry and populating the
RegsitryCache like you explained, what Central should I use?
CentralDigestCachedImpl? Do I need both caching mechanisms? How do
they differ?
Thanks for your help,
.../Ola
On Oct 30, 2007, at 01:43 , Paul Gordon wrote:
> Hi Ola,
>
> If you want to explicitly cache the ontologies, you need to work with
> the Registry and RegistryCache objects like so:
>
> ********
> //To delete stale files
> RegistryCache.deleteExpiredCacheFiles(allowedAgeInMilliseconds);
>
> // In what file would the ontology be cached, if it was cached?
> File namespacesDefFile = RegistryCache.getOntologyFile
> (preferredRegistry,
>
> Central.NAMESPACES_RESOURCE_NAME);
> URL namespacesDefURL = namespacesDefFile.toURI().toURL();
> if(namespacesDefFile.exists()){
> // Use the existing cached file rather than actually going to
> the
> registry
> MobyNamespace.loadNamespaces(namespacesDefURL,
> preferredRegistry);
> }
> else{
> // Create the cached file from the remote source, then load it
> into MobyNamespace so MobyNamespace.getNamespace() can retrieve it.
> RegistryCache.cacheRegistryOntology(preferredRegistry,
> Central.NAMESPACES_RESOURCE_NAME);
> MobyNamespace.loadNamespaces(namespacesDefURL,
> preferredRegistry);
> }
> ********
>
> The other relevant fields/methods are
> Central.DATA_TYPES_RESOURCE_NAME/Central.SERVICE_TYPES_RESOURCE_NAME
> and MobyDataType.loadDataTypes()/MobyServiceType.loadServiceTypes().
>
> _______________________________________________
> MOBY-dev mailing list
> MOBY-dev at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/moby-dev
More information about the MOBY-dev
mailing list