annotate a constructor

Hi,

What is the scala equivalent to the following java code:

public class FavouriteDAO {

    @Inject
    public FavouriteDAO( SessionProvider sessionProvider ){

.....

}

if I have a scala class

class FavouriteDAO( sessionProvider : SessionProvider ) {
....
}

how do I annotate the constructor, such that existing java code sees the constructor for my FavouriteDAO class annotated with @Inject. I have tried adding @inject before that class and between 'class' and FavouriteDAO, but it did not work. I'm trying to integrate my code with Google Guice

Thanks, Niels
 

--
BinaryConstructors ApS
Vestergade 10a, 4th
1456 Kbh K
Denmark
phone: +4528138757
web: http://www.binaryconstructors.dk
mail: nb [at] binaryconstructors [dot] dk
skype: nielsboldt

Re: annotate a constructor



On Sun, Sep 20, 2009 at 16:47, Niels Boldt <nielsboldt [at] gmail [dot] com> wrote:
Hi,

What is the scala equivalent to the following java code:

public class FavouriteDAO {

    @Inject
    public FavouriteDAO( SessionProvider sessionProvider ){

.....

}

if I have a scala class

class FavouriteDAO( sessionProvider : SessionProvider ) {
....
}

how do I annotate the constructor, such that existing java code sees the constructor for my FavouriteDAO class annotated with @Inject. I have tried adding @inject before that class and between 'class' and FavouriteDAO, but it did not work. I'm trying to integrate my code with Google Guice


Hi,

in 2.8 it will be

  class FavouriteDAO @Inject() (sessionProvider: SessionProvider)

The parens are needed. The syntax requires constructor annotations to have exactly
one parameter list, possibly empty.

For 2.7.x I don't know, the implementation was a bit buggy.

Cheers: Lukas


 
Thanks, Niels
 

--
BinaryConstructors ApS
Vestergade 10a, 4th
1456 Kbh K
Denmark
phone: +4528138757
web: http://www.binaryconstructors.dk
mail: nb [at] binaryconstructors [dot] dk
skype: nielsboldt

Re: annotate a constructor

On Sun, 2009-09-20 at 19:34 +0200, Lukas Rytz wrote:
> in 2.8 it will be
>
> class FavouriteDAO @Inject() (sessionProvider: SessionProvider)
>
> The parens are needed. The syntax requires constructor annotations to
> have exactly
> one parameter list, possibly empty.
>
> For 2.7.x I don't know, the implementation was a bit buggy.

I've been using the same approach in 2.7.5 without issues (so far).

Best,
Ismael

Re: annotate a constructor

Thanks for the answers, solved my problem

Best Regards
Niels

On Sun, Sep 20, 2009 at 9:11 PM, Ismael Juma <mlists [at] juma [dot] me [dot] uk> wrote:
On Sun, 2009-09-20 at 19:34 +0200, Lukas Rytz wrote:
> in 2.8 it will be
>
>   class FavouriteDAO @Inject() (sessionProvider: SessionProvider)
>
> The parens are needed. The syntax requires constructor annotations to
> have exactly
> one parameter list, possibly empty.
>
> For 2.7.x I don't know, the implementation was a bit buggy.

I've been using the same approach in 2.7.5 without issues (so far).

Best,
Ismael





--
BinaryConstructors ApS
Vestergade 10a, 4th
1456 Kbh K
Denmark
phone: +4528138757
web: http://www.binaryconstructors.dk
mail: nb [at] binaryconstructors [dot] dk
skype: nielsboldt

Copyright © 2013 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland