/*******************************************************************************
 * Copyright (c) 2011, 2016 Eurotech and/or its affiliates and others
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Eurotech - initial API and implementation
 *
 *******************************************************************************/
package org.eclipse.kapua.locator.guice;

import com.google.inject.ConfigurationException;
import org.eclipse.kapua.KapuaRuntimeException;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.locator.KapuaLocatorErrorCodes;
import org.eclipse.kapua.model.KapuaObjectFactory;
import org.eclipse.kapua.service.KapuaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Guice;
import com.google.inject.Injector;

/**
 * Kapua locator implementation bases on Guice framework
 * 
 * @since 1.0
 * 
 */
public class GuiceLocatorImpl extends KapuaLocator {

    private static final Logger logger = LoggerFactory.getLogger(GuiceLocatorImpl.class);

    private static Injector s_injector = null;

    static {
        try {
            s_injector = Guice.createInjector(new KapuaModule());
        } catch (Throwable e) {
            logger.error("Cannot instantiate injector {}", e.getMessage(), e);
            throw e;
        }
    }

    @Override
    public <S extends KapuaService> S getService(Class<S> serviceClass) {
        try {
            return s_injector.getInstance(serviceClass);
        } catch (ConfigurationException e) {
            throw new KapuaRuntimeException(KapuaLocatorErrorCodes.SERVICE_UNAVAILABLE, serviceClass);
        }
    }

    @Override
    public <F extends KapuaObjectFactory> F getFactory(Class<F> factoryClass) {
        F kapuaEntityFactory = s_injector.getInstance(factoryClass);
        if (kapuaEntityFactory == null) {
            throw new KapuaRuntimeException(KapuaLocatorErrorCodes.SERVICE_UNAVAILABLE, factoryClass);
        }

        return kapuaEntityFactory;
    }
}

@@ -104,9 +104,9 @@
  201
-6
+7
  Eur
@@ -462,16 +462,35 @@
 ntation%0A
+ *     Red Hat Inc%0A
  *%0A ****
@@ -1284,16 +1284,22 @@
  static 
+final 
 Injector
@@ -1299,26 +1299,24 @@
 njector 
-s_
 injector
  = null;
@@ -1311,15 +1311,8 @@
 ctor
- = null
 ;%0A%0A 
@@ -1349,18 +1349,16 @@
         
-s_
 injector
@@ -1671,18 +1671,16 @@
  return 
-s_
 injector
@@ -2001,10 +2001,8 @@
 y = 
-s_
 inje
@@ -2025,32 +2025,33 @@
 (factoryClass);%0A
+%0A
         if (kapu

Make a final static variable and fix naming