[webbeans-commits] Webbeans SVN: r1972 - in test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl: util and 1 other directory.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Fri Mar 13 10:35:31 EDT 2009
Author: pete.muir at jboss.org
Date: 2009-03-13 10:35:31 -0400 (Fri, 13 Mar 2009)
New Revision: 1972
Modified:
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/ConfigurationImpl.java
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/PropertiesBasedConfigurationBuilder.java
test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/DeploymentProperties.java
Log:
minor
Modified: test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/ConfigurationImpl.java
===================================================================
--- test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/ConfigurationImpl.java 2009-03-13 13:54:08 UTC (rev 1971)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/ConfigurationImpl.java 2009-03-13 14:35:31 UTC (rev 1972)
@@ -14,12 +14,17 @@
public class ConfigurationImpl implements Configuration
{
- private static Configuration current;
+ private static final Configuration current;
static
{
DeploymentProperties properties = new DeploymentProperties();
- current = properties.getInstanceValue(ConfigurationBuilder.PROPERTY_NAME, ConfigurationBuilder.class, true).init().getConfiguration();
+ ConfigurationBuilder builder = properties.getInstanceValue(ConfigurationBuilder.PROPERTY_NAME, ConfigurationBuilder.class, false);
+ if (builder == null)
+ {
+ builder = new PropertiesBasedConfigurationBuilder<ConfigurationImpl>(new ConfigurationImpl());
+ }
+ current = builder.init().getConfiguration();
}
public static <T extends Configuration> T get(Class<T> expectedType)
Modified: test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/PropertiesBasedConfigurationBuilder.java
===================================================================
--- test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/PropertiesBasedConfigurationBuilder.java 2009-03-13 13:54:08 UTC (rev 1971)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/PropertiesBasedConfigurationBuilder.java 2009-03-13 14:35:31 UTC (rev 1972)
@@ -22,7 +22,7 @@
import org.jboss.testharness.spi.Containers;
import org.jboss.testharness.spi.StandaloneContainers;
-public abstract class PropertiesBasedConfigurationBuilder<T extends Configuration> implements ConfigurationBuilder
+public class PropertiesBasedConfigurationBuilder<T extends Configuration> implements ConfigurationBuilder
{
private final DeploymentProperties deploymentProperties;
Modified: test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/DeploymentProperties.java
===================================================================
--- test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/DeploymentProperties.java 2009-03-13 13:54:08 UTC (rev 1971)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/util/DeploymentProperties.java 2009-03-13 14:35:31 UTC (rev 1972)
@@ -145,13 +145,18 @@
return classes;
}
- public <T> Class<T> getClassValue(String propertyName, Class<T> expectedType, boolean required)
+ public <T> Class<? extends T> getClassValue(String propertyName, Class<T> expectedType, Class<? extends T> defaultType, boolean required)
{
- Set<Class<T>> classes = getClasses(propertyName, expectedType);
+ Set<Class<? extends T>> classes = new HashSet<Class<? extends T>>();
+ classes.addAll(getClasses(propertyName, expectedType));
if (classes.size() == 0)
{
- if (required)
+ if (defaultType != null)
{
+ classes.add(defaultType);
+ }
+ else if (required)
+ {
throw new IllegalArgumentException("Cannot find any implementations of " + expectedType.getSimpleName() + ", check that " + propertyName + " is specified");
}
else
@@ -163,15 +168,18 @@
{
throw new IllegalArgumentException("More than one implementation of " + expectedType.getSimpleName() + " specified by " + propertyName + ", not sure which one to use!");
}
- else
- {
- return classes.iterator().next();
- }
+ return classes.iterator().next();
}
public <T> T getInstanceValue(String propertyName, Class<T> expectedType, boolean required)
{
- Class<T> clazz = getClassValue(propertyName, expectedType, required);
+ return getInstanceValue(propertyName, expectedType, null, required);
+ }
+
+
+ public <T> T getInstanceValue(String propertyName, Class<T> expectedType, Class<? extends T> defaultType, boolean required)
+ {
+ Class<? extends T> clazz = getClassValue(propertyName, expectedType, defaultType, required);
if (clazz != null)
{
try
More information about the weld-commits
mailing list