Coverage Report - de.smartics.properties.impl.config.properties.PropertiesConfigurationPropertiesFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
PropertiesConfigurationPropertiesFactory
0%
0/10
N/A
N/A
1
 
 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.properties;
 17  
 
 18  
 import javax.annotation.concurrent.ThreadSafe;
 19  
 
 20  
 import de.smartics.properties.api.config.domain.ConfigurationException;
 21  
 import de.smartics.properties.api.config.domain.key.ApplicationId;
 22  
 import de.smartics.properties.api.config.domain.key.ConfigurationKey;
 23  
 import de.smartics.properties.spi.config.domain.key.ConfigurationKeyContextManager;
 24  
 import de.smartics.properties.spi.config.support.AbstractConfigurationPropertiesFactory;
 25  
 
 26  
 /**
 27  
  * Factory to create instances of {@link PropertiesConfigurationProperties}.
 28  
  * <p>
 29  
  * This implementation fetches the properties information from the classpath
 30  
  * available at runtime. Therefore the environment identifier of the passed in
 31  
  * configuration key is irrelevant to this implementation, since the environment
 32  
  * is always the local runtime of the node it is running on.
 33  
  * </p>
 34  
  */
 35  0
 @ThreadSafe
 36  
 public final class PropertiesConfigurationPropertiesFactory extends
 37  
     AbstractConfigurationPropertiesFactory<PropertiesConfigurationProperties>
 38  
 {
 39  
   // ********************************* Fields *********************************
 40  
 
 41  
   // --- constants ------------------------------------------------------------
 42  
 
 43  
   /**
 44  
    * The class version identifier.
 45  
    */
 46  
   private static final long serialVersionUID = 1L;
 47  
 
 48  
   // --- members --------------------------------------------------------------
 49  
 
 50  
   // ****************************** Initializer *******************************
 51  
 
 52  
   // ****************************** Constructors ******************************
 53  
 
 54  
   /**
 55  
    * Default constructor.
 56  
    */
 57  
   public PropertiesConfigurationPropertiesFactory()
 58  0
   {
 59  0
   }
 60  
 
 61  
   // ****************************** Inner Classes *****************************
 62  
 
 63  
   // ********************************* Methods ********************************
 64  
 
 65  
   // --- init -----------------------------------------------------------------
 66  
 
 67  
   // --- get&set --------------------------------------------------------------
 68  
 
 69  
   // --- business -------------------------------------------------------------
 70  
 
 71  
   /**
 72  
    * Creates a configuration properties instance for an artificial environment.
 73  
    *
 74  
    * @param applicationId the identifier of the application whose properties are
 75  
    *          to be created.
 76  
    * @return the requested configuration properties. Never <code>null</code>.
 77  
    * @throws NullPointerException if {@code applicationId} is <code>null</code>.
 78  
    * @throws ConfigurationException on any problem loading the configuration
 79  
    *           properties.
 80  
    */
 81  
   public PropertiesConfigurationProperties create(
 82  
       final ApplicationId applicationId) throws NullPointerException,
 83  
     ConfigurationException
 84  
   {
 85  0
     final ConfigurationKey<?> key = createKey(applicationId);
 86  0
     return createManagement(key);
 87  
   }
 88  
 
 89  
   private static ConfigurationKey<?> createKey(final ApplicationId applicationId)
 90  
   {
 91  0
     return ConfigurationKeyContextManager.INSTANCE.context()
 92  
         .configurationKeyFactory().createKey(applicationId);
 93  
   }
 94  
 
 95  
   /**
 96  
    * Creates a configuration properties management instance for an artificial
 97  
    * environment.
 98  
    *
 99  
    * @param applicationId the identifier of the application whose properties are
 100  
    *          to be created.
 101  
    * @return the requested configuration properties. Never <code>null</code>.
 102  
    * @throws NullPointerException if {@code applicationId} is <code>null</code>.
 103  
    * @throws ConfigurationException on any problem loading the configuration
 104  
    *           properties.
 105  
    */
 106  
   public PropertiesConfigurationProperties createManagement(
 107  
       final ApplicationId applicationId) throws NullPointerException,
 108  
     ConfigurationException
 109  
   {
 110  0
     final ConfigurationKey<?> key = createKey(applicationId);
 111  0
     return createManagement(key);
 112  
   }
 113  
 
 114  
   @Override
 115  
   protected PropertiesConfigurationProperties createNewConfiguration(
 116  
       final ConfigurationKey<?> key) throws NullPointerException,
 117  
     ConfigurationException
 118  
   {
 119  0
     final PropertiesConfigurationProperties config =
 120  
         new PropertiesConfigurationProperties(key, getRegistry(),
 121  
             getFactoryConfiguration().getDecrypter());
 122  0
     return config;
 123  
   }
 124  
 
 125  
   // --- object basics --------------------------------------------------------
 126  
 
 127  
 }