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.api.config.domain;
17  
18  import java.io.Serializable;
19  
20  /**
21   * Base implementation to support administration modes.
22   */
23  public abstract class AbstractAdminModeSupportedPropertiesManagement implements
24      ConfigurationPropertiesManagement, Serializable
25  {
26    // ********************************* Fields *********************************
27  
28    // --- constants ------------------------------------------------------------
29  
30    /**
31     * The class version identifier.
32     */
33    private static final long serialVersionUID = 1L;
34  
35    // --- members --------------------------------------------------------------
36  
37    /**
38     * The switch to turn the management configuration into an administration
39     * configuration. In administration mode the configuration allows to deal with
40     * properties not allowed in management mode. E.g. read-only properties are
41     * not allowed to be changed in management mode, but are allowed to be changed
42     * in administration mode.
43     *
44     * @serial
45     */
46    private boolean adminMode;
47  
48    // ****************************** Initializer *******************************
49  
50    // ****************************** Constructors ******************************
51  
52    // ****************************** Inner Classes *****************************
53  
54    // ********************************* Methods ********************************
55  
56    // --- init -----------------------------------------------------------------
57  
58    // --- get&set --------------------------------------------------------------
59  
60    /**
61     *  {@inheritDoc}
62     *  <p>
63     *  This implementation also checks whether the admin mode is set for the
64     *  current thread only. Please refer to {@link ConfigControl} for details on
65     *  how to set the admin mode for the current thread.
66     *  </p>
67     */
68    @Override
69    public boolean isInAdminMode()
70    {
71      return adminMode && ConfigControl.get().isAdminMode();
72    }
73  
74    @Override
75    public void setToAdminMode(final boolean newMode)
76    {
77      this.adminMode = newMode;
78    }
79  
80    // --- business -------------------------------------------------------------
81  
82    // --- object basics --------------------------------------------------------
83  
84    @Override
85    public ConfigurationPropertiesManagement toRepresentative()
86    {
87      return this;
88    }
89  
90  }