Skip to content

Commit

Permalink
BVTCK-54 Using qualifiers for injected Strings in order to avoid clas…
Browse files Browse the repository at this point in the history
…hes with String producer methods from other extensions
  • Loading branch information
gunnarmorling committed Apr 2, 2013
1 parent eea9e1b commit 578b397
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 6 deletions.
Expand Up @@ -35,7 +35,7 @@ public interface IgnoredValidationGroup {
@Inject
@ValidAnotherBookingService
@Null(groups = IgnoredValidationGroup.class)
public AnotherBookingService(@Size(min = 5) @Null(groups = IgnoredValidationGroup.class) String name) {
public AnotherBookingService(@LongName @Size(min = 5) @Null(groups = IgnoredValidationGroup.class) String name) {
AnotherBookingService.name = name;
invocationCount++;
}
Expand Down
@@ -0,0 +1,36 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed 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.hibernate.beanvalidation.tck.tests.integration.cdi.executable;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.inject.Qualifier;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* @author Gunnar Morling
*/
@Qualifier
@Retention(RUNTIME)
@Target({ TYPE, METHOD, FIELD, PARAMETER })
public @interface LongName {
}
Expand Up @@ -30,6 +30,7 @@ public class NameProducer {

@Produces
@Dependent
@LongName
public String getName() {
return name;
}
Expand Down
Expand Up @@ -26,6 +26,6 @@ public class UserService {

@Inject
@CrossParameterConstraint
public UserService(@Size(min = 5) String name) {
public UserService(@LongName @Size(min = 5) String name) {
}
}
Expand Up @@ -28,6 +28,6 @@ public class AnotherCalendarService {

@Inject
@ValidateOnExecution(type = ExecutableType.NON_GETTER_METHODS)
public AnotherCalendarService(@Size(min = 5) String name) {
public AnotherCalendarService(@LongName @Size(min = 5) String name) {
}
}
Expand Up @@ -27,6 +27,6 @@ public class AnotherDeliveryService {

@Inject
@ValidateOnExecution
public AnotherDeliveryService(@Size(min = 5) String id) {
public AnotherDeliveryService(@LongName @Size(min = 5) String id) {
}
}
@@ -0,0 +1,36 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed 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.hibernate.beanvalidation.tck.tests.integration.cdi.executable.types;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.inject.Qualifier;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* @author Gunnar Morling
*/
@Qualifier
@Retention(RUNTIME)
@Target({ TYPE, METHOD, FIELD, PARAMETER })
public @interface LongName {
}
Expand Up @@ -28,6 +28,6 @@ public class OnlineCalendarService {

@Inject
@ValidateOnExecution(type = ExecutableType.CONSTRUCTORS)
public OnlineCalendarService(@Size(min = 5) String name) {
public OnlineCalendarService(@LongName @Size(min = 5) String name) {
}
}
Expand Up @@ -24,6 +24,7 @@
public class ParameterProducer {

@Produces
@LongName
public String getName() {
return "Bob";
}
Expand Down
Expand Up @@ -28,6 +28,6 @@ public class YetAnotherCalendarService {

@Inject
@ValidateOnExecution(type = ExecutableType.ALL)
public YetAnotherCalendarService(@Size(min = 5) String name) {
public YetAnotherCalendarService(@LongName @Size(min = 5) String name) {
}
}

0 comments on commit 578b397

Please sign in to comment.