| 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.servermanager.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.domain.Location; |
| 25 | import org.jclouds.location.suppliers.OnlyLocationOrFirstZone; |
| 26 | import org.jclouds.servermanager.Datacenter; |
| 27 | import org.jclouds.servermanager.Hardware; |
| 28 | import org.jclouds.servermanager.Image; |
| 29 | import org.jclouds.servermanager.Server; |
| 30 | import org.jclouds.servermanager.ServerManager; |
| 31 | import org.jclouds.servermanager.compute.functions.DatacenterToLocation; |
| 32 | import org.jclouds.servermanager.compute.functions.ServerManagerHardwareToHardware; |
| 33 | import org.jclouds.servermanager.compute.functions.ServerManagerImageToImage; |
| 34 | import org.jclouds.servermanager.compute.functions.ServerToNodeMetadata; |
| 35 | import org.jclouds.servermanager.compute.strategy.ServerManagerComputeServiceAdapter; |
| 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 ServerManagerComputeServiceContextModule extends |
| 46 | ComputeServiceAdapterContextModule<ServerManager, ServerManager, Server, Hardware, Image, Datacenter> { |
| 47 | |
| 48 | public ServerManagerComputeServiceContextModule() { |
| 49 | super(ServerManager.class, ServerManager.class); |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | protected void configure() { |
| 54 | super.configure(); |
| 55 | bind(new TypeLiteral<ComputeServiceAdapter<Server, Hardware, Image, Datacenter>>() { |
| 56 | }).to(ServerManagerComputeServiceAdapter.class); |
| 57 | bind(new TypeLiteral<Function<Server, NodeMetadata>>() { |
| 58 | }).to(ServerToNodeMetadata.class); |
| 59 | bind(new TypeLiteral<Function<Image, org.jclouds.compute.domain.Image>>() { |
| 60 | }).to(ServerManagerImageToImage.class); |
| 61 | bind(new TypeLiteral<Function<Hardware, org.jclouds.compute.domain.Hardware>>() { |
| 62 | }).to(ServerManagerHardwareToHardware.class); |
| 63 | bind(new TypeLiteral<Function<Datacenter, Location>>() { |
| 64 | }).to(DatacenterToLocation.class); |
| 65 | bind(new TypeLiteral<Supplier<Location>>() { |
| 66 | }).to(OnlyLocationOrFirstZone.class); |
| 67 | } |
| 68 | } |