openstack-nova extensibility

This commit is contained in:
Andrew Donald Kennedy 2012-08-12 12:29:36 +01:00
parent 6c9524dabc
commit 9acfa880d4
14 changed files with 18 additions and 18 deletions

View File

@ -129,12 +129,12 @@ public class NovaRestClientModule<S extends NovaApi, A extends NovaAsyncApi> ext
@Provides @Provides
@Singleton @Singleton
public LoadingCache<String, Set<Extension>> provideExtensionsByZone(final Provider<NovaApi> novaApi) { public LoadingCache<String, Set<? extends Extension>> provideExtensionsByZone(final Provider<NovaApi> novaApi) {
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS) return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
.build(new CacheLoader<String, Set<Extension>>() { .build(new CacheLoader<String, Set<? extends Extension>>() {
@Override @Override
public Set<Extension> load(String key) throws Exception { public Set<? extends Extension> load(String key) throws Exception {
return novaApi.get().getExtensionApiForZone(key).listExtensions(); return novaApi.get().getExtensionApiForZone(key).listExtensions();
} }

View File

@ -42,7 +42,7 @@ public interface ExtensionApi {
* *
* @return all extensions * @return all extensions
*/ */
Set<Extension> listExtensions(); Set<? extends Extension> listExtensions();
/** /**
* Extensions may also be queried individually by their unique alias. * Extensions may also be queried individually by their unique alias.

View File

@ -59,7 +59,7 @@ public interface ExtensionAsyncApi {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/extensions") @Path("/extensions")
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Extension>> listExtensions(); ListenableFuture<? extends Set<? extends Extension>> listExtensions();
/** /**
* @see ExtensionApi#getExtensionByAlias * @see ExtensionApi#getExtensionByAlias
@ -69,6 +69,6 @@ public interface ExtensionAsyncApi {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/extensions/{alias}") @Path("/extensions/{alias}")
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Extension> getExtensionByAlias(@PathParam("alias") String id); ListenableFuture<? extends Extension> getExtensionByAlias(@PathParam("alias") String id);
} }

View File

@ -43,7 +43,7 @@ public interface FlavorApi {
* *
* @return all flavors (IDs, names, links) * @return all flavors (IDs, names, links)
*/ */
Set<Resource> listFlavors(); Set<? extends Resource> listFlavors();
/** /**
* List all flavors (all details) * List all flavors (all details)

View File

@ -61,7 +61,7 @@ public interface FlavorAsyncApi {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/flavors") @Path("/flavors")
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Resource>> listFlavors(); ListenableFuture<? extends Set<? extends Resource>> listFlavors();
/** /**
* @see FlavorApi#listFlavorsInDetail * @see FlavorApi#listFlavorsInDetail

View File

@ -43,7 +43,7 @@ public interface ImageApi {
* *
* @return all images (IDs, names, links) * @return all images (IDs, names, links)
*/ */
Set<Resource> listImages(); Set<? extends Resource> listImages();
/** /**
* List all images (all details) * List all images (all details)

View File

@ -59,7 +59,7 @@ public interface ImageAsyncApi {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/images") @Path("/images")
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Resource>> listImages(); ListenableFuture<? extends Set<? extends Resource>> listImages();
/** /**
* @see ImageApi#listImagesInDetail * @see ImageApi#listImagesInDetail

View File

@ -47,7 +47,7 @@ public interface ServerApi {
* *
* @return all servers (IDs, names, links) * @return all servers (IDs, names, links)
*/ */
Set<Resource> listServers(); Set<? extends Resource> listServers();
/** /**
* List all servers (all details) * List all servers (all details)

View File

@ -76,7 +76,7 @@ public interface ServerAsyncApi {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/servers") @Path("/servers")
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Resource>> listServers(); ListenableFuture<? extends Set<? extends Resource>> listServers();
/** /**
* @see ServerApi#listServersInDetail * @see ServerApi#listServersInDetail

View File

@ -51,7 +51,7 @@ import com.google.common.collect.Multimap;
@Singleton @Singleton
public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet implements public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet implements
ImplicitOptionalConverter { ImplicitOptionalConverter {
private final LoadingCache<String, Set<Extension>> extensions; private final LoadingCache<String, Set<? extends Extension>> extensions;
@com.google.inject.Inject(optional=true) @com.google.inject.Inject(optional=true)
@Named("openstack.nova.extensions") @Named("openstack.nova.extensions")
@ -88,7 +88,7 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio
@Inject @Inject
public PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet( public PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet(
LoadingCache<String, Set<Extension>> extensions) { LoadingCache<String, Set<? extends Extension>> extensions) {
this.extensions = checkNotNull(extensions, "extensions"); this.extensions = checkNotNull(extensions, "extensions");
} }

View File

@ -44,7 +44,7 @@ public class ExtensionApiLiveTest extends BaseNovaApiLiveTest {
public void testListExtensions() throws Exception { public void testListExtensions() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) { for (String zoneId : novaContext.getApi().getConfiguredZones()) {
ExtensionApi api = novaContext.getApi().getExtensionApiForZone(zoneId); ExtensionApi api = novaContext.getApi().getExtensionApiForZone(zoneId);
Set<Extension> response = api.listExtensions(); Set<? extends Extension> response = api.listExtensions();
assert null != response; assert null != response;
assertTrue(response.size() >= 0); assertTrue(response.size() >= 0);
for (Extension extension : response) { for (Extension extension : response) {

View File

@ -45,7 +45,7 @@ public class FlavorApiLiveTest extends BaseNovaApiLiveTest {
public void testListFlavors() throws Exception { public void testListFlavors() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) { for (String zoneId : novaContext.getApi().getConfiguredZones()) {
FlavorApi api = novaContext.getApi().getFlavorApiForZone(zoneId); FlavorApi api = novaContext.getApi().getFlavorApiForZone(zoneId);
Set<Resource> response = api.listFlavors(); Set<? extends Resource> response = api.listFlavors();
assert null != response; assert null != response;
assertTrue(response.size() >= 0); assertTrue(response.size() >= 0);
for (Resource flavor : response) { for (Resource flavor : response) {

View File

@ -41,7 +41,7 @@ public class ImageApiLiveTest extends BaseNovaApiLiveTest {
public void testListImages() throws Exception { public void testListImages() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) { for (String zoneId : novaContext.getApi().getConfiguredZones()) {
ImageApi api = novaContext.getApi().getImageApiForZone(zoneId); ImageApi api = novaContext.getApi().getImageApiForZone(zoneId);
Set<Resource> response = api.listImages(); Set<? extends Resource> response = api.listImages();
assertNotNull(response); assertNotNull(response);
assertTrue(response.size() >= 0); assertTrue(response.size() >= 0);
for (Resource image : response) { for (Resource image : response) {

View File

@ -40,7 +40,7 @@ public class ServerApiLiveTest extends BaseNovaApiLiveTest {
public void testListServersInDetail() throws Exception { public void testListServersInDetail() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) { for (String zoneId : novaContext.getApi().getConfiguredZones()) {
ServerApi api = novaContext.getApi().getServerApiForZone(zoneId); ServerApi api = novaContext.getApi().getServerApiForZone(zoneId);
Set<Resource> response = api.listServers(); Set<? extends Resource> response = api.listServers();
assert null != response; assert null != response;
assertTrue(response.size() >= 0); assertTrue(response.size() >= 0);
for (Resource server : response) { for (Resource server : response) {