From 72989e54823026f388827c309f9d02537a20ea48 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 27 Sep 2011 15:36:33 -0700 Subject: [PATCH] vbox: switched out use of host, as there's no useful data --- .../VirtualBoxComputeServiceAdapter.java | 39 +++++++++++------ ...VirtualBoxComputeServiceContextModule.java | 43 +++++++++++-------- .../org/jclouds/virtualbox/domain/Host.java | 25 ----------- .../virtualbox/functions/HostToLocation.java | 36 ---------------- 4 files changed, 50 insertions(+), 93 deletions(-) delete mode 100644 sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/Host.java delete mode 100644 sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/functions/HostToLocation.java diff --git a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapter.java b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapter.java index 5f4748a204..144fda0478 100644 --- a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapter.java +++ b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapter.java @@ -21,19 +21,27 @@ package org.jclouds.virtualbox.compute; -import com.google.common.base.Throwables; -import com.google.inject.Singleton; -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.domain.Template; -import org.jclouds.domain.Credentials; -import org.jclouds.virtualbox.domain.Host; -import org.virtualbox_4_1.*; +import static com.google.common.base.Preconditions.checkNotNull; -import javax.inject.Inject; import java.util.Collections; import java.util.Map; -import static com.google.common.base.Preconditions.checkNotNull; +import javax.inject.Inject; + +import org.jclouds.compute.ComputeServiceAdapter; +import org.jclouds.compute.domain.Template; +import org.jclouds.domain.Credentials; +import org.jclouds.domain.Location; +import org.jclouds.location.suppliers.JustProvider; +import org.virtualbox_4_1.CleanupMode; +import org.virtualbox_4_1.IMachine; +import org.virtualbox_4_1.IProgress; +import org.virtualbox_4_1.ISession; +import org.virtualbox_4_1.SessionState; +import org.virtualbox_4_1.VirtualBoxManager; + +import com.google.common.base.Throwables; +import com.google.inject.Singleton; /** * Defines the connection between the {@link org.virtualbox_4_1.VirtualBoxManager} implementation and the jclouds @@ -42,13 +50,15 @@ import static com.google.common.base.Preconditions.checkNotNull; * @author Mattias Holmqvist, Andrea Turli */ @Singleton -public class VirtualBoxComputeServiceAdapter implements ComputeServiceAdapter { +public class VirtualBoxComputeServiceAdapter implements ComputeServiceAdapter { private final VirtualBoxManager manager; + private final JustProvider justProvider; @Inject - public VirtualBoxComputeServiceAdapter(VirtualBoxManager manager) { + public VirtualBoxComputeServiceAdapter(VirtualBoxManager manager, JustProvider justProvider) { this.manager = checkNotNull(manager, "manager"); + this.justProvider = checkNotNull(justProvider, "justProvider"); } @Override @@ -71,9 +81,10 @@ public class VirtualBoxComputeServiceAdapter implements ComputeServiceAdapter listLocations() { - return Collections.emptyList(); + @SuppressWarnings("unchecked") + @Override + public Iterable listLocations() { + return (Iterable) justProvider.get(); } @Override diff --git a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java index 5bed29ecf2..8a952b9ec5 100644 --- a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java +++ b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java @@ -21,23 +21,26 @@ package org.jclouds.virtualbox.config; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Injector; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; +import java.net.URI; +import java.util.Map; + +import javax.inject.Named; +import javax.inject.Singleton; + import org.jclouds.Constants; import org.jclouds.compute.ComputeServiceAdapter; import org.jclouds.compute.config.ComputeServiceAdapterContextModule; -import org.jclouds.compute.domain.*; +import org.jclouds.compute.domain.Hardware; +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.NodeState; +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.domain.Location; +import org.jclouds.functions.IdentityFunction; import org.jclouds.location.Provider; import org.jclouds.location.suppliers.OnlyLocationOrFirstZone; import org.jclouds.virtualbox.compute.VirtualBoxComputeServiceAdapter; -import org.jclouds.virtualbox.domain.Host; -import org.jclouds.virtualbox.functions.HostToLocation; import org.jclouds.virtualbox.functions.IMachineToHardware; import org.jclouds.virtualbox.functions.IMachineToImage; import org.jclouds.virtualbox.functions.IMachineToNodeMetadata; @@ -45,15 +48,18 @@ import org.virtualbox_4_1.IMachine; import org.virtualbox_4_1.MachineState; import org.virtualbox_4_1.VirtualBoxManager; -import javax.inject.Named; -import javax.inject.Singleton; -import java.net.URI; -import java.util.Map; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableMap; +import com.google.inject.Injector; +import com.google.inject.Provides; +import com.google.inject.TypeLiteral; /** * @author Mattias Holmqvist, Andrea Turli */ -public class VirtualBoxComputeServiceContextModule extends ComputeServiceAdapterContextModule { +public class VirtualBoxComputeServiceContextModule extends ComputeServiceAdapterContextModule { public VirtualBoxComputeServiceContextModule() { super(VirtualBoxManager.class, VirtualBoxManager.class); @@ -68,15 +74,16 @@ public class VirtualBoxComputeServiceContextModule extends ComputeServiceAdapter return manager; } + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected void configure() { super.configure(); - bind(new TypeLiteral>() { + bind(new TypeLiteral>() { }).to(VirtualBoxComputeServiceAdapter.class); bind(new TypeLiteral>() { }).to(IMachineToNodeMetadata.class); - bind(new TypeLiteral>() { - }).to(HostToLocation.class); + bind(new TypeLiteral>() { + }).to((Class) IdentityFunction.class); bind(new TypeLiteral>() { }).to(IMachineToHardware.class); bind(new TypeLiteral>() { diff --git a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/Host.java b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/Host.java deleted file mode 100644 index 97e6b62ce1..0000000000 --- a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/domain/Host.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * * - * * Licensed to jclouds, Inc. (jclouds) under one or more - * * contributor license agreements. See the NOTICE file - * * distributed with this work for additional information - * * regarding copyright ownership. jclouds licenses this file - * * to you under the Apache License, Version 2.0 (the - * * "License"); you may not use this file except in compliance - * * with the License. You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, - * * software distributed under the License is distributed on an - * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * * KIND, either express or implied. See the License for the - * * specific language governing permissions and limitations - * * under the License. - * - */ - -package org.jclouds.virtualbox.domain; - -public class Host { -} diff --git a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/functions/HostToLocation.java b/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/functions/HostToLocation.java deleted file mode 100644 index ca25a45180..0000000000 --- a/sandbox-apis/virtualbox/src/main/java/org/jclouds/virtualbox/functions/HostToLocation.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * * - * * Licensed to jclouds, Inc. (jclouds) under one or more - * * contributor license agreements. See the NOTICE file - * * distributed with this work for additional information - * * regarding copyright ownership. jclouds licenses this file - * * to you under the Apache License, Version 2.0 (the - * * "License"); you may not use this file except in compliance - * * with the License. You may obtain a copy of the License at - * * - * * http://www.apache.org/licenses/LICENSE-2.0 - * * - * * Unless required by applicable law or agreed to in writing, - * * software distributed under the License is distributed on an - * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * * KIND, either express or implied. See the License for the - * * specific language governing permissions and limitations - * * under the License. - * - */ - -package org.jclouds.virtualbox.functions; - -import com.google.common.base.Function; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.virtualbox.domain.Host; - -public class HostToLocation implements Function { - @Override - public Location apply(@Nullable Host input) { - LocationBuilder locationBuilder = new LocationBuilder(); - return locationBuilder.build(); - } -}