Expose the Guice injector as a @Beta API

This commit is contained in:
andreisavu 2011-11-21 10:52:32 +02:00
parent 8dd04b5ce5
commit 3cec3293f0
3 changed files with 32 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import java.util.concurrent.ExecutorService;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import com.google.inject.Injector;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.compute.Utils; import org.jclouds.compute.Utils;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
@ -49,11 +50,11 @@ public class UtilsImpl extends org.jclouds.rest.internal.UtilsImpl implements Ut
private final Function<NodeMetadata, SshClient> sshForNode; private final Function<NodeMetadata, SshClient> sshForNode;
@Inject @Inject
UtilsImpl(Json json, HttpClient simpleClient, HttpAsyncClient simpleAsyncClient, Crypto encryption, UtilsImpl(Injector injector, Json json, HttpClient simpleClient, HttpAsyncClient simpleAsyncClient, Crypto encryption,
DateService date, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, DateService date, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads,
@Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioThreads, LoggerFactory loggerFactory, @Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioThreads, LoggerFactory loggerFactory,
Function<NodeMetadata, SshClient> sshForNode) { Function<NodeMetadata, SshClient> sshForNode) {
super(json, simpleClient, simpleAsyncClient, encryption, date, userThreads, ioThreads, loggerFactory); super(injector, json, simpleClient, simpleAsyncClient, encryption, date, userThreads, ioThreads, loggerFactory);
this.sshForNode = sshForNode; this.sshForNode = sshForNode;
} }
@ -71,5 +72,4 @@ public class UtilsImpl extends org.jclouds.rest.internal.UtilsImpl implements Ut
public Function<NodeMetadata, SshClient> sshForNode() { public Function<NodeMetadata, SshClient> sshForNode() {
return sshForNode; return sshForNode;
} }
} }

View File

@ -20,6 +20,8 @@ package org.jclouds.rest;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import com.google.common.annotations.Beta;
import com.google.inject.Injector;
import org.jclouds.crypto.Crypto; import org.jclouds.crypto.Crypto;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.json.Json; import org.jclouds.json.Json;
@ -92,4 +94,14 @@ public interface Utils {
* #see #getLoggerFactory * #see #getLoggerFactory
*/ */
LoggerFactory loggerFactory(); LoggerFactory loggerFactory();
@Beta
Injector getInjector();
/**
* #see #getInjector
*/
@Beta
Injector injector();
} }

View File

@ -23,6 +23,8 @@ import java.util.concurrent.ExecutorService;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import com.google.common.annotations.Beta;
import com.google.inject.Injector;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.crypto.Crypto; import org.jclouds.crypto.Crypto;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
@ -48,12 +50,14 @@ public class UtilsImpl implements Utils {
private final ExecutorService userExecutor; private final ExecutorService userExecutor;
private final ExecutorService ioExecutor; private final ExecutorService ioExecutor;
private final LoggerFactory loggerFactory; private final LoggerFactory loggerFactory;
private Injector injector;
@Inject @Inject
protected UtilsImpl(Json json, HttpClient simpleClient, HttpAsyncClient simpleAsyncClient, protected UtilsImpl(Injector injector, Json json, HttpClient simpleClient, HttpAsyncClient simpleAsyncClient,
Crypto encryption, DateService date, Crypto encryption, DateService date,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads,
@Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioThreads, LoggerFactory loggerFactory) { @Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioThreads, LoggerFactory loggerFactory) {
this.injector = injector;
this.json = json; this.json = json;
this.simpleClient = simpleClient; this.simpleClient = simpleClient;
this.simpleAsyncClient = simpleAsyncClient; this.simpleAsyncClient = simpleAsyncClient;
@ -144,4 +148,16 @@ public class UtilsImpl implements Utils {
return json; return json;
} }
@Override
@Beta
public Injector getInjector() {
return injector;
}
@Override
@Beta
public Injector injector() {
return getInjector();
}
} }