1 package org.e2etrace.trace; 2 3 /* 4 * Copyright 2006 Gunther Popp 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 /** 20 * Default implementation of a trace session manager. 21 * <p> 22 * 23 * This simple trace session manager maintains a single trace session. Hence, it 24 * is only suitable for monitoring sequential service execution in an 25 * application. This approach does <em>not</em> work in application server 26 * environments! 27 * <p> 28 * 29 * This class implements the singleton pattern. 30 * <p> 31 * 32 * @author Gunther Popp 33 * 34 */ 35 public class DefaultTraceSessionManager extends AbstractTraceSessionManager { 36 37 private static final DefaultTraceSessionManager instance = new DefaultTraceSessionManager(); 38 39 private ITraceSession session; 40 41 /** 42 * Returns the singleton instance of the session manager. 43 * <p> 44 * 45 * @return trace session manager 46 */ 47 public static DefaultTraceSessionManager getInstance() { 48 return instance; 49 } 50 51 /** 52 * Default constructor. 53 * <p> 54 * 55 */ 56 private DefaultTraceSessionManager() { 57 super(); 58 } 59 60 /** {@inheritDoc} */ 61 protected ITraceSession requestCurrentSession() { 62 return this.session; 63 } 64 65 /** {@inheritDoc} */ 66 protected void assignCurrentSession(ITraceSession session) { 67 this.session = session; 68 } 69 70 /** {@inheritDoc} */ 71 public void releaseCurrentSession() { 72 this.session = null; 73 } 74 75 }