fix SectionForVApp usage

This commit is contained in:
danikov 2012-04-25 11:34:25 +01:00
parent ef79f94e1d
commit 9b7bd20986
3 changed files with 9 additions and 12 deletions

View File

@ -60,7 +60,8 @@ public class VCloudDirectorComputeUtils {
return vApp.getChildren().getVms().size() > 0 ? toComputeOs(Iterables.get(vApp.getChildren().getVms(), 0)) : null;
}
@Inject private static SectionForVApp<OperatingSystemSection> findOperatingSystemSectionForVApp;
private static SectionForVApp<OperatingSystemSection> findOperatingSystemSectionForVApp =
new SectionForVApp<OperatingSystemSection>(OperatingSystemSection.class);
public static CIMOperatingSystem toComputeOs(Vm vm) {
return toComputeOs(findOperatingSystemSectionForVApp.apply(vm));
@ -75,7 +76,8 @@ public class VCloudDirectorComputeUtils {
getVirtualSystemIdentifierOf(Iterables.get(vApp.getChildren().getVms(), 0)) : null;
}
@Inject private static SectionForVApp<VirtualHardwareSection> findVirtualHardwareSectionForVApp;
@Inject private static SectionForVApp<VirtualHardwareSection> findVirtualHardwareSectionForVApp =
new SectionForVApp<VirtualHardwareSection>(VirtualHardwareSection.class);
public static String getVirtualSystemIdentifierOf(Vm vm) {
VirtualHardwareSection virtualHardwareSection = findVirtualHardwareSectionForVApp.apply(vm);
@ -93,7 +95,8 @@ public class VCloudDirectorComputeUtils {
return vApp.getChildren().size() > 0 ? getCredentialsFrom(Iterables.get(vApp.getChildren(), 0)) : null;
}
@Inject private static SectionForVApp<GuestCustomizationSection> findGuestCustomizationSectionForVApp;
@Inject private static SectionForVApp<GuestCustomizationSection> findGuestCustomizationSectionForVApp =
new SectionForVApp<GuestCustomizationSection>(GuestCustomizationSection.class);
public static LoginCredentials getCredentialsFrom(Vm vm) {
LoginCredentials.Builder builder = LoginCredentials.builder();
@ -103,7 +106,8 @@ public class VCloudDirectorComputeUtils {
return builder.build();
}
@Inject private static SectionForVApp<NetworkConnectionSection> findNetworkConnectionSectionForVApp;
@Inject private static SectionForVApp<NetworkConnectionSection> findNetworkConnectionSectionForVApp =
new SectionForVApp<NetworkConnectionSection>(NetworkConnectionSection.class);
public static Set<String> getIpsFromVApp(VApp vApp) {
// TODO make this work with composite vApps

View File

@ -174,8 +174,6 @@ public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirec
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(InvalidateSessionAndRetryOn401AndLogoutOnClose.class);
requestStaticInjection(VCloudDirectorComputeUtils.class);
super.configure();
}

View File

@ -18,9 +18,6 @@
*/
package org.jclouds.vcloud.director.v1_5.functions;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.dmtf.ovf.SectionType;
import org.jclouds.vcloud.director.v1_5.domain.AbstractVAppType;
@ -29,13 +26,11 @@ import com.google.common.base.Function;
/**
* @author danikov
*/
@Singleton
public class SectionForVApp<S extends SectionType> implements Function<AbstractVAppType, S> {
private final Class<? extends SectionType> sectionType;
@Inject
SectionForVApp(Class<S> sectionType) {
public SectionForVApp(Class<S> sectionType) {
this.sectionType = sectionType;
}