[jboss-cvs] JBossAS SVN: r77146 - in projects/metadata/trunk/src: main/java/org/jboss/metadata/annotation/creator/jboss and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Aug 18 03:32:34 EDT 2008


Author: emuckenhuber
Date: 2008-08-18 03:32:34 -0400 (Mon, 18 Aug 2008)
New Revision: 77146

Added:
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractPersistenceUnitProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextsClassProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitClassProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitFieldProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitMethodProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitsClassProcessor.java
Modified:
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractComponentProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/jboss/AbstractComponentProcessor.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/client/AnnotationClientUnitTestCase.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/web/AnnotationWebUnitTestCase.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/web/MyServlet.java
Log:
[JBMETA-96] - @PersistenceUnit processing


Property changes on: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator
___________________________________________________________________
Name: svn:ignore
   + base


Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractComponentProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractComponentProcessor.java	2008-08-18 06:35:52 UTC (rev 77145)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractComponentProcessor.java	2008-08-18 07:32:34 UTC (rev 77146)
@@ -65,6 +65,12 @@
       addFieldProcessor(new PersistenceContextFieldProcessor(finder));
       addMethodProcessor(new PersistenceContextMethodProcessor(finder));
       addTypeProcessor(new PersistenceContextClassProcessor(finder));
+      addTypeProcessor(new PersistenceContextsClassProcessor(finder));
+      // @PersistenceUnit/@PersistenceUnits
+      addFieldProcessor(new PersistenceUnitFieldProcessor(finder));
+      addMethodProcessor(new PersistenceUnitMethodProcessor(finder));
+      addTypeProcessor(new PersistenceUnitClassProcessor(finder));
+      addTypeProcessor(new PersistenceUnitsClassProcessor(finder));
       // @PostConstruct/@PreDestroy
       addMethodProcessor(new PostConstructMethodProcessor(finder));
       addMethodProcessor(new PreDestroyMethodProcessor(finder));

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractPersistenceUnitProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractPersistenceUnitProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractPersistenceUnitProcessor.java	2008-08-18 07:32:34 UTC (rev 77146)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.metadata.annotation.creator;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+import java.util.Set;
+
+import javax.persistence.PersistenceUnit;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.javaee.spec.PersistenceUnitReferenceMetaData;
+import org.jboss.metadata.javaee.spec.PersistenceUnitReferencesMetaData;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+
+/**
+ * @PersistenceUnit processor
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractPersistenceUnitProcessor<E extends AnnotatedElement>
+   extends AbstractInjectionTargetProcessor<E>
+{
+
+   protected AbstractPersistenceUnitProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+   
+   public void process(PersistenceUnitReferencesMetaData metaData, E element)
+   {
+      PersistenceUnit annotation = finder.getAnnotation(element, PersistenceUnit.class);
+      if(annotation == null)
+         return;
+      
+      process(metaData, element, annotation);
+   }
+   
+   protected void process(PersistenceUnitReferencesMetaData refs, E element, PersistenceUnit annotation)
+   {
+      PersistenceUnitReferenceMetaData ref = createPU(element, annotation);
+      addReference(refs, ref);
+   }
+   
+   protected abstract String getName(E element);
+   protected abstract String getInjectionName(E element);
+   
+   protected PersistenceUnitReferenceMetaData createPU(E element, PersistenceUnit annotation)
+   {
+      PersistenceUnitReferenceMetaData ref = new PersistenceUnitReferenceMetaData();
+      String name = annotation.name();
+      if(name.length() == 0)
+         name = getName(element);
+      ref.setPersistenceUnitRefName(name);
+      if(annotation.unitName().length() != 0)
+         ref.setPersistenceUnitName(annotation.unitName());
+      
+      String injectionName = getInjectionName(element);
+      Set<ResourceInjectionTargetMetaData> injectionTargets = ProcessorUtils.getInjectionTargets(injectionName, element);
+      if(injectionTargets != null)
+         ref.setInjectionTargets(injectionTargets);
+
+      return ref;
+   }
+   
+   public Collection<Class<? extends Annotation>> getAnnotationTypes()
+   {
+      return ProcessorUtils.createAnnotationSet(PersistenceUnit.class);
+   }
+}
+

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextsClassProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextsClassProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceContextsClassProcessor.java	2008-08-18 07:32:34 UTC (rev 77146)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.metadata.annotation.creator;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContexts;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.javaee.spec.PersistenceContextReferencesMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class PersistenceContextsClassProcessor extends PersistenceContextClassProcessor
+   implements Processor<PersistenceContextReferencesMetaData, Class>
+{
+
+   public PersistenceContextsClassProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+   
+   @Override
+   public void process(PersistenceContextReferencesMetaData refs, Class element)
+   {
+      PersistenceContexts annotation = finder.getAnnotation(element, PersistenceContexts.class);
+      if(annotation == null)
+         return;
+      
+      for(PersistenceContext context : annotation.value())
+      {
+         process(refs, element, context);
+      }
+   }
+
+   public Collection<Class<? extends Annotation>> getAnnotationTypes()
+   {
+      return ProcessorUtils.createAnnotationSet(PersistenceContexts.class);
+   }
+
+}
+

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitClassProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitClassProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitClassProcessor.java	2008-08-18 07:32:34 UTC (rev 77146)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.javaee.spec.PersistenceUnitReferencesMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class PersistenceUnitClassProcessor extends AbstractPersistenceUnitProcessor<Class<?>>
+   implements Processor<PersistenceUnitReferencesMetaData, Class<?>>
+{
+
+   public PersistenceUnitClassProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+
+   @Override
+   protected String getName(Class<?> element)
+   {
+      return element.getSimpleName();
+   }
+   
+   @Override
+   protected String getInjectionName(Class<?> element)
+   {
+      return null;
+   }
+
+}
+

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitFieldProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitFieldProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitFieldProcessor.java	2008-08-18 07:32:34 UTC (rev 77146)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.javaee.spec.PersistenceUnitReferencesMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class PersistenceUnitFieldProcessor extends AbstractPersistenceUnitProcessor<Field>
+   implements Processor<PersistenceUnitReferencesMetaData, Field>
+{
+
+   public PersistenceUnitFieldProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+
+   @Override
+   protected String getInjectionName(Field element)
+   {
+      return element.getName();
+   }
+
+   @Override
+   protected String getName(Field element)
+   {
+      return element.getName();
+   }
+
+}
+

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitMethodProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitMethodProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitMethodProcessor.java	2008-08-18 07:32:34 UTC (rev 77146)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.metadata.annotation.creator;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.javaee.spec.PersistenceUnitReferencesMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class PersistenceUnitMethodProcessor extends AbstractPersistenceUnitProcessor<Method>
+   implements Processor<PersistenceUnitReferencesMetaData, Method>
+{
+
+   public PersistenceUnitMethodProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+
+   @Override
+   protected String getInjectionName(Method element)
+   {
+      return element.getName();
+   }
+
+   @Override
+   protected String getName(Method element)
+   {
+      String name = element.getName().substring(3);
+      if (name.length() > 1)
+      {
+         name = name.substring(0, 1).toLowerCase() + name.substring(1);
+      }
+      else
+      {
+         name = name.toLowerCase();
+      }
+      return name;
+   }
+
+}
+

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitsClassProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitsClassProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/PersistenceUnitsClassProcessor.java	2008-08-18 07:32:34 UTC (rev 77146)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.metadata.annotation.creator;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+
+import javax.persistence.PersistenceUnit;
+import javax.persistence.PersistenceUnits;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.javaee.spec.PersistenceUnitReferencesMetaData;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class PersistenceUnitsClassProcessor extends PersistenceUnitClassProcessor
+   implements Processor<PersistenceUnitReferencesMetaData, Class<?>>
+{
+
+   public PersistenceUnitsClassProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+   
+   @Override
+   public void process(PersistenceUnitReferencesMetaData refs, Class<?> element)
+   {
+      PersistenceUnits annotation = finder.getAnnotation(element, PersistenceUnits.class);
+      if(annotation == null)
+         return;
+      
+      for(PersistenceUnit unit : annotation.value())
+      {
+         process(refs, element, unit);
+      }
+    }
+   
+   public Collection<Class<? extends Annotation>> getAnnotationTypes()
+   {
+      return ProcessorUtils.createAnnotationSet(PersistenceUnits.class);
+   }
+}
+

Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/jboss/AbstractComponentProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/jboss/AbstractComponentProcessor.java	2008-08-18 06:35:52 UTC (rev 77145)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/jboss/AbstractComponentProcessor.java	2008-08-18 07:32:34 UTC (rev 77146)
@@ -31,6 +31,11 @@
 import org.jboss.metadata.annotation.creator.PersistenceContextClassProcessor;
 import org.jboss.metadata.annotation.creator.PersistenceContextFieldProcessor;
 import org.jboss.metadata.annotation.creator.PersistenceContextMethodProcessor;
+import org.jboss.metadata.annotation.creator.PersistenceContextsClassProcessor;
+import org.jboss.metadata.annotation.creator.PersistenceUnitClassProcessor;
+import org.jboss.metadata.annotation.creator.PersistenceUnitFieldProcessor;
+import org.jboss.metadata.annotation.creator.PersistenceUnitMethodProcessor;
+import org.jboss.metadata.annotation.creator.PersistenceUnitsClassProcessor;
 import org.jboss.metadata.annotation.creator.PostConstructMethodProcessor;
 import org.jboss.metadata.annotation.creator.PreDestroyMethodProcessor;
 import org.jboss.metadata.annotation.creator.ResourceClassProcessor;
@@ -80,6 +85,12 @@
       addFieldProcessor(new PersistenceContextFieldProcessor(finder));
       addMethodProcessor(new PersistenceContextMethodProcessor(finder));
       addTypeProcessor(new PersistenceContextClassProcessor(finder));
+      addTypeProcessor(new PersistenceContextsClassProcessor(finder));
+      // @PersistenceUnit/@PersistenceUnits
+      addFieldProcessor(new PersistenceUnitFieldProcessor(finder));
+      addMethodProcessor(new PersistenceUnitMethodProcessor(finder));
+      addTypeProcessor(new PersistenceUnitClassProcessor(finder));
+      addTypeProcessor(new PersistenceUnitsClassProcessor(finder));
       // @PostConstruct/@PreDestroy
       addMethodProcessor(new PostConstructMethodProcessor(finder));
       addMethodProcessor(new PreDestroyMethodProcessor(finder));

Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/client/AnnotationClientUnitTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/client/AnnotationClientUnitTestCase.java	2008-08-18 06:35:52 UTC (rev 77145)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/client/AnnotationClientUnitTestCase.java	2008-08-18 07:32:34 UTC (rev 77146)
@@ -35,6 +35,9 @@
 import javax.ejb.EJB;
 import javax.ejb.EJBs;
 import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContexts;
+import javax.persistence.PersistenceUnit;
+import javax.persistence.PersistenceUnits;
 import javax.xml.ws.WebServiceRef;
 import javax.xml.ws.WebServiceRefs;
 
@@ -396,6 +399,9 @@
       typeAnnotations.add(EJB.class);
       typeAnnotations.add(EJBs.class);
       typeAnnotations.add(PersistenceContext.class);
+      typeAnnotations.add(PersistenceContexts.class);
+      typeAnnotations.add(PersistenceUnit.class);
+      typeAnnotations.add(PersistenceUnits.class);
       typeAnnotations.add(WebServiceRef.class);
       typeAnnotations.add(WebServiceRefs.class);
       
@@ -408,6 +414,7 @@
       methodAnnotations.add(Resource.class);
       methodAnnotations.add(EJB.class);
       methodAnnotations.add(PersistenceContext.class);
+      methodAnnotations.add(PersistenceUnit.class);
       methodAnnotations.add(WebServiceRef.class);
       
       // Assert Method annotations
@@ -417,6 +424,7 @@
       fieldAnnotations.add(Resource.class);
       fieldAnnotations.add(EJB.class);
       fieldAnnotations.add(PersistenceContext.class);
+      fieldAnnotations.add(PersistenceUnit.class);
       fieldAnnotations.add(WebServiceRef.class);
       
       // Assert Field annotations

Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/web/AnnotationWebUnitTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/web/AnnotationWebUnitTestCase.java	2008-08-18 06:35:52 UTC (rev 77145)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/web/AnnotationWebUnitTestCase.java	2008-08-18 07:32:34 UTC (rev 77146)
@@ -38,6 +38,9 @@
 import javax.ejb.EJB;
 import javax.ejb.EJBs;
 import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContexts;
+import javax.persistence.PersistenceUnit;
+import javax.persistence.PersistenceUnits;
 import javax.transaction.UserTransaction;
 import javax.xml.ws.WebServiceRef;
 import javax.xml.ws.WebServiceRefs;
@@ -53,6 +56,7 @@
 import org.jboss.metadata.javaee.spec.EnvironmentRefsGroupMetaData;
 import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
 import org.jboss.metadata.javaee.spec.MessageDestinationReferencesMetaData;
+import org.jboss.metadata.javaee.spec.PersistenceContextReferenceMetaData;
 import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
 import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferencesMetaData;
 import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
@@ -70,7 +74,6 @@
 import org.jboss.metadata.web.spec.ServletMetaData;
 import org.jboss.metadata.web.spec.Web25MetaData;
 import org.jboss.metadata.web.spec.WebMetaData;
-import org.jboss.test.metadata.annotation.ejb3.MyStateful21;
 import org.jboss.test.metadata.annotation.ejb3.MyStatelessLocal;
 import org.jboss.test.metadata.annotation.ws.TestEndpoint;
 import org.jboss.test.metadata.annotation.ws.TestEndpointService;
@@ -276,6 +279,19 @@
       assertEquals("setUp", metaData.getPostConstructs().get(0).getMethodName());
       // @PreDestroy
       assertEquals("tearDown", metaData.getPreDestroys().get(0).getMethodName());
+      
+      
+      assertNotNull(metaData.getPersistenceContextRefs());
+      assertEquals(2, metaData.getPersistenceContextRefs().size());
+      PersistenceContextReferenceMetaData ref = metaData.getPersistenceContextReferenceByName("injectedEntityManager");
+      assertNotNull(ref);
+      ref = metaData.getPersistenceContextReferenceByName("persistence/ABC");
+      assertNotNull(ref);
+      assertEquals("ABC", ref.getPersistenceUnitName());
+      
+      assertNotNull(metaData.getPersistenceUnitRefs());
+      assertEquals(1, metaData.getPersistenceUnitRefs().size());
+      assertNotNull(metaData.getPersistenceUnitReferenceByName("injectedEntityManagerFactory"));
    }
 
    public void testAnnotationRead() throws Exception
@@ -455,6 +471,9 @@
       typeAnnotations.add(EJB.class);
       typeAnnotations.add(EJBs.class);
       typeAnnotations.add(PersistenceContext.class);
+      typeAnnotations.add(PersistenceContexts.class);
+      typeAnnotations.add(PersistenceUnit.class);
+      typeAnnotations.add(PersistenceUnits.class);
       typeAnnotations.add(WebServiceRef.class);
       typeAnnotations.add(WebServiceRefs.class);
 
@@ -467,6 +486,7 @@
       methodAnnotations.add(Resource.class);
       methodAnnotations.add(EJB.class);
       methodAnnotations.add(PersistenceContext.class);
+      methodAnnotations.add(PersistenceUnit.class);
       methodAnnotations.add(WebServiceRef.class);
 
       // Assert Method annotations
@@ -476,6 +496,7 @@
       fieldAnnotations.add(Resource.class);
       fieldAnnotations.add(EJB.class);
       fieldAnnotations.add(PersistenceContext.class);
+      fieldAnnotations.add(PersistenceUnit.class);
       fieldAnnotations.add(WebServiceRef.class);
 
       // Assert Field Annotations

Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/web/MyServlet.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/web/MyServlet.java	2008-08-18 06:35:52 UTC (rev 77145)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/web/MyServlet.java	2008-08-18 07:32:34 UTC (rev 77146)
@@ -44,6 +44,7 @@
    @WebServiceRef(name = "service2", value = TestEndpointService.class),
    @WebServiceRef(name = "port1", value = TestEndpointService.class, type = TestEndpoint.class)
 })
+ at PersistenceContext(name="persistence/ABC", unitName="ABC")
 public class MyServlet
 {
    @Resource




More information about the jboss-cvs-commits mailing list