Remove pointless *Srv subclasses of GerritJsonServlet
Guice can handle injecting the RemoteJsonService implementation into the GerritJsonServlet instance, so long as we use some fancy binding configurations that aren't entirely obvious in the documentation. The idea here is we setup a provider which knows how to create the servlet by creating a child Injector with a mapping for the service interface to the concrete implementation. This allows the Injector to create the concrete implementation and feed its constructors any data the implementation wants to know about from the Guice modules we had previously setup. However to ensure we get a unique servlet instance for each implementation of RemoteJsonService we must make an annotation which serves as a uniqueness key to identify each of the configurations from each other. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -38,6 +38,7 @@ import com.google.gwtjsonrpc.server.XsrfException;
|
||||
import com.google.gwtorm.client.OrmDuplicateKeyException;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.gwtorm.client.Transaction;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -62,6 +63,7 @@ class AccountSecurityImpl extends BaseServiceImplementation implements
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final ContactStore contactStore;
|
||||
|
||||
@Inject
|
||||
AccountSecurityImpl(final GerritServer gs, final ContactStore cs) {
|
||||
super(gs);
|
||||
contactStore = cs;
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
|
||||
/** Publishes {@link AccountSecurityImpl} over JSON. */
|
||||
@SuppressWarnings("serial")
|
||||
@Singleton
|
||||
class AccountSecuritySrv extends GerritJsonServlet {
|
||||
private final ContactStore contactStore;
|
||||
|
||||
@Inject
|
||||
AccountSecuritySrv(final GerritServer gs, final ContactStore cs) {
|
||||
super(gs);
|
||||
contactStore = cs;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createServiceHandle() throws Exception {
|
||||
return new AccountSecurityImpl(server, contactStore);
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwtjsonrpc.client.VoidResult;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.gwtorm.client.Transaction;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -38,6 +39,7 @@ import java.util.Set;
|
||||
|
||||
class AccountServiceImpl extends BaseServiceImplementation implements
|
||||
AccountService {
|
||||
@Inject
|
||||
AccountServiceImpl(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
|
||||
/** Publishes {@link AccountServiceImpl} over JSON. */
|
||||
@SuppressWarnings("serial")
|
||||
@Singleton
|
||||
class AccountServiceSrv extends GerritJsonServlet {
|
||||
@Inject
|
||||
AccountServiceSrv(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createServiceHandle() throws Exception {
|
||||
return new AccountServiceImpl(server);
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,11 @@ import com.google.gerrit.client.reviewdb.ReviewDb;
|
||||
import com.google.gerrit.client.rpc.NoSuchEntityException;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
class ChangeDetailServiceImpl extends BaseServiceImplementation implements
|
||||
ChangeDetailService {
|
||||
@Inject
|
||||
ChangeDetailServiceImpl(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
|
||||
/** Publishes {@link ChangeDetailServiceImpl} over JSON. */
|
||||
@SuppressWarnings("serial")
|
||||
@Singleton
|
||||
class ChangeDetailServiceSrv extends GerritJsonServlet {
|
||||
@Inject
|
||||
ChangeDetailServiceSrv(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createServiceHandle() throws Exception {
|
||||
return new ChangeDetailServiceImpl(server);
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ import com.google.gwtorm.client.OrmException;
|
||||
import com.google.gwtorm.client.ResultSet;
|
||||
import com.google.gwtorm.client.Transaction;
|
||||
import com.google.gwtorm.client.impl.ListResultSet;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -81,6 +82,7 @@ class ChangeListServiceImpl extends BaseServiceImplementation implements
|
||||
return 0 < pageSize && pageSize <= MAX_PER_PAGE ? pageSize : MAX_PER_PAGE;
|
||||
}
|
||||
|
||||
@Inject
|
||||
ChangeListServiceImpl(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
|
||||
/** Publishes {@link ChangeListServiceImpl} over JSON. */
|
||||
@SuppressWarnings("serial")
|
||||
@Singleton
|
||||
class ChangeListServiceSrv extends GerritJsonServlet {
|
||||
@Inject
|
||||
ChangeListServiceSrv(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createServiceHandle() throws Exception {
|
||||
return new ChangeListServiceImpl(server);
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwtjsonrpc.client.VoidResult;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.gwtorm.client.Transaction;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -39,6 +40,7 @@ import java.util.List;
|
||||
|
||||
class ChangeManageServiceImpl extends BaseServiceImplementation implements
|
||||
ChangeManageService {
|
||||
@Inject
|
||||
ChangeManageServiceImpl(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
|
||||
/** Publishes {@link ChangeManageServiceImpl} over JSON. */
|
||||
@SuppressWarnings("serial")
|
||||
@Singleton
|
||||
class ChangeManageServiceSrv extends GerritJsonServlet {
|
||||
@Inject
|
||||
ChangeManageServiceSrv(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createServiceHandle() throws Exception {
|
||||
return new ChangeManageServiceImpl(server);
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,10 @@ package com.google.gerrit.server;
|
||||
import com.google.gerrit.client.rpc.NotSignedInException;
|
||||
import com.google.gerrit.client.rpc.SignInRequired;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gwtjsonrpc.client.RemoteJsonService;
|
||||
import com.google.gwtjsonrpc.server.JsonServlet;
|
||||
import com.google.gwtjsonrpc.server.SignedToken;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -27,16 +29,19 @@ import javax.servlet.http.HttpServletResponse;
|
||||
* Base JSON servlet to ensure the current user is not forged.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class GerritJsonServlet extends JsonServlet<GerritCall> {
|
||||
public final class GerritJsonServlet extends JsonServlet<GerritCall> {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static final GerritCall getCurrentCall() {
|
||||
return JsonServlet.<GerritCall> getCurrentCall();
|
||||
}
|
||||
|
||||
protected GerritServer server;
|
||||
private RemoteJsonService service;
|
||||
|
||||
protected GerritJsonServlet(final GerritServer gs) {
|
||||
@Inject
|
||||
GerritJsonServlet(final GerritServer gs, final RemoteJsonService s) {
|
||||
server = gs;
|
||||
service = s;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,5 +90,7 @@ public abstract class GerritJsonServlet extends JsonServlet<GerritCall> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected abstract Object createServiceHandle() throws Exception;
|
||||
protected Object createServiceHandle() {
|
||||
return service;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.gwtjsonrpc.client.RemoteJsonService;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
/** Creates {@link GerritJsonServlet} with a {@link RemoteJsonService}. */
|
||||
class GerritJsonServletProvider implements Provider<GerritJsonServlet> {
|
||||
@Inject
|
||||
private Injector injector;
|
||||
private final Class<? extends RemoteJsonService> serviceClass;
|
||||
|
||||
GerritJsonServletProvider(final Class<? extends RemoteJsonService> c) {
|
||||
serviceClass = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GerritJsonServlet get() {
|
||||
final RemoteJsonService srv = injector.getInstance(serviceClass);
|
||||
return injector.createChildInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(RemoteJsonService.class).toInstance(srv);
|
||||
}
|
||||
}).getInstance(GerritJsonServlet.class);
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,14 @@
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.gerrit.git.WorkQueue;
|
||||
import com.google.gerrit.server.patch.PatchDetailServiceSrv;
|
||||
import com.google.gerrit.server.patch.PatchDetailServiceImpl;
|
||||
import com.google.gerrit.server.ssh.SshServlet;
|
||||
import com.google.gwtexpui.server.CacheControlFilter;
|
||||
import com.google.gwtjsonrpc.client.RemoteJsonService;
|
||||
import com.google.gwtjsonrpc.server.XsrfException;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.BindingAnnotation;
|
||||
import com.google.inject.ConfigurationException;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
@@ -30,14 +32,44 @@ import com.google.inject.Scopes;
|
||||
import com.google.inject.servlet.GuiceServletContextListener;
|
||||
import com.google.inject.servlet.ServletModule;
|
||||
|
||||
import org.openid4java.consumer.ConsumerException;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.security.ProviderException;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
|
||||
/** Configures the web application environment for Gerrit Code Review. */
|
||||
public class GerritServletConfig extends GuiceServletContextListener {
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@BindingAnnotation
|
||||
private static @interface ServletName {
|
||||
String value();
|
||||
}
|
||||
|
||||
private static final class ServletNameImpl implements ServletName {
|
||||
private final String name;
|
||||
|
||||
ServletNameImpl(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String value() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Annotation> annotationType() {
|
||||
return ServletName.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServletName[" + value() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
private static Module createServletModule() {
|
||||
return new ServletModule() {
|
||||
@Override
|
||||
@@ -54,33 +86,39 @@ public class GerritServletConfig extends GuiceServletContextListener {
|
||||
serve("/cat/*").with(CatServlet.class);
|
||||
serve("/static/*").with(StaticServlet.class);
|
||||
|
||||
rpc(AccountServiceSrv.class);
|
||||
rpc(AccountSecuritySrv.class);
|
||||
rpc(GroupAdminServiceSrv.class);
|
||||
rpc(ChangeDetailServiceSrv.class);
|
||||
rpc(ChangeListServiceSrv.class);
|
||||
rpc(ChangeManageServiceSrv.class);
|
||||
rpc(OpenIdServiceSrv.class);
|
||||
rpc(PatchDetailServiceSrv.class);
|
||||
rpc(ProjectAdminServiceSrv.class);
|
||||
rpc(SuggestServiceSrv.class);
|
||||
rpc(SystemInfoServiceSrv.class);
|
||||
rpc(AccountServiceImpl.class);
|
||||
rpc(AccountSecurityImpl.class);
|
||||
rpc(GroupAdminServiceImpl.class);
|
||||
rpc(ChangeDetailServiceImpl.class);
|
||||
rpc(ChangeListServiceImpl.class);
|
||||
rpc(ChangeManageServiceImpl.class);
|
||||
rpc(OpenIdServiceImpl.class);
|
||||
rpc(PatchDetailServiceImpl.class);
|
||||
rpc(ProjectAdminServiceImpl.class);
|
||||
rpc(SuggestServiceImpl.class);
|
||||
rpc(SystemInfoServiceImpl.class);
|
||||
|
||||
if (BecomeAnyAccountLoginServlet.isAllowed()) {
|
||||
serve("/become").with(BecomeAnyAccountLoginServlet.class);
|
||||
}
|
||||
}
|
||||
|
||||
private void rpc(Class<? extends GerritJsonServlet> clazz) {
|
||||
private void rpc(Class<? extends RemoteJsonService> clazz) {
|
||||
String name = clazz.getSimpleName();
|
||||
if (name.endsWith("Srv")) {
|
||||
name = name.substring(0, name.length() - 3);
|
||||
if (name.endsWith("Impl")) {
|
||||
name = name.substring(0, name.length() - 4);
|
||||
}
|
||||
rpc(name, clazz);
|
||||
}
|
||||
|
||||
private void rpc(String name, Class<? extends GerritJsonServlet> clazz) {
|
||||
serve("/gerrit/rpc/" + name).with(clazz);
|
||||
private void rpc(final String name,
|
||||
Class<? extends RemoteJsonService> clazz) {
|
||||
final Key<GerritJsonServlet> srv =
|
||||
Key.get(GerritJsonServlet.class, new ServletNameImpl(name));
|
||||
final GerritJsonServletProvider provider =
|
||||
new GerritJsonServletProvider(clazz);
|
||||
serve("/gerrit/rpc/" + name).with(srv);
|
||||
bind(srv).toProvider(provider).in(Scopes.SINGLETON);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -93,14 +131,11 @@ public class GerritServletConfig extends GuiceServletContextListener {
|
||||
final GerritServer gs = GerritServer.getInstance(true);
|
||||
bind(GerritServer.class).toInstance(gs);
|
||||
bind(ContactStore.class).toInstance(EncryptedContactStore.create(gs));
|
||||
bind(OpenIdServiceImpl.class).toInstance(new OpenIdServiceImpl(gs));
|
||||
bind(FileTypeRegistry.class).toInstance(new FileTypeRegistry(gs));
|
||||
} catch (OrmException e) {
|
||||
addError(e);
|
||||
} catch (XsrfException e) {
|
||||
addError(e);
|
||||
} catch (ConsumerException e) {
|
||||
addError(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwtjsonrpc.client.VoidResult;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.gwtorm.client.Transaction;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -41,6 +42,7 @@ import java.util.Set;
|
||||
|
||||
class GroupAdminServiceImpl extends BaseServiceImplementation implements
|
||||
GroupAdminService {
|
||||
@Inject
|
||||
GroupAdminServiceImpl(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
|
||||
/** Publishes {@link GroupAdminServiceImpl} over JSON. */
|
||||
@SuppressWarnings("serial")
|
||||
@Singleton
|
||||
class GroupAdminServiceSrv extends GerritJsonServlet {
|
||||
@Inject
|
||||
GroupAdminServiceSrv(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createServiceHandle() throws Exception {
|
||||
return new GroupAdminServiceImpl(server);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,8 @@ import com.google.gwtorm.client.KeyUtil;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.gwtorm.client.ResultSet;
|
||||
import com.google.gwtorm.client.Transaction;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import net.sf.ehcache.Element;
|
||||
import net.sf.ehcache.constructs.blocking.CacheEntryFactory;
|
||||
@@ -68,6 +70,7 @@ import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@Singleton
|
||||
class OpenIdServiceImpl implements OpenIdService {
|
||||
private static final Logger log =
|
||||
LoggerFactory.getLogger(OpenIdServiceImpl.class);
|
||||
@@ -95,6 +98,7 @@ class OpenIdServiceImpl implements OpenIdService {
|
||||
private final ConsumerManager manager;
|
||||
private final SelfPopulatingCache discoveryCache;
|
||||
|
||||
@Inject
|
||||
OpenIdServiceImpl(final GerritServer gs) throws ConsumerException {
|
||||
server = gs;
|
||||
manager = new ConsumerManager();
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
|
||||
/** Publishes {@link OpenIdServiceImpl} over JSON. */
|
||||
@SuppressWarnings("serial")
|
||||
@Singleton
|
||||
class OpenIdServiceSrv extends GerritJsonServlet {
|
||||
private final OpenIdServiceImpl impl;
|
||||
|
||||
@Inject
|
||||
OpenIdServiceSrv(final GerritServer gs, final OpenIdServiceImpl i) {
|
||||
super(gs);
|
||||
impl =i;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createServiceHandle() throws Exception {
|
||||
return impl;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import com.google.gerrit.git.PushQueue;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwtjsonrpc.client.VoidResult;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -66,6 +67,7 @@ class ProjectAdminServiceImpl extends BaseServiceImplementation implements
|
||||
ProjectAdminService {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Inject
|
||||
ProjectAdminServiceImpl(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
|
||||
/** Publishes {@link ProjectAdminServiceImpl} over JSON. */
|
||||
@SuppressWarnings("serial")
|
||||
@Singleton
|
||||
class ProjectAdminServiceSrv extends GerritJsonServlet {
|
||||
@Inject
|
||||
ProjectAdminServiceSrv(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createServiceHandle() throws Exception {
|
||||
return new ProjectAdminServiceImpl(server);
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import com.google.gerrit.client.rpc.Common;
|
||||
import com.google.gerrit.client.ui.SuggestService;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -34,6 +35,7 @@ class SuggestServiceImpl extends BaseServiceImplementation implements
|
||||
SuggestService {
|
||||
private static final String MAX_SUFFIX = "\u9fa5";
|
||||
|
||||
@Inject
|
||||
SuggestServiceImpl(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
|
||||
/** Publishes {@link SuggestServiceImpl} over JSON. */
|
||||
@SuppressWarnings("serial")
|
||||
@Singleton
|
||||
class SuggestServiceSrv extends GerritJsonServlet {
|
||||
@Inject
|
||||
SuggestServiceSrv(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createServiceHandle() throws Exception {
|
||||
return new SuggestServiceImpl(server);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import com.google.gerrit.client.rpc.Common;
|
||||
import com.google.gerrit.server.ssh.GerritSshDaemon;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import com.jcraft.jsch.HostKey;
|
||||
import com.jcraft.jsch.JSch;
|
||||
@@ -53,6 +54,7 @@ class SystemInfoServiceImpl implements SystemInfoService {
|
||||
|
||||
private final GerritServer server;
|
||||
|
||||
@Inject
|
||||
SystemInfoServiceImpl(final GerritServer gs) {
|
||||
server = gs;
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
|
||||
/** Publishes {@link SystemInfoServiceImpl} over JSON. */
|
||||
@SuppressWarnings("serial")
|
||||
@Singleton
|
||||
class SystemInfoServiceSrv extends GerritJsonServlet {
|
||||
@Inject
|
||||
SystemInfoServiceSrv(final GerritServer gs) {
|
||||
super(gs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createServiceHandle() throws Exception {
|
||||
return new SystemInfoServiceImpl(server);
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@ import com.google.gwtjsonrpc.client.VoidResult;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.gwtorm.client.OrmRunnable;
|
||||
import com.google.gwtorm.client.Transaction;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -63,11 +64,12 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
||||
public class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
||||
PatchDetailService {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final FileTypeRegistry registry;
|
||||
|
||||
@Inject
|
||||
PatchDetailServiceImpl(final GerritServer gs, final FileTypeRegistry ftr) {
|
||||
super(gs);
|
||||
registry = ftr;
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
// Copyright (C) 2008 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.patch;
|
||||
|
||||
import com.google.gerrit.server.FileTypeRegistry;
|
||||
import com.google.gerrit.server.GerritJsonServlet;
|
||||
import com.google.gerrit.server.GerritServer;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
/** Publishes {@link PatchDetailServiceImpl} over JSON. */
|
||||
@SuppressWarnings("serial")
|
||||
@Singleton
|
||||
public class PatchDetailServiceSrv extends GerritJsonServlet {
|
||||
private final FileTypeRegistry registry;
|
||||
|
||||
@Inject
|
||||
PatchDetailServiceSrv(final GerritServer gs, final FileTypeRegistry ftr) {
|
||||
super(gs);
|
||||
registry = ftr;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createServiceHandle() throws Exception {
|
||||
return new PatchDetailServiceImpl(server, registry);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user