1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.maxur.perfmodel.backend;
17
18 import org.glassfish.hk2.api.InjectionResolver;
19 import org.glassfish.hk2.api.InterceptionService;
20 import org.glassfish.hk2.api.TypeLiteral;
21 import org.glassfish.hk2.utilities.binding.AbstractBinder;
22 import org.glassfish.jersey.server.ResourceConfig;
23 import org.maxur.perfmodel.backend.domain.Project;
24 import org.maxur.perfmodel.backend.domain.Repository;
25 import org.maxur.perfmodel.backend.infrastructure.ProjectRepositoryLevelDbImpl;
26 import org.maxur.perfmodel.backend.rest.RestServiceConfig;
27 import org.maxur.perfmodel.backend.service.*;
28 import org.maxur.perfmodel.backend.service.impl.PropertiesServiceHoconImpl;
29 import org.maxur.perfmodel.backend.service.impl.WebServerGrizzlyImpl;
30
31 import javax.inject.Named;
32 import javax.inject.Singleton;
33
34
35
36
37
38
39
40
41 final class Config extends AbstractBinder {
42
43 @Override
44 protected void configure() {
45 bind(ConfigurationInjectionResolver.class)
46 .to(new TypeLiteral<InjectionResolver<Named>>() {
47 })
48 .in(Singleton.class);
49 bind(RestServiceConfig.class)
50 .to(ResourceConfig.class)
51 .in(Singleton.class);
52 bind(HK2InterceptionService.class)
53 .to(InterceptionService.class)
54 .in(Singleton.class);
55 bind(PropertiesServiceHoconImpl.class)
56 .to(PropertiesService.class)
57 .in(Singleton.class);
58 bind(WebServerGrizzlyImpl.class)
59 .to(WebServer.class)
60 .in(Singleton.class);
61 bindFactory(ApplicationProvider.class)
62 .to(Application.class)
63 .in(Singleton.class);
64 bindAsContract(new TypeLiteral<ProjectRepositoryLevelDbImpl>() {
65 }).to(new TypeLiteral<Repository<Project>>() {
66 }).in(Singleton.class);
67
68 bindFactory(DataSourceProvider.class)
69 .to(DataSource.class)
70 .in(Singleton.class);
71 bindFactory(DataSourceProvider.class)
72 .to(Database.class)
73 .in(Singleton.class);
74
75 }
76 }