Quantcast

Integrating Grails

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Integrating Grails

Babelex
We use a a services based IOC service based application server for many of our apps. We have Jetty , Scedulers Pooled Datasources etc... It's all java based and is a good structured framework for some of our clients.

I am interested in be able to add Groovy into the mix (We already use groovy in a number of areas). My question is how would I go about doing so.

For example we integrate web apps regularly with minor changes to the servlets in order to pass in the IOC kernel to enable the application to access other service componets we have installed. Obviously we could use this method but I would imagine we need more than just that. Can any one give me some pointers on where to start investigating?

I would appreciate it, and would love to provide benefit from Grails and add any contributions back.

--
regards
babelex
http://babelex.blogspot.com/
#OpenSource means free to innovate#
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Integrating Grails

graemer
Hi,

Grails is built on top of Spring, now I'm not entirely clear what you
are trying to achieve but you can wire in existing components and
services into a Grails-app by adding spring beans to the
"%MY_PROJECT%\spring\resources.xml" file.

All Grails controllers and service classes are then configured to
auto-wire bean into them. Controllers are configured for auto-wire by
name so if you have a service you want to inject into a Grails
controller you would have some like this:

<bean id="myService class="MyServiceImpl" />

then the controller:

class MyController {
     @Property MyService myService

     @Property callService = {
               println myService.getSomething()
       }
}

I hope that helps answer your question. Also I have just committed an
update and Grails will now compile on JDK 1.4

Cheers,
Graeme

On 15/12/05, Babelex <[hidden email]> wrote:

> We use a a services based IOC service based application server for many of
> our apps. We have Jetty , Scedulers Pooled Datasources etc... It's all java
> based and is a good structured framework for some of our clients.
>
>  I am interested in be able to add Groovy into the mix (We already use
> groovy in a number of areas). My question is how would I go about doing so.
>
> For example we integrate web apps regularly with minor changes to the
> servlets in order to pass in the IOC kernel to enable the application to
> access other service componets we have installed. Obviously we could use
> this method but I would imagine we need more than just that. Can any one
> give me some pointers on where to start investigating?
>
> I would appreciate it, and would love to provide benefit from Grails and add
> any contributions back.
>
> --
> regards
> babelex
> http://babelex.blogspot.com/
> #OpenSource means free to innovate#
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Integrating Grails

Babelex
Thanks for the reply Graeme, see my comments below

On 12/16/05, Graeme Rocher <[hidden email] > wrote:
Hi,

Grails is built on top of Spring, now I'm not entirely clear what you
are trying to achieve but you can wire in existing components and
services into a Grails-app by adding spring beans to the
"%MY_PROJECT%\spring\resources.xml" file.


I've had a a liitle peek around the source code and can see a lot of Spring stuff, although I am not familiar with spring I think I understand what it provides  (I just took in a few online presentations etc.. about it). We use our own IOC container and component framework that we developed internally. We started this when the only other options available were things like the Avalon framework, our framework is similar to Avalon but with reduced complexity. At this time spring was not around which is a shame having nseen what spring offers.
 

All Grails controllers and service classes are then configured to
auto-wire bean into them. Controllers are configured for auto-wire by
name so if you have a service you want to inject into a Grails
controller you would have some like this:

<bean id="myService class="MyServiceImpl" />

then the controller:

class MyController {
     @Property MyService myService

     @Property callService = {
               println myService.getSomething()
       }
}


This look usefull for embeding components and such but in our case doesn't solve the original issue. I was really looking at it from a different persepective, that of our aplication server actually running Grails as one of it's services via some sort of wrapper. The only reason I would suggest this is to enable us to backport Grails into existing installations which could be usefull.

Moving forward would be different and we could happily live in a spring environment for any new projects. In fact we could probably port some of our older IOC components into the spring mix with a little more research and maybe an adapter port two.

On this front we are about to embark on a new project and I am weighing up the use of Grails within part of it. My main goal here is rapid development of a number of interactive web based  components in the project, I figure that the Grails/Groovy combination will give us both agile and rapid GUI production with good seperation of concerns. I am however concious that Grails is not finished per se. I would not be using grails on what we term the critical parts of the application initially and therefore reducing our risk on the project. I would however like some feedback on the Grails timetable if possible, also I offer my own personal help where our Grails usage overlap Grails development/testing etc..and would of course contribute this back into Grails where relevant.

I hope that helps answer your question. Also I have just committed an
update and Grails will now compile on JDK 1.4


That is just brilliant thanks, I can now have a hack on my powerbook and will be doing so shortly.

--
regards
babelex
http://babelex.blogspot.com/
#OpenSource means free to innovate#
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Integrating Grails

graemer
On 16/12/05, Babelex <[hidden email]> wrote:

> Thanks for the reply Graeme, see my comments below
>
> On 12/16/05, Graeme Rocher <[hidden email] > wrote:
> > Hi,
> >
> > Grails is built on top of Spring, now I'm not entirely clear what you
> > are trying to achieve but you can wire in existing components and
> > services into a Grails-app by adding spring beans to the
> > "%MY_PROJECT%\spring\resources.xml" file.
>
>
> I've had a a liitle peek around the source code and can see a lot of Spring
> stuff, although I am not familiar with spring I think I understand what it
> provides  (I just took in a few online presentations etc.. about it). We use
> our own IOC container and component framework that we developed internally.
> We started this when the only other options available were things like the
> Avalon framework, our framework is similar to Avalon but with reduced
> complexity. At this time spring was not around which is a shame having nseen
> what spring offers.
>
> > All Grails controllers and service classes are then configured to
> > auto-wire bean into them. Controllers are configured for auto-wire by
> > name so if you have a service you want to inject into a Grails
> > controller you would have some like this:
> >
> > <bean id="myService class="MyServiceImpl" />
> >
> > then the controller:
> >
> > class MyController {
> >      @Property MyService myService
> >
> >      @Property callService = {
> >                println myService.getSomething()
> >        }
> > }
>
>
> This look usefull for embeding components and such but in our case doesn't
> solve the original issue. I was really looking at it from a different
> persepective, that of our aplication server actually running Grails as one
> of it's services via some sort of wrapper. The only reason I would suggest
> this is to enable us to backport Grails into existing installations which
> could be usefull.

Well grails can be deployed as a war in any servlet container if that
is of any use. Otherwise one of the tasks ahead is to break grails
down into components that can be used indenpendantly.. so you could
for example just use it for ORM mapping or just dynamic methods or
just MVC controllers.. stay tuned on that front

>
> Moving forward would be different and we could happily live in a spring
> environment for any new projects. In fact we could probably port some of our
> older IOC components into the spring mix with a little more research and
> maybe an adapter port two.
>
> On this front we are about to embark on a new project and I am weighing up
> the use of Grails within part of it. My main goal here is rapid development
> of a number of interactive web based  components in the project, I figure
> that the Grails/Groovy combination will give us both agile and rapid GUI
> production with good seperation of concerns. I am however concious that
> Grails is not finished per se. I would not be using grails on what we term
> the critical parts of the application initially and therefore reducing our
> risk on the project. I would however like some feedback on the Grails
> timetable if possible, also I offer my own personal help where our Grails
> usage overlap Grails development/testing etc..and would of course contribute
> this back into Grails where relevant.

Yeh the only issue with pre-release software is that everything is
subject to change a bit. Although i don't think that things like
controllers, domain classes, etc will change that much.

In terms of release I am hoping for a first release of Grails to
appear in mid-march 2006. There are however a number of tasks to
complete before then, including but not limited to:

- finish scaffolding
- improve error reporting
- the grails custom tag library for linking, validation etc.

Oh and thanks for volunteering any contributions from testing to
patches would be great!

>
> > I hope that helps answer your question. Also I have just committed an
> > update and Grails will now compile on JDK 1.4
> >
> >
>
> That is just brilliant thanks, I can now have a hack on my powerbook and
> will be doing so shortly.

Great can you let me know how this goes because a friend of mine is
having trouble using Grails on his powerbook which I'm sure is down to
his classpath (duplicate asm jars conflicting with hibernate) and i
would love someone to confirm that it does work find on a Mac.



>
> --
>
> regards
> babelex
> http://babelex.blogspot.com/
> #OpenSource means free to innovate#
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Integrating Grails

graemer
In reply to this post by Babelex
On 16/12/05, Babelex <[hidden email]> wrote:

>
>
>
> >
> > - finish scaffolding
> > - improve error reporting
> > - the grails custom tag library for linking, validation etc.
>
> What is the plan for the custom tag library, I would love to help on this.
> Can you give me an idea what your using and what the requirements are?

Would love the help if the offer is there, at the moment i would like
to develop the custom tags using GvTags (http://www.gvtags.org) but
there are still some performance issues with it and i'm not sure
whether to take the plunge just yet... otherwise we are looking at a
jsp tag library

with regards to the requirements there will be validation specific
tags to validate forms against a domain class constraints (see
http://grails.codehaus.org/Validation).. something like:

<gr:validate form="myForm" against="MyDomainClass" />

this will generate the necessary javascript for the validation of the form..
We also need tags to easy link to actions like:

<gr:link action="someAction" params="$myParams" />
and
<gr:link controller="someController" action="someAction" params="$myParams" />
and
<gr:link action="someAction" id="1" />

Also need tags to retrieve i18n messages from the message source for
error codes and other i18n text

<gr:resource code="error.code" />

Also want to support Ajax tags for linking to remote calls:

<gr:remote-link action="ajaxAction" result="resultDiv" />

We also need template tags so apply templates against a model

<gr:template apply="myTemplate" value="[1,2]" />

This will apply the template twice...

And there will likely be more requirements for creating UI components
like calenders, drops downs, etc.

Graeme

>
> > Great can you let me know how this goes because a friend of mine is
> > having trouble using Grails on his powerbook which I'm sure is down to
> > his classpath (duplicate asm jars conflicting with hibernate) and i
> > would love someone to confirm that it does work find on a Mac.
>
> Will let you know
>
> > >
> > > --
> > >
> > > regards
> > > babelex
> > > http://babelex.blogspot.com/
> > > #OpenSource means free to innovate#
> >
>
>
>
> --
>
> regards
> babelex
> http://babelex.blogspot.com/
> #OpenSource means free to innovate#
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Integrating Grails

Babelex
Cool I would love to help with the gr:tags

Would love the help if the offer is there, at the moment i would like
to develop the custom tags using GvTags (http://www.gvtags.org) but
there are still some performance issues with it and i'm not sure
whether to take the plunge just yet... otherwise we are looking at a
jsp tag library

I would go with a JSP tag library (I prefer implementing in java at this point, and performance would likely be better for now), although I haven't built a jsp tag library, I have built other tag libraries for Jelly, coocon and our own etc.. I have just downloaded suns 44 page guide to creating tag libraries for JSP and it looks pretty straightforward, just the instalation and TLD that differs really.

with regards to the requirements there will be validation specific
tags to validate forms against a domain class constraints (see
http://grails.codehaus.org/Validation).. something like:

<gr:validate form="myForm" against="MyDomainClass" />


I will need to look at the validation page in more detail for this, I have breifly scanned it
 

this will generate the necessary javascript for the validation of the form..
We also need tags to easy link to actions like:

<gr:link action="someAction" params="$myParams" />
and
<gr:link controller="someController" action="someAction" params="$myParams" />
and
<gr:link action="someAction" id="1" />

This looks to me just like the ROR stuff so I get the picture. I have also been looking at ROR recently (we are evaluating it) and have a copy installed on my PowerBook.
 

Also need tags to retrieve i18n messages from the message source for
error codes and other i18n text

<gr:resource code="error.code" />

Not an expert on i18n text, would need more of an explanation on this particular  requirement.

Also want to support Ajax tags for linking to remote calls:

<gr:remote-link action="ajaxAction" result="resultDiv" />

Yup this looks like an OpenRico element/object candidate ?

We also need template tags so apply templates against a model

<gr:template apply="myTemplate" value="[1,2]" />

This will apply the template twice...

Need to understand this better, not quite sure what you are using/meaning here

And there will likely be more requirements for creating UI components
like calenders, drops downs, etc.

Well the more contributors the better!!

Have you made a start? I would love to add my input and can start working on some of the tag classes straight away as long as you don't mind me badgering you about the internals of grails where needed
 

--
regards
babelex
http://babelex.blogspot.com/
#OpenSource means free to innovate#
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Integrating Grails

graemer
On 16/12/05, Babelex <[hidden email]> wrote:

> Cool I would love to help with the gr:tags
>
>
> > Would love the help if the offer is there, at the moment i would like
> > to develop the custom tags using GvTags (http://www.gvtags.org) but
> > there are still some performance issues with it and i'm not sure
> > whether to take the plunge just yet... otherwise we are looking at a
> > jsp tag library
>
> I would go with a JSP tag library (I prefer implementing in java at this
> point, and performance would likely be better for now), although I haven't
> built a jsp tag library, I have built other tag libraries for Jelly, coocon
> and our own etc.. I have just downloaded suns 44 page guide to creating tag
> libraries for JSP and it looks pretty straightforward, just the instalation
> and TLD that differs really.

Yes likely we will go with a JSP based library

>
> > with regards to the requirements there will be validation specific
> > tags to validate forms against a domain class constraints (see
> > http://grails.codehaus.org/Validation).. something like:
> >
> > <gr:validate form="myForm" against="MyDomainClass" />
>
>
> I will need to look at the validation page in more detail for this, I have
> breifly scanned it
>
> > this will generate the necessary javascript for the validation of the
> form..
> > We also need tags to easy link to actions like:
> >
> > <gr:link action="someAction" params="$myParams" />
> > and
> > <gr:link controller="someController" action="someAction"
> params="$myParams" />
> > and
> > <gr:link action="someAction" id="1" />
>
> This looks to me just like the ROR stuff so I get the picture. I have also
> been looking at ROR recently (we are evaluating it) and have a copy
> installed on my PowerBook.

Yup, it mainly to make sure the linking works whatever the url context

>
> > Also need tags to retrieve i18n messages from the message source for
> > error codes and other i18n text
> >
> > <gr:resource code="error.code" />
>
> Not an expert on i18n text, would need more of an explanation on this
> particular  requirement.

Essentially this will lookup text from the message source for the
locale. at the moment Grails creates a default message source by
creating a "grails-app/i18n/messages.properties" file this is where
error codes get placed and the corresponding messages..

the idea is then that you can create others for other languages like
messages_fr.properties etc.

>
> > Also want to support Ajax tags for linking to remote calls:
> >
> > <gr:remote-link action="ajaxAction" result="resultDiv" />
>
> Yup this looks like an OpenRico element/object candidate ?

Yes Grails integrates with OpenRico through a Builder (see
http://grails.codehaus.org/Builders) and is the Ajax library of choice
so we will be using it to do this.


>
> > We also need template tags so apply templates against a model
> >
> > <gr:template apply="myTemplate" value="[1,2]" />
> >
> > This will apply the template twice...
>
> Need to understand this better, not quite sure what you are using/meaning
> here

For example if you had a number of User objects in a "users" model
that you wanted to display in your view you could do this by looping
through each like so in your view:

<c:forEach var="u" value="${users}">
        <p><c:out value="{firstName}" /></p>
        <p><c:out value="{lastName}" /></p>
</c:forEach>

The problem with this approach is it is not very re-usable a better
way is to use a template so you create the above as a separte jsp
maybe called "user_template.jsp"

and then you can do:

<gr:template apply="user_template" expr="users" />

This is one of the best features of XSLT (with the apply-templates
tag) and is used on RoR (see the 20 minute video its in the demo)

>
> > And there will likely be more requirements for creating UI components
> > like calenders, drops downs, etc.
>
> Well the more contributors the better!!

Indeed!

>
> Have you made a start? I would love to add my input and can start working on
> some of the tag classes straight away as long as you don't mind me badgering
> you about the internals of grails where needed

A good start would be to document what we've discussed and if you are
serious about contributing come to agreement on the spec

This is done through our Wiki:
http://docs.codehaus.org/pages/createpage.action?spaceKey=GRAILS&title=Tag+Library+Reference&linkCreation=true&fromPageId=40788

Feel free to add your ideas I will be adding what I've talked about
already shortly

>
> --
>
> regards
> babelex
> http://babelex.blogspot.com/
> #OpenSource means free to innovate#
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Integrating Grails

Babelex
OK


This is done through our Wiki:
http://docs.codehaus.org/pages/createpage.action?spaceKey=GRAILS&title=Tag+Library+Reference&linkCreation=true&fromPageId=40788

I have staretd the wiki page above, I still have to add some more in there yet but it's a start!

Thanks

--
regards
babelex
http://babelex.blogspot.com/
#OpenSource means free to innovate#
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Integrating Grails

Babelex


I have staretd the wiki page above, I still have to add some more in there yet but it's a start!




--
regards
babelex
http://babelex.blogspot.com/
#OpenSource means free to innovate#
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Integrating Grails

graemer
Nice start! I've added the detail for the validate tag, will add more later..

Graeme

On 16/12/05, Babelex <[hidden email]> wrote:

>
>
> >
> >
> >
> > I have staretd the wiki page above, I still have to add some more in there
> yet but it's a start!
>
> Whoops here teh finished link
> :http://docs.codehaus.org/display/GRAILS/Tag+Library+Reference
>
> ;)
>
>
>
>
> --
> regards
> babelex
> http://babelex.blogspot.com/
> #OpenSource means free to innovate#
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Integrating Grails

Babelex
I'll add the ajax remoting later



--
regards
babelex
http://babelex.blogspot.com/
#OpenSource means free to innovate#
Loading...