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.api.config.domain.key.EnvironmentId;
 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 class path
 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 new ConfigurationKey(EnvironmentId.ANY_ENV, applicationId);
 92  
   }
 93  
 
 94  
   /**
 95  
    * Creates a configuration properties management instance for an artificial
 96  
    * environment.
 97  
    *
 98  
    * @param applicationId the identifier of the application whose properties are
 99  
    *          to be created.
 100  
    * @return the requested configuration properties. Never <code>null</code>.
 101  
    * @throws NullPointerException if {@code applicationId} is <code>null</code>.
 102  
    * @throws ConfigurationException on any problem loading the configuration
 103  
    *           properties.
 104  
    */
 105  
   public PropertiesConfigurationProperties createManagement(
 106  
       final ApplicationId applicationId) throws NullPointerException,
 107  
     ConfigurationException
 108  
   {
 109  0
     final ConfigurationKey key = createKey(applicationId);
 110  0
     return createManagement(key);
 111  
   }
 112  
 
 113  
   @Override
 114  
   protected PropertiesConfigurationProperties createNewConfiguration(
 115  
       final ConfigurationKey key) throws NullPointerException,
 116  
     ConfigurationException
 117  
   {
 118  0
     final PropertiesConfigurationProperties config =
 119  
         new PropertiesConfigurationProperties(key, getRegistry());
 120  0
     return config;
 121  
   }
 122  
 
 123  
   // --- object basics --------------------------------------------------------
 124  
 
 125  
 }