Do not use ListenerRegistration
[mdsal.git] / trace / mdsal-trace-impl / src / main / java / org / opendaylight / mdsal / trace / impl / AbstractCloseTracked.java
1 /*
2  * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.trace.impl;
9
10 import org.eclipse.jdt.annotation.Nullable;
11
12 /**
13  * Convenience abstract base class for {@link CloseTracked} implementors.
14  *
15  * @author Michael Vorburger.ch
16  */
17 abstract class AbstractCloseTracked<T extends AbstractCloseTracked<T>> implements CloseTracked<T> {
18     private final CloseTrackedTrait<T> closeTracker;
19
20     AbstractCloseTracked(CloseTrackedRegistry<T> transactionChainRegistry) {
21         this.closeTracker = new CloseTrackedTrait<>(transactionChainRegistry, this);
22     }
23
24     protected void removeFromTrackedRegistry() {
25         closeTracker.removeFromTrackedRegistry();
26     }
27
28     @Override
29     public @Nullable StackTraceElement[] getAllocationContextStackTrace() {
30         return closeTracker.getAllocationContextStackTrace();
31     }
32
33     @Override
34     public final CloseTracked<T> getRealCloseTracked() {
35         return this;
36     }
37 }