Skip to content

Commit

Permalink
Merge pull request #1023 from anuchandy/fixrawtype
Browse files Browse the repository at this point in the history
Fixing a bunch of RawType usages and minor improvments in simplying callback
  • Loading branch information
jianghaolu authored Aug 18, 2016
2 parents da82c36 + 5b2c095 commit 937bfd6
Show file tree
Hide file tree
Showing 19 changed files with 296 additions and 209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.microsoft.azure.management.compute.InstanceViewStatus;
import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource;
import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl;
import com.microsoft.azure.management.resources.fluentcore.model.implementation.ResourceServiceCall;
import com.microsoft.rest.ServiceCall;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceResponse;
Expand Down Expand Up @@ -92,12 +93,12 @@ public AvailabilitySetImpl withFaultDomainCount(int faultDomainCount) {
}

@Override
public AvailabilitySetImpl apply() throws Exception {
public AvailabilitySet apply() throws Exception {
return this.create();
}

@Override
public ServiceCall applyAsync(ServiceCallback<AvailabilitySet> callback) {
public ServiceCall<AvailabilitySet> applyAsync(ServiceCallback<AvailabilitySet> callback) {
return this.createAsync(callback);
}

Expand All @@ -112,21 +113,18 @@ public Resource createResource() throws Exception {
}

@Override
public ServiceCall createResourceAsync(final ServiceCallback<Resource> callback) {
final AvailabilitySetImpl self = this;
return this.client.createOrUpdateAsync(this.resourceGroupName(), this.name(), this.inner(),
new ServiceCallback<AvailabilitySetInner>() {
@Override
public void failure(Throwable t) {
callback.failure(t);
}

@Override
public void success(ServiceResponse<AvailabilitySetInner> response) {
self.setInner(response.getBody());
idOfVMsInSet = null;
callback.success(new ServiceResponse<Resource>(self, response.getResponse()));
}
});
public ServiceCall<Resource> createResourceAsync(final ServiceCallback<Resource> callback) {
ResourceServiceCall<AvailabilitySet, AvailabilitySetInner, AvailabilitySetImpl> serviceCall = new ResourceServiceCall<>(this);
serviceCall.withSuccessHandler(new ResourceServiceCall.SuccessHandler<AvailabilitySetInner>() {
@Override
public void success(ServiceResponse<AvailabilitySetInner> response) {
idOfVMsInSet = null;
}
});
this.client.createOrUpdateAsync(this.resourceGroupName(),
this.name(),
this.inner(),
serviceCall.wrapCallBack(callback));
return serviceCall;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource;
import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl;
import com.microsoft.azure.management.resources.fluentcore.model.Creatable;
import com.microsoft.azure.management.resources.fluentcore.model.implementation.ResourceServiceCall;
import com.microsoft.azure.management.resources.fluentcore.utils.PagedListConverter;
import com.microsoft.azure.management.resources.fluentcore.utils.ResourceNamer;
import com.microsoft.azure.management.resources.implementation.PageImpl;
Expand Down Expand Up @@ -150,12 +151,12 @@ public VirtualMachine refresh() throws Exception {
}

@Override
public VirtualMachineImpl apply() throws Exception {
public VirtualMachine apply() throws Exception {
return this.create();
}

@Override
public ServiceCall applyAsync(ServiceCallback<VirtualMachine> callback) {
public ServiceCall<VirtualMachine> applyAsync(ServiceCallback<VirtualMachine> callback) {
return this.createAsync(callback);
}

Expand Down Expand Up @@ -876,42 +877,34 @@ public Resource createResource() throws Exception {
}

@Override
public ServiceCall createResourceAsync(final ServiceCallback<Resource> callback) {
public ServiceCall<Resource> createResourceAsync(final ServiceCallback<Resource> callback) {
if (isInCreateMode()) {
setOSDiskAndOSProfileDefaults();
setHardwareProfileDefaults();
}
DataDiskImpl.setDataDisksDefaults(this.dataDisks, this.vmName);
final VirtualMachineImpl self = this;
final ServiceCall call = new ServiceCall(null);
final ResourceServiceCall<VirtualMachine, VirtualMachineInner, VirtualMachineImpl> serviceCall = new ResourceServiceCall<>(this);
handleStorageSettingsAsync(new ServiceCallback<Void>() {
@Override
public void failure(Throwable t) {
callback.failure(t);
serviceCall.failure(t);
}

@Override
public void success(ServiceResponse<Void> result) {
handleNetworkSettings();
handleAvailabilitySettings();
call.newCall(client.createOrUpdateAsync(resourceGroupName(), vmName, inner(),
new ServiceCallback<VirtualMachineInner>() {
@Override
public void failure(Throwable t) {
callback.failure(t);
}

@Override
public void success(ServiceResponse<VirtualMachineInner> response) {
self.setInner(response.getBody());
clearCachedRelatedResources();
initializeDataDisks();
callback.success(new ServiceResponse<Resource>(self, response.getResponse()));
}
}).getCall());
serviceCall.withSuccessHandler(new ResourceServiceCall.SuccessHandler<VirtualMachineInner>() {
@Override
public void success(ServiceResponse<VirtualMachineInner> response) {
clearCachedRelatedResources();
initializeDataDisks();
}
});
client.createOrUpdateAsync(resourceGroupName(), vmName, inner(), serviceCall.wrapCallBack(callback));
}
});
return call;
return serviceCall;
}

// Helpers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource;
import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl;
import com.microsoft.azure.management.resources.fluentcore.model.Creatable;
import com.microsoft.azure.management.resources.fluentcore.model.implementation.ResourceServiceCall;
import com.microsoft.rest.ServiceCall;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceResponse;
Expand Down Expand Up @@ -60,12 +61,12 @@ public LoadBalancerImpl refresh() throws Exception {
}

@Override
public LoadBalancerImpl apply() throws Exception {
public LoadBalancer apply() throws Exception {
return this.create();
}

@Override
public ServiceCall applyAsync(ServiceCallback<LoadBalancer> callback) {
public ServiceCall<LoadBalancer> applyAsync(ServiceCallback<LoadBalancer> callback) {
return createAsync(callback);
}

Expand Down Expand Up @@ -225,27 +226,21 @@ public Resource createResource() throws Exception {
}

@Override
public ServiceCall createResourceAsync(final ServiceCallback<Resource> callback) {
final LoadBalancerImpl self = this;
public ServiceCall<Resource> createResourceAsync(final ServiceCallback<Resource> callback) {
ensureCreationPrerequisites();
return this.innerCollection.createOrUpdateAsync(this.resourceGroupName(), this.name(), this.inner(),
new ServiceCallback<LoadBalancerInner>() {
@Override
public void failure(Throwable t) {
callback.failure(t);
}

@Override
public void success(ServiceResponse<LoadBalancerInner> response) {
self.setInner(response.getBody());
callback.success(new ServiceResponse<Resource>(self, response.getResponse()));
try {
runPostCreationTasks();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
ResourceServiceCall<LoadBalancer, LoadBalancerInner, LoadBalancerImpl> serviceCall = new ResourceServiceCall<>(this);
serviceCall.withSuccessHandler(new ResourceServiceCall.SuccessHandler<LoadBalancerInner>() {
@Override
public void success(ServiceResponse<LoadBalancerInner> response) {
try {
runPostCreationTasks();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
this.innerCollection.createOrUpdateAsync(this.resourceGroupName(), this.name(), this.inner(), serviceCall.wrapCallBack(callback));
return serviceCall;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.microsoft.azure.management.network.Subnet;
import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource;
import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl;
import com.microsoft.azure.management.resources.fluentcore.model.implementation.ResourceServiceCall;
import com.microsoft.rest.ServiceCall;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceResponse;
Expand Down Expand Up @@ -65,12 +66,12 @@ public NetworkImpl refresh() throws Exception {
}

@Override
public NetworkImpl apply() throws Exception {
public Network apply() throws Exception {
return this.create();
}

@Override
public ServiceCall applyAsync(ServiceCallback<Network> callback) {
public ServiceCall<Network> applyAsync(ServiceCallback<Network> callback) {
return createAsync(callback);
}

Expand Down Expand Up @@ -192,22 +193,19 @@ public Resource createResource() throws Exception {
}

@Override
public ServiceCall createResourceAsync(final ServiceCallback<Resource> callback) {
final NetworkImpl self = this;
public ServiceCall<Resource> createResourceAsync(final ServiceCallback<Resource> callback) {
ensureCreationPrerequisites();
return this.innerCollection.createOrUpdateAsync(this.resourceGroupName(), this.name(), this.inner(),
new ServiceCallback<VirtualNetworkInner>() {
@Override
public void failure(Throwable t) {
callback.failure(t);
}

@Override
public void success(ServiceResponse<VirtualNetworkInner> response) {
self.setInner(response.getBody());
initializeSubnetsFromInner();
callback.success(new ServiceResponse<Resource>(self, response.getResponse()));
}
});
ResourceServiceCall<Network, VirtualNetworkInner, NetworkImpl> serviceCall = new ResourceServiceCall<>(this);
serviceCall.withSuccessHandler(new ResourceServiceCall.SuccessHandler<VirtualNetworkInner>() {
@Override
public void success(ServiceResponse<VirtualNetworkInner> response) {
initializeSubnetsFromInner();
}
});
this.innerCollection.createOrUpdateAsync(this.resourceGroupName(),
this.name(),
this.inner(),
serviceCall.wrapCallBack(callback));
return serviceCall;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource;
import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl;
import com.microsoft.azure.management.resources.fluentcore.model.Creatable;
import com.microsoft.azure.management.resources.fluentcore.model.implementation.ResourceServiceCall;
import com.microsoft.azure.management.resources.fluentcore.utils.ResourceNamer;
import com.microsoft.azure.management.resources.fluentcore.utils.Utils;
import com.microsoft.rest.ServiceCall;
Expand Down Expand Up @@ -86,12 +87,12 @@ public NetworkInterface refresh() throws Exception {
}

@Override
public NetworkInterfaceImpl apply() throws Exception {
public NetworkInterface apply() throws Exception {
return this.create();
}

@Override
public ServiceCall applyAsync(ServiceCallback<NetworkInterface> callback) {
public ServiceCall<NetworkInterface> applyAsync(ServiceCallback<NetworkInterface> callback) {
return createAsync(callback);
}

Expand Down Expand Up @@ -373,26 +374,22 @@ public Resource createResource() throws Exception {
}

@Override
public ServiceCall createResourceAsync(final ServiceCallback<Resource> callback) {
final NetworkInterfaceImpl self = this;
public ServiceCall<Resource> createResourceAsync(final ServiceCallback<Resource> callback) {
NicIpConfigurationImpl.ensureConfigurations(this.nicIpConfigurations);
return this.client.createOrUpdateAsync(this.resourceGroupName(),
ResourceServiceCall<NetworkInterface, NetworkInterfaceInner, NetworkInterfaceImpl> serviceCall = new ResourceServiceCall<>(this);
serviceCall.withSuccessHandler(new ResourceServiceCall.SuccessHandler<NetworkInterfaceInner>() {
@Override
public void success(ServiceResponse<NetworkInterfaceInner> response) {
clearCachedRelatedResources();
initializeNicIpConfigurations();
}
});

this.client.createOrUpdateAsync(this.resourceGroupName(),
this.nicName,
this.inner(),
new ServiceCallback<NetworkInterfaceInner>() {
@Override
public void failure(Throwable t) {
callback.failure(t);
}

@Override
public void success(ServiceResponse<NetworkInterfaceInner> response) {
self.setInner(response.getBody());
clearCachedRelatedResources();
initializeNicIpConfigurations();
callback.success(new ServiceResponse<Resource>(self, response.getResponse()));
}
});
serviceCall.wrapCallBack((callback)));
return serviceCall;
}

/**************************************************.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.microsoft.azure.management.network.NetworkSecurityRule;
import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource;
import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl;
import com.microsoft.azure.management.resources.fluentcore.model.implementation.ResourceServiceCall;
import com.microsoft.rest.ServiceCall;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceResponse;
Expand Down Expand Up @@ -91,12 +92,12 @@ public NetworkSecurityGroupImpl refresh() throws Exception {
}

@Override
public NetworkSecurityGroupImpl apply() throws Exception {
public NetworkSecurityGroup apply() throws Exception {
return this.create();
}

@Override
public ServiceCall applyAsync(ServiceCallback<NetworkSecurityGroup> callback) {
public ServiceCall<NetworkSecurityGroup> applyAsync(ServiceCallback<NetworkSecurityGroup> callback) {
return createAsync(callback);
}

Expand Down Expand Up @@ -161,21 +162,19 @@ public Resource createResource() throws Exception {
}

@Override
public ServiceCall createResourceAsync(final ServiceCallback<Resource> callback) {
final NetworkSecurityGroupImpl self = this;
return this.innerCollection.createOrUpdateAsync(this.resourceGroupName(), this.name(), this.inner(),
new ServiceCallback<NetworkSecurityGroupInner>() {
@Override
public void failure(Throwable t) {
callback.failure(t);
}

@Override
public void success(ServiceResponse<NetworkSecurityGroupInner> response) {
self.setInner(response.getBody());
initializeRulesFromInner();
callback.success(new ServiceResponse<Resource>(self, response.getResponse()));
}
});
public ServiceCall<Resource> createResourceAsync(final ServiceCallback<Resource> callback) {
ResourceServiceCall<NetworkSecurityGroup, NetworkSecurityGroupInner, NetworkSecurityGroupImpl> serviceCall = new ResourceServiceCall<>(this);
serviceCall.withSuccessHandler(new ResourceServiceCall.SuccessHandler<NetworkSecurityGroupInner>() {
@Override
public void success(ServiceResponse<NetworkSecurityGroupInner> response) {
initializeRulesFromInner();
}
});

this.innerCollection.createOrUpdateAsync(this.resourceGroupName(),
this.name(),
this.inner(),
serviceCall.wrapCallBack(callback));
return serviceCall;
}
}
Loading

0 comments on commit 937bfd6

Please sign in to comment.