Use Guice to inject GerritServer into RPC backends
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -60,10 +60,9 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
class AccountSecurityImpl extends BaseServiceImplementation implements
|
class AccountSecurityImpl extends BaseServiceImplementation implements
|
||||||
AccountSecurity {
|
AccountSecurity {
|
||||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
private final GerritServer server;
|
|
||||||
|
|
||||||
AccountSecurityImpl(final GerritServer gs) {
|
AccountSecurityImpl(final GerritServer gs) {
|
||||||
server = gs;
|
super(gs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mySshKeys(final AsyncCallback<List<AccountSshKey>> callback) {
|
public void mySshKeys(final AsyncCallback<List<AccountSshKey>> callback) {
|
||||||
|
|||||||
@@ -14,15 +14,21 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
|
||||||
/** Publishes {@link AccountSecurityImpl} over JSON. */
|
/** Publishes {@link AccountSecurityImpl} over JSON. */
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AccountSecuritySrv extends GerritJsonServlet {
|
class AccountSecuritySrv extends GerritJsonServlet {
|
||||||
|
@Inject
|
||||||
|
AccountSecuritySrv(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object createServiceHandle() throws Exception {
|
protected Object createServiceHandle() throws Exception {
|
||||||
return new AccountSecurityImpl(GerritServer.getInstance());
|
return new AccountSecurityImpl(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,12 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class AccountServiceImpl extends BaseServiceImplementation implements
|
class AccountServiceImpl extends BaseServiceImplementation implements
|
||||||
AccountService {
|
AccountService {
|
||||||
|
AccountServiceImpl(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
public void myAccount(final AsyncCallback<Account> callback) {
|
public void myAccount(final AsyncCallback<Account> callback) {
|
||||||
run(callback, new Action<Account>() {
|
run(callback, new Action<Account>() {
|
||||||
public Account run(ReviewDb db) throws Failure {
|
public Account run(ReviewDb db) throws Failure {
|
||||||
|
|||||||
@@ -14,15 +14,21 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
|
||||||
/** Publishes {@link AccountServiceImpl} over JSON. */
|
/** Publishes {@link AccountServiceImpl} over JSON. */
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AccountServiceSrv extends GerritJsonServlet {
|
class AccountServiceSrv extends GerritJsonServlet {
|
||||||
|
@Inject
|
||||||
|
AccountServiceSrv(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object createServiceHandle() throws Exception {
|
protected Object createServiceHandle() throws Exception {
|
||||||
return new AccountServiceImpl();
|
return new AccountServiceImpl(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ import java.util.Set;
|
|||||||
|
|
||||||
/** Support for services which require a {@link ReviewDb} instance. */
|
/** Support for services which require a {@link ReviewDb} instance. */
|
||||||
public class BaseServiceImplementation {
|
public class BaseServiceImplementation {
|
||||||
|
protected final GerritServer server;
|
||||||
|
|
||||||
|
protected BaseServiceImplementation(final GerritServer gs) {
|
||||||
|
server = gs;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes <code>action.run</code> with an active ReviewDb connection.
|
* Executes <code>action.run</code> with an active ReviewDb connection.
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -25,8 +25,12 @@ import com.google.gerrit.client.rpc.NoSuchEntityException;
|
|||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwtorm.client.OrmException;
|
import com.google.gwtorm.client.OrmException;
|
||||||
|
|
||||||
public class ChangeDetailServiceImpl extends BaseServiceImplementation
|
class ChangeDetailServiceImpl extends BaseServiceImplementation implements
|
||||||
implements ChangeDetailService {
|
ChangeDetailService {
|
||||||
|
ChangeDetailServiceImpl(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
public void changeDetail(final Change.Id id,
|
public void changeDetail(final Change.Id id,
|
||||||
final AsyncCallback<ChangeDetail> callback) {
|
final AsyncCallback<ChangeDetail> callback) {
|
||||||
run(callback, new ChangeDetailFactory(id));
|
run(callback, new ChangeDetailFactory(id));
|
||||||
|
|||||||
@@ -14,15 +14,21 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
|
||||||
/** Publishes {@link ChangeDetailServiceImpl} over JSON. */
|
/** Publishes {@link ChangeDetailServiceImpl} over JSON. */
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ChangeDetailServiceSrv extends GerritJsonServlet {
|
class ChangeDetailServiceSrv extends GerritJsonServlet {
|
||||||
|
@Inject
|
||||||
|
ChangeDetailServiceSrv(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object createServiceHandle() throws Exception {
|
protected Object createServiceHandle() throws Exception {
|
||||||
return new ChangeDetailServiceImpl();
|
return new ChangeDetailServiceImpl(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ChangeListServiceImpl extends BaseServiceImplementation implements
|
class ChangeListServiceImpl extends BaseServiceImplementation implements
|
||||||
ChangeListService {
|
ChangeListService {
|
||||||
private static final Comparator<ChangeInfo> ID_COMP =
|
private static final Comparator<ChangeInfo> ID_COMP =
|
||||||
new Comparator<ChangeInfo>() {
|
new Comparator<ChangeInfo>() {
|
||||||
@@ -81,6 +81,10 @@ public class ChangeListServiceImpl extends BaseServiceImplementation implements
|
|||||||
return 0 < pageSize && pageSize <= MAX_PER_PAGE ? pageSize : MAX_PER_PAGE;
|
return 0 < pageSize && pageSize <= MAX_PER_PAGE ? pageSize : MAX_PER_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChangeListServiceImpl(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
public void allOpenPrev(final String pos, final int pageSize,
|
public void allOpenPrev(final String pos, final int pageSize,
|
||||||
final AsyncCallback<SingleListChangeInfo> callback) {
|
final AsyncCallback<SingleListChangeInfo> callback) {
|
||||||
run(callback, new QueryPrev(pageSize, pos) {
|
run(callback, new QueryPrev(pageSize, pos) {
|
||||||
@@ -467,8 +471,8 @@ public class ChangeListServiceImpl extends BaseServiceImplementation implements
|
|||||||
* email addresses. The returned changes are unique and sorted by time
|
* email addresses. The returned changes are unique and sorted by time
|
||||||
* stamp, newer first.
|
* stamp, newer first.
|
||||||
*/
|
*/
|
||||||
private Set<Change.Id> changesReviewedBy(final ReviewDb db, final String userName)
|
private Set<Change.Id> changesReviewedBy(final ReviewDb db,
|
||||||
throws OrmException {
|
final String userName) throws OrmException {
|
||||||
final Set<Change.Id> resultChanges = new HashSet<Change.Id>();
|
final Set<Change.Id> resultChanges = new HashSet<Change.Id>();
|
||||||
for (Account.Id account : getAccountSources(db, userName)) {
|
for (Account.Id account : getAccountSources(db, userName)) {
|
||||||
for (ChangeApproval a : db.changeApprovals().openByUser(account)) {
|
for (ChangeApproval a : db.changeApprovals().openByUser(account)) {
|
||||||
|
|||||||
@@ -14,15 +14,21 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
|
||||||
/** Publishes {@link ChangeListServiceImpl} over JSON. */
|
/** Publishes {@link ChangeListServiceImpl} over JSON. */
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ChangeListServiceSrv extends GerritJsonServlet {
|
class ChangeListServiceSrv extends GerritJsonServlet {
|
||||||
|
@Inject
|
||||||
|
ChangeListServiceSrv(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object createServiceHandle() throws Exception {
|
protected Object createServiceHandle() throws Exception {
|
||||||
return new ChangeListServiceImpl();
|
return new ChangeListServiceImpl(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ChangeManageServiceImpl extends BaseServiceImplementation
|
class ChangeManageServiceImpl extends BaseServiceImplementation implements
|
||||||
implements ChangeManageService {
|
ChangeManageService {
|
||||||
|
ChangeManageServiceImpl(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
public void patchSetAction(final ApprovalCategoryValue.Id value,
|
public void patchSetAction(final ApprovalCategoryValue.Id value,
|
||||||
final PatchSet.Id patchSetId, final AsyncCallback<VoidResult> callback) {
|
final PatchSet.Id patchSetId, final AsyncCallback<VoidResult> callback) {
|
||||||
|
|||||||
@@ -14,15 +14,21 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
|
||||||
/** Publishes {@link ChangeManageServiceImpl} over JSON. */
|
/** Publishes {@link ChangeManageServiceImpl} over JSON. */
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ChangeManageServiceSrv extends GerritJsonServlet {
|
class ChangeManageServiceSrv extends GerritJsonServlet {
|
||||||
|
@Inject
|
||||||
|
ChangeManageServiceSrv(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object createServiceHandle() throws Exception {
|
protected Object createServiceHandle() throws Exception {
|
||||||
return new ChangeManageServiceImpl();
|
return new ChangeManageServiceImpl(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,15 +16,10 @@ package com.google.gerrit.server;
|
|||||||
|
|
||||||
import com.google.gerrit.client.rpc.NotSignedInException;
|
import com.google.gerrit.client.rpc.NotSignedInException;
|
||||||
import com.google.gerrit.client.rpc.SignInRequired;
|
import com.google.gerrit.client.rpc.SignInRequired;
|
||||||
import com.google.gerrit.git.WorkQueue;
|
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gwtjsonrpc.server.JsonServlet;
|
import com.google.gwtjsonrpc.server.JsonServlet;
|
||||||
import com.google.gwtjsonrpc.server.SignedToken;
|
import com.google.gwtjsonrpc.server.SignedToken;
|
||||||
import com.google.gwtjsonrpc.server.XsrfException;
|
|
||||||
import com.google.gwtorm.client.OrmException;
|
|
||||||
|
|
||||||
import javax.servlet.ServletConfig;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@@ -38,35 +33,15 @@ public abstract class GerritJsonServlet extends JsonServlet<GerritCall> {
|
|||||||
return JsonServlet.<GerritCall> getCurrentCall();
|
return JsonServlet.<GerritCall> getCurrentCall();
|
||||||
}
|
}
|
||||||
|
|
||||||
private GerritServer server;
|
protected GerritServer server;
|
||||||
|
|
||||||
@Override
|
protected GerritJsonServlet(final GerritServer gs) {
|
||||||
public void init(final ServletConfig config) throws ServletException {
|
server = gs;
|
||||||
super.init(config);
|
|
||||||
|
|
||||||
try {
|
|
||||||
server = GerritServer.getInstance();
|
|
||||||
} catch (OrmException e) {
|
|
||||||
throw new ServletException("Cannot configure GerritServer", e);
|
|
||||||
} catch (XsrfException e) {
|
|
||||||
throw new ServletException("Cannot configure GerritServer", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
protected SignedToken createXsrfSignedToken() {
|
||||||
WorkQueue.terminate();
|
return server.getXsrfToken();
|
||||||
GerritServer.closeDataSource();
|
|
||||||
super.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected SignedToken createXsrfSignedToken() throws XsrfException {
|
|
||||||
try {
|
|
||||||
return GerritServer.getInstance().getXsrfToken();
|
|
||||||
} catch (OrmException e) {
|
|
||||||
throw new XsrfException("Cannot configure GerritServer", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
|
import com.google.gerrit.git.WorkQueue;
|
||||||
|
import com.google.gerrit.server.patch.PatchDetailServiceSrv;
|
||||||
import com.google.gerrit.server.ssh.SshServlet;
|
import com.google.gerrit.server.ssh.SshServlet;
|
||||||
import com.google.gwtjsonrpc.server.XsrfException;
|
import com.google.gwtjsonrpc.server.XsrfException;
|
||||||
import com.google.gwtorm.client.OrmException;
|
import com.google.gwtorm.client.OrmException;
|
||||||
@@ -115,7 +117,7 @@ public class GerritServletConfig extends GuiceServletContextListener {
|
|||||||
} catch (ProviderException ce) {
|
} catch (ProviderException ce) {
|
||||||
// Assume it never started.
|
// Assume it never started.
|
||||||
}
|
}
|
||||||
|
WorkQueue.terminate();
|
||||||
super.contextDestroyed(event);
|
super.contextDestroyed(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,12 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class GroupAdminServiceImpl extends BaseServiceImplementation implements
|
class GroupAdminServiceImpl extends BaseServiceImplementation implements
|
||||||
GroupAdminService {
|
GroupAdminService {
|
||||||
|
GroupAdminServiceImpl(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
public void ownedGroups(final AsyncCallback<List<AccountGroup>> callback) {
|
public void ownedGroups(final AsyncCallback<List<AccountGroup>> callback) {
|
||||||
run(callback, new Action<List<AccountGroup>>() {
|
run(callback, new Action<List<AccountGroup>>() {
|
||||||
public List<AccountGroup> run(ReviewDb db) throws OrmException {
|
public List<AccountGroup> run(ReviewDb db) throws OrmException {
|
||||||
|
|||||||
@@ -14,15 +14,21 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
|
||||||
/** Publishes {@link GroupAdminServiceImpl} over JSON. */
|
/** Publishes {@link GroupAdminServiceImpl} over JSON. */
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Singleton
|
@Singleton
|
||||||
public class GroupAdminServiceSrv extends GerritJsonServlet {
|
class GroupAdminServiceSrv extends GerritJsonServlet {
|
||||||
|
@Inject
|
||||||
|
GroupAdminServiceSrv(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object createServiceHandle() throws Exception {
|
protected Object createServiceHandle() throws Exception {
|
||||||
return new GroupAdminServiceImpl();
|
return new GroupAdminServiceImpl(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,19 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
|
||||||
/** Publishes {@link OpenIdServiceImpl} over JSON. */
|
/** Publishes {@link OpenIdServiceImpl} over JSON. */
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OpenIdServiceSrv extends GerritJsonServlet {
|
class OpenIdServiceSrv extends GerritJsonServlet {
|
||||||
|
@Inject
|
||||||
|
OpenIdServiceSrv(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object createServiceHandle() throws Exception {
|
protected Object createServiceHandle() throws Exception {
|
||||||
return OpenIdServiceImpl.getInstance();
|
return OpenIdServiceImpl.getInstance();
|
||||||
|
|||||||
@@ -62,13 +62,12 @@ import java.util.Set;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
public class ProjectAdminServiceImpl extends BaseServiceImplementation
|
class ProjectAdminServiceImpl extends BaseServiceImplementation implements
|
||||||
implements ProjectAdminService {
|
ProjectAdminService {
|
||||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
private final GerritServer server;
|
|
||||||
|
|
||||||
ProjectAdminServiceImpl(final GerritServer gs) {
|
ProjectAdminServiceImpl(final GerritServer gs) {
|
||||||
server = gs;
|
super(gs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ownedProjects(final AsyncCallback<List<Project>> callback) {
|
public void ownedProjects(final AsyncCallback<List<Project>> callback) {
|
||||||
|
|||||||
@@ -14,15 +14,21 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
|
||||||
/** Publishes {@link ProjectAdminServiceImpl} over JSON. */
|
/** Publishes {@link ProjectAdminServiceImpl} over JSON. */
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ProjectAdminServiceSrv extends GerritJsonServlet {
|
class ProjectAdminServiceSrv extends GerritJsonServlet {
|
||||||
|
@Inject
|
||||||
|
ProjectAdminServiceSrv(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object createServiceHandle() throws Exception {
|
protected Object createServiceHandle() throws Exception {
|
||||||
return new ProjectAdminServiceImpl(GerritServer.getInstance());
|
return new ProjectAdminServiceImpl(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,14 @@ import java.util.ArrayList;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SuggestServiceImpl extends BaseServiceImplementation implements
|
class SuggestServiceImpl extends BaseServiceImplementation implements
|
||||||
SuggestService {
|
SuggestService {
|
||||||
private static final String MAX_SUFFIX = "\u9fa5";
|
private static final String MAX_SUFFIX = "\u9fa5";
|
||||||
|
|
||||||
|
SuggestServiceImpl(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
public void suggestProjectNameKey(final String query, final int limit,
|
public void suggestProjectNameKey(final String query, final int limit,
|
||||||
final AsyncCallback<List<Project.NameKey>> callback) {
|
final AsyncCallback<List<Project.NameKey>> callback) {
|
||||||
run(callback, new Action<List<Project.NameKey>>() {
|
run(callback, new Action<List<Project.NameKey>>() {
|
||||||
|
|||||||
@@ -14,15 +14,21 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
|
||||||
/** Publishes {@link SuggestServiceImpl} over JSON. */
|
/** Publishes {@link SuggestServiceImpl} over JSON. */
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SuggestServiceSrv extends GerritJsonServlet {
|
class SuggestServiceSrv extends GerritJsonServlet {
|
||||||
|
@Inject
|
||||||
|
SuggestServiceSrv(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object createServiceHandle() throws Exception {
|
protected Object createServiceHandle() throws Exception {
|
||||||
return new SuggestServiceImpl();
|
return new SuggestServiceImpl(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,11 +46,17 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
public class SystemInfoServiceImpl implements SystemInfoService {
|
class SystemInfoServiceImpl implements SystemInfoService {
|
||||||
private static final Logger log =
|
private static final Logger log =
|
||||||
LoggerFactory.getLogger(SystemInfoServiceImpl.class);
|
LoggerFactory.getLogger(SystemInfoServiceImpl.class);
|
||||||
private static final JSch JSCH = new JSch();
|
private static final JSch JSCH = new JSch();
|
||||||
|
|
||||||
|
private final GerritServer server;
|
||||||
|
|
||||||
|
SystemInfoServiceImpl(final GerritServer gs) {
|
||||||
|
server = gs;
|
||||||
|
}
|
||||||
|
|
||||||
public static GerritConfig getGerritConfig() {
|
public static GerritConfig getGerritConfig() {
|
||||||
final GerritConfig cfg = Common.getGerritConfig();
|
final GerritConfig cfg = Common.getGerritConfig();
|
||||||
synchronized (cfg) {
|
synchronized (cfg) {
|
||||||
|
|||||||
@@ -14,15 +14,21 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
|
||||||
/** Publishes {@link SystemInfoServiceImpl} over JSON. */
|
/** Publishes {@link SystemInfoServiceImpl} over JSON. */
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SystemInfoServiceSrv extends GerritJsonServlet {
|
class SystemInfoServiceSrv extends GerritJsonServlet {
|
||||||
|
@Inject
|
||||||
|
SystemInfoServiceSrv(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object createServiceHandle() throws Exception {
|
protected Object createServiceHandle() throws Exception {
|
||||||
return new SystemInfoServiceImpl();
|
return new SystemInfoServiceImpl(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,13 +62,12 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
||||||
PatchDetailService {
|
PatchDetailService {
|
||||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
private final GerritServer server;
|
|
||||||
|
|
||||||
public PatchDetailServiceImpl(final GerritServer gs) {
|
PatchDetailServiceImpl(final GerritServer gs) {
|
||||||
server = gs;
|
super(gs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void patchScript(final Patch.Key patchKey, final PatchSet.Id psa,
|
public void patchScript(final Patch.Key patchKey, final PatchSet.Id psa,
|
||||||
|
|||||||
@@ -12,17 +12,24 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server.patch;
|
||||||
|
|
||||||
import com.google.gerrit.server.patch.PatchDetailServiceImpl;
|
import com.google.gerrit.server.GerritJsonServlet;
|
||||||
|
import com.google.gerrit.server.GerritServer;
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
/** Publishes {@link PatchDetailServiceImpl} over JSON. */
|
/** Publishes {@link PatchDetailServiceImpl} over JSON. */
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Singleton
|
@Singleton
|
||||||
public class PatchDetailServiceSrv extends GerritJsonServlet {
|
public class PatchDetailServiceSrv extends GerritJsonServlet {
|
||||||
|
@Inject
|
||||||
|
PatchDetailServiceSrv(final GerritServer gs) {
|
||||||
|
super(gs);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object createServiceHandle() throws Exception {
|
protected Object createServiceHandle() throws Exception {
|
||||||
return new PatchDetailServiceImpl(GerritServer.getInstance());
|
return new PatchDetailServiceImpl(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user