/**
 * Copyright (c) 2013 Puppet Labs, Inc. and other contributors, as listed below.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Apache License, Version 2.0
 * which accompanies this distribution, and is available at
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Contributors:
 *   Puppet Labs
 */
package com.puppetlabs.puppetdb.javaclient;

import com.google.inject.Guice;
import com.google.inject.Module;
import com.puppetlabs.puppetdb.javaclient.impl.DefaultModule;

/**
 * A factory used for creating fully configured PuppetDBClient instances
 */
public class PuppetDBClientFactory {

	/**
	 * Create a new PuppetDBClient that will connect using the given <code>preferences</code>.
	 * 
	 * @param preferences
	 *            The preferences used for hte connection
	 * @return The created client instance
	 */
	public static PuppetDBClient newClient(APIPreferences preferences) {
		return newClient(new DefaultModule(preferences));
	}

	/**
	 * Create a new PuppetDBClient using the bindings of one or several
	 * Guice modules.
	 * 
	 * @param modules
	 *            The Guice modules where the bindings have been defined
	 * @return The created client instance
	 */
	public static PuppetDBClient newClient(Module... modules) {
		return Guice.createInjector(modules).getInstance(PuppetDBClient.class);
	}
}

@@ -477,16 +477,55 @@
 Module;%0A
+import com.google.inject.util.Modules;%0A
 import c
@@ -698,16 +698,339 @@
 tory %7B%0A%0A
+%09/**%0A%09 * Returns a Module that contains all default bindings%0A%09 * %0A%09 * @param preferences%0A%09 *            Preferences used when connecting to the PuppetDB instance%0A%09 * @return The default bindings module%0A%09 */%0A%09public static Module getDefaultBindings(APIPreferences preferences) %7B%0A%09%09return new DefaultModule(preferences);%0A%09%7D%0A%0A
 %09/**%0A%09 *
@@ -1086,16 +1086,52 @@
 ing the 
+default%0A%09 * bindigns module and the 
 given %3Cc
@@ -1237,16 +1237,105 @@
 nection%0A
+%09 * @param overrides%0A%09 *            Modules overriding or extending the default bindings%0A
 %09 * @ret
@@ -1441,61 +1441,190 @@
 nces
-) %7B%0A%09%09return newClient(new DefaultModule(preferences)
+, Module... overrides) %7B%0A%09%09Module module = getDefaultBindings(preferences);%0A%09%09if(overrides.length %3E 0)%0A%09%09%09module = Modules.override(module).with(overrides);%0A%09%09return newClient(module
 );%0A%09
@@ -1741,17 +1741,16 @@
 m module
-s
 %0A%09 *    
@@ -1773,17 +1773,16 @@
 e module
-s
  where t
@@ -1906,19 +1906,15 @@
 dule
-...
  module
-s
 ) %7B%0A
@@ -1949,17 +1949,16 @@
 r(module
-s
 ).getIns

Add more flexible way to override Guice injections