incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1073946 - in /incubator/bval/trunk/bval-guice/src: main/java/org/apache/bval/guice/ test/java/org/apache/bval/guice/
Date Wed, 23 Feb 2011 21:01:07 GMT
Author: simonetripodi
Date: Wed Feb 23 21:01:07 2011
New Revision: 1073946

URL: http://svn.apache.org/viewvc?rev=1073946&view=rev
Log:
switched to JSR330(DI) annotations

Modified:
    incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ConfigurationStateProvider.java
    incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/GuiceAwareConstraintValidatorFactory.java
    incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidateMethodInterceptor.java
    incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidationModule.java
    incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidatorFactoryProvider.java
    incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidatorProvider.java
    incubator/bval/trunk/bval-guice/src/test/java/org/apache/bval/guice/DummyCountryDao.java
    incubator/bval/trunk/bval-guice/src/test/java/org/apache/bval/guice/GuiceAwareValidationTestCase.java

Modified: incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ConfigurationStateProvider.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ConfigurationStateProvider.java?rev=1073946&r1=1073945&r2=1073946&view=diff
==============================================================================
--- incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ConfigurationStateProvider.java
(original)
+++ incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ConfigurationStateProvider.java
Wed Feb 23 21:01:07 2011
@@ -16,53 +16,68 @@
  */
 package org.apache.bval.guice;
 
+import javax.inject.Inject;
+import javax.inject.Provider;
 import javax.validation.ConstraintValidatorFactory;
 import javax.validation.MessageInterpolator;
 import javax.validation.TraversableResolver;
+import javax.validation.spi.BootstrapState;
 import javax.validation.spi.ConfigurationState;
 import javax.validation.spi.ValidationProvider;
 
 import org.apache.bval.jsr303.ConfigurationImpl;
 
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.Singleton;
-
 /**
  * The {@code javax.validation.spi.ConfigurationState} provider implementation.
  *
  * @version $Id$
  */
-@Singleton
 public final class ConfigurationStateProvider implements Provider<ConfigurationState>
{
 
-    private final ConfigurationImpl configurationState;
+    @com.google.inject.Inject(optional = true)
+    private BootstrapState bootstrapState;
 
     @Inject
-    public ConfigurationStateProvider(ValidationProvider<?> aProvider) {
-        this.configurationState = new ConfigurationImpl(null, aProvider);
-    }
+    private ValidationProvider<?> validationProvider;
 
     @Inject
-    public void traversableResolver(TraversableResolver traversableResolver) {
-        this.configurationState.traversableResolver(traversableResolver);
-    }
+    private TraversableResolver traversableResolver;
 
     @Inject
-    public void messageInterpolator(MessageInterpolator messageInterpolator) {
-        this.configurationState.messageInterpolator(messageInterpolator);
-    }
+    private MessageInterpolator messageInterpolator;
 
     @Inject
-    public void constraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory)
{
-        this.configurationState.constraintValidatorFactory(constraintValidatorFactory);
+    private ConstraintValidatorFactory constraintValidatorFactory;
+
+    public void setBootstrapState(BootstrapState bootstrapState) {
+        this.bootstrapState = bootstrapState;
+    }
+
+    public void setValidationProvider(ValidationProvider<?> validationProvider) {
+        this.validationProvider = validationProvider;
+    }
+
+    public void setTraversableResolver(TraversableResolver traversableResolver) {
+        this.traversableResolver = traversableResolver;
+    }
+
+    public void setMessageInterpolator(MessageInterpolator messageInterpolator) {
+        this.messageInterpolator = messageInterpolator;
+    }
+
+    public void setConstraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory)
{
+        this.constraintValidatorFactory = constraintValidatorFactory;
     }
 
     /**
      * {@inheritDoc}
      */
     public ConfigurationState get() {
-        return this.configurationState;
+        ConfigurationImpl configuration = new ConfigurationImpl(this.bootstrapState, this.validationProvider);
+        configuration.traversableResolver(this.traversableResolver);
+        configuration.messageInterpolator(this.messageInterpolator);
+        configuration.constraintValidatorFactory(this.constraintValidatorFactory);
+        return configuration;
     }
 
 }

Modified: incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/GuiceAwareConstraintValidatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/GuiceAwareConstraintValidatorFactory.java?rev=1073946&r1=1073945&r2=1073946&view=diff
==============================================================================
--- incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/GuiceAwareConstraintValidatorFactory.java
(original)
+++ incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/GuiceAwareConstraintValidatorFactory.java
Wed Feb 23 21:01:07 2011
@@ -16,12 +16,12 @@
  */
 package org.apache.bval.guice;
 
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorFactory;
 
-import com.google.inject.Inject;
 import com.google.inject.Injector;
-import com.google.inject.Singleton;
 
 /**
  * {@code javax.validation.ConstraintValidatorFactory} implementation that
@@ -32,10 +32,10 @@ import com.google.inject.Singleton;
 @Singleton
 final class GuiceAwareConstraintValidatorFactory implements ConstraintValidatorFactory {
 
-    private final Injector injector;
-
     @Inject
-    public GuiceAwareConstraintValidatorFactory(Injector injector) {
+    private Injector injector;
+
+    public void setInjector(Injector injector) {
         this.injector = injector;
     }
 

Modified: incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidateMethodInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidateMethodInterceptor.java?rev=1073946&r1=1073945&r2=1073946&view=diff
==============================================================================
--- incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidateMethodInterceptor.java
(original)
+++ incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidateMethodInterceptor.java
Wed Feb 23 21:01:07 2011
@@ -22,6 +22,7 @@ import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.inject.Inject;
 import javax.validation.ConstraintViolation;
 import javax.validation.ConstraintViolationException;
 import javax.validation.Validator;
@@ -30,8 +31,6 @@ import org.aopalliance.intercept.MethodI
 import org.aopalliance.intercept.MethodInvocation;
 import org.apache.bval.jsr303.extensions.MethodValidator;
 
-import com.google.inject.Inject;
-
 /**
  * Method interceptor for {@link Validate} annotation.
  *

Modified: incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidationModule.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidationModule.java?rev=1073946&r1=1073945&r2=1073946&view=diff
==============================================================================
--- incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidationModule.java
(original)
+++ incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidationModule.java
Wed Feb 23 21:01:07 2011
@@ -51,8 +51,8 @@ public final class ValidationModule exte
         this.bind(TraversableResolver.class).to(DefaultTraversableResolver.class).in(Scopes.SINGLETON);
         this.bind(ConstraintValidatorFactory.class).to(GuiceAwareConstraintValidatorFactory.class);
         this.bind(new TypeLiteral<ValidationProvider<?>>() {}).to(ApacheValidationProvider.class).in(Scopes.SINGLETON);
-        this.bind(ConfigurationState.class).toProvider(ConfigurationStateProvider.class);
-        this.bind(ValidatorFactory.class).toProvider(ValidatorFactoryProvider.class);
+        this.bind(ConfigurationState.class).toProvider(ConfigurationStateProvider.class).in(Scopes.SINGLETON);
+        this.bind(ValidatorFactory.class).toProvider(ValidatorFactoryProvider.class).in(Scopes.SINGLETON);
         this.bind(Validator.class).toProvider(ValidatorProvider.class);
 
         // AOP stuff

Modified: incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidatorFactoryProvider.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidatorFactoryProvider.java?rev=1073946&r1=1073945&r2=1073946&view=diff
==============================================================================
--- incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidatorFactoryProvider.java
(original)
+++ incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidatorFactoryProvider.java
Wed Feb 23 21:01:07 2011
@@ -16,15 +16,14 @@
  */
 package org.apache.bval.guice;
 
+import javax.inject.Inject;
+import javax.inject.Provider;
+import javax.inject.Singleton;
 import javax.validation.ValidatorFactory;
 import javax.validation.spi.ConfigurationState;
 
 import org.apache.bval.jsr303.ApacheValidationProvider;
 
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.Singleton;
-
 /**
  * Validator Factory guice provider implementation.
  *
@@ -33,18 +32,18 @@ import com.google.inject.Singleton;
 @Singleton
 final class ValidatorFactoryProvider implements Provider<ValidatorFactory> {
 
-    private final ValidatorFactory validatorFactory;
-
     @Inject
-    public ValidatorFactoryProvider(ConfigurationState configurationState) {
-        this.validatorFactory = new ApacheValidationProvider().buildValidatorFactory(configurationState);
+    private ConfigurationState configurationState;
+
+    public void setConfigurationState(ConfigurationState configurationState) {
+        this.configurationState = configurationState;
     }
 
     /**
      * {@inheritDoc}
      */
     public ValidatorFactory get() {
-        return this.validatorFactory;
+        return new ApacheValidationProvider().buildValidatorFactory(this.configurationState);
     }
 
 }

Modified: incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidatorProvider.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidatorProvider.java?rev=1073946&r1=1073945&r2=1073946&view=diff
==============================================================================
--- incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidatorProvider.java
(original)
+++ incubator/bval/trunk/bval-guice/src/main/java/org/apache/bval/guice/ValidatorProvider.java
Wed Feb 23 21:01:07 2011
@@ -16,13 +16,12 @@
  */
 package org.apache.bval.guice;
 
+import javax.inject.Inject;
+import javax.inject.Provider;
+import javax.inject.Singleton;
 import javax.validation.Validator;
 import javax.validation.ValidatorFactory;
 
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.Singleton;
-
 /**
  * Validator guice provider implementation.
  *
@@ -34,15 +33,10 @@ final class ValidatorProvider implements
     /**
      * The validator reference.
      */
-    private final ValidatorFactory validatorFactory;
-
-    /**
-     * Build a new ValidatorProvider by ValidatorFactory.
-     *
-     * @param validatorFactory the ValidatorFactory reference.
-     */
     @Inject
-    public ValidatorProvider(ValidatorFactory validatorFactory) {
+    private ValidatorFactory validatorFactory;
+
+    public void setValidatorFactory(ValidatorFactory validatorFactory) {
         this.validatorFactory = validatorFactory;
     }
 

Modified: incubator/bval/trunk/bval-guice/src/test/java/org/apache/bval/guice/DummyCountryDao.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-guice/src/test/java/org/apache/bval/guice/DummyCountryDao.java?rev=1073946&r1=1073945&r2=1073946&view=diff
==============================================================================
--- incubator/bval/trunk/bval-guice/src/test/java/org/apache/bval/guice/DummyCountryDao.java
(original)
+++ incubator/bval/trunk/bval-guice/src/test/java/org/apache/bval/guice/DummyCountryDao.java
Wed Feb 23 21:01:07 2011
@@ -16,12 +16,11 @@
  */
 package org.apache.bval.guice;
 
+import javax.inject.Singleton;
 import javax.validation.Valid;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 
-import com.google.inject.Singleton;
-
 /**
  * 
  *

Modified: incubator/bval/trunk/bval-guice/src/test/java/org/apache/bval/guice/GuiceAwareValidationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-guice/src/test/java/org/apache/bval/guice/GuiceAwareValidationTestCase.java?rev=1073946&r1=1073945&r2=1073946&view=diff
==============================================================================
--- incubator/bval/trunk/bval-guice/src/test/java/org/apache/bval/guice/GuiceAwareValidationTestCase.java
(original)
+++ incubator/bval/trunk/bval-guice/src/test/java/org/apache/bval/guice/GuiceAwareValidationTestCase.java
Wed Feb 23 21:01:07 2011
@@ -18,6 +18,7 @@ package org.apache.bval.guice;
 
 import java.util.Set;
 
+import javax.inject.Inject;
 import javax.validation.ConstraintViolation;
 import javax.validation.ConstraintViolationException;
 import javax.validation.Validator;
@@ -25,7 +26,6 @@ import javax.validation.Validator;
 import junit.framework.TestCase;
 
 import com.google.inject.Guice;
-import com.google.inject.Inject;
 import com.google.inject.Injector;
 
 /**



Mime
View raw message