本文整理汇总了Java中com.google.gerrit.server.util.RequestContext类的典型用法代码示例。如果您正苦于以下问题:Java RequestContext类的具体用法?Java RequestContext怎么用?Java RequestContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestContext类属于com.google.gerrit.server.util包,在下文中一共展示了RequestContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
@Override
public void run() {
RequestContext old = requestContext.setContext(this);
try {
MergedSender cm = mergedSenderFactory.create(project, changeId);
if (submitter != null) {
cm.setFrom(submitter);
}
cm.setNotify(notifyHandling);
cm.setAccountsToNotify(accountsToNotify);
cm.send();
} catch (Exception e) {
log.error("Cannot email merged notification for " + changeId, e);
} finally {
requestContext.setContext(old);
if (db != null) {
db.close();
db = null;
}
}
}
示例2: AdministrateServerGroupsProvider
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
@Inject
public AdministrateServerGroupsProvider(
GroupBackend groupBackend,
@GerritServerConfig Config config,
ThreadLocalRequestContext threadContext,
ServerRequestContext serverCtx) {
RequestContext ctx = threadContext.setContext(serverCtx);
try {
ImmutableSet.Builder<GroupReference> builder = ImmutableSet.builder();
for (String value : config.getStringList("capability", null, "administrateServer")) {
PermissionRule rule = PermissionRule.fromString(value, false);
String name = rule.getGroup().getName();
GroupReference g = GroupBackends.findBestSuggestion(groupBackend, name);
if (g != null) {
builder.add(g);
} else {
Logger log = LoggerFactory.getLogger(getClass());
log.warn("Group \"{}\" not available, skipping.", name);
}
}
groups = builder.build();
} finally {
threadContext.setContext(ctx);
}
}
示例3: GroupSetProvider
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
protected GroupSetProvider(
GroupBackend groupBackend,
ThreadLocalRequestContext threadContext,
ServerRequestContext serverCtx,
List<String> groupNames) {
RequestContext ctx = threadContext.setContext(serverCtx);
try {
ImmutableSet.Builder<AccountGroup.UUID> builder = ImmutableSet.builder();
for (String n : groupNames) {
GroupReference g = GroupBackends.findBestSuggestion(groupBackend, n);
if (g != null) {
builder.add(g.getUUID());
} else {
Logger log = LoggerFactory.getLogger(getClass());
log.warn("Group \"{}\" not available, skipping.", n);
}
}
groupIds = builder.build();
} finally {
threadContext.setContext(ctx);
}
}
示例4: run
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
@Override
public void run() {
RequestContext old = requestContext.setContext(this);
try {
CommentSender cm = commentSenderFactory.create(notes.getProjectName(), notes.getChangeId());
cm.setFrom(user.getAccountId());
cm.setPatchSet(patchSet, patchSetInfoFactory.get(notes.getProjectName(), patchSet));
cm.setChangeMessage(message.getMessage(), message.getWrittenOn());
cm.setComments(comments);
cm.setPatchSetComment(patchSetComment);
cm.setLabels(labels);
cm.setNotify(notify);
cm.setAccountsToNotify(accountsToNotify);
cm.send();
} catch (Exception e) {
log.error("Cannot email comments for " + patchSet.getId(), e);
} finally {
requestContext.setContext(old);
if (db != null) {
db.close();
db = null;
}
}
}
示例5: onStartPlugin
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
public void onStartPlugin(Plugin plugin) {
RequestContext oldContext = enter(plugin);
try {
attachItem(sysItems, plugin.getSysInjector(), plugin);
attachItem(sshItems, plugin.getSshInjector(), plugin);
attachItem(httpItems, plugin.getHttpInjector(), plugin);
attachSet(sysSets, plugin.getSysInjector(), plugin);
attachSet(sshSets, plugin.getSshInjector(), plugin);
attachSet(httpSets, plugin.getHttpInjector(), plugin);
attachMap(sysMaps, plugin.getSysInjector(), plugin);
attachMap(sshMaps, plugin.getSshInjector(), plugin);
attachMap(httpMaps, plugin.getHttpInjector(), plugin);
} finally {
exit(oldContext);
}
for (StartPluginListener l : onStart) {
l.onStartPlugin(plugin);
}
}
示例6: setUp
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
Injector injector = Guice.createInjector(new InMemoryModule());
injector.injectMembers(this);
lifecycle = new LifecycleManager();
lifecycle.add(injector);
lifecycle.start();
db = schemaFactory.open();
schemaCreator.create(db);
// Need to create at least one user to be admin before creating a "normal"
// registered user.
// See AccountManager#create().
accountManager.authenticate(AuthRequest.forUser("admin")).getAccountId();
admins = groupCache.get(new AccountGroup.NameKey("Administrators")).orElse(null).getGroupUUID();
setUpPermissions();
Account.Id userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
user = userFactory.create(userId);
Project.NameKey name = new Project.NameKey("project");
InMemoryRepository inMemoryRepo = repoManager.createRepository(name);
project = new ProjectConfig(name);
project.load(inMemoryRepo);
repo = new TestRepository<>(inMemoryRepo);
requestContext.setContext(
new RequestContext() {
@Override
public CurrentUser getUser() {
return user;
}
@Override
public Provider<ReviewDb> getReviewDbProvider() {
return Providers.of(db);
}
});
}
示例7: doFilter
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
RequestContext old = local.setContext(requestContext.get());
try {
try {
chain.doFilter(request, response);
} finally {
cleanup.get().run();
}
} finally {
local.setContext(old);
}
}
示例8: scope
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
public <T> Callable<T> scope(RequestContext requestContext, Callable<T> callable) {
Context ctx = new Context();
Callable<T> wrapped = context(requestContext, cleanup(callable));
return () -> {
Context old = current.get();
current.set(ctx);
try {
return wrapped.call();
} finally {
current.set(old);
}
};
}
示例9: impl
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
@Override
protected List<Change> impl(RequestContext ctx) throws OrmException {
String ref = event.getRefName();
Project.NameKey project = new Project.NameKey(event.getProjectName());
if (ref.equals(RefNames.REFS_CONFIG)) {
return asChanges(queryProvider.get().byProjectOpen(project));
}
return asChanges(queryProvider.get().byBranchNew(new Branch.NameKey(project, ref)));
}
示例10: start
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
@Override
protected void start(PluginGuiceEnvironment env) throws Exception {
RequestContext oldContext = env.enter(this);
try {
startPlugin(env);
} finally {
env.exit(oldContext);
}
}
示例11: stop
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
@Override
protected void stop(PluginGuiceEnvironment env) {
if (serverManager != null) {
RequestContext oldContext = env.enter(this);
try {
serverManager.stop();
} finally {
env.exit(oldContext);
}
serverManager = null;
sysInjector = null;
sshInjector = null;
httpInjector = null;
}
}
示例12: onReloadPlugin
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
void onReloadPlugin(Plugin oldPlugin, Plugin newPlugin) {
// Index all old registrations by the raw type. These may be replaced
// during the reattach calls below. Any that are not replaced will be
// removed when the old plugin does its stop routine.
ListMultimap<TypeLiteral<?>, ReloadableRegistrationHandle<?>> old = LinkedListMultimap.create();
for (ReloadableRegistrationHandle<?> h : oldPlugin.getReloadableHandles()) {
old.put(h.getKey().getTypeLiteral(), h);
}
RequestContext oldContext = enter(newPlugin);
try {
reattachMap(old, sysMaps, newPlugin.getSysInjector(), newPlugin);
reattachMap(old, sshMaps, newPlugin.getSshInjector(), newPlugin);
reattachMap(old, httpMaps, newPlugin.getHttpInjector(), newPlugin);
reattachSet(old, sysSets, newPlugin.getSysInjector(), newPlugin);
reattachSet(old, sshSets, newPlugin.getSshInjector(), newPlugin);
reattachSet(old, httpSets, newPlugin.getHttpInjector(), newPlugin);
reattachItem(old, sysItems, newPlugin.getSysInjector(), newPlugin);
reattachItem(old, sshItems, newPlugin.getSshInjector(), newPlugin);
reattachItem(old, httpItems, newPlugin.getHttpInjector(), newPlugin);
} finally {
exit(oldContext);
}
for (ReloadPluginListener l : onReload) {
l.onReloadPlugin(oldPlugin, newPlugin);
}
}
示例13: setApiUser
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
public void setApiUser(Account.Id id) {
IdentifiedUser user = userFactory.create(id);
requestContext.setContext(
new RequestContext() {
@Override
public CurrentUser getUser() {
return user;
}
@Override
public Provider<ReviewDb> getReviewDbProvider() {
return Providers.of(db);
}
});
}
示例14: setUpInjector
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
@Before
public void setUpInjector() throws Exception {
Injector injector = Guice.createInjector(new InMemoryModule());
injector.injectMembers(this);
lifecycle = new LifecycleManager();
lifecycle.add(injector);
lifecycle.start();
db = schemaFactory.open();
schemaCreator.create(db);
userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
user = userFactory.create(userId);
requestContext.setContext(
new RequestContext() {
@Override
public CurrentUser getUser() {
return user;
}
@Override
public Provider<ReviewDb> getReviewDbProvider() {
return Providers.of(db);
}
});
configureProject();
setUpChange();
}
示例15: newRequestContext
import com.google.gerrit.server.util.RequestContext; //导入依赖的package包/类
protected RequestContext newRequestContext(Account.Id requestUserId) {
final CurrentUser requestUser = userFactory.create(requestUserId);
return new RequestContext() {
@Override
public CurrentUser getUser() {
return requestUser;
}
@Override
public Provider<ReviewDb> getReviewDbProvider() {
return Providers.of(db);
}
};
}