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.ui.framework.ioc;
35
36 import java.lang.annotation.Annotation;
37 import java.lang.annotation.ElementType;
38 import java.lang.annotation.Retention;
39 import java.lang.annotation.RetentionPolicy;
40 import java.lang.annotation.Target;
41 import java.util.Objects;
42
43 import com.google.inject.BindingAnnotation;
44
45
46
47
48
49
50
51 @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
52 @Retention(RetentionPolicy.RUNTIME)
53 @BindingAnnotation
54 public @interface DatasourceComponent {
55
56 String datasourceName();
57
58
59
60
61 class DatasourceComponentImpl implements DatasourceComponent, UiContextAnnotation {
62
63 private String datasourceName;
64
65 public DatasourceComponentImpl(String datasourceName) {
66 this.datasourceName = datasourceName;
67 }
68
69 @Override
70 public Class<DatasourceComponent> annotationType() {
71 return DatasourceComponent.class;
72 }
73
74 @Override
75 public String datasourceName() {
76 return this.datasourceName;
77 }
78
79 @Override
80 public boolean equals(Object o) {
81 if (this == o) return true;
82 if (!(o instanceof DatasourceComponentImpl)) return false;
83 DatasourceComponentImpl component = (DatasourceComponentImpl) o;
84 return Objects.equals(datasourceName, component.datasourceName);
85 }
86
87 @Override
88 public int hashCode() {
89 return Objects.hash(datasourceName);
90 }
91
92 @Override
93 public Class<? extends Annotation> getRelatedScopeAnnotation(boolean isEager) {
94 return DatasourceComponent.class;
95 }
96 }
97 }
98