fixed generic types for CloudStackContext

This commit is contained in:
Adrian Cole 2012-01-10 17:12:50 -08:00
parent 3db62b6f8b
commit 3870313e95
4 changed files with 19 additions and 9 deletions

View File

@ -33,8 +33,12 @@ import com.google.inject.ImplementedBy;
@ImplementedBy(CloudStackContextImpl.class) @ImplementedBy(CloudStackContextImpl.class)
public interface CloudStackContext extends ComputeServiceContext { public interface CloudStackContext extends ComputeServiceContext {
RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext(); @SuppressWarnings("unchecked")
@Override
RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> getGlobalContext(); RestContext<CloudStackClient, CloudStackAsyncClient> getProviderSpecificContext();
RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext();
RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> getGlobalContext();
} }

View File

@ -42,19 +42,27 @@ import org.jclouds.rest.RestContext;
@Singleton @Singleton
public class CloudStackContextImpl extends ComputeServiceContextImpl<CloudStackClient, CloudStackAsyncClient> implements public class CloudStackContextImpl extends ComputeServiceContextImpl<CloudStackClient, CloudStackAsyncClient> implements
CloudStackContext { CloudStackContext {
private final RestContext<CloudStackClient,CloudStackAsyncClient> providerSpecificContext;
private final RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext; private final RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext;
private final RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext; private final RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext;
@Inject @Inject
public CloudStackContextImpl(ComputeService computeService, Map<String, Credentials> credentialStore, Utils utils, public CloudStackContextImpl(ComputeService computeService, Map<String, Credentials> credentialStore, Utils utils,
@SuppressWarnings("rawtypes") RestContext providerSpecificContext, RestContext<CloudStackClient,CloudStackAsyncClient> providerSpecificContext,
RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext, RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext,
RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext) { RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext) {
super(computeService, credentialStore, utils, providerSpecificContext); super(computeService, credentialStore, utils, providerSpecificContext);
this.providerSpecificContext=providerSpecificContext;
this.domainContext = domainContext; this.domainContext = domainContext;
this.globalContext = globalContext; this.globalContext = globalContext;
} }
@SuppressWarnings("unchecked")
@Override
public RestContext<CloudStackClient,CloudStackAsyncClient> getProviderSpecificContext() {
return providerSpecificContext;
}
@Override @Override
public RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext() { public RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext() {
return domainContext; return domainContext;

View File

@ -23,7 +23,6 @@ import static org.testng.Assert.assertEquals;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import org.jclouds.cloudstack.CloudStackClient;
import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.cloudstack.CloudStackContext;
import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.domain.User; import org.jclouds.cloudstack.domain.User;
@ -110,6 +109,6 @@ public class AccountClientExpectTest extends BaseCloudStackRestClientExpectTest<
@Override @Override
protected AccountClient clientFrom(CloudStackContext context) { protected AccountClient clientFrom(CloudStackContext context) {
return CloudStackClient.class.cast(context.getProviderSpecificContext().getApi()).getAccountClient(); return context.getProviderSpecificContext().getApi().getAccountClient();
} }
} }

View File

@ -24,7 +24,6 @@ import static org.testng.Assert.assertNull;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import org.jclouds.cloudstack.CloudStackClient;
import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.cloudstack.CloudStackContext;
import org.jclouds.cloudstack.domain.AsyncCreateResponse; import org.jclouds.cloudstack.domain.AsyncCreateResponse;
import org.jclouds.cloudstack.domain.FirewallRule; import org.jclouds.cloudstack.domain.FirewallRule;
@ -311,6 +310,6 @@ public class FirewallClientExpectTest extends BaseCloudStackRestClientExpectTest
@Override @Override
protected FirewallClient clientFrom(CloudStackContext context) { protected FirewallClient clientFrom(CloudStackContext context) {
return CloudStackClient.class.cast(context.getProviderSpecificContext().getApi()).getFirewallClient(); return context.getProviderSpecificContext().getApi().getFirewallClient();
} }
} }