[MOBY-dev] RegistryCache

Paul Gordon gordonp at ucalgary.ca
Tue Oct 30 00:43:04 UTC 2007


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().




More information about the MOBY-dev mailing list