Skip to content

Commit

Permalink
WELD-1088 Resource definition which specifies an EL name should be de…
Browse files Browse the repository at this point in the history
…finition error

Conflicts:

	impl/src/main/java/org/jboss/weld/bean/builtin/ee/EEResourceProducerField.java
	impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java
	impl/src/main/resources/org/jboss/weld/messages/bean_en.properties
	jboss-tck-runner/1.1/src/test/resources/tck-tests.xml
  • Loading branch information
jharting committed Aug 1, 2012
1 parent 1de0f42 commit b3cd5e6
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 6 deletions.
Expand Up @@ -16,6 +16,11 @@
*/
package org.jboss.weld.bean.builtin.ee;

import static org.jboss.weld.logging.messages.BeanMessage.BEAN_NOT_EE_RESOURCE_PRODUCER;
import static org.jboss.weld.logging.messages.BeanMessage.INVALID_RESOURCE_PRODUCER_FIELD;
import static org.jboss.weld.logging.messages.BeanMessage.NAMED_RESOURCE_PRODUCER_FIELD;
import static org.jboss.weld.logging.messages.BeanMessage.NON_DEPENDENT_RESOURCE_PRODUCER_FIELD;

import java.io.Serializable;

import javax.enterprise.context.Dependent;
Expand Down Expand Up @@ -44,10 +49,6 @@
import org.jboss.weld.util.reflection.Reflections;
import org.jboss.weld.ws.WSApiAbstraction;

import static org.jboss.weld.logging.messages.BeanMessage.BEAN_NOT_EE_RESOURCE_PRODUCER;
import static org.jboss.weld.logging.messages.BeanMessage.INVALID_RESOURCE_PRODUCER_FIELD;
import static org.jboss.weld.logging.messages.BeanMessage.NON_DEPENDENT_RESOURCE_PRODUCER_FIELD;

/**
* @author pmuir
*/
Expand Down Expand Up @@ -120,6 +121,9 @@ protected void checkEEResource() {
if (!getScope().equals(Dependent.class)) {
throw new DefinitionException(NON_DEPENDENT_RESOURCE_PRODUCER_FIELD, this);
}
if (getName() != null) {
throw new DefinitionException(NAMED_RESOURCE_PRODUCER_FIELD, this);
}
EJBApiAbstraction ejbApiAbstraction = beanManager.getServices().get(EJBApiAbstraction.class);
PersistenceApiAbstraction persistenceApiAbstraction = beanManager.getServices().get(PersistenceApiAbstraction.class);
WSApiAbstraction wsApiAbstraction = beanManager.getServices().get(WSApiAbstraction.class);
Expand Down
Expand Up @@ -144,6 +144,11 @@ public enum BeanMessage {
@MessageId("001508")INJECTION_TARGET_CANNOT_BE_CREATED_FOR_INTERFACE,
@MessageId("001509")BEAN_NOT_PASIVATION_CAPABLE_IN_SERIALIZATION,
@MessageId("001510")PROXY_HANDLER_SERIALIZED_FOR_NON_SERIALIZABLE_BEAN,
@MessageId("001511")SPECIALIZING_BEAN_MISSING_SPECIALIZED_TYPE;
@MessageId("001511")SPECIALIZING_BEAN_MISSING_SPECIALIZED_TYPE,
@MessageId("001512")INVALID_INJECTION_POINT_TYPE,
@MessageId("001513")INVALID_ANNOTATED_CALLABLE,
@MessageId("001514")INVALID_ANNOTATED_MEMBER,
@MessageId("001515")UNABLE_TO_LOAD_MEMBER,
@MessageId("001516")NAMED_RESOURCE_PRODUCER_FIELD;

}
Expand Up @@ -107,4 +107,8 @@ FAILED_TO_SET_THREAD_LOCAL_ON_PROXY=Failed to set ThreadLocal for serialization
CREATED_NEW_CLIENT_PROXY_TYPE=Created new client proxy of type {0} for bean {1} with ID {2}
LOOKED_UP_CLIENT_PROXY=Located client proxy of type {0} for bean {1}
INJECTION_TARGET_CANNOT_BE_CREATED_FOR_INTERFACE=Cannot create an InjectionTarget from {0} as it is an interface
SPECIALIZING_BEAN_MISSING_SPECIALIZED_TYPE=Specializing bean {0} does not have bean type {1} of specialized bean {2}
INVALID_INJECTION_POINT_TYPE={0} cannot be constructed for {1}
INVALID_ANNOTATED_CALLABLE=An implementation of AnnotatedCallable must implement either AnnotatedConstructor or AnnotatedMethod, {0}
INVALID_ANNOTATED_MEMBER=An implementation of AnnotatedMember must implement either AnnotatedConstructor, AnnotatedMethod or AnnotatedField, {0}
UNABLE_TO_LOAD_MEMBER=Unable to load annotated member {0}
NAMED_RESOURCE_PRODUCER_FIELD=Resource producer field [{0}] must not have an EL name
@@ -0,0 +1,36 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., 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.jboss.weld.tests.cditck11.simple.resource.broken.name;

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;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import javax.inject.Qualifier;

@Target({ TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
@Qualifier
public @interface Another {
}
@@ -0,0 +1,45 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., 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.jboss.weld.tests.cditck11.simple.resource.broken.name;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.ShouldThrowException;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.BeanArchive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* @author Martin Kouba
*/
@RunWith(Arquillian.class)
public class ResourceDefinitionWithNameTest {

@ShouldThrowException(Exception.class)
@Deployment
public static Archive<?> createTestArchive() {
return ShrinkWrap.create(BeanArchive.class).addPackage(ResourceDefinitionWithNameTest.class.getPackage());
}

@Test
public void testDeployment() {
}

}
@@ -0,0 +1,32 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., 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.jboss.weld.tests.cditck11.simple.resource.broken.name;

import javax.annotation.Resource;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Named;

public class ResourceProducer {

@SuppressWarnings("unused")
@Named
@Another
@Produces
@Resource(mappedName = "java:comp/BeanManager")
private BeanManager manager;
}

0 comments on commit b3cd5e6

Please sign in to comment.