alias

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

alias

S.GOUGI
Hi,

We started the development of a open source application
 that used Grails. We wish to express our gratitude to
you who developed Grails.

Well, I have one proposal for one Groovy.

I think it is convenient if coming to put `alias' as follows.

class FooController {

   def hogehogehogeService alias hoge


   bar = {
      return hoge.functionA()
   }

...
}

I always have a hard time in typing ....Service.  :-)

Thanks
--
http://sourceforge.jp/projects/spacecard/


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: alias

burtbeckwith
You could override the implicit setter and set the injected service into a
private variable, e.g.:

   private def hoge

   def hogehogehogeService

   void setHogehogehogeService(hogehogehogeService) {
      hoge = hogehogehogeService
   }

Burt

On Sunday 02 March 2008 11:37:29 am Shigeru GOUGI wrote:

> Hi,
>
> We started the development of a open source application
>  that used Grails. We wish to express our gratitude to
> you who developed Grails.
>
> Well, I have one proposal for one Groovy.
>
> I think it is convenient if coming to put `alias' as follows.
>
> class FooController {
>
>    def hogehogehogeService alias hoge
>
>
>    bar = {
>       return hoge.functionA()
>    }
>
> ...
> }
>
> I always have a hard time in typing ....Service.  :-)
>
> Thanks



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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: alias

S.GOUGI
Hi, Burt
Thank you. However, when I think
about the case where two or more
services exists, I like to be able
to write simply. ;-)

On Sun, 2 Mar 2008 11:50:39 -0500
Burt Beckwith <[hidden email]> wrote:

> You could override the implicit setter and set the injected service into a
> private variable, e.g.:
>
>    private def hoge
>
>    def hogehogehogeService
>
>    void setHogehogehogeService(hogehogehogeService) {
>       hoge = hogehogehogeService
>    }
>
> Burt
>
> On Sunday 02 March 2008 11:37:29 am Shigeru GOUGI wrote:
> > Hi,
> >
> > We started the development of a open source application
> >  that used Grails. We wish to express our gratitude to
> > you who developed Grails.
> >
> > Well, I have one proposal for one Groovy.
> >
> > I think it is convenient if coming to put `alias' as follows.
> >
> > class FooController {
> >
> >    def hogehogehogeService alias hoge
> >
> >
> >    bar = {
> >       return hoge.functionA()
> >    }
> >
> > ...
> > }
> >
> > I always have a hard time in typing ....Service.  :-)
> >
> > Thanks
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>

--
http://sourceforge.jp/projects/spacecard/


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: alias

burtbeckwith
Sure - your suggestion is a good one and I was just proposing a workaround.

This is interesting to me because I wish I could specify the bean name of a
service - there doesn't appear to be any way to override the default behavior
of lowercasing the 1st letter of the class short name (the "natural name"). I
prefer to use interfaces, e.g. UserService, then implement the Groovy class
as UserServiceImpl or GroovyUserService. But the implementation name is used
as the bean name, and I'd prefer to have the Spring name be the interface
name.

So my current solution is to name my interface IUserService (which I _hate_)
and my implemenation class UserService, but it would be more convenient if I
could either specify the bean name in the service or alias injected beans.

Burt

On Sunday 02 March 2008 12:26:16 pm Shigeru GOUGI wrote:

> Hi, Burt
> Thank you. However, when I think
> about the case where two or more
> services exists, I like to be able
> to write simply. ;-)
>
> On Sun, 2 Mar 2008 11:50:39 -0500
>
> Burt Beckwith <[hidden email]> wrote:
> > You could override the implicit setter and set the injected service into
> > a private variable, e.g.:
> >
> >    private def hoge
> >
> >    def hogehogehogeService
> >
> >    void setHogehogehogeService(hogehogehogeService) {
> >       hoge = hogehogehogeService
> >    }
> >
> > Burt
> >
> > On Sunday 02 March 2008 11:37:29 am Shigeru GOUGI wrote:
> > > Hi,
> > >
> > > We started the development of a open source application
> > >  that used Grails. We wish to express our gratitude to
> > > you who developed Grails.
> > >
> > > Well, I have one proposal for one Groovy.
> > >
> > > I think it is convenient if coming to put `alias' as follows.
> > >
> > > class FooController {
> > >
> > >    def hogehogehogeService alias hoge
> > >
> > >
> > >    bar = {
> > >       return hoge.functionA()
> > >    }
> > >
> > > ...
> > > }
> > >
> > > I always have a hard time in typing ....Service.  :-)
> > >
> > > Thanks
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> >
> >     http://xircles.codehaus.org/manage_email
>
> --
> http://sourceforge.jp/projects/spacecard/
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email



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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: alias

S.GOUGI
Hi, Burt

> But the implementation name is used
> as the bean name, and I'd prefer to have the Spring name be the interface
> name.

It certainly is. The following code example
is good meaning it.

def userService inject(groovyUserService)

or

@inject(groovyUserService)
def userService

Thanks,
sg

On Sun, 2 Mar 2008 12:38:44 -0500
Burt Beckwith <[hidden email]> wrote:

> Sure - your suggestion is a good one and I was just proposing a workaround.
>
> This is interesting to me because I wish I could specify the bean name of a
> service - there doesn't appear to be any way to override the default behavior
> of lowercasing the 1st letter of the class short name (the "natural name"). I
> prefer to use interfaces, e.g. UserService, then implement the Groovy class
> as UserServiceImpl or GroovyUserService. But the implementation name is used
> as the bean name, and I'd prefer to have the Spring name be the interface
> name.
>
> So my current solution is to name my interface IUserService (which I _hate_)
> and my implemenation class UserService, but it would be more convenient if I
> could either specify the bean name in the service or alias injected beans.
>
> Burt
>
> On Sunday 02 March 2008 12:26:16 pm Shigeru GOUGI wrote:
> > Hi, Burt
> > Thank you. However, when I think
> > about the case where two or more
> > services exists, I like to be able
> > to write simply. ;-)
> >
> > On Sun, 2 Mar 2008 11:50:39 -0500
> >
> > Burt Beckwith <[hidden email]> wrote:
> > > You could override the implicit setter and set the injected service into
> > > a private variable, e.g.:
> > >
> > >    private def hoge
> > >
> > >    def hogehogehogeService
> > >
> > >    void setHogehogehogeService(hogehogehogeService) {
> > >       hoge = hogehogehogeService
> > >    }
> > >
> > > Burt
> > >
> > > On Sunday 02 March 2008 11:37:29 am Shigeru GOUGI wrote:
> > > > Hi,
> > > >
> > > > We started the development of a open source application
> > > >  that used Grails. We wish to express our gratitude to
> > > > you who developed Grails.
> > > >
> > > > Well, I have one proposal for one Groovy.
> > > >
> > > > I think it is convenient if coming to put `alias' as follows.
> > > >
> > > > class FooController {
> > > >
> > > >    def hogehogehogeService alias hoge
> > > >
> > > >
> > > >    bar = {
> > > >       return hoge.functionA()
> > > >    }
> > > >
> > > > ...
> > > > }
> > > >
> > > > I always have a hard time in typing ....Service.  :-)
> > > >
> > > > Thanks
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe from this list, please visit:
> > >
> > >     http://xircles.codehaus.org/manage_email
> >
> > --
> > http://sourceforge.jp/projects/spacecard/
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> >
> >     http://xircles.codehaus.org/manage_email
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>

--
http://sourceforge.jp/projects/spacecard/


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

    http://xircles.codehaus.org/manage_email