-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainer.java
More file actions
54 lines (45 loc) · 1.98 KB
/
Container.java
File metadata and controls
54 lines (45 loc) · 1.98 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.pityubak.liberator;
import com.pityubak.founder.Founder;
import com.pityubak.liberator.proxy.InjectConsumer;
import com.pityubak.liberator.service.InjectionService;
import com.pityubak.liberator.proxy.InjectionProxy;
import com.pityubak.liberator.proxy.InjectionStream;
import com.pityubak.liberator.service.AbstractMethodHandling;
import com.pityubak.liberator.service.DetailsService;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import com.pityubak.liberator.builder.MethodDependencyService;
/**
* @author Pityubak
*/
public class Container {
private final Founder founder;
private final MethodDependencyService methodDependency;
private final InjectionService injectionService;
private final AbstractMethodHandling methodHandler;
private final DetailsService detailsService;
public Container(Founder founder, MethodDependencyService methodDependency,
DetailsService detailsService, AbstractMethodHandling methodHandling) {
this.founder = founder;
this.methodDependency = methodDependency;
this.detailsService = detailsService;
this.methodHandler = methodHandling;
this.injectionService = new InjectionService(this.founder, this.methodDependency, this.detailsService, this.methodHandler);
}
public void inject(final Map<String, Class<?>> injectedClasses) {
final List<Object> namedObjectList = new ArrayList<>();
injectedClasses.keySet().forEach(name -> {
Class<?> cls = injectedClasses.get(name);
namedObjectList.add(founder.createSingleton(cls, name));
});
//
this.inject(namedObjectList);
}
public void inject(final List<Object> injectedClass) {
final Consumer consumer = new InjectConsumer(injectedClass, this.injectionService);
final InjectionStream injectionStream = new InjectionProxy(consumer, this.methodHandler);
injectionStream.execute();
}
}