orbeon / orbeon-forms

Orbeon Forms is an open source web forms solution. It includes an XForms engine, the Form Builder web-based form editor, and the Form Runner runtime.
http://www.orbeon.com/
GNU Lesser General Public License v2.1
518 stars 220 forks source link

Support for the JCache API (JSR-107) #5399

Closed ebruchez closed 1 year ago

ebruchez commented 2 years ago

We are currently using Ehcache 2.x as cache. We have considered upgrading to Ehcache 3.x (#3404), which is not hard to do, except that the replication setup now requires a separate Terracotta server. We didn't want to change this right away for questions of time and also impact on existing users, who would have to do more work to upgrade. Since Ehcache 2.x still has the occasional update, we have accepted to defer upgrading to Ehcache 3.x.

Now using the JCache API could provide a smooth migration path:

This would allow users to:

+1 from customer

ebruchez commented 2 years ago

Uses of Ehcache:

Uses are basic:

ebruchez commented 1 year ago

Also the use of JCache allows more easily integrating into environments like Kubernetes.

ebruchez commented 1 year ago

Looking at JCache doc, in particular with Ehcache 2 and Ehcache 3.

Right now, we hardcode Ehcache 2 support. We load the config from oxf:/config/ehcache.xml, through our own resource manager.

Using JCache with Ehcache 2, getCacheManager() loads an ehcache.xml using classloaders (it seems you could also use getCacheManager("foo") but that doesn't appear to even compile). It doesn't seem that we can get backward compatibility while keeping the file location.

Using JCache with Ehcache 3, you can pass getClass.getResource("/config/ehcache3.xml").toURI, which would bring some compatibility of the file location, but would not allow all oxf:/ resource support. In addition, the configuration is of course different from Ehcache 2's.

If we want to keep full backward compatibility, we'd need either:

  1. to have an option to enable the cache provider type: built-in (Ehcache 2), or JCache
  2. or to try JCache, and if a provider is available use that, or else fall back to built-in (with the risk that there would be a provider in the classpath? can that happen?)
ebruchez commented 1 year ago

If we provide two types of caches, we need some kind of abstraction for put()/get()/remove(), as the API is different.

ebruchez commented 1 year ago

Also, we make use of the version: Long parameter, not present with JCache.

The keys are always strings.

Values are of types:

ebruchez commented 1 year ago
ebruchez commented 1 year ago

Managed to get Ehcache 3 to work through JCache. However, I have to specify a URI pointing to the XML configuration, which of course is not cache provider-independent. Or maybe, add another property:

Not sure if that makes sense.

ebruchez commented 1 year ago

We probably should add that URI property. However, I am not sure there is a way to specify a URI for the configuration that allows storing the configuration in a JAR or the webapp without using an absolute path, whether using file: or jar:. Still, that would allow pointing to a specific configuration. Ideally, we would use oxf:, but since we pass a URI and not a URL, and there is no independently-registered URLStreamHandler, we probably can't.

ebruchez commented 1 year ago

It seems that using getResource() would be a good idea. This searches under WEB-INF/lib/WEB-INF/classes and would at least allow placing a configuration file in the WAR file in an deployment-independent way.

ebruchez commented 1 year ago
ebruchez commented 1 year ago
ebruchez commented 1 year ago

Documented