| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.deltacloud.compute.config; |
| 20 | |
| 21 | import org.jclouds.compute.ComputeServiceAdapter; |
| 22 | import org.jclouds.compute.config.ComputeServiceAdapterContextModule; |
| 23 | import org.jclouds.compute.domain.NodeMetadata; |
| 24 | import org.jclouds.deltacloud.DeltacloudAsyncClient; |
| 25 | import org.jclouds.deltacloud.DeltacloudClient; |
| 26 | import org.jclouds.deltacloud.compute.functions.DeltacloudImageToImage; |
| 27 | import org.jclouds.deltacloud.compute.functions.HardwareProfileToHardware; |
| 28 | import org.jclouds.deltacloud.compute.functions.InstanceToNodeMetadata; |
| 29 | import org.jclouds.deltacloud.compute.functions.RealmToLocation; |
| 30 | import org.jclouds.deltacloud.compute.strategy.DeltacloudComputeServiceAdapter; |
| 31 | import org.jclouds.deltacloud.domain.HardwareProfile; |
| 32 | import org.jclouds.deltacloud.domain.Instance; |
| 33 | import org.jclouds.deltacloud.domain.Realm; |
| 34 | import org.jclouds.domain.Location; |
| 35 | import org.jclouds.location.suppliers.OnlyLocationOrFirstZone; |
| 36 | |
| 37 | import com.google.common.base.Function; |
| 38 | import com.google.common.base.Supplier; |
| 39 | import com.google.inject.TypeLiteral; |
| 40 | |
| 41 | /** |
| 42 | * |
| 43 | * @author Adrian Cole |
| 44 | */ |
| 45 | public class DeltacloudComputeServiceContextModule |
| 46 | extends |
| 47 | ComputeServiceAdapterContextModule<DeltacloudClient, DeltacloudAsyncClient, Instance, HardwareProfile, org.jclouds.deltacloud.domain.Image, Realm> { |
| 48 | |
| 49 | public DeltacloudComputeServiceContextModule() { |
| 50 | super(DeltacloudClient.class, DeltacloudAsyncClient.class); |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | protected void configure() { |
| 55 | super.configure(); |
| 56 | bind( |
| 57 | new TypeLiteral<ComputeServiceAdapter<Instance, HardwareProfile, org.jclouds.deltacloud.domain.Image, Realm>>() { |
| 58 | }).to(DeltacloudComputeServiceAdapter.class); |
| 59 | bind(new TypeLiteral<Function<Instance, NodeMetadata>>() { |
| 60 | }).to(InstanceToNodeMetadata.class); |
| 61 | bind(new TypeLiteral<Function<org.jclouds.deltacloud.domain.Image, org.jclouds.compute.domain.Image>>() { |
| 62 | }).to(DeltacloudImageToImage.class); |
| 63 | bind(new TypeLiteral<Function<HardwareProfile, org.jclouds.compute.domain.Hardware>>() { |
| 64 | }).to(HardwareProfileToHardware.class); |
| 65 | bind(new TypeLiteral<Function<Realm, Location>>() { |
| 66 | }).to(RealmToLocation.class); |
| 67 | bind(new TypeLiteral<Supplier<Location>>() { |
| 68 | }).to(OnlyLocationOrFirstZone.class); |
| 69 | } |
| 70 | } |