| 1 | /** | 
| 2 |  * | 
| 3 |  * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> | 
| 4 |  * | 
| 5 |  * ==================================================================== | 
| 6 |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
| 7 |  * you may not use this file except in compliance with the License. | 
| 8 |  * 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, software | 
| 13 |  * distributed under the License is distributed on an "AS IS" BASIS, | 
| 14 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
| 15 |  * See the License for the specific language governing permissions and | 
| 16 |  * limitations under the License. | 
| 17 |  * ==================================================================== | 
| 18 |  */ | 
| 19 | package org.jclouds.compute.internal; | 
| 20 |   | 
| 21 | import java.util.concurrent.ExecutorService; | 
| 22 |   | 
| 23 | import javax.inject.Named; | 
| 24 | import javax.inject.Singleton; | 
| 25 |   | 
| 26 | import org.jclouds.Constants; | 
| 27 | import org.jclouds.compute.Utils; | 
| 28 | import org.jclouds.compute.domain.NodeMetadata; | 
| 29 | import org.jclouds.crypto.Crypto; | 
| 30 | import org.jclouds.date.DateService; | 
| 31 | import org.jclouds.json.Json; | 
| 32 | import org.jclouds.logging.Logger.LoggerFactory; | 
| 33 | import org.jclouds.rest.HttpAsyncClient; | 
| 34 | import org.jclouds.rest.HttpClient; | 
| 35 | import org.jclouds.ssh.SshClient; | 
| 36 | import org.jclouds.ssh.SshClient.Factory; | 
| 37 |   | 
| 38 | import com.google.common.base.Function; | 
| 39 | import com.google.inject.Inject; | 
| 40 |   | 
| 41 | /** | 
| 42 |  *  | 
| 43 |  * @author Adrian Cole | 
| 44 |  */ | 
| 45 | @Singleton | 
| 46 | public class UtilsImpl extends org.jclouds.rest.internal.UtilsImpl implements Utils { | 
| 47 |    @Inject(optional = true) | 
| 48 |    private Factory sshFactory; | 
| 49 |    private final Function<NodeMetadata, SshClient> sshForNode; | 
| 50 |   | 
| 51 |    @Inject | 
| 52 |    UtilsImpl(Json json, HttpClient simpleClient, HttpAsyncClient simpleAsyncClient, Crypto encryption, | 
| 53 |          DateService date, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, | 
| 54 |          @Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioThreads, LoggerFactory loggerFactory, | 
| 55 |          Function<NodeMetadata, SshClient> sshForNode) { | 
| 56 |       super(json, simpleClient, simpleAsyncClient, encryption, date, userThreads, ioThreads, loggerFactory); | 
| 57 |       this.sshForNode = sshForNode; | 
| 58 |    } | 
| 59 |   | 
| 60 |    @Override | 
| 61 |    public Factory getSshClientFactory() { | 
| 62 |       return sshFactory; | 
| 63 |    } | 
| 64 |   | 
| 65 |    @Override | 
| 66 |    public Factory sshFactory() { | 
| 67 |       return sshFactory; | 
| 68 |    } | 
| 69 |   | 
| 70 |    @Override | 
| 71 |    public Function<NodeMetadata, SshClient> sshForNode() { | 
| 72 |       return sshForNode; | 
| 73 |    } | 
| 74 |   | 
| 75 | } |