All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jclouds.compute.config.BindComputeStrategiesByClass Maven / Gradle / Ivy

The newest version!
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF 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.compute.config;

import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet;
import org.jclouds.compute.strategy.DestroyNodeStrategy;
import org.jclouds.compute.strategy.GetImageStrategy;
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
import org.jclouds.compute.strategy.ListNodesStrategy;
import org.jclouds.compute.strategy.RebootNodeStrategy;
import org.jclouds.compute.strategy.ResumeNodeStrategy;
import org.jclouds.compute.strategy.SuspendNodeStrategy;
import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet;

import com.google.inject.AbstractModule;
import com.google.inject.Scopes;

/**
 * 
 * @author Adrian Cole
 * 
 */
public abstract class BindComputeStrategiesByClass extends AbstractModule {
   protected void configure() {
      bindRunNodesAndAddToSetStrategy(defineRunNodesAndAddToSetStrategy());
      bindAddNodeWithTagStrategy(defineAddNodeWithTagStrategy());
      bindListNodesStrategy(defineListNodesStrategy());
      bindGetNodeMetadataStrategy(defineGetNodeMetadataStrategy());
      bindGetImageStrategy(defineGetImageStrategy());
      bindRebootNodeStrategy(defineRebootNodeStrategy());
      bindStartNodeStrategy(defineStartNodeStrategy());
      bindStopNodeStrategy(defineStopNodeStrategy());
      bindDestroyNodeStrategy(defineDestroyNodeStrategy());
   }

   protected void bindRunNodesAndAddToSetStrategy(Class clazz) {
      bind(CreateNodesInGroupThenAddToSet.class).to(clazz).in(Scopes.SINGLETON);
   }

   /**
    * needed, if {@link CreateNodesInGroupThenAddToSet} requires it
    */
   protected void bindAddNodeWithTagStrategy(Class clazz) {
      bind(CreateNodeWithGroupEncodedIntoName.class).to(clazz).in(Scopes.SINGLETON);
   }

   protected void bindDestroyNodeStrategy(Class clazz) {
      bind(DestroyNodeStrategy.class).to(clazz).in(Scopes.SINGLETON);
   }

   protected void bindRebootNodeStrategy(Class clazz) {
      bind(RebootNodeStrategy.class).to(clazz).in(Scopes.SINGLETON);
   }

   protected void bindStartNodeStrategy(Class clazz) {
      bind(ResumeNodeStrategy.class).to(clazz).in(Scopes.SINGLETON);
   }

   protected void bindStopNodeStrategy(Class clazz) {
      bind(SuspendNodeStrategy.class).to(clazz).in(Scopes.SINGLETON);
   }

   protected void bindGetNodeMetadataStrategy(Class clazz) {
      bind(GetNodeMetadataStrategy.class).to(clazz).in(Scopes.SINGLETON);
   }
   
   protected void bindGetImageStrategy(Class clazz) {
      bind(GetImageStrategy.class).to(clazz).in(Scopes.SINGLETON);
   }
   
   protected void bindListNodesStrategy(Class clazz) {
      bind(ListNodesStrategy.class).to(clazz).in(Scopes.SINGLETON);
   }

   protected Class defineRunNodesAndAddToSetStrategy() {
      return CreateNodesWithGroupEncodedIntoNameThenAddToSet.class;
   }

   /**
    * needed, if {@link CreateNodesInGroupThenAddToSet} requires it
    */
   protected abstract Class defineAddNodeWithTagStrategy();

   protected abstract Class defineDestroyNodeStrategy();

   protected abstract Class defineRebootNodeStrategy();

   protected abstract Class defineStartNodeStrategy();

   protected abstract Class defineStopNodeStrategy();

   protected abstract Class defineGetNodeMetadataStrategy();

   protected abstract Class defineGetImageStrategy();

   protected abstract Class defineListNodesStrategy();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy