Hi Francesco, thanks for the clarification. I will look into how we best handle this in our scenario. If I find a solution that seems to be interesting for others I will come back to the list.
One option that I tried was using a groovy command implementation "CallableCommand" with the following code: import groovy.transform.CompileStatic import org.apache.syncope.common.lib.command.CommandArgs import org.apache.syncope.core.provisioning.api.macro.Command @CompileStatic class CallableCommand implements Command<CommandArgs> { String run(CommandArgs args) { return "SUCCESS" } } To test this I added the following groovy Implementation: import groovy.transform.CompileStatic import org.apache.syncope.common.lib.command.CommandArgs import org.springframework.context.ApplicationContext import org.springframework.beans.factory.annotation.Autowired import org.apache.syncope.core.logic.CommandLogic import org.apache.syncope.common.lib.command.CommandOutput; import org.apache.syncope.common.lib.command.CommandTO; import org.apache.syncope.core.provisioning.api.macro.Command; import org.apache.syncope.core.logic.CommandLogic; @CompileStatic class TestCommand implements Command<CommandArgs> { @Autowired private CommandLogic commandLogic; String run(CommandArgs args) { return commandLogic.run(commandLogic.read("CallableCommand")); } } This works and calls "CallableCommand" but I was not able to pass arguments and I am not sure if this route is a good way to go. 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/ > -----Ursprüngliche Nachricht----- > Von: Francesco Chicchiriccò <ilgro...@apache.org> > Gesendet: Mittwoch, 17. Juli 2024 08:27 > An: user@syncope.apache.org > Betreff: Re: Code Reuse in groovy Implementations > > 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/b69ecb26fe20c7be64ea0949c7b4 > 78d97df4e620/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/
smime.p7s
Description: S/MIME cryptographic signature