package org.nnsoft.guice.autobind.configuration;

/*
 *    Copyright 2012 The 99 Software Foundation
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    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.
 */

import static java.util.logging.Level.WARNING;
import static java.util.logging.Logger.getLogger;

import java.net.URL;
import java.util.Properties;
import java.util.logging.Logger;

import javax.inject.Provider;

public class PropertiesProvider
    implements Provider<Properties>
{

    private final Logger _logger = getLogger( getClass().getName() );

    private URL url;

    private boolean isXML;

    public PropertiesProvider( URL url, boolean isXML )
    {
        super();
        this.url = url;
        this.isXML = isXML;
    }

    @Override
    public Properties get()
    {
        try
        {
            _logger.info( "Doing lazy Loading for Configuration " + url );
            return new PropertiesReader( url, isXML ).readNative();
        }
        catch ( Exception e )
        {
            _logger.log( WARNING, "Configuration in " + url + " couldn't be read.", e );
            return new Properties();
        }
    }

}

@@ -683,16 +683,55 @@
 e.%0A */%0A%0A
+import static java.lang.String.format;%0A
 import s
@@ -1360,16 +1360,24 @@
 er.info(
+ format(
  %22Doing 
@@ -1407,23 +1407,26 @@
 uration 
-%22 +
+%25s%22,
  url
+ )
  );%0A    
@@ -1572,16 +1572,24 @@
 WARNING,
+ format(
  %22Config
@@ -1603,19 +1603,10 @@
  in 
-%22 + url + %22
+%25s
  cou
@@ -1621,16 +1621,22 @@
  read.%22,
+ url),
  e );%0A  

avoid string concatenation