785e2ef6ae86e1b154c447bc469b636c54582152
[controller.git] / opendaylight / md-sal / mdsal-trace / dom-impl / src / main / java / org / opendaylight / controller / md / sal / trace / closetracker / 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.controller.md.sal.trace.closetracker.impl;
9
10 import javax.annotation.Nullable;
11
12 /**
13  * Convenience abstract base class for {@link CloseTracked} implementors.
14  *
15  * @author Michael Vorburger.ch
16  */
17 public abstract class AbstractCloseTracked<T extends AbstractCloseTracked<T>> implements CloseTracked<T> {
18
19     private final CloseTrackedTrait<T> closeTracker;
20
21     protected AbstractCloseTracked(CloseTrackedRegistry<T> transactionChainRegistry) {
22         this.closeTracker = new CloseTrackedTrait<>(transactionChainRegistry, this);
23     }
24
25     protected void removeFromTrackedRegistry() {
26         closeTracker.removeFromTrackedRegistry();
27     }
28
29     @Override
30     public @Nullable StackTraceElement[] getAllocationContextStackTrace() {
31         return closeTracker.getAllocationContextStackTrace();
32     }
33
34     @Override
35     public final CloseTracked<T> getRealCloseTracked() {
36         return this;
37     }
38 }