incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r942372 - in /incubator/bval/sandbox/guice-integration/src: main/java/org/apache/bval/extentions/guice/ test/java/org/apache/bval/extentions/guice/
Date Sat, 08 May 2010 12:02:03 GMT
Author: simonetripodi
Date: Sat May  8 12:02:02 2010
New Revision: 942372

URL: http://svn.apache.org/viewvc?rev=942372&view=rev
Log:
added groups support for AOP validation

Added:
    incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Insert.java
  (with props)
    incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Update.java
  (with props)
Modified:
    incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/Validate.java
    incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidateMethodInterceptor.java
    incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Country.java
    incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/DummyCountryDao.java

Modified: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/Validate.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/Validate.java?rev=942372&r1=942371&r2=942372&view=diff
==============================================================================
--- incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/Validate.java
(original)
+++ incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/Validate.java
Sat May  8 12:02:02 2010
@@ -33,4 +33,6 @@ import com.google.inject.BindingAnnotati
 @Target(ElementType.METHOD)
 public @interface Validate {
 
+    Class<?>[] groups() default {};
+
 }

Modified: incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidateMethodInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidateMethodInterceptor.java?rev=942372&r1=942371&r2=942372&view=diff
==============================================================================
--- incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidateMethodInterceptor.java
(original)
+++ incubator/bval/sandbox/guice-integration/src/main/java/org/apache/bval/extentions/guice/ValidateMethodInterceptor.java
Sat May  8 12:02:02 2010
@@ -55,8 +55,10 @@ public final class ValidateMethodInterce
     public Object invoke(MethodInvocation invocation) throws Throwable {
         Set<ConstraintViolation<?>> constraintViolations = new HashSet<ConstraintViolation<?>>();
 
+        Class<?>[] groups = invocation.getMethod().getAnnotation(Validate.class).groups();
+
         for (Object arg : invocation.getArguments()) {
-            constraintViolations.addAll(this.validator.validate(arg));
+            constraintViolations.addAll(this.validator.validate(arg, groups));
         }
 
         if (!constraintViolations.isEmpty()) {

Modified: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Country.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Country.java?rev=942372&r1=942371&r2=942372&view=diff
==============================================================================
--- incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Country.java
(original)
+++ incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Country.java
Sat May  8 12:02:02 2010
@@ -28,15 +28,28 @@ import javax.validation.constraints.Size
  */
 public class Country {
 
-    @NotNull
+    @NotNull(groups = { Update.class })
+    private Long id;
+
+    @NotNull(groups = { Insert.class })
     private String name;
 
-    @Size(max = 2)
+    @NotNull(groups = { Insert.class })
+    @Size(max = 2, groups = { Insert.class, Update.class })
     private String iso2Code;
 
-    @Size(max = 3)
+    @NotNull(groups = { Insert.class })
+    @Size(max = 3, groups = { Insert.class, Update.class })
     private String iso3Code;
 
+    public Long getId() {
+        return this.id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
     public String getName() {
         return name;
     }

Modified: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/DummyCountryDao.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/DummyCountryDao.java?rev=942372&r1=942371&r2=942372&view=diff
==============================================================================
--- incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/DummyCountryDao.java
(original)
+++ incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/DummyCountryDao.java
Sat May  8 12:02:02 2010
@@ -23,7 +23,7 @@ package org.apache.bval.extentions.guice
  */
 public class DummyCountryDao {
 
-    @Validate
+    @Validate(groups = { Insert.class })
     public void insertCountry(Country country) {
         // do nothing
     }

Added: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Insert.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Insert.java?rev=942372&view=auto
==============================================================================
--- incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Insert.java
(added)
+++ incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Insert.java
Sat May  8 12:02:02 2010
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.bval.extentions.guice;
+
+/**
+ * 
+ *
+ * @version $Id$
+ */
+public interface Insert {
+
+}

Propchange: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Insert.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Insert.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Insert.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Update.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Update.java?rev=942372&view=auto
==============================================================================
--- incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Update.java
(added)
+++ incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Update.java
Sat May  8 12:02:02 2010
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.bval.extentions.guice;
+
+/**
+ * 
+ *
+ * @version $Id$
+ */
+public interface Update {
+
+}

Propchange: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Update.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Update.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/sandbox/guice-integration/src/test/java/org/apache/bval/extentions/guice/Update.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message