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.compute.config; |
20 | |
21 | import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; |
22 | import org.jclouds.compute.strategy.DestroyNodeStrategy; |
23 | import org.jclouds.compute.strategy.GetNodeMetadataStrategy; |
24 | import org.jclouds.compute.strategy.ListNodesStrategy; |
25 | import org.jclouds.compute.strategy.RebootNodeStrategy; |
26 | import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; |
27 | import org.jclouds.compute.strategy.ResumeNodeStrategy; |
28 | import org.jclouds.compute.strategy.SuspendNodeStrategy; |
29 | import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet; |
30 | |
31 | import com.google.inject.AbstractModule; |
32 | import com.google.inject.Scopes; |
33 | |
34 | /** |
35 | * |
36 | * @author Adrian Cole |
37 | * |
38 | */ |
39 | public abstract class BindComputeStrategiesByClass extends AbstractModule { |
40 | protected void configure() { |
41 | bindRunNodesAndAddToSetStrategy(defineRunNodesAndAddToSetStrategy()); |
42 | bindAddNodeWithTagStrategy(defineAddNodeWithTagStrategy()); |
43 | bindListNodesStrategy(defineListNodesStrategy()); |
44 | bindGetNodeMetadataStrategy(defineGetNodeMetadataStrategy()); |
45 | bindRebootNodeStrategy(defineRebootNodeStrategy()); |
46 | bindStartNodeStrategy(defineStartNodeStrategy()); |
47 | bindStopNodeStrategy(defineStopNodeStrategy()); |
48 | bindDestroyNodeStrategy(defineDestroyNodeStrategy()); |
49 | } |
50 | |
51 | protected void bindRunNodesAndAddToSetStrategy(Class<? extends CreateNodesInGroupThenAddToSet> clazz) { |
52 | bind(CreateNodesInGroupThenAddToSet.class).to(clazz).in(Scopes.SINGLETON); |
53 | } |
54 | |
55 | /** |
56 | * needed, if {@link CreateNodesInGroupThenAddToSet} requires it |
57 | */ |
58 | protected void bindAddNodeWithTagStrategy(Class<? extends CreateNodeWithGroupEncodedIntoName> clazz) { |
59 | bind(CreateNodeWithGroupEncodedIntoName.class).to(clazz).in(Scopes.SINGLETON); |
60 | } |
61 | |
62 | protected void bindDestroyNodeStrategy(Class<? extends DestroyNodeStrategy> clazz) { |
63 | bind(DestroyNodeStrategy.class).to(clazz).in(Scopes.SINGLETON); |
64 | } |
65 | |
66 | protected void bindRebootNodeStrategy(Class<? extends RebootNodeStrategy> clazz) { |
67 | bind(RebootNodeStrategy.class).to(clazz).in(Scopes.SINGLETON); |
68 | } |
69 | |
70 | protected void bindStartNodeStrategy(Class<? extends ResumeNodeStrategy> clazz) { |
71 | bind(ResumeNodeStrategy.class).to(clazz).in(Scopes.SINGLETON); |
72 | } |
73 | |
74 | protected void bindStopNodeStrategy(Class<? extends SuspendNodeStrategy> clazz) { |
75 | bind(SuspendNodeStrategy.class).to(clazz).in(Scopes.SINGLETON); |
76 | } |
77 | |
78 | protected void bindGetNodeMetadataStrategy(Class<? extends GetNodeMetadataStrategy> clazz) { |
79 | bind(GetNodeMetadataStrategy.class).to(clazz).in(Scopes.SINGLETON); |
80 | } |
81 | |
82 | protected void bindListNodesStrategy(Class<? extends ListNodesStrategy> clazz) { |
83 | bind(ListNodesStrategy.class).to(clazz).in(Scopes.SINGLETON); |
84 | } |
85 | |
86 | protected Class<? extends CreateNodesInGroupThenAddToSet> defineRunNodesAndAddToSetStrategy() { |
87 | return CreateNodesWithGroupEncodedIntoNameThenAddToSet.class; |
88 | } |
89 | |
90 | /** |
91 | * needed, if {@link CreateNodesInGroupThenAddToSet} requires it |
92 | */ |
93 | protected abstract Class<? extends CreateNodeWithGroupEncodedIntoName> defineAddNodeWithTagStrategy(); |
94 | |
95 | protected abstract Class<? extends DestroyNodeStrategy> defineDestroyNodeStrategy(); |
96 | |
97 | protected abstract Class<? extends RebootNodeStrategy> defineRebootNodeStrategy(); |
98 | |
99 | protected abstract Class<? extends ResumeNodeStrategy> defineStartNodeStrategy(); |
100 | |
101 | protected abstract Class<? extends SuspendNodeStrategy> defineStopNodeStrategy(); |
102 | |
103 | protected abstract Class<? extends GetNodeMetadataStrategy> defineGetNodeMetadataStrategy(); |
104 | |
105 | protected abstract Class<? extends ListNodesStrategy> defineListNodesStrategy(); |
106 | } |