From: <nri...@us...> - 2012-11-15 09:32:33
|
Revision: 914 http://webassembletool.svn.sourceforge.net/webassembletool/?rev=914&view=rev Author: nricheton Date: 2012-11-15 09:32:24 +0000 (Thu, 15 Nov 2012) Log Message: ----------- Fixed log message Modified Paths: -------------- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java Modified: trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java =================================================================== --- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2012-11-15 09:25:55 UTC (rev 913) +++ trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2012-11-15 09:32:24 UTC (rev 914) @@ -65,7 +65,7 @@ inputStream = new FileInputStream(new File(envPath)); } catch (FileNotFoundException e) { LOG.error( - "Can't read file {} (from -Dorg.esigate.config)", + "Can't read file {} (from -Desigate.config)", envPath, e); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nri...@us...> - 2013-03-20 07:29:40
|
Revision: 1083 http://sourceforge.net/p/webassembletool/code/1083 Author: nricheton Date: 2013-03-20 07:29:36 +0000 (Wed, 20 Mar 2013) Log Message: ----------- 0000193: Synchronization optimizations on DriverFactory. https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=193 Modified Paths: -------------- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java Modified: trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java =================================================================== --- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2013-03-20 04:15:58 UTC (rev 1082) +++ trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2013-03-20 07:29:36 UTC (rev 1083) @@ -25,6 +25,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Properties; +import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,7 +38,7 @@ * @author Nicolas Richeton */ public class DriverFactory { - private static final Map<String, Driver> INSTANCES = new HashMap<String, Driver>(); + private static Map<String, Driver> INSTANCES = new HashMap<String, Driver>(); private static final String DEFAULT_INSTANCE_NAME = "default"; private static final Logger LOG = LoggerFactory.getLogger(DriverFactory.class); @@ -161,20 +162,24 @@ driverProperties.put(name, value); } } + // Merge with default properties - synchronized (INSTANCES) { - INSTANCES.clear(); - for (Entry<String, Properties> entry : driversProps.entrySet()) { - String name = entry.getKey(); - Properties properties = new Properties(); - properties.putAll(defaultProperties); - properties.putAll(entry.getValue()); - configure(name, properties); - } - if (INSTANCES.get(DEFAULT_INSTANCE_NAME) == null && Parameters.REMOTE_URL_BASE.getValueString(defaultProperties) != null) { - configure(DEFAULT_INSTANCE_NAME, defaultProperties); - } + Map<String, Driver> newInstances = new HashMap<String, Driver>(); + for (Entry<String, Properties> entry : driversProps.entrySet()) { + String name = entry.getKey(); + Properties properties = new Properties(); + properties.putAll(defaultProperties); + properties.putAll(entry.getValue()); + newInstances.put(name, new Driver(name, properties)); } + if (newInstances.get(DEFAULT_INSTANCE_NAME) == null + && Parameters.REMOTE_URL_BASE.getValueString(defaultProperties) != null) { + + newInstances.put(DEFAULT_INSTANCE_NAME, new Driver( + DEFAULT_INSTANCE_NAME, defaultProperties)); + } + + INSTANCES = newInstances; } /** @@ -184,8 +189,8 @@ * @param name * @param props */ - public static void configure(String name, Properties props) { - INSTANCES.put(name, new Driver(name, props)); + public static final void configure(String name, Properties props) { + setInstance(name, new Driver(name, props)); } /** @@ -199,18 +204,19 @@ * @return the named instance */ public final static Driver getInstance(String instanceName) { - synchronized (INSTANCES) { - if (instanceName == null) - instanceName = DEFAULT_INSTANCE_NAME; - if (INSTANCES.isEmpty()) { - throw new ConfigurationException("Driver has not been configured and driver.properties file was not found"); - } - Driver instance = INSTANCES.get(instanceName); - if (instance == null) { - throw new ConfigurationException("No configuration properties found for factory : " + instanceName); - } - return instance; + if (instanceName == null) + instanceName = DEFAULT_INSTANCE_NAME; + if (INSTANCES.isEmpty()) { + throw new ConfigurationException( + "Driver has not been configured and driver.properties file was not found"); } + Driver instance = INSTANCES.get(instanceName); + if (instance == null) { + throw new ConfigurationException( + "No configuration properties found for factory : " + + instanceName); + } + return instance; } /** @@ -232,8 +238,30 @@ * The instance */ public final static void put(String instanceName, Driver instance) { + setInstance(instanceName, instance); + } + + /** + * Add/replace instance in current instance map. Work on a copy of the + * current map and replace it atomically. + * + * @param instanceName + * @param d + */ + private static final void setInstance(String instanceName, Driver d) { + // Copy current instances + Map<String, Driver> newInstances = new HashMap<String, Driver>(); synchronized (INSTANCES) { - INSTANCES.put(instanceName, instance); + Set<String> keys = INSTANCES.keySet(); + + for (String key : keys) { + newInstances.put(key, INSTANCES.get(key)); + } } + + // Add new instance + newInstances.put(instanceName, d); + + INSTANCES = newInstances; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nri...@us...> - 2013-06-17 10:22:20
|
Revision: 1168 http://sourceforge.net/p/webassembletool/code/1168 Author: nricheton Date: 2013-06-17 10:22:18 +0000 (Mon, 17 Jun 2013) Log Message: ----------- 0000175: Externalize Provider configuration. https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=175 Modified Paths: -------------- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java Modified: trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java =================================================================== --- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2013-06-17 10:21:24 UTC (rev 1167) +++ trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2013-06-17 10:22:18 UTC (rev 1168) @@ -47,7 +47,6 @@ static { // Load default settings configure(); - System.out.println( "configure done"); } private DriverFactory() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nri...@us...> - 2013-06-19 09:54:09
|
Revision: 1172 http://sourceforge.net/p/webassembletool/code/1172 Author: nricheton Date: 2013-06-19 09:54:04 +0000 (Wed, 19 Jun 2013) Log Message: ----------- javadoc Modified Paths: -------------- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java Modified: trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java =================================================================== --- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2013-06-17 20:42:37 UTC (rev 1171) +++ trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2013-06-19 09:54:04 UTC (rev 1172) @@ -287,6 +287,10 @@ INSTANCES = new IndexedInstances(newInstances); } + /** + * Ensure configuration has been loaded at least once. Helps to prevent + * delay on first call because of initialization. + */ public static void ensureConfigured(){ // Just trigger static init. } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nri...@us...> - 2013-10-27 20:31:06
|
Revision: 1437 http://sourceforge.net/p/webassembletool/code/1437 Author: nricheton Date: 2013-10-27 20:31:04 +0000 (Sun, 27 Oct 2013) Log Message: ----------- cleanup Modified Paths: -------------- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java Modified: trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java =================================================================== --- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2013-10-27 19:36:34 UTC (rev 1436) +++ trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2013-10-27 20:31:04 UTC (rev 1437) @@ -29,6 +29,7 @@ import java.util.Properties; import java.util.Set; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import org.esigate.Driver.DriverBuilder; @@ -196,8 +197,9 @@ private static Driver createDriver(String name, Properties properties) { DriverBuilder builder = Driver.builder().setName(name).setProperties(properties); - if (properties.getProperty("driverClass") != null && properties.getProperty("driverClass").equals(ServletRequestExecutor.class.getName())) + if (StringUtils.equals(properties.getProperty("driverClass"), ServletRequestExecutor.class.getName())){ builder.setRequestExecutorBuilder(ServletRequestExecutor.builder()); + } return builder.build(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fxb...@us...> - 2013-12-27 15:03:56
|
Revision: 1521 http://sourceforge.net/p/webassembletool/code/1521 Author: fxbonnet Date: 2013-12-27 15:03:52 +0000 (Fri, 27 Dec 2013) Log Message: ----------- 0000280: Allow programmatic configuration without configuration file https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=280 Modified Paths: -------------- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java Modified: trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java =================================================================== --- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2013-12-27 14:25:57 UTC (rev 1520) +++ trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2013-12-27 15:03:52 UTC (rev 1521) @@ -60,16 +60,15 @@ "development version"); String rev = defaultIfBlank(DriverFactory.class.getPackage().getImplementationVersion(), "unknown"); LOG.info("Starting esigate {} rev. {}", version, rev); - - // Load default settings - configure(); } private DriverFactory() { - + // Do not instantiate } - /** Loads all instances according to default configuration file. */ + /** + * Loads all instances according to default configuration file. + */ public static void configure() { InputStream inputStream = null; InputStream extInputStream = null; @@ -154,7 +153,7 @@ } /** - * Loads all instancies according to the properties parameter. + * Loads all instances according to the properties parameter. * * @param props * properties to use for configuration @@ -211,7 +210,7 @@ * @param props */ public static void configure(String name, Properties props) { - setInstance(name, createDriver(name, props)); + put(name, createDriver(name, props)); } /** @@ -273,7 +272,7 @@ } /** - * Method used to inject providers. Useful mainly for unit testing purpose + * Add/replace instance in current instance map. Work on a copy of the current map and replace it atomically. * * @param instanceName * The name of the provider @@ -281,16 +280,6 @@ * The instance */ public static void put(String instanceName, Driver instance) { - setInstance(instanceName, instance); - } - - /** - * Add/replace instance in current instance map. Work on a copy of the current map and replace it atomically. - * - * @param instanceName - * @param d - */ - private static void setInstance(String instanceName, Driver d) { // Copy current instances Map<String, Driver> newInstances = new HashMap<String, Driver>(); synchronized (instances) { @@ -302,7 +291,7 @@ } // Add new instance - newInstances.put(instanceName, d); + newInstances.put(instanceName, instance); instances = new IndexedInstances(newInstances); } @@ -312,6 +301,9 @@ * initialization. */ public static void ensureConfigured() { - // Just trigger static init. + if (instances.getInstances().isEmpty()) { + // Load default settings + configure(); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ath...@us...> - 2014-04-14 11:42:19
|
Revision: 1595 http://sourceforge.net/p/webassembletool/code/1595 Author: athaveau Date: 2014-04-14 11:42:15 +0000 (Mon, 14 Apr 2014) Log Message: ----------- Add method to retrieve driver instances Modified Paths: -------------- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java Modified: trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java =================================================================== --- trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2014-03-28 14:50:29 UTC (rev 1594) +++ trunk/esigate-core/src/main/java/org/esigate/DriverFactory.java 2014-04-14 11:42:15 UTC (rev 1595) @@ -15,13 +15,21 @@ package org.esigate; -import static org.apache.commons.lang3.StringUtils.defaultIfBlank; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.http.HttpStatus; +import org.esigate.Driver.DriverBuilder; +import org.esigate.impl.IndexedInstances; +import org.esigate.impl.UriMapping; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.util.Collection; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; @@ -29,14 +37,7 @@ import java.util.Properties; import java.util.Set; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.http.HttpStatus; -import org.esigate.Driver.DriverBuilder; -import org.esigate.impl.IndexedInstances; -import org.esigate.impl.UriMapping; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import static org.apache.commons.lang3.StringUtils.defaultIfBlank; /** * Factory class used to configure and retrieve {@linkplain Driver} INSTANCIES. @@ -66,7 +67,17 @@ // Do not instantiate } + /** + * + * @return All configured driver + */ + public static Collection<Driver> getInstances(){ + DriverFactory.ensureConfigured(); + return instances.getInstances().values(); + + } + /** * Loads all instances according to default configuration file. */ public static void configure() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |