[jboss-cvs] JBossAS SVN: r93414 - in projects/ejb3/trunk/core/src: test/java/org/jboss/ejb3/core/test and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Sep 11 11:33:30 EDT 2009
Author: wolfc
Date: 2009-09-11 11:33:29 -0400 (Fri, 11 Sep 2009)
New Revision: 93414
Added:
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1914/
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1914/DummyException.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1914/unit/
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1914/unit/OverrideAnnotationTestCase.java
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/aop/annotation/CachingAnnotationRepository.java
Log:
EJBTHREE-1917: make CachingAnnotationRepository implement ExtendedAnnotationRepository
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/aop/annotation/CachingAnnotationRepository.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/aop/annotation/CachingAnnotationRepository.java 2009-09-11 14:42:05 UTC (rev 93413)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/aop/annotation/CachingAnnotationRepository.java 2009-09-11 15:33:29 UTC (rev 93414)
@@ -30,6 +30,8 @@
import org.jboss.annotation.factory.AnnotationCreator;
import org.jboss.aop.annotation.AnnotationRepository;
+import org.jboss.ejb3.metadata.annotation.AnnotationRepositoryToMetaData;
+import org.jboss.ejb3.metadata.annotation.ExtendedAnnotationRepository;
import org.jboss.logging.Logger;
/**
@@ -46,14 +48,14 @@
* @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
* @version $Revision: $
*/
-public class CachingAnnotationRepository extends AnnotationRepository
+public class CachingAnnotationRepository extends AnnotationRepository implements ExtendedAnnotationRepository
{
private static final Logger log = Logger.getLogger(CachingAnnotationRepository.class);
// a magic NULL marker for in the cache
private static final Object NULL = new Object();
- private AnnotationRepository delegate;
+ private AnnotationRepositoryToMetaData delegate;
// Because AnnotationRepositoryToMetaData also does class loading, we should do this as well to
// cache the String variants of annotation lookup.
private ClassLoader classLoader;
@@ -61,7 +63,7 @@
private Map<Class<?>, Object> classAnnotationsCache = new ConcurrentHashMap<Class<?>, Object>();
private ConcurrentHashMap<Member, Map<Class<?>, Object>> memberCache = new ConcurrentHashMap<Member, Map<Class<?>, Object>>();
- public CachingAnnotationRepository(AnnotationRepository delegate, ClassLoader classLoader)
+ public CachingAnnotationRepository(AnnotationRepositoryToMetaData delegate, ClassLoader classLoader)
{
assert delegate != null;
assert classLoader != null;
@@ -150,6 +152,16 @@
throw new UnsupportedOperationException("EJBTHREE-1914: Unsupported");
}
+ public boolean hasAnnotation(Class<?> cls, Class<? extends Annotation> annotationType)
+ {
+ return delegate.hasAnnotation(cls, annotationType);
+ }
+
+ public boolean hasAnnotation(Class<?> cls, Member member, Class<? extends Annotation> annotationType)
+ {
+ return delegate.hasAnnotation(cls, member, annotationType);
+ }
+
@Override
public boolean hasAnnotation(CtMember m, String annotation)
{
@@ -239,6 +251,16 @@
}
}
+ public <A extends Annotation> A resolveAnnotation(Class<?> cls, Class<A> annotationType)
+ {
+ return delegate.resolveAnnotation(cls, annotationType);
+ }
+
+ public <A extends Annotation> A resolveAnnotation(Class<?> cls, Member member, Class<A> annotationType)
+ {
+ return delegate.resolveAnnotation(cls, member, annotationType);
+ }
+
@Override
public Object resolveAnnotation(Member m, Class annotationType)
{
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1914/DummyException.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1914/DummyException.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1914/DummyException.java 2009-09-11 15:33:29 UTC (rev 93414)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.ejbthree1914;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class DummyException extends Exception
+{
+ private static final long serialVersionUID = 1L;
+
+}
Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1914/unit/OverrideAnnotationTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1914/unit/OverrideAnnotationTestCase.java (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1914/unit/OverrideAnnotationTestCase.java 2009-09-11 15:33:29 UTC (rev 93414)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.core.test.ejbthree1914.unit;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.HashMap;
+import java.util.List;
+
+import javax.ejb.ApplicationException;
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3DescriptorHandler;
+import org.jboss.ejb3.core.test.common.AbstractEJB3TestCase;
+import org.jboss.ejb3.core.test.common.MockEjb3Deployment;
+import org.jboss.ejb3.core.test.ejbthree1506.TestBean;
+import org.jboss.ejb3.core.test.ejbthree1914.DummyException;
+import org.jboss.ejb3.interceptors.aop.ExtendedAdvisorHelper;
+import org.jboss.ejb3.test.cachepassivation.MockDeploymentUnit;
+import org.jboss.metadata.ejb.jboss.JBossAssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.ApplicationExceptionMetaData;
+import org.jboss.metadata.ejb.spec.ApplicationExceptionsMetaData;
+import org.jboss.metadata.ejb.spec.SessionType;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class OverrideAnnotationTestCase extends AbstractEJB3TestCase
+{
+ @Test
+ public void test1() throws Exception
+ {
+ JBossMetaData metaData = new JBossMetaData();
+ JBossEnterpriseBeansMetaData enterpriseBeans = new JBossEnterpriseBeansMetaData();
+ metaData.setEnterpriseBeans(enterpriseBeans);
+ JBossAssemblyDescriptorMetaData assemblyDescriptor = new JBossAssemblyDescriptorMetaData();
+ ApplicationExceptionsMetaData applicationExceptions = new ApplicationExceptionsMetaData();
+ ApplicationExceptionMetaData applicationExceptionMD = new ApplicationExceptionMetaData();
+ applicationExceptionMD.setExceptionClass(DummyException.class.getName());
+ applicationExceptions.add(applicationExceptionMD );
+ assemblyDescriptor.setApplicationExceptions(applicationExceptions );
+ metaData.setAssemblyDescriptor(assemblyDescriptor);
+ JBossSessionBeanMetaData sessionBeanMetaData = new JBossSessionBeanMetaData();
+ sessionBeanMetaData.setEnterpriseBeansMetaData(enterpriseBeans);
+ sessionBeanMetaData.setEjbClass(TestBean.class.getName());
+ sessionBeanMetaData.setEjbName("TestBean");
+ sessionBeanMetaData.setSessionType(SessionType.Stateful);
+ enterpriseBeans.add(sessionBeanMetaData);
+
+ MockEjb3Deployment deployment = new MockEjb3Deployment(new MockDeploymentUnit());
+ Ejb3DescriptorHandler handler = new Ejb3DescriptorHandler(deployment, metaData);
+ List<Container> containers = handler.getContainers(deployment, new HashMap<String, Container>());
+
+ EJBContainer container = (EJBContainer) containers.get(0);
+ Stateful annotation = ((EJBContainer) containers.get(0)).getAnnotation(Stateful.class);
+ assertNotNull("Can't find annotation @Stateful on the container", annotation);
+
+ //ApplicationException ex = container.getAnnotation(ApplicationException.class, DummyException.class);
+ ApplicationException ex = ExtendedAdvisorHelper.getExtendedAdvisor(container.getAdvisor()).resolveAnnotation(DummyException.class, ApplicationException.class);
+ assertNotNull("Can't find annotation @ApplicationException in the meta data", ex);
+ }
+}
More information about the jboss-cvs-commits
mailing list