javax.jcr.Repository repository = ... boolean supportLocks = repository.getDescriptorValue(Repository.OPTION_LOCKING_SUPPORTED).getBoolean();
Not every JCR repository supports all features. This may be because the particular implementation you've chosen has not implemented every feature, or a particular repository may have certain features disabled. If your application assumes certain behaviors, then it will break if the repository is configured differently than expected or if another JCR implementation is used.
Another JCR best practice is for your application to use the repository descriptors to determine which of the features/behaviors used by the application are indeed available and supported. Your application can even gracefully degrade its functionality based upon the results.
Typically it is sufficient for the application to check the descriptors only the first time it obtains the Repository instance. However, be aware that some repositories (including ModeShape) may change the value of some descriptors as features are dynamically enabled or disabled through implementation-specific means.
The following code shows how to check whether a repository supports locking nodes:
javax.jcr.Repository repository = ... boolean supportLocks = repository.getDescriptorValue(Repository.OPTION_LOCKING_SUPPORTED).getBoolean();
If not, the parts of your application that rely upon locking might be disabled.
Another example is determining the set of query languages supported by a repository:
javax.jcr.Repository repository = ... Value[] languages = repository.getDescriptorValues(Repository.QUERY_LANGUAGES); Set<String> supportedLangs = new HashSet<String>(); for ( Value language : languages ) { supportedLangs.add(language.getString()); }
There are over 50 standard descriptors that expose a wide variety of functionality. Check the specification or JavaDocs for more details.