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