pkriens commented on a change in pull request #36: URL: https://github.com/apache/felix-dev/pull/36#discussion_r468360257
########## File path: scr/src/main/java/org/apache/felix/scr/impl/logger/LogManager.java ########## @@ -0,0 +1,203 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.apache.felix.scr.impl.logger; + +import java.io.Closeable; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleEvent; +import org.osgi.framework.BundleListener; +import org.osgi.framework.ServiceReference; +import org.osgi.service.log.Logger; +import org.osgi.service.log.LoggerFactory; +import org.osgi.util.tracker.ServiceTracker; + +/* + * A class that tracks the LoggerFactory of a bundle and its associated Logger objects. + * When a bundle is stopped and/or the service is unregistered, the logger objects are cleaned. + * + * The basic technique is to use a facade. Instead of returning a log object, we return a facade. The + * methods delegate to the actual logger object. If there is no logger object, we create one. + * + * The LogDomain represents every bundle. Per LogDomain, we keep the facades. If the factory goes, + * we reset the facades. + */ +class LogManager extends ServiceTracker<LoggerFactory, LoggerFactory> { Review comment: I'd rather keep it separate for cohesion. The LogManager is the part that handles the life cycle and could theoretically be used in other projects. The ScrLogManager handles the interface to SCR. The life cycle is tricky as it is and combining it with the oddities of SCR makes it way more complicated than separating these parts. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
