Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Configuration |
|
| 0.0;0 | ||||
Configuration$Type |
|
| 0.0;0 |
1 | package org.apache.onami.autobind.configuration; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
5 | * contributor license agreements. See the NOTICE file distributed with | |
6 | * this work for additional information regarding copyright ownership. | |
7 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
8 | * (the "License"); you may not use this file except in compliance with | |
9 | * the License. You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, software | |
14 | * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | * See the License for the specific language governing permissions and | |
17 | * limitations under the License. | |
18 | */ | |
19 | ||
20 | import static java.lang.annotation.ElementType.TYPE; | |
21 | import static java.lang.annotation.RetentionPolicy.RUNTIME; | |
22 | import static org.apache.onami.autobind.configuration.Configuration.Type.CONFIGURATION; | |
23 | ||
24 | import java.lang.annotation.Documented; | |
25 | import java.lang.annotation.Retention; | |
26 | import java.lang.annotation.Target; | |
27 | import java.util.Properties; | |
28 | ||
29 | import javax.inject.Named; | |
30 | ||
31 | /** | |
32 | * Use this Annotation to express your need, that a Configuration should be | |
33 | * loaded, so it can be bound to an Object. | |
34 | */ | |
35 | @Documented | |
36 | @Retention( RUNTIME ) | |
37 | @Target( TYPE ) | |
38 | public @interface Configuration | |
39 | { | |
40 | ||
41 | /** | |
42 | * Name the Configuration should be bound to. | |
43 | * | |
44 | * @return Name the Configuration should be bound to. | |
45 | */ | |
46 | Named name() default @Named( "" ); | |
47 | ||
48 | /** | |
49 | * Path/URL where the Configuration could be found. | |
50 | * | |
51 | * @return Path/URL where the Configuration could be found. | |
52 | */ | |
53 | PathConfig location(); | |
54 | ||
55 | PathConfig alternative() default @PathConfig( "" ); | |
56 | ||
57 | /** | |
58 | * Class/Interface where the Configuration should be bound to. | |
59 | * | |
60 | * @return Class/Interface where the Configuration should be bound to. | |
61 | */ | |
62 | Class<? extends Object> to() default Properties.class; | |
63 | ||
64 | /** | |
65 | * This does only make sense if you are using the Provider Interface. public class Service{ | |
66 | * | |
67 | * @Inject Provider<Properties> properties; public void do(){ Properties properties = properties.get(); } } | |
68 | * @return true if the Configuration should be load lazy | |
69 | */ | |
70 | boolean lazy() default false; | |
71 | ||
72 | /** | |
73 | * Specify what should be bound for the Configuration Configuration -> Configuration only Values -> Named Bindings | |
74 | * for the Values Both -> Configuration and Named Bindings | |
75 | * | |
76 | * @return | |
77 | */ | |
78 | Type type() default CONFIGURATION; | |
79 | ||
80 | 0 | public static enum Type |
81 | { | |
82 | ||
83 | /** | |
84 | * Binds only the Configuration itself. | |
85 | */ | |
86 | 0 | CONFIGURATION, |
87 | ||
88 | /** | |
89 | * Named Bindings for the Key/Values (only possible if not lazy) | |
90 | */ | |
91 | 0 | VALUES, |
92 | ||
93 | /** | |
94 | * The Configuration and Named Bindings will be done. (only possible if not lazy) | |
95 | */ | |
96 | 0 | BOTH |
97 | ||
98 | } | |
99 | ||
100 | } |