DebugFileProviderImpl.java revision 10165d7e4cd84a62ad539bbc21526ff549137fc1
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL * The contents of this file are subject to the terms of the Common Development and
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL * Distribution License (the License). You may not use this file except in compliance with the
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL * specific language governing permission and limitations under the License.
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL * When distributing Covered Software, include this CDDL Header Notice in each file and include
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL * Header, with the fields enclosed by brackets [] replaced by your own identifying
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL * information: "Portions copyright [year] [name of copyright owner]".
ce2e2c2c7126b18ccfce0fe69a3bfa2eafea68b7Quentin CASTEL * Copyright 2014-2015 ForgeRock AS.
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTELpackage com.sun.identity.shared.debug.file.impl;
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTELimport com.sun.identity.shared.debug.DebugConstants;
ce2e2c2c7126b18ccfce0fe69a3bfa2eafea68b7Quentin CASTELimport com.sun.identity.shared.debug.file.DebugConfiguration;
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTELimport com.sun.identity.shared.debug.file.DebugFile;
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTELimport com.sun.identity.shared.debug.file.DebugFileProvider;
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL * Debug file provider
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL * Manage Debug files controller
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL * Keep the following constraint one :
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL * - One debugFile instance for One log file
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTELpublic class DebugFileProviderImpl implements DebugFileProvider {
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL private Map<String, DebugFile> debugMap = new HashMap<String, DebugFile>();
ce2e2c2c7126b18ccfce0fe69a3bfa2eafea68b7Quentin CASTEL * Default constructor
ce2e2c2c7126b18ccfce0fe69a3bfa2eafea68b7Quentin CASTEL this.configuration = new DebugConfigurationFromProperties(DebugConstants.CONFIG_DEBUG_PROPERTIES);
ce2e2c2c7126b18ccfce0fe69a3bfa2eafea68b7Quentin CASTEL } catch (InvalidDebugConfigurationException e) {
ce2e2c2c7126b18ccfce0fe69a3bfa2eafea68b7Quentin CASTEL StdDebugFile.printError("DebugConfiguration", "'" + DebugConstants.CONFIG_DEBUG_PROPERTIES +
ce2e2c2c7126b18ccfce0fe69a3bfa2eafea68b7Quentin CASTEL "isn't valid, the default configuration will be used instead.", e);
ce2e2c2c7126b18ccfce0fe69a3bfa2eafea68b7Quentin CASTEL this.configuration = DefaultDebugConfiguration.getInstance();
ce2e2c2c7126b18ccfce0fe69a3bfa2eafea68b7Quentin CASTEL * Get debug file instance
ce2e2c2c7126b18ccfce0fe69a3bfa2eafea68b7Quentin CASTEL * @param debugName name of the debug instance which will be returned.
ce2e2c2c7126b18ccfce0fe69a3bfa2eafea68b7Quentin CASTEL * @return debug file
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL public synchronized DebugFile getInstance(String debugName) {
5e89746cb5bec21d15a044ce89cfcdbf99d3d49dQuentin CASTEL DebugFile debugFile = debugMap.get(debugName);
10165d7e4cd84a62ad539bbc21526ff549137fc1Quentin CASTEL debugFile = new DebugFileImpl(configuration, debugName);
ce2e2c2c7126b18ccfce0fe69a3bfa2eafea68b7Quentin CASTEL * Get std out debug file
ce2e2c2c7126b18ccfce0fe69a3bfa2eafea68b7Quentin CASTEL * @return debug file