Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #5 from mgeiss/develop
added UserContext to context delegating
- Loading branch information
Showing
6 changed files
with
75 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,44 @@ | ||
package io.mifos.core.async.core; | ||
|
||
import io.mifos.core.api.util.UserContext; | ||
import io.mifos.core.api.util.UserContextHolder; | ||
import io.mifos.core.lang.TenantContextHolder; | ||
|
||
public class DelegatingContextRunnable implements Runnable { | ||
|
||
private final Runnable delegate; | ||
private final String tenantIdentifier; | ||
private final UserContext userContext; | ||
|
||
DelegatingContextRunnable(final Runnable delegate) { | ||
this.delegate = delegate; | ||
this.tenantIdentifier = null; | ||
this.userContext = null; | ||
} | ||
|
||
DelegatingContextRunnable(final Runnable delegate, final String tenantIdentifier, | ||
final UserContext userContext) { | ||
super(); | ||
this.delegate = delegate; | ||
this.tenantIdentifier = tenantIdentifier; | ||
this.userContext = userContext; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
try { | ||
TenantContextHolder.clear(); | ||
if(this.tenantIdentifier != null) { | ||
TenantContextHolder.setIdentifier(this.tenantIdentifier); | ||
} | ||
UserContextHolder.clear(); | ||
if (this.userContext != null) { | ||
UserContextHolder.setUserContext(this.userContext); | ||
} | ||
this.delegate.run(); | ||
} finally { | ||
TenantContextHolder.clear(); | ||
UserContextHolder.clear();; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.