mirror of https://github.com/apache/jclouds.git
updated some javadoc
This commit is contained in:
parent
ce6749dbd4
commit
ded6cb2f7a
|
@ -35,6 +35,8 @@ import com.google.inject.TypeLiteral;
|
||||||
import com.google.inject.name.Names;
|
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
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@ -47,8 +49,7 @@ public class ClientProvider<S, A> implements Provider<S> {
|
||||||
private final Map<Class<?>, Class<?>> sync2Async;
|
private final Map<Class<?>, Class<?>> sync2Async;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ClientProvider(Class<S> syncClientType, Class<A> asyncClientType,
|
ClientProvider(Class<S> syncClientType, Class<A> asyncClientType, Map<Class<?>, Class<?>> sync2Async) {
|
||||||
Map<Class<?>, Class<?>> sync2Async) {
|
|
||||||
this.asyncClientType = asyncClientType;
|
this.asyncClientType = asyncClientType;
|
||||||
this.syncClientType = syncClientType;
|
this.syncClientType = syncClientType;
|
||||||
this.sync2Async = sync2Async;
|
this.sync2Async = sync2Async;
|
||||||
|
@ -62,8 +63,7 @@ public class ClientProvider<S, A> implements Provider<S> {
|
||||||
new TypeLiteral<Cache<ClassMethodArgs, Object>>() {
|
new TypeLiteral<Cache<ClassMethodArgs, Object>>() {
|
||||||
}, Names.named("sync")));
|
}, Names.named("sync")));
|
||||||
try {
|
try {
|
||||||
return (S) SyncProxy.proxy(syncClientType, new SyncProxy(syncClientType, client,
|
return (S) SyncProxy.proxy(syncClientType, new SyncProxy(syncClientType, client, delegateMap, sync2Async));
|
||||||
delegateMap, sync2Async));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.propagate(e);
|
Throwables.propagate(e);
|
||||||
assert false : "should have propagated";
|
assert false : "should have propagated";
|
||||||
|
|
|
@ -35,6 +35,9 @@ import com.google.common.cache.Cache;
|
||||||
import com.google.common.cache.CacheLoader;
|
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
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
@ -54,13 +57,11 @@ public class CreateClientForCaller extends CacheLoader<ClassMethodArgs, Object>
|
||||||
public Object load(ClassMethodArgs from) throws ExecutionException {
|
public Object load(ClassMethodArgs from) throws ExecutionException {
|
||||||
Class<?> syncClass = from.getMethod().getReturnType();
|
Class<?> syncClass = from.getMethod().getReturnType();
|
||||||
Class<?> asyncClass = sync2Async.get(syncClass);
|
Class<?> asyncClass = sync2Async.get(syncClass);
|
||||||
checkState(asyncClass != null, "configuration error, sync class " + syncClass
|
checkState(asyncClass != null, "configuration error, sync class " + syncClass + " not mapped to an async class");
|
||||||
+ " not mapped to an async class");
|
|
||||||
Object asyncClient = asyncMap.get(from);
|
Object asyncClient = asyncMap.get(from);
|
||||||
checkState(asyncClient != null, "configuration error, sync client for " + from + " not found");
|
checkState(asyncClient != null, "configuration error, sync client for " + from + " not found");
|
||||||
try {
|
try {
|
||||||
return SyncProxy.proxy(syncClass, new SyncProxy(syncClass, asyncClient, delegateMap.get(),
|
return SyncProxy.proxy(syncClass, new SyncProxy(syncClass, asyncClient, delegateMap.get(), sync2Async));
|
||||||
sync2Async));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.propagate(e);
|
Throwables.propagate(e);
|
||||||
assert false : "should have propagated";
|
assert false : "should have propagated";
|
||||||
|
|
Loading…
Reference in New Issue