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.spi.config.support;
17  
18  import de.smartics.properties.api.config.domain.ConfigurationPropertiesManagement;
19  import de.smartics.properties.api.config.domain.key.ConfigurationKey;
20  import de.smartics.properties.api.core.domain.PropertyDescriptorRegistry;
21  import de.smartics.properties.api.core.security.PropertyValueSecurity;
22  import de.smartics.util.lang.NullArgumentException;
23  
24  /**
25   * Base implementation to support administration modes.
26   */
27  public abstract class AbstractAdminModeConfigurationProperties extends
28      AbstractConfigurationProperties implements
29      ConfigurationPropertiesManagement
30  {
31    // ********************************* Fields *********************************
32  
33    // --- constants ------------------------------------------------------------
34  
35    // --- members --------------------------------------------------------------
36  
37    // ********************************* Fields *********************************
38  
39    // --- constants ------------------------------------------------------------
40  
41    // --- members --------------------------------------------------------------
42  
43    /**
44     * The switch to turn the management configuration into an administration
45     * configuration. In administration mode the configuration allows to deal with
46     * properties not allowed in management mode. E.g. read-only properties are
47     * not allowed to be changed in management mode, but are allowed to be changed
48     * in administration mode.
49     *
50     * @serial
51     */
52    private boolean adminMode;
53  
54    // ****************************** Initializer *******************************
55  
56    // ****************************** Constructors ******************************
57  
58    /**
59     * Constructor for serializable subclasses.
60     */
61    protected AbstractAdminModeConfigurationProperties()
62    {
63      super();
64    }
65  
66    /**
67     * Default constructor.
68     *
69     * @param key the key that identifies the configuration.
70     * @param registry the registry to resolve property descriptors.
71     * @param decrypter the helper to decrypt secured property values.
72     * @throws NullArgumentException if {@code key}, {@code registry} or
73     *           {@code decrypter} is <code>null</code>.
74     */
75    protected AbstractAdminModeConfigurationProperties(
76        final ConfigurationKey<?> key, final PropertyDescriptorRegistry registry,
77        final PropertyValueSecurity decrypter) throws NullArgumentException
78    {
79      super(key, registry, decrypter);
80    }
81  
82    // ****************************** Inner Classes *****************************
83  
84    // ********************************* Methods ********************************
85  
86    // --- init -----------------------------------------------------------------
87  
88    // --- get&set --------------------------------------------------------------
89  
90    @Override
91    public final boolean isInAdminMode()
92    {
93      return adminMode;
94    }
95  
96    @Override
97    public final void setToAdminMode(final boolean newMode)
98    {
99      this.adminMode = newMode;
100   }
101 
102   // --- business -------------------------------------------------------------
103 
104   // --- object basics --------------------------------------------------------
105 
106   @Override
107   public ConfigurationPropertiesManagement toRepresentative()
108   {
109     return this;
110   }
111 
112 }