updated some javadoc

This commit is contained in:
Adrian Cole 2011-09-30 21:54:01 -07:00
parent ce6749dbd4
commit ded6cb2f7a
2 changed files with 9 additions and 8 deletions

View File

@ -35,6 +35,8 @@ import com.google.inject.TypeLiteral;
import com.google.inject.name.Names;
/**
* ClientProvider makes the primary interface for the provider context. ex. {@code
* context.getProviderSpecificContext().getApi()} is created by ClientProvider, which is a singleton
*
* @author Adrian Cole
*/
@ -47,8 +49,7 @@ public class ClientProvider<S, A> implements Provider<S> {
private final Map<Class<?>, Class<?>> sync2Async;
@Inject
ClientProvider(Class<S> syncClientType, Class<A> asyncClientType,
Map<Class<?>, Class<?>> sync2Async) {
ClientProvider(Class<S> syncClientType, Class<A> asyncClientType, Map<Class<?>, Class<?>> sync2Async) {
this.asyncClientType = asyncClientType;
this.syncClientType = syncClientType;
this.sync2Async = sync2Async;
@ -62,8 +63,7 @@ public class ClientProvider<S, A> implements Provider<S> {
new TypeLiteral<Cache<ClassMethodArgs, Object>>() {
}, Names.named("sync")));
try {
return (S) SyncProxy.proxy(syncClientType, new SyncProxy(syncClientType, client,
delegateMap, sync2Async));
return (S) SyncProxy.proxy(syncClientType, new SyncProxy(syncClientType, client, delegateMap, sync2Async));
} catch (Exception e) {
Throwables.propagate(e);
assert false : "should have propagated";

View File

@ -35,6 +35,9 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheLoader;
/**
* CreateClientForCaller is parameterized, so clients it creates aren't singletons. For example,
* CreateClientForCaller satisfies a call like this:
* {@code context.getProviderSpecificContext().getApi().getOrgClientForName(name)}
*
* @author Adrian Cole
*/
@ -54,13 +57,11 @@ public class CreateClientForCaller extends CacheLoader<ClassMethodArgs, Object>
public Object load(ClassMethodArgs from) throws ExecutionException {
Class<?> syncClass = from.getMethod().getReturnType();
Class<?> asyncClass = sync2Async.get(syncClass);
checkState(asyncClass != null, "configuration error, sync class " + syncClass
+ " not mapped to an async class");
checkState(asyncClass != null, "configuration error, sync class " + syncClass + " not mapped to an async class");
Object asyncClient = asyncMap.get(from);
checkState(asyncClient != null, "configuration error, sync client for " + from + " not found");
try {
return SyncProxy.proxy(syncClass, new SyncProxy(syncClass, asyncClient, delegateMap.get(),
sync2Async));
return SyncProxy.proxy(syncClass, new SyncProxy(syncClass, asyncClient, delegateMap.get(), sync2Async));
} catch (Exception e) {
Throwables.propagate(e);
assert false : "should have propagated";