Repository: logging-log4j2 Updated Branches: refs/heads/master c67ed221a -> 0b1c77d35
Comment. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0b1c77d3 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0b1c77d3 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0b1c77d3 Branch: refs/heads/master Commit: 0b1c77d355a9dc4a687cffae3901881eb3d9cfef Parents: c67ed22 Author: ggregory <[email protected]> Authored: Mon Aug 22 10:20:36 2016 -0700 Committer: ggregory <[email protected]> Committed: Mon Aug 22 10:20:36 2016 -0700 ---------------------------------------------------------------------- .../core/selector/BasicContextSelector.java | 131 ++++++++++--------- 1 file changed, 66 insertions(+), 65 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0b1c77d3/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java index 4b2c74a..502084d 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/selector/BasicContextSelector.java @@ -1,65 +1,66 @@ -/* - * 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.logging.log4j.core.selector; - -import java.net.URI; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.apache.logging.log4j.core.LoggerContext; -import org.apache.logging.log4j.core.impl.ContextAnchor; - -/** - * Returns either this Thread's context or the default LoggerContext. - */ -public class BasicContextSelector implements ContextSelector { - - private static final LoggerContext CONTEXT = new LoggerContext("Default"); - - @Override - public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext) { - - final LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get(); - return ctx != null ? ctx : CONTEXT; - } - - - @Override - public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext, - final URI configLocation) { - - final LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get(); - return ctx != null ? ctx : CONTEXT; - } - - public LoggerContext locateContext(final String name, final String configLocation) { - return CONTEXT; - } - - @Override - public void removeContext(final LoggerContext context) { - } - - @Override - public List<LoggerContext> getLoggerContexts() { - final List<LoggerContext> list = new ArrayList<>(); - list.add(CONTEXT); - return Collections.unmodifiableList(list); - } - -} +/* + * 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.logging.log4j.core.selector; + +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.impl.ContextAnchor; + +/** + * Returns either this Thread's context or the default LoggerContext. + */ +public class BasicContextSelector implements ContextSelector { + + private static final LoggerContext CONTEXT = new LoggerContext("Default"); + + @Override + public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext) { + + final LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get(); + return ctx != null ? ctx : CONTEXT; + } + + + @Override + public LoggerContext getContext(final String fqcn, final ClassLoader loader, final boolean currentContext, + final URI configLocation) { + + final LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get(); + return ctx != null ? ctx : CONTEXT; + } + + public LoggerContext locateContext(final String name, final String configLocation) { + return CONTEXT; + } + + @Override + public void removeContext(final LoggerContext context) { + // does not remove anything + } + + @Override + public List<LoggerContext> getLoggerContexts() { + final List<LoggerContext> list = new ArrayList<>(); + list.add(CONTEXT); + return Collections.unmodifiableList(list); + } + +}
