Skip to content

Commit

Permalink
switch to autoconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
hussainkarafallah committed Nov 14, 2024
1 parent 6053fa5 commit 5076dff
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions tw-context-starter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ apply from: '../build.common.gradle'
dependencies {
implementation libraries.springBootAutoconfigure
implementation libraries.twBaseUtils
implementation libraries.micrometerContextPropagation
api project(":tw-context:")

testImplementation libraries.springBootStarterTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
@Configuration
public class TwContextAutoConfiguration {

TwContextAutoConfiguration() {
ContextRegistry.getInstance().registerThreadLocalAccessor(new TwContextThreadLocalAccessor());
}

@Bean
@ConditionalOnMissingBean
public UnitOfWorkManager twContextUnitOfWorkManager(IMeterCache meterCache) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.RateLimiter;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.micrometer.context.ContextRegistry;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -40,10 +39,6 @@ public class TwContext {

static final TwContext ROOT_CONTEXT = new TwContext(null, true);

static {
ContextRegistry.getInstance().registerThreadLocalAccessor(new TwContextThreadLocalAccessor());
}

public static TwContext current() {
Optional<TwContext> twContext = contextTl.get();
return twContext == null || !twContext.isPresent() ? ROOT_CONTEXT : twContext.get();
Expand Down

0 comments on commit 5076dff

Please sign in to comment.