1 package com.atlassian.plugin.osgi.hostcomponents.impl;
2
3 import org.osgi.framework.Bundle;
4
5 /**
6 * A store for the current bundle invoking a host component.
7 * <p>
8 * This should _not_ be used directly. {@link com.atlassian.plugin.osgi.hostcomponents.CallingBundleAccessor} should
9 * be used instead
10 *
11 * @see com.atlassian.plugin.osgi.hostcomponents.CallingBundleAccessor
12 */
13 public class CallingBundleStore {
14
15 private static final ThreadLocal<Bundle> callingBundle = new ThreadLocal<>();
16
17 public static Bundle get() {
18 return callingBundle.get();
19 }
20
21 static void set(Bundle bundle) {
22 if (bundle == null) {
23 callingBundle.remove();
24 } else {
25 callingBundle.set(bundle);
26 }
27 }
28
29 }