| 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.gogrid.config; |
| 20 | |
| 21 | import java.lang.reflect.Type; |
| 22 | import java.util.Map; |
| 23 | |
| 24 | import javax.inject.Singleton; |
| 25 | |
| 26 | import org.jclouds.gogrid.domain.IpState; |
| 27 | import org.jclouds.gogrid.domain.JobState; |
| 28 | import org.jclouds.gogrid.domain.LoadBalancerOs; |
| 29 | import org.jclouds.gogrid.domain.LoadBalancerPersistenceType; |
| 30 | import org.jclouds.gogrid.domain.LoadBalancerState; |
| 31 | import org.jclouds.gogrid.domain.LoadBalancerType; |
| 32 | import org.jclouds.gogrid.domain.ObjectType; |
| 33 | import org.jclouds.gogrid.domain.ServerImageState; |
| 34 | import org.jclouds.gogrid.domain.ServerImageType; |
| 35 | import org.jclouds.gogrid.domain.ServerState; |
| 36 | import org.jclouds.gogrid.functions.internal.CustomDeserializers; |
| 37 | import org.jclouds.json.config.GsonModule.DateAdapter; |
| 38 | |
| 39 | import com.google.common.collect.Maps; |
| 40 | import com.google.inject.AbstractModule; |
| 41 | import com.google.inject.Provides; |
| 42 | |
| 43 | /** |
| 44 | * Configures the GoGrid connection. |
| 45 | * |
| 46 | * @author Adrian Cole |
| 47 | * @author Oleksiy Yarmula |
| 48 | */ |
| 49 | |
| 50 | public class GoGridParserModule extends AbstractModule { |
| 51 | |
| 52 | @Provides |
| 53 | @Singleton |
| 54 | public Map<Type, Object> provideCustomAdapterBindings() { |
| 55 | Map<Type, Object> bindings = Maps.newHashMap(); |
| 56 | bindings.put(ObjectType.class, new CustomDeserializers.ObjectTypeAdapter()); |
| 57 | bindings.put(LoadBalancerOs.class, new CustomDeserializers.LoadBalancerOsAdapter()); |
| 58 | bindings.put(LoadBalancerState.class, new CustomDeserializers.LoadBalancerStateAdapter()); |
| 59 | bindings.put(LoadBalancerPersistenceType.class, new CustomDeserializers.LoadBalancerPersistenceTypeAdapter()); |
| 60 | bindings.put(LoadBalancerType.class, new CustomDeserializers.LoadBalancerTypeAdapter()); |
| 61 | bindings.put(ServerState.class, new CustomDeserializers.ServerStateAdapter()); |
| 62 | bindings.put(IpState.class, new CustomDeserializers.IpStateAdapter()); |
| 63 | bindings.put(JobState.class, new CustomDeserializers.JobStateAdapter()); |
| 64 | bindings.put(ServerImageState.class, new CustomDeserializers.ServerImageStateAdapter()); |
| 65 | bindings.put(ServerImageType.class, new CustomDeserializers.ServerImageTypeAdapter()); |
| 66 | return bindings; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | protected void configure() { |
| 71 | bind(DateAdapter.class).to(DateSecondsAdapter.class); |
| 72 | } |
| 73 | |
| 74 | } |