On 16/07/24 19:52, Bergmann, Clemens wrote:
Hi, I am currently looking into possibilities to reuse code when implementing different implementations with groovy. For example some ATTR_VALUE_VALIDATOR implementations might share some functionality. Most of these shared code fragments should be implementable as static functions. Therefore my first idea was to implement it as static function in a groovy Implementation but I don’t know how packages for these implementation work and If I understand ImplementationManager [1] correctly, the groovy implementations are also only created on demand so they would not be available to other groovy implementations. The other option would be to implement them in Java and deploy them with core but this would require redeploy whenever something in one of these shared “libraries” changes. Is there something that I am missing?
Hi Clemens, no you are not. Currently, Groovy implementations are classes built and run with the same classpath as Java implementations (not exactly "on-demand" as they are cached at first access unless explicitly told not to do so, BTW). This means that you can reference all Core classes from within Groovy or Java implementations, but no other Groovy classes (unless you add such classes to the Core classpath somehow). In cases like yours, a successful approach was found to provide shared utility classes in the Core classpath (thus, any change will require redeploy as you're saying) and leverage them from Groovy implementations. Regards.
[1] https://github.com/apache/syncope/blob/b69ecb26fe20c7be64ea0949c7b478d97df4e620/core/spring/src/main/java/org/apache/syncope/core/spring/implementation/ImplementationManager.java#L50 Mit freundlichen Grüßen Clemens (Bergmann) -- Clemens Bergmann [er/ihm; he/him] Gruppe Nutzermanagement und Entwicklung Technische Universität Darmstadt Hochschulrechenzentrum, Alexanderstraße 2, 64283 Darmstadt Tel. +49 6151 16 71184 http://www.hrz.tu-darmstadt.de/ <http://www.hrz.tu-darmstadt.de/>
-- Francesco Chicchiriccò Tirasa - Open Source Excellence http://www.tirasa.net/ Member at The Apache Software Foundation Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail http://home.apache.org/~ilgrosso/