Skip to content

Commit e62fd6b

Browse files
author
emineoymak
committed
Merge remote-tracking branch 'origin/BAEL-2399' into BAEL-2399
2 parents 3ac9666 + d740cb2 commit e62fd6b

1 file changed

Lines changed: 50 additions & 47 deletions

File tree

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,50 @@
1-
package com.baeldung.examples.guice.modules;
2-
3-
import com.baeldung.examples.common.AccountService;
4-
import com.baeldung.examples.common.AccountServiceImpl;
5-
import com.baeldung.examples.common.BookService;
6-
import com.baeldung.examples.common.BookServiceImpl;
7-
import com.baeldung.examples.guice.Foo;
8-
import com.baeldung.examples.guice.Person;
9-
import com.google.inject.AbstractModule;
10-
import com.google.inject.Provider;
11-
import com.google.inject.Provides;
12-
13-
public class GuiceModule extends AbstractModule {
14-
15-
@Override
16-
protected void configure() {
17-
try {
18-
bind(AccountService.class).to(AccountServiceImpl.class);
19-
bind(Foo.class).toProvider(new Provider<Foo>() {
20-
public Foo get() {
21-
return null;
22-
}
23-
});
24-
25-
bind(Person.class).toConstructor(Person.class.getConstructor());
26-
// bind(Person.class).toProvider(new Provider<Person>() {
27-
// public Person get() {
28-
// Person p = new Person();
29-
// return p;
30-
// }
31-
// });
32-
} catch (NoSuchMethodException e) {
33-
// TODO Auto-generated catch block
34-
e.printStackTrace();
35-
} catch (SecurityException e) {
36-
// TODO Auto-generated catch block
37-
e.printStackTrace();
38-
}
39-
40-
}
41-
42-
@Provides
43-
public BookService bookServiceGenerator() {
44-
return new BookServiceImpl();
45-
}
46-
47-
}
1+
package com.baeldung.examples.guice.modules;
2+
3+
import com.baeldung.examples.common.AccountService;
4+
import com.baeldung.examples.common.AccountServiceImpl;
5+
import com.baeldung.examples.common.BookService;
6+
import com.baeldung.examples.common.BookServiceImpl;
7+
import com.baeldung.examples.common.PersonDao;
8+
import com.baeldung.examples.common.PersonDaoImpl;
9+
import com.baeldung.examples.guice.Foo;
10+
import com.baeldung.examples.guice.Person;
11+
import com.google.inject.AbstractModule;
12+
import com.google.inject.Provider;
13+
import com.google.inject.Provides;
14+
15+
public class GuiceModule extends AbstractModule {
16+
17+
@Override
18+
protected void configure() {
19+
try {
20+
bind(PersonDao.class).to(PersonDaoImpl.class);
21+
bind(AccountService.class).to(AccountServiceImpl.class);
22+
bind(Foo.class).toProvider(new Provider<Foo>() {
23+
public Foo get() {
24+
return null;
25+
}
26+
});
27+
28+
bind(Person.class).toConstructor(Person.class.getConstructor());
29+
// bind(Person.class).toProvider(new Provider<Person>() {
30+
// public Person get() {
31+
// Person p = new Person();
32+
// return p;
33+
// }
34+
// });
35+
} catch (NoSuchMethodException e) {
36+
// TODO Auto-generated catch block
37+
e.printStackTrace();
38+
} catch (SecurityException e) {
39+
// TODO Auto-generated catch block
40+
e.printStackTrace();
41+
}
42+
43+
}
44+
45+
@Provides
46+
public BookService bookServiceGenerator() {
47+
return new BookServiceImpl();
48+
}
49+
50+
}

0 commit comments

Comments
 (0)