You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by Serge Huber <sh...@apache.org> on 2019/11/07 10:00:31 UTC

Groovy actions !

Hi guys,

I have just created a PR (https://github.com/apache/unomi/pull/106) and a
JIRA ticket https://issues.apache.org/jira/browse/UNOMI-254 to discuss my
latest prototype to add Groovy language support for implementing actions.

The rationale behind this is to make it easier for non-Java developers to
be able to provide their own action implementations, using a scripting like
language.

I have also provided a sample project here :
https://github.com/apache/unomi/tree/UNOMI-254-groovy-actions/samples/groovy-actions

What I have done is that I have made the ActionExecutorDispatcher class
pluggeable so that it can accept ActionDispatcher implementations that
integrate through a prefix in the actionType "actionExecutor" property. For
example "groovy:testGroovyAction" means that it will look for the
ActionDispatcher implementation that can handle the "groovy" prefix and
then pass "testGroovyAction" to it as an actionName to execute.

Some things that are still not settled are:
- which Groovy libraries should be provided by default ? For example for
the moment only groovy and groovy-xml are provided by default and bundles
can add their own (look at the sample that adds HttpBuilder), but maybe it
would make sense to have some basic ones such as HttpBuilder provided so
that plugin integrators don't have to include them ?
- the Groovy implementation is provided as a feature but it is not part of
the default boot features. I would think that maybe it would be a good
thing for it to be activated by default ?

So what do you think ? I'd love to hear your feedback.

cheers,
  Serge...

Re: Groovy actions !

Posted by Serge Huber <sh...@apache.org>.
One last thing I forgot to mention.

The sample comes with a testing rule that react to a view event. So a
simple way to generate a view event is to open the web tracker page that's
provided in Unomi at the following URL:

http://localhost:8181/tracker/

This will trigger execution of the rule and the testGroovyAction will
execute. You should look at the console where you are running Unomi because
it uses println statement to output results.

Regards,
  Serge...

On Fri, Nov 15, 2019 at 9:47 PM Serge Huber <sh...@apache.org> wrote:

> Hi all,
>
> I've just pushed to the PR some improvements that include:
>
> - Moved HttpBuilder and Jsoup library to Groovy Action feature
> - Added example of retrieving data from event
> - Added DynamicImport-Package for Groovy script dependencies (is there a
> better way to do this ?)
> - Fix dynamic reloading of Groovy scripts from project source code
>
> I'm not very proud of the usage of DynamicImport-Package but I couldn't
> find a way around this except for listing explicit imports manually. Any
> ideas ?
>
> Also I made dynamic loading from source code works. The way this works is
> that the pom.xml includes this:
>
> <plugin>
>     <groupId>org.apache.felix</groupId>
>     <artifactId>maven-bundle-plugin</artifactId>
>     <extensions>true</extensions>
>     <configuration>
>         <instructions>
>             <Unomi-Source-Folders>${project.basedir}</Unomi-Source-Folders>
>
> Basically this header is checked by the Groovy script resolver and if
> found will load the groovy file from source code (only if it exists) making
> it possible to modify the Groovy script without even compiling the module !
>
> I'd love to have your feedback and hope to be able to merge this PR soon.
>
> I will also need to write some documentation.
>
> Btw to install the support for Groovy you must use the following commands:
>
> feature:repo-add
> mvn:org.apache.unomi/unomi-groovy-actions/1.5.0-SNAPSHOT/xml/features
> feature:installl unomi-groovy-actions
>
>
> And to install the sample (make sure its compiled and installed first!) :
>
> bundle:install -s
> mvn:org.apache.unomi/test-groovy-action-sample/1.5.0-SNAPSHOT
>
>
>
> Regards,
>   Serge...
>
> On Tue, Nov 12, 2019 at 10:21 AM Serge Huber <sh...@apache.org> wrote:
>
>> Thanks Romain for your feedback. I'll answer your questions below:
>>
>>
>>> - How can I access the action and the event object from the groovy
>>> action?
>>> In Java, they are provided as arguments of the execute method, but I
>>> didn't
>>> find how to access them in Groovy. Would it be possible to update the
>>> example provided here?
>>>
>>> https://github.com/apache/unomi/blob/UNOMI-254-groovy-actions/samples/groovy-actions/src/main/resources/META-INF/cxs/actions/testGroovyAction.groovy
>>
>>
>> Yes you are right. Actually the "action" and "event" objects are passed
>> to the Groovy Script engine as variables, but it's true it's not evident
>> and will need to be documented and demonstrate in the example.
>>
>>
>>> - I enjoy a lot that blueprint.xml is not needed :)
>>>
>>
>> We have plans to get rid of Blueprint entirely in Unomi, JB is working on
>> it. The idea is to not require Blueprint and (hopefully) replace it with DS
>> (or CDI?) annotations
>>
>>
>>> - Would it be possible (maybe for Unomi 2.0..) to be able to deploy
>>> groovy
>>> scripts (and eventually json descriptor and cfg file for configuration)
>>> directly in a running Unomi? Maybe it is just because I'm not yet used to
>>> the karaf way of doing things with bundle:install and bundle:watch, but
>>> writing groovy directly on a running platform seems like the fastest way
>>> to
>>> extend Unomi.
>>>
>>
>> Well I'm not sure I understand what you mean but bundle:watch and install
>> are already runtime commands. However I was wondering if there should be a
>> way to script directly from a rule, and there could be ways to do this but
>> we would have to probably use another language than Groovy that would
>> introduce security issues and possibly something like the Painless language
>> that ElasticSearch uses :
>> https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-lang-spec.html Basically
>> a more restricted language that would be more secure. But that would also
>> not allow to use custom libraries so it would be more restricted. The
>> Groovy action implementation I'm proposing here is a 100% replacement of
>> Java actions, and can do as much as a Java action could do.
>>
>>
>>> - Is there a unit test that I could reuse to test my action without
>>> deploying it and having to trigger a real event? It could be a great to
>>> have such uni test with the groovy sample, maybe with a Pageview event as
>>> it is generated by the web tracker?
>>>
>>
>> What I do is that I use the built-in web tracker example packaged with
>> Unomi at http://localhost:8181/tracker . This generates a page view
>> event and then I can just setup a test rule to test my action. It's not the
>> same as a unit test but it's easy enough to use during development (I even
>> use this for debugging).
>>
>>
>>>
>>> - From my perspective, I'd really enjoy that the groovy compatibility is
>>> activated by default. That could make the development flow easier: adding
>>> custom actions to Unomi is one of the first things that is needed when
>>> implementing it.
>>>
>>
>> Ok thanks for your feedback. I'm also in favor of activating it by
>> default. Do you have any feedback on Groovy libraries we should package by
>> default ? I'm thinking we should package http-builder-ng but I'm wondering
>> if it would make sense to package any other.
>>
>> Regards,
>>   Serge ...
>>
>>
>

Re: Groovy actions !

Posted by Serge Huber <sh...@apache.org>.
Hi all,

I've just pushed to the PR some improvements that include:

- Moved HttpBuilder and Jsoup library to Groovy Action feature
- Added example of retrieving data from event
- Added DynamicImport-Package for Groovy script dependencies (is there a
better way to do this ?)
- Fix dynamic reloading of Groovy scripts from project source code

I'm not very proud of the usage of DynamicImport-Package but I couldn't
find a way around this except for listing explicit imports manually. Any
ideas ?

Also I made dynamic loading from source code works. The way this works is
that the pom.xml includes this:

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
        <instructions>
            <Unomi-Source-Folders>${project.basedir}</Unomi-Source-Folders>

Basically this header is checked by the Groovy script resolver and if found
will load the groovy file from source code (only if it exists) making it
possible to modify the Groovy script without even compiling the module !

I'd love to have your feedback and hope to be able to merge this PR soon.

I will also need to write some documentation.

Btw to install the support for Groovy you must use the following commands:

feature:repo-add
mvn:org.apache.unomi/unomi-groovy-actions/1.5.0-SNAPSHOT/xml/features
feature:installl unomi-groovy-actions


And to install the sample (make sure its compiled and installed first!) :

bundle:install -s
mvn:org.apache.unomi/test-groovy-action-sample/1.5.0-SNAPSHOT



Regards,
  Serge...

On Tue, Nov 12, 2019 at 10:21 AM Serge Huber <sh...@apache.org> wrote:

> Thanks Romain for your feedback. I'll answer your questions below:
>
>
>> - How can I access the action and the event object from the groovy action?
>> In Java, they are provided as arguments of the execute method, but I
>> didn't
>> find how to access them in Groovy. Would it be possible to update the
>> example provided here?
>>
>> https://github.com/apache/unomi/blob/UNOMI-254-groovy-actions/samples/groovy-actions/src/main/resources/META-INF/cxs/actions/testGroovyAction.groovy
>
>
> Yes you are right. Actually the "action" and "event" objects are passed to
> the Groovy Script engine as variables, but it's true it's not evident and
> will need to be documented and demonstrate in the example.
>
>
>> - I enjoy a lot that blueprint.xml is not needed :)
>>
>
> We have plans to get rid of Blueprint entirely in Unomi, JB is working on
> it. The idea is to not require Blueprint and (hopefully) replace it with DS
> (or CDI?) annotations
>
>
>> - Would it be possible (maybe for Unomi 2.0..) to be able to deploy groovy
>> scripts (and eventually json descriptor and cfg file for configuration)
>> directly in a running Unomi? Maybe it is just because I'm not yet used to
>> the karaf way of doing things with bundle:install and bundle:watch, but
>> writing groovy directly on a running platform seems like the fastest way
>> to
>> extend Unomi.
>>
>
> Well I'm not sure I understand what you mean but bundle:watch and install
> are already runtime commands. However I was wondering if there should be a
> way to script directly from a rule, and there could be ways to do this but
> we would have to probably use another language than Groovy that would
> introduce security issues and possibly something like the Painless language
> that ElasticSearch uses :
> https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-lang-spec.html Basically
> a more restricted language that would be more secure. But that would also
> not allow to use custom libraries so it would be more restricted. The
> Groovy action implementation I'm proposing here is a 100% replacement of
> Java actions, and can do as much as a Java action could do.
>
>
>> - Is there a unit test that I could reuse to test my action without
>> deploying it and having to trigger a real event? It could be a great to
>> have such uni test with the groovy sample, maybe with a Pageview event as
>> it is generated by the web tracker?
>>
>
> What I do is that I use the built-in web tracker example packaged with
> Unomi at http://localhost:8181/tracker . This generates a page view event
> and then I can just setup a test rule to test my action. It's not the same
> as a unit test but it's easy enough to use during development (I even use
> this for debugging).
>
>
>>
>> - From my perspective, I'd really enjoy that the groovy compatibility is
>> activated by default. That could make the development flow easier: adding
>> custom actions to Unomi is one of the first things that is needed when
>> implementing it.
>>
>
> Ok thanks for your feedback. I'm also in favor of activating it by
> default. Do you have any feedback on Groovy libraries we should package by
> default ? I'm thinking we should package http-builder-ng but I'm wondering
> if it would make sense to package any other.
>
> Regards,
>   Serge ...
>
>

Re: Groovy actions !

Posted by Serge Huber <sh...@apache.org>.
Thanks Romain for your feedback. I'll answer your questions below:


> - How can I access the action and the event object from the groovy action?
> In Java, they are provided as arguments of the execute method, but I didn't
> find how to access them in Groovy. Would it be possible to update the
> example provided here?
>
> https://github.com/apache/unomi/blob/UNOMI-254-groovy-actions/samples/groovy-actions/src/main/resources/META-INF/cxs/actions/testGroovyAction.groovy


Yes you are right. Actually the "action" and "event" objects are passed to
the Groovy Script engine as variables, but it's true it's not evident and
will need to be documented and demonstrate in the example.


> - I enjoy a lot that blueprint.xml is not needed :)
>

We have plans to get rid of Blueprint entirely in Unomi, JB is working on
it. The idea is to not require Blueprint and (hopefully) replace it with DS
(or CDI?) annotations


> - Would it be possible (maybe for Unomi 2.0..) to be able to deploy groovy
> scripts (and eventually json descriptor and cfg file for configuration)
> directly in a running Unomi? Maybe it is just because I'm not yet used to
> the karaf way of doing things with bundle:install and bundle:watch, but
> writing groovy directly on a running platform seems like the fastest way to
> extend Unomi.
>

Well I'm not sure I understand what you mean but bundle:watch and install
are already runtime commands. However I was wondering if there should be a
way to script directly from a rule, and there could be ways to do this but
we would have to probably use another language than Groovy that would
introduce security issues and possibly something like the Painless language
that ElasticSearch uses :
https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-lang-spec.html
Basically
a more restricted language that would be more secure. But that would also
not allow to use custom libraries so it would be more restricted. The
Groovy action implementation I'm proposing here is a 100% replacement of
Java actions, and can do as much as a Java action could do.


> - Is there a unit test that I could reuse to test my action without
> deploying it and having to trigger a real event? It could be a great to
> have such uni test with the groovy sample, maybe with a Pageview event as
> it is generated by the web tracker?
>

What I do is that I use the built-in web tracker example packaged with
Unomi at http://localhost:8181/tracker . This generates a page view event
and then I can just setup a test rule to test my action. It's not the same
as a unit test but it's easy enough to use during development (I even use
this for debugging).


>
> - From my perspective, I'd really enjoy that the groovy compatibility is
> activated by default. That could make the development flow easier: adding
> custom actions to Unomi is one of the first things that is needed when
> implementing it.
>

Ok thanks for your feedback. I'm also in favor of activating it by default.
Do you have any feedback on Groovy libraries we should package by default ?
I'm thinking we should package http-builder-ng but I'm wondering if it
would make sense to package any other.

Regards,
  Serge ...

Re: Groovy actions !

Posted by Romain Gauthier <rg...@jahia.com>.
Hi everyone,

Thanks a lot Serge!

I think that being able to write actions with a scripting language less
verbose than java is really cool. From what I've seen, many actions are
really meant to be scripted, so Groovy will really help.

I'm working to adapt my "SlackMessageAction" to groovy and I have a couple
of comments/questions:

- How can I access the action and the event object from the groovy action?
In Java, they are provided as arguments of the execute method, but I didn't
find how to access them in Groovy. Would it be possible to update the
example provided here?
https://github.com/apache/unomi/blob/UNOMI-254-groovy-actions/samples/groovy-actions/src/main/resources/META-INF/cxs/actions/testGroovyAction.groovy

- I enjoy a lot that blueprint.xml is not needed :)

- Would it be possible (maybe for Unomi 2.0..) to be able to deploy groovy
scripts (and eventually json descriptor and cfg file for configuration)
directly in a running Unomi? Maybe it is just because I'm not yet used to
the karaf way of doing things with bundle:install and bundle:watch, but
writing groovy directly on a running platform seems like the fastest way to
extend Unomi.

- Is there a unit test that I could reuse to test my action without
deploying it and having to trigger a real event? It could be a great to
have such uni test with the groovy sample, maybe with a Pageview event as
it is generated by the web tracker?

- From my perspective, I'd really enjoy that the groovy compatibility is
activated by default. That could make the development flow easier: adding
custom actions to Unomi is one of the first things that is needed when
implementing it.

Again thanks a lot, it's really great news,


On Thu, 7 Nov 2019 at 13:37, Julian Feinauer <j....@pragmaticminds.de>
wrote:

> Hi Serge,
>
> thanks for the clarification.
> Indeed I confused "scripting language" with "live deployment" : )
>
> Julian
>
> Am 07.11.19, 13:16 schrieb "Serge Huber" <sh...@apache.org>:
>
>     Hello Julian,
>
>     Thanks for your quick feedback.
>
>     Interesting points about security. Actually the way it is designed
> right
>     now the Groovy scripts still have to be packaged in an OSGi plugin
> bundle
>     (especially if they want to use custom libraries) so it is up to the
> server
>     administrators to deploy them. It is not possible to deploy a Groovy
> script
>     through a REST API call for example. Once they are deployed, you can
> then
>     use them with rules that you setup through REST API calls.
>
>     But I do get your point for a scripting language that would be directly
>     available for users of the API. Currently Unomi already uses the Apache
>     Common OGNL expression language in rules, so that's another extension
> point
>     with a more limited attack surface than Groovy.
>
>     Finally, to setup a rule through the API, credentials must be provided
> so
>     that also limits the attack surface.
>
>     But coming back to the Groovy implementation, it is basically at the
> same
>     level as a Java implementation, it just offers an alternative to the
> people
>     that are not familiar with Java. But you DSL idea is great and I think
> we
>     should investigate this a bit further.
>
>     Regards,
>       Serge...
>
>     On Thu, Nov 7, 2019 at 12:02 PM Julian Feinauer <
>     j.feinauer@pragmaticminds.de> wrote:
>
>     > Hi Serge,
>     >
>     > first, awesome feature, really!
>     >
>     > To you questons... I think there are several things to learn from
> Jenkins
>     > and their scripting integration.
>     > They also do a lot with security, I'm unsure if its needed but the
>     > drawback with "fast and easy" languages like python and groovy is
> that you
>     > execute something "bad" more often.
>     > And they have some libs included by default and also a nice "online
>     > editing" feature with Highlighting (which I think is important).
>     > Do you accept plain groovy then or some kind of DSL on top where
> users can
>     > integrate their code (like imperative Jenkinsfile)?
>     >
>     > Julian
>     >
>     > Am 07.11.19, 11:00 schrieb "Serge Huber" <sh...@apache.org>:
>     >
>     >     Hi guys,
>     >
>     >     I have just created a PR (
> https://github.com/apache/unomi/pull/106)
>     > and a
>     >     JIRA ticket https://issues.apache.org/jira/browse/UNOMI-254 to
>     > discuss my
>     >     latest prototype to add Groovy language support for implementing
>     > actions.
>     >
>     >     The rationale behind this is to make it easier for non-Java
> developers
>     > to
>     >     be able to provide their own action implementations, using a
> scripting
>     > like
>     >     language.
>     >
>     >     I have also provided a sample project here :
>     >
>     >
> https://github.com/apache/unomi/tree/UNOMI-254-groovy-actions/samples/groovy-actions
>     >
>     >     What I have done is that I have made the
> ActionExecutorDispatcher class
>     >     pluggeable so that it can accept ActionDispatcher
> implementations that
>     >     integrate through a prefix in the actionType "actionExecutor"
>     > property. For
>     >     example "groovy:testGroovyAction" means that it will look for the
>     >     ActionDispatcher implementation that can handle the "groovy"
> prefix and
>     >     then pass "testGroovyAction" to it as an actionName to execute.
>     >
>     >     Some things that are still not settled are:
>     >     - which Groovy libraries should be provided by default ? For
> example
>     > for
>     >     the moment only groovy and groovy-xml are provided by default and
>     > bundles
>     >     can add their own (look at the sample that adds HttpBuilder), but
>     > maybe it
>     >     would make sense to have some basic ones such as HttpBuilder
> provided
>     > so
>     >     that plugin integrators don't have to include them ?
>     >     - the Groovy implementation is provided as a feature but it is
> not
>     > part of
>     >     the default boot features. I would think that maybe it would be
> a good
>     >     thing for it to be activated by default ?
>     >
>     >     So what do you think ? I'd love to hear your feedback.
>     >
>     >     cheers,
>     >       Serge...
>     >
>     >
>     >
>
>
>

-- 
Romain Gauthier
Product Manager at Jahia
+ 33 6 20 18 35 25
8 Rue du sentier | 75002 Paris | France

Re: Groovy actions !

Posted by Julian Feinauer <j....@pragmaticminds.de>.
Hi Serge,

thanks for the clarification.
Indeed I confused "scripting language" with "live deployment" : )

Julian

Am 07.11.19, 13:16 schrieb "Serge Huber" <sh...@apache.org>:

    Hello Julian,
    
    Thanks for your quick feedback.
    
    Interesting points about security. Actually the way it is designed right
    now the Groovy scripts still have to be packaged in an OSGi plugin bundle
    (especially if they want to use custom libraries) so it is up to the server
    administrators to deploy them. It is not possible to deploy a Groovy script
    through a REST API call for example. Once they are deployed, you can then
    use them with rules that you setup through REST API calls.
    
    But I do get your point for a scripting language that would be directly
    available for users of the API. Currently Unomi already uses the Apache
    Common OGNL expression language in rules, so that's another extension point
    with a more limited attack surface than Groovy.
    
    Finally, to setup a rule through the API, credentials must be provided so
    that also limits the attack surface.
    
    But coming back to the Groovy implementation, it is basically at the same
    level as a Java implementation, it just offers an alternative to the people
    that are not familiar with Java. But you DSL idea is great and I think we
    should investigate this a bit further.
    
    Regards,
      Serge...
    
    On Thu, Nov 7, 2019 at 12:02 PM Julian Feinauer <
    j.feinauer@pragmaticminds.de> wrote:
    
    > Hi Serge,
    >
    > first, awesome feature, really!
    >
    > To you questons... I think there are several things to learn from Jenkins
    > and their scripting integration.
    > They also do a lot with security, I'm unsure if its needed but the
    > drawback with "fast and easy" languages like python and groovy is that you
    > execute something "bad" more often.
    > And they have some libs included by default and also a nice "online
    > editing" feature with Highlighting (which I think is important).
    > Do you accept plain groovy then or some kind of DSL on top where users can
    > integrate their code (like imperative Jenkinsfile)?
    >
    > Julian
    >
    > Am 07.11.19, 11:00 schrieb "Serge Huber" <sh...@apache.org>:
    >
    >     Hi guys,
    >
    >     I have just created a PR (https://github.com/apache/unomi/pull/106)
    > and a
    >     JIRA ticket https://issues.apache.org/jira/browse/UNOMI-254 to
    > discuss my
    >     latest prototype to add Groovy language support for implementing
    > actions.
    >
    >     The rationale behind this is to make it easier for non-Java developers
    > to
    >     be able to provide their own action implementations, using a scripting
    > like
    >     language.
    >
    >     I have also provided a sample project here :
    >
    > https://github.com/apache/unomi/tree/UNOMI-254-groovy-actions/samples/groovy-actions
    >
    >     What I have done is that I have made the ActionExecutorDispatcher class
    >     pluggeable so that it can accept ActionDispatcher implementations that
    >     integrate through a prefix in the actionType "actionExecutor"
    > property. For
    >     example "groovy:testGroovyAction" means that it will look for the
    >     ActionDispatcher implementation that can handle the "groovy" prefix and
    >     then pass "testGroovyAction" to it as an actionName to execute.
    >
    >     Some things that are still not settled are:
    >     - which Groovy libraries should be provided by default ? For example
    > for
    >     the moment only groovy and groovy-xml are provided by default and
    > bundles
    >     can add their own (look at the sample that adds HttpBuilder), but
    > maybe it
    >     would make sense to have some basic ones such as HttpBuilder provided
    > so
    >     that plugin integrators don't have to include them ?
    >     - the Groovy implementation is provided as a feature but it is not
    > part of
    >     the default boot features. I would think that maybe it would be a good
    >     thing for it to be activated by default ?
    >
    >     So what do you think ? I'd love to hear your feedback.
    >
    >     cheers,
    >       Serge...
    >
    >
    >
    


Re: Groovy actions !

Posted by Serge Huber <sh...@apache.org>.
Hello Julian,

Thanks for your quick feedback.

Interesting points about security. Actually the way it is designed right
now the Groovy scripts still have to be packaged in an OSGi plugin bundle
(especially if they want to use custom libraries) so it is up to the server
administrators to deploy them. It is not possible to deploy a Groovy script
through a REST API call for example. Once they are deployed, you can then
use them with rules that you setup through REST API calls.

But I do get your point for a scripting language that would be directly
available for users of the API. Currently Unomi already uses the Apache
Common OGNL expression language in rules, so that's another extension point
with a more limited attack surface than Groovy.

Finally, to setup a rule through the API, credentials must be provided so
that also limits the attack surface.

But coming back to the Groovy implementation, it is basically at the same
level as a Java implementation, it just offers an alternative to the people
that are not familiar with Java. But you DSL idea is great and I think we
should investigate this a bit further.

Regards,
  Serge...

On Thu, Nov 7, 2019 at 12:02 PM Julian Feinauer <
j.feinauer@pragmaticminds.de> wrote:

> Hi Serge,
>
> first, awesome feature, really!
>
> To you questons... I think there are several things to learn from Jenkins
> and their scripting integration.
> They also do a lot with security, I'm unsure if its needed but the
> drawback with "fast and easy" languages like python and groovy is that you
> execute something "bad" more often.
> And they have some libs included by default and also a nice "online
> editing" feature with Highlighting (which I think is important).
> Do you accept plain groovy then or some kind of DSL on top where users can
> integrate their code (like imperative Jenkinsfile)?
>
> Julian
>
> Am 07.11.19, 11:00 schrieb "Serge Huber" <sh...@apache.org>:
>
>     Hi guys,
>
>     I have just created a PR (https://github.com/apache/unomi/pull/106)
> and a
>     JIRA ticket https://issues.apache.org/jira/browse/UNOMI-254 to
> discuss my
>     latest prototype to add Groovy language support for implementing
> actions.
>
>     The rationale behind this is to make it easier for non-Java developers
> to
>     be able to provide their own action implementations, using a scripting
> like
>     language.
>
>     I have also provided a sample project here :
>
> https://github.com/apache/unomi/tree/UNOMI-254-groovy-actions/samples/groovy-actions
>
>     What I have done is that I have made the ActionExecutorDispatcher class
>     pluggeable so that it can accept ActionDispatcher implementations that
>     integrate through a prefix in the actionType "actionExecutor"
> property. For
>     example "groovy:testGroovyAction" means that it will look for the
>     ActionDispatcher implementation that can handle the "groovy" prefix and
>     then pass "testGroovyAction" to it as an actionName to execute.
>
>     Some things that are still not settled are:
>     - which Groovy libraries should be provided by default ? For example
> for
>     the moment only groovy and groovy-xml are provided by default and
> bundles
>     can add their own (look at the sample that adds HttpBuilder), but
> maybe it
>     would make sense to have some basic ones such as HttpBuilder provided
> so
>     that plugin integrators don't have to include them ?
>     - the Groovy implementation is provided as a feature but it is not
> part of
>     the default boot features. I would think that maybe it would be a good
>     thing for it to be activated by default ?
>
>     So what do you think ? I'd love to hear your feedback.
>
>     cheers,
>       Serge...
>
>
>

Re: Groovy actions !

Posted by Julian Feinauer <j....@pragmaticminds.de>.
Hi Serge,

first, awesome feature, really!

To you questons... I think there are several things to learn from Jenkins and their scripting integration.
They also do a lot with security, I'm unsure if its needed but the drawback with "fast and easy" languages like python and groovy is that you execute something "bad" more often.
And they have some libs included by default and also a nice "online editing" feature with Highlighting (which I think is important).
Do you accept plain groovy then or some kind of DSL on top where users can integrate their code (like imperative Jenkinsfile)?

Julian

Am 07.11.19, 11:00 schrieb "Serge Huber" <sh...@apache.org>:

    Hi guys,
    
    I have just created a PR (https://github.com/apache/unomi/pull/106) and a
    JIRA ticket https://issues.apache.org/jira/browse/UNOMI-254 to discuss my
    latest prototype to add Groovy language support for implementing actions.
    
    The rationale behind this is to make it easier for non-Java developers to
    be able to provide their own action implementations, using a scripting like
    language.
    
    I have also provided a sample project here :
    https://github.com/apache/unomi/tree/UNOMI-254-groovy-actions/samples/groovy-actions
    
    What I have done is that I have made the ActionExecutorDispatcher class
    pluggeable so that it can accept ActionDispatcher implementations that
    integrate through a prefix in the actionType "actionExecutor" property. For
    example "groovy:testGroovyAction" means that it will look for the
    ActionDispatcher implementation that can handle the "groovy" prefix and
    then pass "testGroovyAction" to it as an actionName to execute.
    
    Some things that are still not settled are:
    - which Groovy libraries should be provided by default ? For example for
    the moment only groovy and groovy-xml are provided by default and bundles
    can add their own (look at the sample that adds HttpBuilder), but maybe it
    would make sense to have some basic ones such as HttpBuilder provided so
    that plugin integrators don't have to include them ?
    - the Groovy implementation is provided as a feature but it is not part of
    the default boot features. I would think that maybe it would be a good
    thing for it to be activated by default ?
    
    So what do you think ? I'd love to hear your feedback.
    
    cheers,
      Serge...