diff --git a/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudContextFactory.java b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudContextFactory.java new file mode 100644 index 0000000000..95d6b70291 --- /dev/null +++ b/vcloud/terremark/src/main/java/org/jclouds/vcloud/terremark/TerremarkVCloudContextFactory.java @@ -0,0 +1,43 @@ +package org.jclouds.vcloud.terremark; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; +import org.jclouds.logging.jdk.config.JDKLoggingModule; +import org.jclouds.rest.RestContext; + +import com.google.inject.Module; + +/** + * Creates {@link TerremarkVCloudContext} instances based on the most commonly requested arguments. + *

+ * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. + *

+ *

+ * If no Modules are specified, the default {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. + * + * @author Adrian Cole + * @see TerremarkVCloudContext + */ +public class TerremarkVCloudContextFactory { + + public static RestContext createContext(String username, String password, + Module... modules) { + return new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder(username, password).build()) + .withModules(modules).buildContext(); + } + + public static RestContext createContext(URI endpoint, String username, + String password, Module... modules) { + return new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder(username, password).withEndpoint( + endpoint).build()).withModules(modules).buildContext(); + } + + public static RestContext createContext(Properties props, Module... modules) { + return new TerremarkVCloudContextBuilder(new TerremarkVCloudPropertiesBuilder(props).build()) + .withModules(modules).buildContext(); + } + +}