summaryrefslogtreecommitdiffstats
path: root/policy-utils
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-06-22 17:17:28 -0500
committerJorge Hernandez <jh1730@att.com>2017-06-22 17:17:28 -0500
commit8f61e18ef0457745719f05bd5c186992a7155416 (patch)
tree884f4653f957a88a65ea981727dfe26494fb7c55 /policy-utils
parent3cc1a85a832771cb70ed9cbaab9031bc4a114308 (diff)
[POLICY-30] remove problematic layers
add configurability through telemetry API Change-Id: I77ebde12a417d421b98646c32dc74824f4494c2e Signed-off-by: Jorge Hernandez <jh1730@att.com>
Diffstat (limited to 'policy-utils')
-rw-r--r--policy-utils/pom.xml37
-rw-r--r--policy-utils/src/main/java/org/openecomp/policy/drools/utils/OrderedServiceImpl.java8
-rw-r--r--policy-utils/src/main/java/org/openecomp/policy/drools/utils/PropertyUtil.java18
-rw-r--r--policy-utils/src/main/java/org/openecomp/policy/drools/utils/ReflectionUtil.java22
-rw-r--r--policy-utils/src/test/java/org/openecomp/policy/drools/utils/PropertyUtilTest.java26
-rw-r--r--policy-utils/src/test/resources/log4j.properties26
6 files changed, 34 insertions, 103 deletions
diff --git a/policy-utils/pom.xml b/policy-utils/pom.xml
index 509e293c..108d66d7 100644
--- a/policy-utils/pom.xml
+++ b/policy-utils/pom.xml
@@ -32,44 +32,17 @@
</parent>
- <dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.17</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.att.eelf</groupId>
- <artifactId>eelf-core</artifactId>
- <version>0.0.1</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.6</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.policy.common</groupId>
- <artifactId>ECOMP-Logging</artifactId>
- <version>${common-modules.version}</version>
- </dependency>
</dependencies>
diff --git a/policy-utils/src/main/java/org/openecomp/policy/drools/utils/OrderedServiceImpl.java b/policy-utils/src/main/java/org/openecomp/policy/drools/utils/OrderedServiceImpl.java
index c5f9a343..72bf7b8b 100644
--- a/policy-utils/src/main/java/org/openecomp/policy/drools/utils/OrderedServiceImpl.java
+++ b/policy-utils/src/main/java/org/openecomp/policy/drools/utils/OrderedServiceImpl.java
@@ -27,12 +27,18 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ServiceLoader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* This class is a template for building a sorted list of service instances,
* which are discovered and created using 'ServiceLoader'.
*/
public class OrderedServiceImpl<T extends OrderedService>
{
+ // logger
+ private static Logger logger = LoggerFactory.getLogger(OrderedServiceImpl.class);
+
// sorted list of instances implementing the service
private List<T> implementers = null;
@@ -113,7 +119,7 @@ public class OrderedServiceImpl<T extends OrderedService>
// create an unmodifiable version of this list
implementers = Collections.unmodifiableList(tmp);
- System.out.println("***** OrderedServiceImpl implementers:\n" + implementers);
+ logger.info("***** OrderedServiceImpl implementers:\n {}", implementers);
return(implementers);
}
diff --git a/policy-utils/src/main/java/org/openecomp/policy/drools/utils/PropertyUtil.java b/policy-utils/src/main/java/org/openecomp/policy/drools/utils/PropertyUtil.java
index 34ddcc1c..1e8dc267 100644
--- a/policy-utils/src/main/java/org/openecomp/policy/drools/utils/PropertyUtil.java
+++ b/policy-utils/src/main/java/org/openecomp/policy/drools/utils/PropertyUtil.java
@@ -382,22 +382,4 @@ public class PropertyUtil
stopListening(new File(fileName), listener);
}
- /* ============================================================ */
-
- // TEMPORARY - used to test callback interface
- static public class Test implements Listener
- {
- String name;
-
- public Test(String name)
- {
- this.name = name;
- }
-
- public void propertiesChanged(Properties properties, Set<String> changedKeys)
- {
- System.out.println("Test(" + name + ")\nproperties = " + properties
- + "\nchangedKeys = " + changedKeys);
- }
- }
}
diff --git a/policy-utils/src/main/java/org/openecomp/policy/drools/utils/ReflectionUtil.java b/policy-utils/src/main/java/org/openecomp/policy/drools/utils/ReflectionUtil.java
index 1ab68282..0d82e847 100644
--- a/policy-utils/src/main/java/org/openecomp/policy/drools/utils/ReflectionUtil.java
+++ b/policy-utils/src/main/java/org/openecomp/policy/drools/utils/ReflectionUtil.java
@@ -23,43 +23,41 @@
*/
package org.openecomp.policy.drools.utils;
-import org.openecomp.policy.common.logging.eelf.PolicyLogger;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Reflection utilities
*
*/
public class ReflectionUtil {
+ protected final static Logger logger = LoggerFactory.getLogger(ReflectionUtil.class);
+
/**
* returns (if exists) a class fetched from a given classloader
*
* @param classLoader the class loader
- * @param classname the class name
+ * @param className the class name
* @return the actual class
* @throws IllegalArgumentException if an invalid parameter has been passed in
*/
public static Class<?> fetchClass(ClassLoader classLoader,
- String classname)
+ String className)
throws IllegalArgumentException {
-
- PolicyLogger.info("FETCH-CLASS: " + classname + " FROM " + classLoader);
-
if (classLoader == null)
throw new IllegalArgumentException("A class loader must be provided");
- if (classname == null)
+ if (className == null)
throw new IllegalArgumentException("A class name to be fetched in class loader " +
classLoader + " must be provided");
try {
- Class<?> aClass = Class.forName(classname,
+ Class<?> aClass = Class.forName(className,
true,
classLoader);
return aClass;
} catch (Exception e) {
- e.printStackTrace();
- PolicyLogger.error("FETCH-CLASS: " + classname + " IN " + classLoader + " does NOT exist");
+ logger.error("FETCHED-CLASS {} IN {} does NOT EXIST", className, classLoader);
}
return null;
@@ -84,8 +82,6 @@ public class ReflectionUtil {
* @return
*/
public static boolean isSubclass(Class<?> parent, Class<?> presumedSubclass) {
- PolicyLogger.debug("IS-SUBCLASS: superclass: " + parent.getCanonicalName() +
- " subclass: " + presumedSubclass.getCanonicalName());
return (parent.isAssignableFrom(presumedSubclass));
}
diff --git a/policy-utils/src/test/java/org/openecomp/policy/drools/utils/PropertyUtilTest.java b/policy-utils/src/test/java/org/openecomp/policy/drools/utils/PropertyUtilTest.java
index 32386725..b45f1b45 100644
--- a/policy-utils/src/test/java/org/openecomp/policy/drools/utils/PropertyUtilTest.java
+++ b/policy-utils/src/test/java/org/openecomp/policy/drools/utils/PropertyUtilTest.java
@@ -34,12 +34,12 @@ import java.util.UUID;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.openecomp.policy.common.logging.eelf.PolicyLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class PropertyUtilTest
{
- // private static final Logger PolicyLogger =
-// Logger.getLogger(PropertyUtilTest.class.getName());
+ private final static Logger logger = LoggerFactory.getLogger(PropertyUtilTest.class);
private static File directory = null;
@@ -49,7 +49,7 @@ public class PropertyUtilTest
@BeforeClass
static public void setup()
{
- PolicyLogger.info("setup: creating a temporary directory");
+ logger.info("setup: creating a temporary directory");
// create a directory for temporary files
directory = new File(UUID.randomUUID().toString());
@@ -62,7 +62,7 @@ public class PropertyUtilTest
@AfterClass
static public void teardown()
{
- PolicyLogger.info("teardown: remove the temporary directory");
+ logger.info("teardown: remove the temporary directory");
// the assumption is that we only have one level of temporary files
for (File file : directory.listFiles())
@@ -114,7 +114,7 @@ public class PropertyUtilTest
{
// When a notification is received, store the values in the
// 'returns' array, and signal using the same array.
- PolicyLogger.info("Listener invoked: properties=" + properties
+ logger.info("Listener invoked: properties=" + properties
+ ", changedKeys=" + changedKeys);
returns[0] = properties;
returns[1] = changedKeys;
@@ -132,15 +132,15 @@ public class PropertyUtilTest
@Test
public void testGetProperties() throws Exception
{
- PolicyLogger.info("testGetProperties: test the basic properties file interface");
+ logger.info("testGetProperties: test the basic properties file interface");
// copy system properties
- PolicyLogger.info("Copy system properties to a file");
+ logger.info("Copy system properties to a file");
Properties prop1 = System.getProperties();
File file1 = createFile("createAndReadPropertyFile-1", prop1);
// read in properties, and compare
- PolicyLogger.info("Read in properties from new file");
+ logger.info("Read in properties from new file");
Properties prop2 = PropertyUtil.getProperties(file1);
// they should match
@@ -153,14 +153,14 @@ public class PropertyUtilTest
@Test
public void testListenerInterface() throws Exception
{
- PolicyLogger.info("testListenerInterface: test receipt of dynamic updates");
+ logger.info("testListenerInterface: test receipt of dynamic updates");
// create initial property file
Properties prop1 = new Properties();
prop1.setProperty("p1", "p1 value");
prop1.setProperty("p2", "p2 value");
prop1.setProperty("p3", "p3 value");
- PolicyLogger.info("Create initial properties file: " + prop1);
+ logger.info("Create initial properties file: " + prop1);
File file1 = createFile("createAndReadPropertyFile-2", prop1);
// create a listener for the notification interface
@@ -169,7 +169,7 @@ public class PropertyUtilTest
// read it in, and do a comparison
Properties prop2 = PropertyUtil.getProperties(file1, listener);
- PolicyLogger.info("Read in properties: " + prop2);
+ logger.info("Read in properties: " + prop2);
assertEquals(prop1, prop2);
assertEquals(prop2.getProperty("p1"), "p1 value");
assertEquals(prop2.getProperty("p2"), "p2 value");
@@ -179,7 +179,7 @@ public class PropertyUtilTest
prop2.remove("p1"); // remove one property
prop2.setProperty("p2", "new p2 value"); // change one property
prop2.setProperty("p4", "p4 value"); // add a new property
- PolicyLogger.info("Modified properties: " + prop2);
+ logger.info("Modified properties: " + prop2);
// now, update the file, and wait for notification
synchronized(returns)
diff --git a/policy-utils/src/test/resources/log4j.properties b/policy-utils/src/test/resources/log4j.properties
deleted file mode 100644
index 0063f104..00000000
--- a/policy-utils/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# policy-utils
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
-# ================================================================================
-# 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.
-# ============LICENSE_END=========================================================
-###
-
-log4j.rootLogger=INFO, out
-
-# CONSOLE appender not used by default
-log4j.appender.out=org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d %-5p %-30.30c{1} %4L - %m%n