1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.resourceloader.classpath;
35
36
37 import static info.magnolia.resourceloader.classpath.service.impl.base.ClasspathFileConstructionStrategy.*;
38
39 import info.magnolia.init.MagnoliaConfigurationProperties;
40 import info.magnolia.objectfactory.annotation.LazySingleton;
41 import info.magnolia.resourceloader.classpath.service.ClasspathService;
42 import info.magnolia.resourceloader.classpath.service.impl.base.ClasspathEntriesResolver;
43 import info.magnolia.resourceloader.classpath.service.impl.devmode.DevelopmentModeClasspathService;
44 import info.magnolia.resourceloader.classpath.service.impl.production.ProductionModeClasspathService;
45
46 import javax.inject.Inject;
47
48 import com.google.inject.Provider;
49
50
51
52
53
54
55
56 @LazySingleton
57 public class ClasspathServiceProvider implements Provider<ClasspathService> {
58
59 private final MagnoliaConfigurationProperties magnoliaConfigurationProperties;
60 private final DefaultClasspathServiceConfigurations classpathConfigurations;
61
62 private ClasspathService classpathService = null;
63
64 @Inject
65 public ClasspathServiceProvider(MagnoliaConfigurationProperties mcp, DefaultClasspathServiceConfigurations cfg) {
66 this.magnoliaConfigurationProperties = mcp;
67 this.classpathConfigurations = cfg;
68 }
69
70 @Override
71 public ClasspathService get() {
72 if (classpathService == null) {
73 boolean devMode = magnoliaConfigurationProperties.getBooleanProperty("magnolia.develop");
74 if (devMode) {
75 this.classpathService = new DevelopmentModeClasspathService(classpathConfigurations, new ClasspathEntriesResolver.ReflectionsVfsBased(developmentModeWithVfs()));
76 } else {
77 this.classpathService = new ProductionModeClasspathService(classpathConfigurations, new ClasspathEntriesResolver.ReflectionsVfsBased(productionWithVfs()));
78 }
79 }
80 return classpathService;
81 }
82 }