1 /*
2 * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package de.smartics.properties.spi.config.cache;
17
18 import static de.smartics.properties.api.config.codes.LibraryCodeNumbers.CACHE_CODE_START;
19 import de.smartics.exceptions.code.NumberCodeInfo;
20 import de.smartics.exceptions.i18n.message.MessageParamsDescriptor;
21 import de.smartics.properties.api.config.codes.ConfigurationsCode;
22
23 /**
24 * Codes dealing with cache problems.
25 */
26 public enum CacheCode implements ConfigurationsCode
27 {
28 // ***************************** Enumeration ******************************
29
30 /**
31 * Failed to load configuration file.
32 */
33 @MessageParamsDescriptor(CacheMessageBean.class)
34 CONFIGURATION_FILE_LOAD_FAILURE(0),
35
36 /**
37 * Missing mapped name of cache in configuration file.
38 */
39 @MessageParamsDescriptor(CacheMessageBean.class)
40 MISSING_MAPPED_NAME(1),
41
42 /**
43 * Signals the accessing the cache via JNDI failed.
44 */
45 @MessageParamsDescriptor(CacheMessageBean.class)
46 JNDI_PROBLEM(2),
47
48 /**
49 * Failed to load configuration properties via JNDI. The JNDI context cannot
50 * be accessed.
51 */
52 @MessageParamsDescriptor(CacheMessageBean.class)
53 JNDI_LOAD_PROBLEM(10);
54
55 // ******************************** Fields ********************************
56
57 // --- constants ----------------------------------------------------------
58
59 // --- members ------------------------------------------------------------
60
61 /**
62 * The code information.
63 */
64 private final NumberCodeInfo info;
65
66 // ***************************** Constructors *****************************
67
68 /**
69 * Default constructor.
70 *
71 * @param minorNumber the minor part of the error code.
72 */
73 private CacheCode(final Integer minorNumber)
74 {
75 this.info = new NumberCodeInfo("Cache", CACHE_CODE_START, minorNumber);
76 }
77
78 // ******************************** Methods *******************************
79
80 // --- init ---------------------------------------------------------------
81
82 // --- get&set ------------------------------------------------------------
83
84 @Override
85 public String getCode()
86 {
87 return info.getCode();
88 }
89
90 @Override
91 public String getComponentId()
92 {
93 return info.getComponentId();
94 }
95
96 @Override
97 public String getDisplayId()
98 {
99 return info.toString();
100 }
101
102 @Override
103 public Integer getMajorNumber()
104 {
105 return info.getMajorNumber();
106 }
107
108 @Override
109 public Integer getMinorNumber()
110 {
111 return info.getMinorNumber();
112 }
113
114 // --- business -----------------------------------------------------------
115
116 // --- object basics ------------------------------------------------------
117
118 /**
119 * Returns the string representation of the object.
120 *
121 * @return the string representation of the object.
122 */
123 @Override
124 public String toString()
125 {
126 return getDisplayId();
127 }
128 }