I was asked a question on jena-dev that I think bears repeating, since it's fairly frequently asked.
so, my question is, in the case where we need inference capability, if all we need to do is just
OntModel ontModel = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF );
then why does Jena still provide things like
ReasonerRegistry.getOWLReasoner(), ModelFactory.createInfModel , OntModelSpec, etc.?
OK, here's the simple explanation: the first form is exactly the same as the second form, but a bit simpler to use.
Longer explanation: an OntModel has various parameters that allow it to be
more flexible when handling ontologies. OntModel can handle OWL, OWL
DL, OWL Lite, DAML+OIL and RDFS ontologies. So when you say
OntModel.createClass(), it has to know which kind of class (OWL, DAML,
etc) to create. This information is conveyed through the OntModelSpec,
which contains a language profile. Similarly, an OntModel can have an
attached reasoner, or none at all. Which reasoner is attached to the
OntModel is also expressed in the OntModelSpec.
A user can, if desired, create an OntModelSpec entirely from scratch,
setting each field (profile, reasoner, etc) to the desired value.
However, there are some common combinations (e.g. an in-memory model,
using OWL, with the MICRO rule reasoner) that we know are going to be
re-used many times, so we've taken the trouble to pre-define some
constants for commonly used OntModelSpecs. These have suggestive names,
so the one I just described is
OWL_MEM_MICRO_RULE_INF. But all it is is
a pre-defined OntModelSpec with the fields filled-in.
Some fields cannot be filled-in in advance. For example, if the model is in a database, not in memory, then the db type, user-name and password can't be known in advance. Similarly, external reasoners can be at diffenent access URL's. However, in these cases it's still nice to be able to re-use some of the pre-defined common variants, and just adapt them. So you can create a new OntModelSpec using a pre-defined one as a template:
OntModelSpec newSpec = new OntModelSpec( OntModelSpec.OWL_MEM_RULE_INF );
and then just tweak the bits you want to change.
Likewise, the builtin reasoners have a number of configuration options, including which rulesets to use, which rule engine to use, etc. Again, we make it easy to use the common patterns, but provide access to the nuts-and-bolts for those that need them
under what situation do we ever need to use these guys?
Useful heuristic: you probably don't need to use them. When this heuristic breaks (all heuristics break eventually), you'll know that it's time to read up on the details of the low-level interfaces. Until then, don't worry about it!