package org.opendaylight.dlux.loader;
import com.google.common.base.Preconditions;
+import org.osgi.service.http.HttpService;
import org.osgi.service.http.NamespaceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.osgi.service.http.HttpService;
/**
* At startup of each karaf bundle, each UI module creates an instance of this class
public class DluxModule extends Module {
- final static Logger logger = LoggerFactory.getLogger(DluxModule.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DluxModule.class);
/**
* http Service is required to register resources for the specified url.
*/
private HttpService httpService;
/**
- * loader to enable this module with dlux
+ * loader to enable this module with dlux.
*/
private DluxModuleLoader loader;
Preconditions.checkNotNull(url, "module url is missing. Module can not be instantiated");
Preconditions.checkNotNull(directory, "resource directory is missing. Module can not be instantiated");
- logger.info("Registering resources for url {}", url);
+ LOG.info("Registering resources for url {}", url);
try {
httpService.registerResources(url, directory, null);
} catch (NamespaceException e) {
- logger.error("Exception occurred while registering resources with http service.", e);
+ LOG.error("Exception occurred while registering resources with http service.", e);
}
- if(loader != null) {
- Preconditions.checkNotNull(moduleName, "module name is missing. Module can not be registered with dlux");
- Preconditions.checkNotNull(requireJs, "requireJs module name is missing. Module can not be registered with dlux");
- Preconditions.checkNotNull(angularJs, "angularJs module name is missing. Module can not be registered with dlux");
- logger.info("Registering angularJS and requireJs modules for {}", moduleName);
+ if (loader != null) {
+ Preconditions.checkNotNull(moduleName,
+ "module name is missing. Module can not be registered with dlux");
+ Preconditions.checkNotNull(requireJs,
+ "requireJs module name is missing. Module can not be registered with dlux");
+ Preconditions.checkNotNull(angularJs,
+ "angularJs module name is missing. Module can not be registered with dlux");
+ LOG.info("Registering angularJS and requireJs modules for {}", moduleName);
loader.addModule(this);
}
}
public void clean() {
- logger.info("Unregistering resources for url {}", url);
+ LOG.info("Unregistering resources for url {}", url);
httpService.unregister(url);
- if(loader != null) {
+ if (loader != null) {
loader.removeModule(this);
}
}
*/
public interface DluxModuleLoader {
- public void addModule(Module module);
+ void addModule(Module module);
- public void removeModule(Module module);
+ void removeModule(Module module);
}
/**
* Copyright (c) 2014 Inocybe Technologies, and others. All rights reserved.
*
+ * <p>
* 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
public abstract class Module {
/**
- * Name of the dlux module
+ * Name of the dlux module.
*/
String moduleName;
/**
- * url via the module can be accessed
+ * url via the module can be accessed.
*/
String url;
/**
- * Location of resources to be registered
+ * Location of resources to be registered.
*/
String directory;
/**
- * Name of the your requireJS module
+ * Name of the your requireJS module.
*/
String requireJs;
/**
- * Name of the angularJs module
+ * Name of the angularJs module.
*/
String angularJs;
/**
- * List of external or internal css dependencies
+ * List of external or internal css dependencies.
*/
List<String> cssDependencies;
public class DluxLoader implements DluxModuleLoader {
private DluxLoaderIndexServlet index;
- private static Logger logger = LoggerFactory.getLogger(DluxLoader.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DluxLoader.class);
/**
* List of modules registered with dlux
index = new DluxLoaderIndexServlet(this);
httpService.registerServlet(SERVLET_URL, index, null, null);
httpService.registerResources(RESOURCE_URL, RESOURCE_DIRECTORY, null);
- logger.info("DluxLoader Service initialization complete.");
+ LOG.info("DluxLoader Service initialization complete.");
}
}
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.opendaylight.dlux.loader.Module;
import org.opendaylight.dlux.loader.exception.DluxLoaderException;
import org.slf4j.Logger;
public class DluxLoaderIndexServlet extends HttpServlet{
private static final long serialVersionUID = 1L;
- private static Logger logger = LoggerFactory.getLogger(DluxLoaderIndexServlet.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DluxLoaderIndexServlet.class);
private String DEFINEJS_PROPERTY = "defineJS";
private final String NEWLINE = "\n";
+ @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "Maintenance Update")
private final DluxLoader loader;
private final String UTF_CHARSET = "UTF-8";
prop.load(inputStream);
} catch (IOException e) {
- logger.error("Could not load properties from input stream", e);
+ LOG.error("Could not load properties from input stream", e);
throw new DluxLoaderException("Dlux Loader Servlet initialization failed. ", e);
}
return prop;
}
} catch (IOException e) {
- logger.error("Could not load index html from input stream", e);
+ LOG.error("Could not load index html from input stream", e);
throw new DluxLoaderException("Dlux Loader Servlet initialization failed. ", e);
}
return indexHTMLContent;