Grails and Java services

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails and Java services

Fedor Belov
We had problems with service implemented in Groovy. So we have decided to reimplement it in Java. It's strange but Grails doesn't create services from /grails-app/services/*.java files. Why? What's the best practice in this case? Add bean to resources.groovy? Should I add `static boolean transactional = false;` for Java services?

Thank you
Reply | Threaded
Open this post in threaded view
|

Re: Grails and Java services

Dean Del Ponte-2
I'm curious, what were the problems you encountered with services written in Groovy?

If the issue was one of performance, you may create your service in Groovy and factor out the expensive code into Java files that may be saved in the src folder.

- Dean Del Ponte


On Fri, Sep 20, 2013 at 8:14 AM, Fedor Belov <[hidden email]> wrote:
We had problems with service implemented in Groovy. So we have decided to
reimplement it in Java. It's strange but Grails doesn't create services from
/grails-app/services/*.java files. Why? What's the best practice in this
case? Add bean to resources.groovy? Should I add `static boolean
transactional = false;` for Java services?

Thank you



--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-and-Java-services-tp4649373.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Grails and Java services

bksaville
Or you could use @CompileStatic, that typically improves performance to be Java equivalent.

-Brian


On Fri, Sep 20, 2013 at 7:21 AM, Dean Del Ponte <[hidden email]> wrote:
I'm curious, what were the problems you encountered with services written in Groovy?

If the issue was one of performance, you may create your service in Groovy and factor out the expensive code into Java files that may be saved in the src folder.

- Dean Del Ponte


On Fri, Sep 20, 2013 at 8:14 AM, Fedor Belov <[hidden email]> wrote:
We had problems with service implemented in Groovy. So we have decided to
reimplement it in Java. It's strange but Grails doesn't create services from
/grails-app/services/*.java files. Why? What's the best practice in this
case? Add bean to resources.groovy? Should I add `static boolean
transactional = false;` for Java services?

Thank you



--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-and-Java-services-tp4649373.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email




Reply | Threaded
Open this post in threaded view
|

Re: Grails and Java services

Fedor Belov
Yes, we used @CompileStatic to improve performance. But this is still not Java, still has dynamic features and so on... Plain Java is better

>I'm curious, what were the problems you encountered with services written in Groovy?
We had stacktaces locked on dynamic features of Groovy. Filter assigned to HttpServletRequest variable, later service read this variable from request. Too many http requests leads to locks

>you may create your service in Groovy and factor out the expensive code into Java files that may be saved in the src folder.
I think it's better to implement service in Java. Why do we need Groovy wrapper in this case?

20.09.2013 17:47, bksaville [via Grails] пишет:
Or you could use @CompileStatic, that typically improves performance to be Java equivalent.

-Brian


On Fri, Sep 20, 2013 at 7:21 AM, Dean Del Ponte <[hidden email]> wrote:
I'm curious, what were the problems you encountered with services written in Groovy?

If the issue was one of performance, you may create your service in Groovy and factor out the expensive code into Java files that may be saved in the src folder.

- Dean Del Ponte






If you reply to this email, your message will be added to the discussion below:
http://grails.1312388.n4.nabble.com/Grails-and-Java-services-tp4649373p4649375.html
To unsubscribe from Grails and Java services, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Grails and Java services

burtbeckwith
In reply to this post by Fedor Belov
No need for "static boolean transactional = false;" in a Java class since that only applies to Groovy classes in grails-app/services. Think of the property as "autoTransactional". If you register the class yourself as a Spring bean (either as a Java or a Groovy class) the easiest way to make it transactional is with an @Transactional annotation. If you don't need it to be transactional, omit it.

Burt

Fedor Belov wrote
We had problems with service implemented in Groovy. So we have decided to reimplement it in Java. It's strange but Grails doesn't create services from /grails-app/services/*.java files. Why? What's the best practice in this case? Add bean to resources.groovy? Should I add `static boolean transactional = false;` for Java services?

Thank you
Reply | Threaded
Open this post in threaded view
|

Re: Grails and Java services

Fedor Belov
Thanks, Burt

Could you explain why Grails doesn't create services from .java classes?


20.09.2013 18:55, burtbeckwith [via Grails] пишет:
No need for "static boolean transactional = false;" in a Java class since that only applies to Groovy classes in grails-app/services. Think of the property as "autoTransactional". If you register the class yourself as a Spring bean (either as a Java or a Groovy class) the easiest way to make it transactional is with an @Transactional annotation. If you don't need it to be transactional, omit it.

Burt

Fedor Belov wrote
We had problems with service implemented in Groovy. So we have decided to reimplement it in Java. It's strange but Grails doesn't create services from /grails-app/services/*.java files. Why? What's the best practice in this case? Add bean to resources.groovy? Should I add `static boolean transactional = false;` for Java services?

Thank you



If you reply to this email, your message will be added to the discussion below:
http://grails.1312388.n4.nabble.com/Grails-and-Java-services-tp4649373p4649378.html
To unsubscribe from Grails and Java services, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Grails and Java services

burtbeckwith
Grails has very little convention-based support for anything but Groovy classes. We support annotated Java classes as domain classes but that's about it.

I suppose the reason that you can't create services in Java is that it hasn't been requested before. But services are so easy to implement in Java by registering them in resources.groovy (and can easily be made transactional with @Transactional) that it's not very high priority.

Services aren't very "Grailsy" like controllers, domain classes, etc. where we add in behavior with runtime and compile-time metaprogramming. So it'd be easy to add support if you want to JIRA an improvement request.

Burt

Fedor Belov wrote
Thanks, Burt

Could you explain why Grails doesn't create services from .java classes?
Reply | Threaded
Open this post in threaded view
|

Re: Grails and Java services

Fedor Belov
Created ticket for this feature - http://jira.grails.org/browse/GRAILS-10514

>But services are so easy to implement in Java by registering them in resources.groovy
Yes,  I know, it's really simple... but this is not cool =)

20.09.2013 19:29, burtbeckwith [via Grails] пишет:
Grails has very little convention-based support for anything but Groovy classes. We support annotated Java classes as domain classes but that's about it.

I suppose the reason that you can't create services in Java is that it hasn't been requested before. But services are so easy to implement in Java by registering them in resources.groovy (and can easily be made transactional with @Transactional) that it's not very high priority.

Services aren't very "Grailsy" like controllers, domain classes, etc. where we add in behavior with runtime and compile-time metaprogramming. So it'd be easy to add support if you want to JIRA an improvement request.

Burt

Fedor Belov wrote
Thanks, Burt

Could you explain why Grails doesn't create services from .java classes?



If you reply to this email, your message will be added to the discussion below:
http://grails.1312388.n4.nabble.com/Grails-and-Java-services-tp4649373p4649380.html
To unsubscribe from Grails and Java services, click here.
NAML