Skip to content

Commit ca77f61

Browse files
committed
felix.log: Clean up.
1 parent 87aeb3d commit ca77f61

14 files changed

+32
-27
lines changed

log/src/main/java/org/apache/felix/log/Activator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private static boolean getStoreDebug(final BundleContext context)
112112
String storeDebugPropValue = context.getProperty(STORE_DEBUG_PROPERTY);
113113
if (storeDebugPropValue != null)
114114
{
115-
storeDebug = Boolean.valueOf(storeDebugPropValue).booleanValue();
115+
storeDebug = Boolean.parseBoolean(storeDebugPropValue);
116116
}
117117

118118
return storeDebug;

log/src/main/java/org/apache/felix/log/ConfigurationListenerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class ConfigurationListenerImpl {
5252
final Log m_log;
5353
final LoggerAdminImpl m_loggerAdmin;
5454

55-
public ConfigurationListenerImpl(final BundleContext context, final Log log, final LoggerAdminImpl loggerAdmin) throws Exception {
55+
ConfigurationListenerImpl(final BundleContext context, final Log log, final LoggerAdminImpl loggerAdmin) throws Exception {
5656
m_context = context;
5757
m_log = log;
5858
m_loggerAdmin = loggerAdmin;

log/src/main/java/org/apache/felix/log/FormatterLoggerImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626

2727
public class FormatterLoggerImpl extends LoggerImpl implements FormatterLogger {
2828

29-
public FormatterLoggerImpl(
29+
FormatterLoggerImpl(
3030
final String name, final Bundle bundle, final Log log, final LoggerAdminImpl loggerAdmin) {
3131

3232
super(name, bundle, log, loggerAdmin);
3333
}
3434

35+
@Override
3536
String format(String format, LogParameters logParameters) {
3637
StringBuilder sb = new StringBuilder();
3738

log/src/main/java/org/apache/felix/log/Log.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ synchronized Enumeration<LogEntry> getEntries()
206206
"FrameworkEvent STARTED",
207207
"FrameworkEvent ERROR",
208208
"FrameworkEvent PACKAGES REFRESHED",
209-
"FrameworkEvent STARTLEVEL CHANGED",
209+
"FrameworkEvent STARTLEVEL CHANGED",
210210
"FrameworkEvent WARNING",
211211
"FrameworkEvent INFO"
212212
};

log/src/main/java/org/apache/felix/log/LogEntryImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ final class LogEntryImpl implements LogEntry
143143
* @return the bundle that created this LogEntry object;<code>null</code> if no
144144
* bundle is associated with this LogEntry object
145145
*/
146+
@Override
146147
public Bundle getBundle()
147148
{
148149
return m_bundle;
@@ -155,6 +156,7 @@ public Bundle getBundle()
155156
* this LogEntry object; <code>null</code> if no {@link ServiceReference} object
156157
* was provided
157158
*/
159+
@Override
158160
public ServiceReference<?> getServiceReference()
159161
{
160162
return m_serviceReference;
@@ -171,6 +173,7 @@ public ServiceReference<?> getServiceReference()
171173
* @see org.osgi.service.LogService#LOG_INFO
172174
* @see org.osgi.service.LogService#LOG_DEBUG
173175
*/
176+
@Override
174177
public int getLevel()
175178
{
176179
if (m_legacyLevel != m_level.ordinal()) {
@@ -184,6 +187,7 @@ public int getLevel()
184187
* Returns the human readable message associated with this LogEntry object.
185188
* @return a string containing the message associated with this LogEntry object
186189
*/
190+
@Override
187191
public String getMessage()
188192
{
189193
return m_message;
@@ -202,6 +206,7 @@ public String getMessage()
202206
* @return throwable object of the exception associated with this LogEntry;
203207
* <code>null</code> if no exception is associated with this LogEntry object
204208
*/
209+
@Override
205210
public Throwable getException()
206211
{
207212
return m_exception;
@@ -213,6 +218,7 @@ public Throwable getException()
213218
* @return the system time in milliseconds when this LogEntry object was created
214219
* @see System#currentTimeMillis()
215220
*/
221+
@Override
216222
public long getTime()
217223
{
218224
return m_time;

log/src/main/java/org/apache/felix/log/LogListenerThread.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ void shutdown()
106106
* The main method of the thread: waits for new messages to be receieved
107107
* and then delivers them to any registered log listeners.
108108
*/
109+
@Override
109110
public void run()
110111
{
111112
while (!isInterrupted())
@@ -138,10 +139,10 @@ public void run()
138139
{
139140
// Take a snapshot of all current listeners and deliver all
140141
// pending messages to them...
141-
List<LogListener> listeners = new ArrayList<>();
142+
List<LogListener> listeners;
142143
synchronized (m_listeners)
143144
{
144-
listeners.addAll(m_listeners);
145+
listeners = new ArrayList<>(m_listeners);
145146
}
146147

147148
Iterator<LogEntry> entriesIt = entriesToDeliver.iterator();

log/src/main/java/org/apache/felix/log/LogNodeEnumeration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ final class LogNodeEnumeration implements Enumeration<LogEntry>
4848
* Determines whether there are any more elements to return.
4949
* @return <code>true</code> if there are more elements; <code>false</code> otherwise
5050
*/
51+
@Override
5152
public boolean hasMoreElements()
5253
{
5354
return m_next != null;
@@ -57,6 +58,7 @@ public boolean hasMoreElements()
5758
* Returns the current element and moves onto the next element.
5859
* @return the current element
5960
*/
61+
@Override
6062
public LogEntry nextElement()
6163
{
6264
LogEntry result = null;

log/src/main/java/org/apache/felix/log/LogReaderServiceFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ final class LogReaderServiceFactory implements ServiceFactory<LogReaderService>
4747
* @param registration the service registration
4848
* @return the log reader service implementation for the specified bundle
4949
*/
50+
@Override
5051
public LogReaderService getService(final Bundle bundle,
5152
final ServiceRegistration<LogReaderService> registration)
5253
{
@@ -60,6 +61,7 @@ public LogReaderService getService(final Bundle bundle,
6061
* @param registration the service registration
6162
* @param service the service to release
6263
*/
64+
@Override
6365
public void ungetService(final Bundle bundle,
6466
final ServiceRegistration<LogReaderService> registration,
6567
final LogReaderService service)

log/src/main/java/org/apache/felix/log/LogServiceFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class LogServiceFactory implements ServiceFactory<LogService>
3434

3535
/**
3636
* Create a new instance.
37-
* @param log the log to associate the service implementations with.,
37+
* @param loggerAdminImpl
3838
*/
3939
LogServiceFactory(final LoggerAdminImpl loggerAdminImpl)
4040
{

log/src/main/java/org/apache/felix/log/LogServiceImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ final class LogServiceImpl implements LogService
4343

4444
/**
4545
* Create a new instance.
46-
* @param log the log implementation
4746
* @param bundle the bundle associated with this implementation
48-
* @param serviceReference
47+
* @param loggerAdminImpl
4948
*/
5049
LogServiceImpl(final Bundle bundle, final LoggerAdminImpl loggerAdminImpl)
5150
{

log/src/main/java/org/apache/felix/log/LoggerAdminImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class LoggerAdminImpl implements LoggerAdmin {
4444
private final ConcurrentMap<String, LoggerContext> m_contexts = new ConcurrentHashMap<>();
4545
private final ConcurrentMap<LoggerKey, Logger> _loggers = new ConcurrentHashMap<>();
4646

47-
public LoggerAdminImpl(final String defaultLogLevelString, final Log log) {
47+
LoggerAdminImpl(final String defaultLogLevelString, final Log log) {
4848
m_rootContext = new RootLoggerContextImpl(defaultLogLevelString, this);
4949
m_log = log;
5050
}

log/src/main/java/org/apache/felix/log/LoggerContextImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,19 @@ public LoggerContextImpl(String name, LoggerAdminImpl loggerAdminImpl, LoggerCon
4747
_rootContext = rootLoggerContext;
4848
}
4949

50+
@Override
5051
public String getName() {
5152
return _name;
5253
}
5354

55+
@Override
5456
public LogLevel getEffectiveLogLevel(String name) {
5557
_lock.lock();
5658
try {
5759
if (_levels != null && !_levels.isEmpty()) {
5860
String copy = name;
5961
LogLevel level;
60-
while (copy.length() > 0) {
62+
while (!copy.isEmpty()) {
6163
level = _levels.get(copy);
6264
if (level != null) {
6365
return level;
@@ -74,6 +76,7 @@ public LogLevel getEffectiveLogLevel(String name) {
7476
}
7577
}
7678

79+
@Override
7780
public Map<String, LogLevel> getLogLevels() {
7881
_lock.lock();
7982
try {
@@ -87,6 +90,7 @@ public Map<String, LogLevel> getLogLevels() {
8790
}
8891
}
8992

93+
@Override
9094
public void setLogLevels(Map<String, LogLevel> logLevels) {
9195
_lock.lock();
9296
try {
@@ -98,6 +102,7 @@ public void setLogLevels(Map<String, LogLevel> logLevels) {
98102
}
99103
}
100104

105+
@Override
101106
public void clear() {
102107
_lock.lock();
103108
try {
@@ -108,6 +113,7 @@ public void clear() {
108113
}
109114
}
110115

116+
@Override
111117
public boolean isEmpty() {
112118
_lock.lock();
113119
try {

log/src/main/java/org/apache/felix/log/LoggerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ public class LoggerImpl implements Logger {
3636

3737
protected final String m_name;
3838
protected final Bundle m_bundle;
39-
protected final Log m_log;
39+
final Log m_log;
4040
protected final LoggerAdminImpl m_loggerAdmin;
4141

42-
public LoggerImpl(final String name, final Bundle bundle, final Log log, final LoggerAdminImpl loggerAdmin) {
42+
LoggerImpl(final String name, final Bundle bundle, final Log log, final LoggerAdminImpl loggerAdmin) {
4343
m_name = name;
4444
m_bundle = bundle;
4545
m_log = log;

log/src/main/java/org/apache/felix/log/RootLoggerContextImpl.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919

2020
package org.apache.felix.log;
2121

22-
import java.util.Dictionary;
23-
import java.util.Map;
24-
2522
import org.osgi.service.log.LogLevel;
2623
import org.osgi.service.log.Logger;
2724

@@ -45,12 +42,13 @@ public RootLoggerContextImpl(String defaultLogLevelString, LoggerAdminImpl logge
4542
_defaultLevel = defaultLogLevel;
4643
}
4744

45+
@Override
4846
public LogLevel getEffectiveLogLevel(String name) {
4947
_lock.lock();
5048
try {
5149
if (_levels != null && !_levels.isEmpty()) {
5250
LogLevel level;
53-
while (name.length() > 0) {
51+
while (!name.isEmpty()) {
5452
level = _levels.get(name);
5553
if (level != null) {
5654
return level;
@@ -67,16 +65,6 @@ public LogLevel getEffectiveLogLevel(String name) {
6765
}
6866
}
6967

70-
@Override
71-
public void setLogLevels(Map<String, LogLevel> logLevels) {
72-
super.setLogLevels(logLevels);
73-
}
74-
75-
@Override
76-
void updateLoggerContext(Dictionary<String, Object> properties) {
77-
super.updateLoggerContext(properties);
78-
}
79-
8068
private LogLevel getEffectiveRootLogLevel() {
8169
if (_levels == null) return _defaultLevel;
8270
LogLevel logLevel = _levels.get(Logger.ROOT_LOGGER_NAME);

0 commit comments

Comments
 (0)