Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2013 Kametic <epo.jemba@kametic.com> Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; or any later version you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.gnu.org/licenses/lgpl-3.0.txt Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.nuunframework.configuration.common;
 
 import java.io.File;
 import java.util.Map;
 
 
 
 
 {
 
     Logger logger = LoggerFactory.getLogger(PropsConfigurationPlugin.class);
     
     private Module module = null;
 
     private Props props = null;
 
     
     public PropsConfigurationPlugin()
     {
     }
     
     @Override
     public void addConfiguration(Map<StringObjectconfiguration)
     {
         Properties p = new Properties();
         p.putAll(configuration);
     	.load(p);
     	
     }
     
     @Override
     public Object getConfiguration()
     {
         return ;
     }
 
     @Override
     public String name()
     {
         return "nuun-props-configuration-plugin";
     }
     
     
     @Override
     public Module dependencyInjectionDef()
     {
         if ( == null )
         {
              = new PropsConfigurationGuiceModule();
         }
         return ;
     }
     
     
     @Override
     public InitState init(InitContext initContext)
     {
      // find all properties classes in the classpath
         Collection<StringpropertiesFiles = initContext.propertiesFiles();
 
          = new Props();
         
         for (String propertiesFile : propertiesFiles)
         {
             .info("adding {} to configuration"propertiesFile);
             
             try
             {
                 InputStream resourceAsStream = Thread.currentThread().getContextClassLoader().getResourceAsStreampropertiesFile);
                
                .load(resourceAsStream);
            }
            catch (IOException e)
            {
                throw new PluginException("Error When loading properties file " + propertiesFile);
            }
        }
        
        
        return .;
    }
    
    
New to GrepCode? Check out our FAQ X