View Javadoc

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.impl.config.jndi;
17  
18  import de.smartics.exceptions.i18n.message.MessageParam;
19  import de.smartics.properties.api.config.codes.ConfigurationsCode;
20  import de.smartics.properties.api.core.app.AbstractBaseMessageBean;
21  
22  /**
23   * Provides context information for problems dealing with JNDI context access.
24   */
25  public class JndiContextMessageBean extends AbstractBaseMessageBean // NOPMD
26  {
27    // ********************************* Fields *********************************
28  
29    // --- constants ------------------------------------------------------------
30  
31    /**
32     * The class version identifier.
33     * <p>
34     * The value of this constant is {@value}.
35     * </p>
36     */
37    private static final long serialVersionUID = 1L;
38  
39    // --- members --------------------------------------------------------------
40  
41    /**
42     * The identifier of the JNDI context in trouble.
43     *
44     * @serial
45     */
46    @MessageParam
47    private final String sourceId; // NOPMD
48  
49    /**
50     * The key to the configuration where problems arise accessing the JNDI
51     * context.
52     *
53     * @serial
54     */
55    @MessageParam
56    private final String configurationKey; // NOPMD
57  
58    // ****************************** Initializer *******************************
59  
60    // ****************************** Constructors ******************************
61  
62    /**
63     * Constructor without cause.
64     *
65     * @param code the error or exception code of the exception.
66     * @param sourceId the identifier of the JNDI context in trouble.
67     * @param configurationKey the key to the configuration where problems arise
68     *          accessing the property store.
69     */
70    public JndiContextMessageBean(final ConfigurationsCode code,
71        final String sourceId, final String configurationKey)
72    {
73      this(code, null, sourceId, configurationKey);
74    }
75  
76    /**
77     * Default constructor.
78     *
79     * @param code the error or exception code of the exception.
80     * @param cause the cause to the problem.
81     * @param sourceId the identifier of the JNDI context in trouble.
82     * @param configurationKey the key to the configuration where problems arise
83     *          accessing the property store.
84     */
85    public JndiContextMessageBean(final ConfigurationsCode code,
86        final Throwable cause, final String sourceId,
87        final String configurationKey)
88    {
89      super(code, cause);
90      this.sourceId = sourceId;
91      this.configurationKey = configurationKey;
92    }
93  
94    // ****************************** Inner Classes *****************************
95  
96    // ********************************* Methods ********************************
97  
98    // --- init -----------------------------------------------------------------
99  
100   // --- factory --------------------------------------------------------------
101 
102   /**
103    * Creates a message bean for
104    * {@link JndiPropertyStoreCode#INVALID_CONFIGURATION_KEY}.
105    *
106    * @param cause the cause to the problem.
107    * @param sourceId the identifier of the JNDI context in trouble.
108    * @param configurationKey the key to the configuration where problems arise
109    *          accessing the property store.
110    * @return the message bean.
111    */
112   public static JndiContextMessageBean invalidKey(final Throwable cause,
113       final String sourceId, final String configurationKey)
114   {
115     return new JndiContextMessageBean(
116         JndiPropertyStoreCode.INVALID_CONFIGURATION_KEY, cause,
117         configurationKey, null);
118   }
119 
120   // --- get&set --------------------------------------------------------------
121 
122   // --- business -------------------------------------------------------------
123 
124   // --- object basics --------------------------------------------------------
125 
126 }