Merge pull request #700 from aledsage/Issue-1004

Issue 1004: changes default SocketOpen impl
This commit is contained in:
Adrian Cole 2012-07-06 14:38:02 -07:00
commit 25e68b328c
5 changed files with 33 additions and 7 deletions

View File

@ -28,7 +28,7 @@ import com.google.inject.ImplementedBy;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@ImplementedBy(SocketOpenUnsupported.class) @ImplementedBy(InetSocketAddressConnect.class)
public interface SocketOpen extends Predicate<HostAndPort> { public interface SocketOpen extends Predicate<HostAndPort> {
} }

View File

@ -27,6 +27,8 @@ import org.jclouds.http.HttpCommandExecutorService;
import org.jclouds.http.TransformingHttpCommandExecutorService; import org.jclouds.http.TransformingHttpCommandExecutorService;
import org.jclouds.http.TransformingHttpCommandExecutorServiceImpl; import org.jclouds.http.TransformingHttpCommandExecutorServiceImpl;
import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; import org.jclouds.http.config.ConfiguresHttpCommandExecutorService;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.predicates.SocketOpenUnsupported;
import com.google.appengine.api.urlfetch.URLFetchService; import com.google.appengine.api.urlfetch.URLFetchService;
import com.google.appengine.api.urlfetch.URLFetchServiceFactory; import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
@ -35,6 +37,7 @@ import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.Provides; import com.google.inject.Provides;
import com.google.inject.Scopes;
/** /**
* Configures {@link GaeHttpCommandExecutorService}. * Configures {@link GaeHttpCommandExecutorService}.
@ -75,6 +78,7 @@ public class GoogleAppEngineConfigurationModule extends AbstractModule {
protected void configure() { protected void configure() {
install(executorServiceModule); install(executorServiceModule);
bind(TransformingHttpCommandExecutorService.class).to(TransformingHttpCommandExecutorServiceImpl.class); bind(TransformingHttpCommandExecutorService.class).to(TransformingHttpCommandExecutorServiceImpl.class);
bind(SocketOpen.class).to(SocketOpenUnsupported.class).in(Scopes.SINGLETON);
bindHttpCommandExecutorService(); bindHttpCommandExecutorService();
} }

View File

@ -0,0 +1,28 @@
package org.jclouds.gae;
import org.jclouds.Context;
import org.jclouds.ContextBuilder;
import org.jclouds.gae.config.GoogleAppEngineConfigurationModule;
import org.jclouds.http.IntegrationTestAsyncClient;
import org.jclouds.http.IntegrationTestClient;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.providers.AnonymousProviderMetadata;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.HostAndPort;
public class GaeSocketOpenTest {
@Test(expectedExceptions=UnsupportedOperationException.class)
public void testSocketOpenThrowsUnsupported() {
Context context = ContextBuilder.newBuilder(
AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, IntegrationTestAsyncClient.class,
"dummyurl"))
.modules(ImmutableSet.of(new GoogleAppEngineConfigurationModule()))
.build();
SocketOpen socketOpen = context.getUtils().getInjector().getInstance(SocketOpen.class);
socketOpen.apply(HostAndPort.fromParts("localhost", 22));
}
}

View File

@ -24,8 +24,6 @@ import org.jclouds.Constants;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.handlers.BackoffLimitedRetryHandler; import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
import org.jclouds.predicates.InetSocketAddressConnect;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.ssh.ConfiguresSshClient; import org.jclouds.ssh.ConfiguresSshClient;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.jsch.JschSshClient; import org.jclouds.ssh.jsch.JschSshClient;
@ -45,7 +43,6 @@ public class JschSshClientModule extends AbstractModule {
protected void configure() { protected void configure() {
bind(SshClient.Factory.class).to(Factory.class).in(Scopes.SINGLETON); bind(SshClient.Factory.class).to(Factory.class).in(Scopes.SINGLETON);
bind(SocketOpen.class).to(InetSocketAddressConnect.class).in(Scopes.SINGLETON);
} }
private static class Factory implements SshClient.Factory { private static class Factory implements SshClient.Factory {

View File

@ -24,8 +24,6 @@ import org.jclouds.Constants;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.handlers.BackoffLimitedRetryHandler; import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
import org.jclouds.predicates.InetSocketAddressConnect;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.ssh.ConfiguresSshClient; import org.jclouds.ssh.ConfiguresSshClient;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.sshj.SshjSshClient; import org.jclouds.sshj.SshjSshClient;
@ -45,7 +43,6 @@ public class SshjSshClientModule extends AbstractModule {
protected void configure() { protected void configure() {
bind(SshClient.Factory.class).to(Factory.class).in(Scopes.SINGLETON); bind(SshClient.Factory.class).to(Factory.class).in(Scopes.SINGLETON);
bind(SocketOpen.class).to(InetSocketAddressConnect.class).in(Scopes.SINGLETON);
} }
private static class Factory implements SshClient.Factory { private static class Factory implements SshClient.Factory {