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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jun 3 11:44:31 EDT 2010


Author: jaikiran
Date: 2010-06-03 11:44:30 -0400 (Thu, 03 Jun 2010)
New Revision: 105652

Added:
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ScheduleProcessor.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/common/ejb/IScheduleTarget.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossMessageDrivenBean31MetaData.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/MessageDrivenBean31MetaData.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/ScheduleMetaData.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/TimerMetaData.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/MDBWithSchedule.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/SimpleSLSBWithSchedule.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/SingletonWithSchedule.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/ScheduleTestCase.java
   projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/schedule/
   projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/schedule/ejb-jar.xml
Modified:
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/MessageDrivenProcessor.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/SingletonProcessor.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatelessProcessor.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/MessageDrivenProcessor.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/StatelessProcessor.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/EnterpriseBeanMetaData.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java
Log:
JBMETA-287 Added support for @Schedule annotation processing and its xml counterpart

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/MessageDrivenProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/MessageDrivenProcessor.java	2010-06-03 15:36:39 UTC (rev 105651)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/MessageDrivenProcessor.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -48,6 +48,10 @@
    {
       super(finder);
       addMethodProcessor(new TimeoutProcessor(finder));
+      
+      // add @Schedule processor
+      addMethodProcessor(new ScheduleProcessor(finder));
+
    }
 
    @Override

Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ScheduleProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ScheduleProcessor.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/ScheduleProcessor.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -0,0 +1,101 @@
+/*
+ * 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.metadata.annotation.creator.ejb;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+import java.util.Collection;
+
+import javax.ejb.Schedule;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.creator.EjbProcessorUtils;
+import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.creator.ProcessorUtils;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.common.ejb.IScheduleTarget;
+import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
+import org.jboss.metadata.ejb.spec.ScheduleMetaData;
+import org.jboss.metadata.ejb.spec.TimerMetaData;
+
+/**
+ * Processes {@link Schedule} annotation on bean methods.
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ScheduleProcessor extends AbstractFinderUser implements Processor<IScheduleTarget, Method>
+{
+
+   /**
+    * 
+    * @param finder
+    */
+   public ScheduleProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public Collection<Class<? extends Annotation>> getAnnotationTypes()
+   {
+      return ProcessorUtils.createAnnotationSet(Schedule.class);
+   }
+
+   /**
+    * Processes the passed <code>method</code> for {@link Schedule} annotation
+    * and creates {@link TimerMetaData} out of it for the bean
+    */
+   @Override
+   public void process(IScheduleTarget scheduleTargetBeanMetaData, Method method)
+   {
+      Schedule schedule = finder.getAnnotation(method, Schedule.class);
+      if(schedule == null)
+      {
+         return;
+      }
+      // create timer metadata
+      TimerMetaData timerMetadata = new TimerMetaData();
+      timerMetadata.setInfo(schedule.info());
+      timerMetadata.setPersistent(schedule.persistent());
+      timerMetadata.setTimezone(schedule.timezone());
+
+      // create a timeout method metadata for the method on which this
+      // @Schedule is present
+      NamedMethodMetaData timeoutMethod = new NamedMethodMetaData();
+      timeoutMethod.setMethodName(method.getName());
+      timeoutMethod.setMethodParams(EjbProcessorUtils.getMethodParameters(method));
+      timerMetadata.setTimeoutMethod(timeoutMethod);
+      
+      // create schedule metadata
+      ScheduleMetaData scheduleMetadata = new ScheduleMetaData(schedule);
+      timerMetadata.setSchedule(scheduleMetadata);
+
+      // finally set the timer metadata in the bean
+      scheduleTargetBeanMetaData.setTimer(timerMetadata);
+   }
+
+}

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/SingletonProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/SingletonProcessor.java	2010-06-03 15:36:39 UTC (rev 105651)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/SingletonProcessor.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -58,6 +58,10 @@
       
       addMethodProcessor(new LockMethodProcessor(finder));
       addMethodProcessor(new AccessTimeoutMethodProcessor(finder));
+      
+      // add @Schedule processor
+      addMethodProcessor(new ScheduleProcessor(finder));
+
    }
 
    @Override

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatelessProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatelessProcessor.java	2010-06-03 15:36:39 UTC (rev 105651)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/StatelessProcessor.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -43,6 +43,9 @@
    public StatelessProcessor(AnnotationFinder<AnnotatedElement> finder)
    {
       super(finder);
+
+      // add @Schedule processor
+      addMethodProcessor(new ScheduleProcessor(finder));
    }
    
    public SessionBeanMetaData create(Class<?> beanClass)

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/MessageDrivenProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/MessageDrivenProcessor.java	2010-06-03 15:36:39 UTC (rev 105651)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/MessageDrivenProcessor.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -29,7 +29,9 @@
 import javax.ejb.MessageDriven;
 
 import org.jboss.metadata.annotation.creator.ProcessorUtils;
+import org.jboss.metadata.annotation.creator.ejb.ScheduleProcessor;
 import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBean31MetaData;
 import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
 import org.jboss.metadata.ejb.spec.ActivationConfigMetaData;
 import org.jboss.metadata.ejb.spec.ActivationConfigPropertiesMetaData;
@@ -52,6 +54,9 @@
       super(finder);
       addTypeProcessor(new JBossResourceAdapterProcessor(finder));
       addMethodProcessor(new TimeoutProcessor(finder));
+      // add @Schedule processor
+      addMethodProcessor(new ScheduleProcessor(finder));
+
    }
 
    @Override
@@ -61,7 +66,7 @@
       if(annotation == null)
          return null;
 
-      JBossMessageDrivenBeanMetaData metaData = new JBossMessageDrivenBeanMetaData();
+      JBossMessageDrivenBeanMetaData metaData = new JBossMessageDrivenBean31MetaData();
       metaData.setEjbClass(beanClass.getName());
       if(annotation.name().length() > 0)
          metaData.setEjbName(annotation.name());

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/StatelessProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/StatelessProcessor.java	2010-06-03 15:36:39 UTC (rev 105651)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/StatelessProcessor.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -28,6 +28,7 @@
 import javax.ejb.Stateless;
 
 import org.jboss.metadata.annotation.creator.ProcessorUtils;
+import org.jboss.metadata.annotation.creator.ejb.ScheduleProcessor;
 import org.jboss.metadata.annotation.finder.AnnotationFinder;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
 import org.jboss.metadata.ejb.spec.SessionType;
@@ -46,6 +47,9 @@
    protected StatelessProcessor(AnnotationFinder<AnnotatedElement> finder)
    {
       super(finder);
+      
+      // add @Schedule processor
+      addMethodProcessor(new ScheduleProcessor(finder));
    }
 
    @Override

Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/common/ejb/IScheduleTarget.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/common/ejb/IScheduleTarget.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/common/ejb/IScheduleTarget.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -0,0 +1,38 @@
+/*
+ * 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.metadata.common.ejb;
+
+import org.jboss.metadata.ejb.spec.TimerMetaData;
+
+/**
+ * IScheduleTarget
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface IScheduleTarget extends ITimeoutTarget
+{
+
+   TimerMetaData getTimer();
+   
+   void setTimer(TimerMetaData timerMetaData);
+}

Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossMessageDrivenBean31MetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossMessageDrivenBean31MetaData.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossMessageDrivenBean31MetaData.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -0,0 +1,106 @@
+/*
+ * 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.metadata.ejb.jboss;
+
+import javax.ejb.Schedule;
+
+import org.jboss.metadata.common.ejb.IScheduleTarget;
+import org.jboss.metadata.common.ejb.ITimeoutTarget;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.MessageDrivenBean31MetaData;
+import org.jboss.metadata.ejb.spec.TimerMetaData;
+
+/**
+ * Metadata for EJB3.1 MDBs
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class JBossMessageDrivenBean31MetaData extends JBossMessageDrivenBeanMetaData implements ITimeoutTarget, IScheduleTarget
+{
+
+   /**
+    * Represents metadata for {@link Schedule}
+    */
+   private TimerMetaData timer;
+   
+   /**
+    * Returns the {@link TimerMetaData} associated with this bean
+    */
+   @Override
+   public TimerMetaData getTimer()
+   {
+      return this.timer;
+   }
+
+   /**
+    * Sets the {@link TimerMetaData} for this bean
+    */
+   @Override
+   public void setTimer(TimerMetaData timerMetaData)
+   {
+      this.timer = timerMetaData;
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void merge(JBossEnterpriseBeanMetaData override, EnterpriseBeanMetaData original, String overridenFile, String overrideFile, boolean mustOverride)
+   {
+      super.merge(override, original, overridenFile, overrideFile, mustOverride);
+      
+      JBossMessageDrivenBean31MetaData joverride = (JBossMessageDrivenBean31MetaData) override;
+      MessageDrivenBean31MetaData soriginal = (MessageDrivenBean31MetaData) original;
+      
+      if(joverride != null && joverride.timer != null)
+      {
+         this.timer = joverride.timer;
+      }
+      else if (soriginal != null && soriginal.getTimer() != null)
+      {
+         this.timer = soriginal.getTimer();
+      }
+
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   public void merge(JBossEnterpriseBeanMetaData overrideEjb, JBossEnterpriseBeanMetaData originalEjb)
+   {
+      super.merge(overrideEjb, originalEjb);
+      
+      JBossMessageDrivenBean31MetaData override = overrideEjb instanceof JBossGenericBeanMetaData ? null: (JBossMessageDrivenBean31MetaData) overrideEjb;
+      JBossMessageDrivenBean31MetaData original = originalEjb instanceof JBossGenericBeanMetaData ? null: (JBossMessageDrivenBean31MetaData) originalEjb;
+      
+      if(override != null && override.timer != null)
+      {
+         this.timer = override.timer;
+      }
+      else if (original != null && original.timer != null)
+      {
+         this.timer = original.timer;
+      }
+   }
+ 
+}

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java	2010-06-03 15:36:39 UTC (rev 105651)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/JBossSessionBean31MetaData.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -28,8 +28,10 @@
 
 import javax.ejb.ConcurrencyManagementType;
 import javax.ejb.LockType;
+import javax.ejb.Schedule;
 import javax.ejb.Startup;
 
+import org.jboss.metadata.common.ejb.IScheduleTarget;
 import org.jboss.metadata.common.ejb.ITimeoutTarget;
 import org.jboss.metadata.ejb.spec.AccessTimeoutMetaData;
 import org.jboss.metadata.ejb.spec.AsyncMethodsMetaData;
@@ -38,12 +40,13 @@
 import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
 import org.jboss.metadata.ejb.spec.SessionBean31MetaData;
 import org.jboss.metadata.ejb.spec.SessionType;
+import org.jboss.metadata.ejb.spec.TimerMetaData;
 
 /**
  * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
  * @version $Revision: $
  */
-public class JBossSessionBean31MetaData extends JBossSessionBeanMetaData implements ITimeoutTarget // FIXME: AbstractProcessor.processClass doesn't take super interfaces into account
+public class JBossSessionBean31MetaData extends JBossSessionBeanMetaData implements ITimeoutTarget, IScheduleTarget // FIXME: AbstractProcessor.processClass doesn't take super interfaces into account
 {
    private static final long serialVersionUID = 1L;
 
@@ -83,6 +86,11 @@
     * DependsOn for a singleton bean
     */
    private String[] dependsOn;
+   
+   /**
+    * For beans which have auto-timers (ex: through use of {@link Schedule})
+    */
+   private TimerMetaData timer;
 
    public AsyncMethodsMetaData getAsyncMethods()
    {
@@ -282,6 +290,23 @@
       this.setDependsOn(dependsOn.toArray(new String[dependsOn.size()]));
    }
 
+
+   /**
+    * Returns the {@link TimerMetaData} associated (if any) with this bean
+    */
+   public TimerMetaData getTimer()
+   {
+      return this.timer;
+   }
+   
+   /**
+    * Sets the {@link TimerMetaData} associated with this bean
+    */
+   public void setTimer(TimerMetaData timer)
+   {
+      this.timer = timer;
+   }
+   
    @Override
    public void merge(JBossEnterpriseBeanMetaData override, JBossEnterpriseBeanMetaData original)
    {
@@ -325,6 +350,10 @@
          {
             this.dependsOn = joverride.dependsOn;
          }
+         if (joverride.timer != null)
+         {
+            this.timer = joverride.timer;
+         }
       }
       else if (soriginal != null)
       {
@@ -354,6 +383,10 @@
          {
             this.dependsOn = soriginal.dependsOn;
          }
+         if (soriginal.timer != null)
+         {
+            this.timer = soriginal.timer;
+         }
       }
 
    }
@@ -398,6 +431,10 @@
          {
             this.dependsOn = joverride.dependsOn;
          }
+         if (joverride.timer != null)
+         {
+            this.timer = joverride.timer;
+         }
       }
       else if (soriginal != null)
       {
@@ -427,6 +464,10 @@
          {
             this.dependsOn = soriginal.getDependsOn();
          }
+         if (soriginal.getTimer() != null)
+         {
+            this.timer = soriginal.getTimer();
+         }
       }
 
    }

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/EnterpriseBeanMetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/EnterpriseBeanMetaData.java	2010-06-03 15:36:39 UTC (rev 105651)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/EnterpriseBeanMetaData.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -71,7 +71,7 @@
       particles={
             @JBossXmlModelGroup.Particle(element=@XmlElement(name="session"), type=SessionBean31MetaData.class),
             @JBossXmlModelGroup.Particle(element=@XmlElement(name="entity"), type=EntityBeanMetaData.class),
-            @JBossXmlModelGroup.Particle(element=@XmlElement(name="message-driven"), type=MessageDrivenBeanMetaData.class)})
+            @JBossXmlModelGroup.Particle(element=@XmlElement(name="message-driven"), type=MessageDrivenBean31MetaData.class)})
 public abstract class EnterpriseBeanMetaData extends NamedMetaDataWithDescriptionGroup
    implements Environment,
    IEnterpriseBeanMetaData<AssemblyDescriptorMetaData, EnterpriseBeansMetaData, EnterpriseBeanMetaData, EjbJarMetaData>

Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/MessageDrivenBean31MetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/MessageDrivenBean31MetaData.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/MessageDrivenBean31MetaData.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -0,0 +1,93 @@
+/*
+ * 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.metadata.ejb.spec;
+
+import javax.ejb.Schedule;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.metadata.common.ejb.IScheduleTarget;
+import org.jboss.metadata.common.ejb.ITimeoutTarget;
+import org.jboss.xb.annotations.JBossXmlConstants;
+import org.jboss.xb.annotations.JBossXmlType;
+
+/**
+ * Metadata for EJB3.1 MDBs
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at XmlType(name="message-driven-beanType", propOrder={"descriptionGroup", "ejbName", "mappedName", "ejbClass",
+      "transactionType", "messageSelector", "acknowledgeMode", "messageDrivenDestination", // <!-- these are ejb2.x
+      "messagingType",
+      "timeoutMethod", "timer", "transactionType", "messageDestinationType", "messageDestinationLink", "activationConfig", "aroundInvokes",
+      "environmentRefsGroup", "securityIdentity"})
+ at JBossXmlType(modelGroup=JBossXmlConstants.MODEL_GROUP_UNORDERED_SEQUENCE)      
+public class MessageDrivenBean31MetaData extends MessageDrivenBeanMetaData implements ITimeoutTarget, IScheduleTarget
+{
+
+   /**
+    * Represents metadata for {@link Schedule}
+    */
+   private TimerMetaData timer;
+   
+   /**
+    * Returns the {@link TimerMetaData} associated with this bean
+    */
+   @Override
+   public TimerMetaData getTimer()
+   {
+      return this.timer;
+   }
+
+   /**
+    * Sets the {@link TimerMetaData} for this bean
+    */
+   @Override
+   @XmlElement (name = "timer", required = false)
+   public void setTimer(TimerMetaData timerMetaData)
+   {
+      this.timer = timerMetaData;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public void merge(MessageDrivenBeanMetaData override, MessageDrivenBeanMetaData original)
+   {
+      super.merge(override, original);
+      
+      MessageDrivenBean31MetaData overrideMetaData = (MessageDrivenBean31MetaData) override;
+      MessageDrivenBean31MetaData originalMetaData = (MessageDrivenBean31MetaData) original;
+      
+      if (overrideMetaData != null && overrideMetaData.timer != null)
+      {
+         this.timer = overrideMetaData.timer;
+      }
+      else if (originalMetaData != null && originalMetaData.timer != null)
+      {
+         this.timer = originalMetaData.timer;
+      }
+      
+   }
+}

Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/ScheduleMetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/ScheduleMetaData.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/ScheduleMetaData.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -0,0 +1,149 @@
+/*
+ * 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.metadata.ejb.spec;
+
+import java.io.Serializable;
+
+import javax.ejb.Schedule;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.metadata.javaee.support.IdMetaDataImpl;
+
+/**
+ * Represents metadata for &lt;schedule&gt; element in the ejb-jar.xml 
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at XmlType(name = "timer-scheduleType", propOrder =
+{"second", "minute", "hour", "dayOfMonth", "month", "dayOfWeek", "year"})
+public class ScheduleMetaData extends IdMetaDataImpl implements Serializable
+{
+
+   private String second = "0";
+
+   private String minute = "0";
+
+   private String hour = "0";
+
+   private String dayOfWeek = "*";
+
+   private String dayOfMonth = "*";
+
+   private String month = "*";
+
+   private String year = "*";
+
+   public ScheduleMetaData()
+   {
+
+   }
+
+   public ScheduleMetaData(Schedule schedule)
+   {
+      if (schedule == null)
+      {
+         throw new IllegalArgumentException("Cannot create " + this.getClass().getName() + " from a null schedule");
+      }
+      this.second = schedule.second();
+      this.minute = schedule.minute();
+      this.hour = schedule.hour();
+      this.dayOfWeek = schedule.dayOfWeek();
+      this.dayOfMonth = schedule.dayOfMonth();
+      this.month = schedule.month();
+      this.year = schedule.year();
+   }
+
+   public String getSecond()
+   {
+      return second;
+   }
+
+   public void setSecond(String second)
+   {
+      this.second = second;
+   }
+
+   public String getMinute()
+   {
+      return minute;
+   }
+
+   public void setMinute(String minute)
+   {
+      this.minute = minute;
+   }
+
+   public String getHour()
+   {
+      return hour;
+   }
+
+   public void setHour(String hour)
+   {
+      this.hour = hour;
+   }
+
+   public String getDayOfWeek()
+   {
+      return dayOfWeek;
+   }
+
+   @XmlElement(name = "day-of-week", required = false)
+   public void setDayOfWeek(String dayOfWeek)
+   {
+      this.dayOfWeek = dayOfWeek;
+   }
+
+   public String getDayOfMonth()
+   {
+      return dayOfMonth;
+   }
+
+   @XmlElement(name = "day-of-month", required = false)
+   public void setDayOfMonth(String dayOfMonth)
+   {
+      this.dayOfMonth = dayOfMonth;
+   }
+
+   public String getMonth()
+   {
+      return month;
+   }
+
+   public void setMonth(String month)
+   {
+      this.month = month;
+   }
+
+   public String getYear()
+   {
+      return year;
+   }
+
+   public void setYear(String year)
+   {
+      this.year = year;
+   }
+
+}

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java	2010-06-03 15:36:39 UTC (rev 105651)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/SessionBean31MetaData.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -32,6 +32,7 @@
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
+import org.jboss.metadata.common.ejb.IScheduleTarget;
 import org.jboss.metadata.common.ejb.ITimeoutTarget;
 import org.jboss.metadata.javaee.spec.EmptyMetaData;
 
@@ -41,11 +42,11 @@
  */
 @XmlType(name = "session-beanType", propOrder =
 {"descriptionGroup", "ejbName", "mappedName", "home", "remote", "localHome", "local", "businessLocals",
-      "businessRemotes", "localBean", "serviceEndpoint", "ejbClass", "sessionType", "timeoutMethod", "initOnStartup",
+      "businessRemotes", "localBean", "serviceEndpoint", "ejbClass", "sessionType", "timeoutMethod", "timer", "initOnStartup",
       "concurrencyManagementType", "concurrentMethods", "dependsOnMetaData", "initMethods", "removeMethods", "asyncMethods", "transactionType",
       "aroundInvokes", "environmentRefsGroup", "postActivates", "prePassivates", "securityRoleRefs", "securityIdentity"})
 //@JBossXmlType(modelGroup = JBossXmlConstants.MODEL_GROUP_UNORDERED_SEQUENCE)
-public class SessionBean31MetaData extends SessionBeanMetaData implements ITimeoutTarget // FIXME: AbstractProcessor.processClass doesn't take super interfaces into account
+public class SessionBean31MetaData extends SessionBeanMetaData implements ITimeoutTarget, IScheduleTarget // FIXME: AbstractProcessor.processClass doesn't take super interfaces into account
 {
    private static final long serialVersionUID = 1L;
 
@@ -87,6 +88,10 @@
    private DependsOnMetaData dependsOn;
    
 
+   /**
+    * Represents the metadata for auto created timers
+    */
+   private TimerMetaData timer;
 
    /**
     * Returns the init-on-startup value of the session bean metadata.
@@ -318,6 +323,17 @@
       this.setDependsOn(dependsOn.toArray(new String[dependsOn.size()]));
    }
    
+   public TimerMetaData getTimer()
+   {
+      return this.timer;
+   }
+   
+   @XmlElement (name = "timer", required = false)
+   public void setTimer(TimerMetaData timer)
+   {
+      this.timer = timer;
+   }
+   
    /**
     * {@inheritDoc}
     */
@@ -370,6 +386,10 @@
          {
             this.dependsOn = override.dependsOn;
          }
+         if (override.timer != null)
+         {
+            this.timer = override.timer;
+         }
       }
       else if (original != null)
       {
@@ -405,6 +425,10 @@
          {
             this.dependsOn = original.dependsOn;
          }
+         if (original.timer != null)
+         {
+            this.timer = original.timer;
+         }
       }
    }
 }

Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/TimerMetaData.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/TimerMetaData.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/spec/TimerMetaData.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -0,0 +1,130 @@
+/*
+ * 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.metadata.ejb.spec;
+
+import java.io.Serializable;
+import java.util.Calendar;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.metadata.javaee.support.IdMetaDataImplWithDescriptionGroup;
+
+/**
+ * Represents metadata for &lt;timer&gt; element in ejb-jar.xml
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at XmlType(name = "timerType", propOrder =
+{"descriptionGroup", "schedule", "start", "end", "timeoutMethod", "persistent", "timezone", "info"})
+public class TimerMetaData extends IdMetaDataImplWithDescriptionGroup implements Serializable
+{
+
+   private ScheduleMetaData schedule;
+
+   private Calendar start;
+
+   private Calendar end;
+
+   private NamedMethodMetaData timeoutMethod;
+
+   // persistent by default
+   private boolean persistent = true;
+
+   private String timezone;
+
+   private String info;
+
+   public ScheduleMetaData getSchedule()
+   {
+      return schedule;
+   }
+
+   @XmlElement (name = "schedule", required = false)
+   public void setSchedule(ScheduleMetaData schedule)
+   {
+      this.schedule = schedule;
+   }
+
+   public Calendar getStart()
+   {
+      return start;
+   }
+
+   public void setStart(Calendar start)
+   {
+      this.start = start;
+   }
+
+   public Calendar getEnd()
+   {
+      return end;
+   }
+
+   public void setEnd(Calendar end)
+   {
+      this.end = end;
+   }
+
+   public NamedMethodMetaData getTimeoutMethod()
+   {
+      return timeoutMethod;
+   }
+
+   @XmlElement(name = "timeout-method", required = true)
+   public void setTimeoutMethod(NamedMethodMetaData timeoutMethod)
+   {
+      this.timeoutMethod = timeoutMethod;
+   }
+
+   public boolean isPersistent()
+   {
+      return persistent;
+   }
+
+   public void setPersistent(boolean persistent)
+   {
+      this.persistent = persistent;
+   }
+
+   public String getTimezone()
+   {
+      return timezone;
+   }
+
+   public void setTimezone(String timezone)
+   {
+      this.timezone = timezone;
+   }
+
+   public String getInfo()
+   {
+      return info;
+   }
+
+   public void setInfo(String info)
+   {
+      this.info = info;
+   }
+
+}

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/MDBWithSchedule.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/MDBWithSchedule.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/MDBWithSchedule.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -0,0 +1,43 @@
+/*
+ * 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.metadata.ejb.test.schedule;
+
+import javax.ejb.MessageDriven;
+import javax.ejb.Schedule;
+import javax.ejb.Timer;
+
+/**
+ * MDBWithSchedule
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at MessageDriven
+public class MDBWithSchedule
+{
+
+   @Schedule (minute = "*", dayOfMonth="1")
+   public void someMethod(Timer timer)
+   {
+      
+   }
+}

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/SimpleSLSBWithSchedule.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/SimpleSLSBWithSchedule.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/SimpleSLSBWithSchedule.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -0,0 +1,44 @@
+/*
+ * 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.metadata.ejb.test.schedule;
+
+import javax.ejb.Schedule;
+import javax.ejb.Stateless;
+import javax.ejb.Timer;
+
+/**
+ * SimpleSLSBWithSchedule
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateless
+public class SimpleSLSBWithSchedule
+{
+
+   @Schedule
+   public void schedule(Timer timer)
+   {
+      
+   }
+   
+}

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/SingletonWithSchedule.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/SingletonWithSchedule.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/SingletonWithSchedule.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -0,0 +1,45 @@
+/*
+ * 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.metadata.ejb.test.schedule;
+
+import javax.ejb.Schedule;
+import javax.ejb.Singleton;
+import javax.ejb.Timer;
+
+/**
+ * SingletonWithSchedule
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Singleton
+public class SingletonWithSchedule
+{
+
+   public static final String INFO_FOR_SCHEDULE = "SomeInfo";
+   
+   @Schedule (hour = "10", info=SingletonWithSchedule.INFO_FOR_SCHEDULE, dayOfMonth="12", timezone="IST")
+   public void scheduleTimeout(Timer timer)
+   {
+      
+   }
+}

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/ScheduleTestCase.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/ScheduleTestCase.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/schedule/unit/ScheduleTestCase.java	2010-06-03 15:44:30 UTC (rev 105652)
@@ -0,0 +1,304 @@
+/*
+ * 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.metadata.ejb.test.schedule.unit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.AnnotatedElement;
+import java.net.URL;
+import java.util.Collection;
+
+import javax.ejb.Schedule;
+import javax.ejb.Timer;
+
+import junit.framework.Assert;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBean31MetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
+import org.jboss.metadata.ejb.spec.EjbJar31MetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
+import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
+import org.jboss.metadata.ejb.spec.ScheduleMetaData;
+import org.jboss.metadata.ejb.spec.SessionBean31MetaData;
+import org.jboss.metadata.ejb.spec.TimerMetaData;
+import org.jboss.metadata.ejb.test.schedule.MDBWithSchedule;
+import org.jboss.metadata.ejb.test.schedule.SimpleSLSBWithSchedule;
+import org.jboss.metadata.ejb.test.schedule.SingletonWithSchedule;
+import org.jboss.test.metadata.common.PackageScanner;
+import org.jboss.test.metadata.common.ScanPackage;
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.resolver.MultiClassSchemaResolver;
+import org.jboss.xb.binding.resolver.MutableSchemaResolver;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * ScheduleTestCase
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ScheduleTestCase
+{
+
+   private static Logger logger = Logger.getLogger(ScheduleTestCase.class);
+
+   private static MutableSchemaResolver schemaBindingResolver;
+
+   private static UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+
+   @BeforeClass
+   public static void beforeClass()
+   {
+      schemaBindingResolver = new MultiClassSchemaResolver();
+      schemaBindingResolver.mapLocationToClass("ejb-jar_3_1.xsd", EjbJar31MetaData.class);
+   }
+
+   /**
+    * Tests that a SLSB annotated with {@link Schedule} is processed correctly for metadata
+    * 
+    */
+   @Test
+   @ScanPackage("org.jboss.metadata.ejb.test.schedule")
+   public void testSLSBWithSchedule()
+   {
+
+      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+      JBoss50Creator creator = new JBoss50Creator(finder);
+      Collection<Class<?>> classes = PackageScanner.loadClasses();
+      JBossMetaData metaData = creator.create(classes);
+      assertNotNull("Metadata not created", metaData);
+
+      // get hold of the bean
+      JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(SimpleSLSBWithSchedule.class
+            .getSimpleName());
+      assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossSessionBean31MetaData.class,
+            (enterpriseBean instanceof JBossSessionBean31MetaData));
+      JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBean;
+
+      // get timer metadata
+      TimerMetaData timerMetaData = sessionBean.getTimer();
+
+      // check the metadata for validity
+      Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timerMetaData);
+      Assert.assertTrue("Info object was expected to be empty", timerMetaData.getInfo().isEmpty());
+      Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+
+      // get hold of the schedule and validate it
+      ScheduleMetaData schedule = timerMetaData.getSchedule();
+      Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+      Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+      Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+      Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+      Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+      Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+      Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+      
+      // test the timeout method
+      NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+      Assert.assertNotNull("Timeout method is null", timeoutMethod);
+      Assert.assertEquals("Unexpected timeout method", "schedule", timeoutMethod.getMethodName());
+      MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+      Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+      Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+      String timeoutMethodParam = timeoutMethodParams.get(0);
+      Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+
+   }
+
+   /**
+    * Tests that a MDB marked with {@link Schedule} is processed correctly for metadata
+    */
+   @Test
+   @ScanPackage("org.jboss.metadata.ejb.test.schedule")
+   public void testScheduleOnMDB()
+   {
+      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+      JBoss50Creator creator = new JBoss50Creator(finder);
+      Collection<Class<?>> classes = PackageScanner.loadClasses();
+      JBossMetaData metaData = creator.create(classes);
+      assertNotNull("Metadata not created", metaData);
+
+      // get hold of the bean
+      JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(MDBWithSchedule.class.getSimpleName());
+      assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossMessageDrivenBean31MetaData.class,
+            (enterpriseBean instanceof JBossMessageDrivenBean31MetaData));
+      JBossMessageDrivenBean31MetaData mdb = (JBossMessageDrivenBean31MetaData) enterpriseBean;
+
+      // get timer metadata
+      TimerMetaData timerMetaData = mdb.getTimer();
+
+      // check the metadata for validity
+      Assert.assertNotNull("Timer metadata not found on bean " + mdb.getName(), timerMetaData);
+      Assert.assertTrue("Info object was expected to be empty", timerMetaData.getInfo().isEmpty());
+      Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+
+      // get hold of the schedule and validate it
+      ScheduleMetaData schedule = timerMetaData.getSchedule();
+      Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+      Assert.assertEquals("Unexpected minutes in schedule", "*", schedule.getMinute());
+      Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+      Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+      Assert.assertEquals("Unexpected day of month in schedule", "1", schedule.getDayOfMonth());
+      Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+      Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+      
+      // test the timeout method
+      NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+      Assert.assertNotNull("Timeout method is null", timeoutMethod);
+      Assert.assertEquals("Unexpected timeout method", "someMethod", timeoutMethod.getMethodName());
+      MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+      Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+      Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+      String timeoutMethodParam = timeoutMethodParams.get(0);
+      Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+   }
+
+   /**
+    * Tests that a Singleton bean which has a method marked with {@link Schedule} is
+    * processed correctly for metadata
+    */
+   @Test
+   @ScanPackage("org.jboss.metadata.ejb.test.schedule")
+   public void testScheduleOnSingleton()
+   {
+      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+      JBoss50Creator creator = new JBoss50Creator(finder);
+      Collection<Class<?>> classes = PackageScanner.loadClasses();
+      JBossMetaData metaData = creator.create(classes);
+      assertNotNull("Metadata not created", metaData);
+
+      // get hold of the bean
+      JBossEnterpriseBeanMetaData enterpriseBean = metaData.getEnterpriseBean(SingletonWithSchedule.class
+            .getSimpleName());
+      assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + JBossSessionBean31MetaData.class,
+            (enterpriseBean instanceof JBossSessionBean31MetaData));
+      JBossSessionBean31MetaData sessionBean = (JBossSessionBean31MetaData) enterpriseBean;
+      Assert.assertTrue(sessionBean.getName() + " is not a singleton", sessionBean.isSingleton());
+
+      // get timer metadata
+      TimerMetaData timerMetaData = sessionBean.getTimer();
+
+      // check the metadata for validity
+      Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timerMetaData);
+      Assert.assertEquals("Unexpected info on timer metadata", SingletonWithSchedule.INFO_FOR_SCHEDULE, timerMetaData
+            .getInfo());
+      Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+      Assert.assertEquals("Unexpected timezone on timer metadata", "IST", timerMetaData.getTimezone());
+
+      // get hold of the schedule and validate it
+      ScheduleMetaData schedule = timerMetaData.getSchedule();
+      Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+      Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+      Assert.assertEquals("Unexpected hours in schedule", "10", schedule.getHour());
+      Assert.assertEquals("Unexpected day of week in schedule", "*", schedule.getDayOfWeek());
+      Assert.assertEquals("Unexpected day of month in schedule", "12", schedule.getDayOfMonth());
+      Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+      Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+      
+      // test the timeout method
+      NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+      Assert.assertNotNull("Timeout method is null", timeoutMethod);
+      Assert.assertEquals("Unexpected timeout method", "scheduleTimeout", timeoutMethod.getMethodName());
+      MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+      Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+      Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+      String timeoutMethodParam = timeoutMethodParams.get(0);
+      Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+   }
+
+   /**
+    * Tests that a SLSB configured for timer through ejb-jar.xml is processed correctly for metadata
+    */
+   @Test
+   public void testScheduleForSLSBInEjbJarXml() throws Exception
+   {
+      EjbJarMetaData jarMetaData = unmarshal(EjbJarMetaData.class, "/org/jboss/metadata/ejb/test/schedule/ejb-jar.xml");
+      assertNotNull(jarMetaData);
+
+      EnterpriseBeanMetaData enterpriseBean = jarMetaData.getEnterpriseBean("SLSBInEjbJarXml");
+      assertTrue("metadata " + enterpriseBean.getClass() + " is not of type " + SessionBean31MetaData.class,
+            (enterpriseBean instanceof SessionBean31MetaData));
+      SessionBean31MetaData sessionBean = (SessionBean31MetaData) enterpriseBean;
+
+      // get the timer metadata
+      TimerMetaData timerMetaData = sessionBean.getTimer();
+
+      // check the metadata for validity
+      Assert.assertNotNull("Timer metadata not found on bean " + sessionBean.getName(), timerMetaData);
+      Assert.assertNull("Unexpected info on timer metadata", timerMetaData.getInfo());
+      Assert.assertTrue("Timer was expected to be persistent", timerMetaData.isPersistent());
+
+      // get hold of the schedule and validate it
+      ScheduleMetaData schedule = timerMetaData.getSchedule();
+      Assert.assertEquals("Unexpected seconds in schedule", "0", schedule.getSecond());
+      Assert.assertEquals("Unexpected minutes in schedule", "0", schedule.getMinute());
+      Assert.assertEquals("Unexpected hours in schedule", "0", schedule.getHour());
+      Assert.assertEquals("Unexpected day of week in schedule", "Wed", schedule.getDayOfWeek());
+      Assert.assertEquals("Unexpected day of month in schedule", "*", schedule.getDayOfMonth());
+      Assert.assertEquals("Unexpected month in schedule", "*", schedule.getMonth());
+      Assert.assertEquals("Unexpected year in schedule", "*", schedule.getYear());
+      
+      // test the timeout method
+      NamedMethodMetaData timeoutMethod = timerMetaData.getTimeoutMethod();
+      Assert.assertNotNull("Timeout method is null", timeoutMethod);
+      Assert.assertEquals("Unexpected timeout method", "dummySLSBMethod", timeoutMethod.getMethodName());
+      MethodParametersMetaData timeoutMethodParams = timeoutMethod.getMethodParams();
+      Assert.assertNotNull("Timeout method params are null", timeoutMethodParams);
+      Assert.assertEquals("Unexpected number of method params for timeout method", 1, timeoutMethodParams.size());
+      String timeoutMethodParam = timeoutMethodParams.get(0);
+      Assert.assertEquals("Unexpected method param for timeout method", Timer.class.getName(), timeoutMethodParam);
+
+   }
+
+   /**
+    * Utility method
+    * @param <T>
+    * @param type
+    * @param resource
+    * @return
+    * @throws JBossXBException
+    */
+   private static <T> T unmarshal(Class<T> type, String resource) throws JBossXBException
+   {
+      Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+      unmarshaller.setValidation(false);
+      URL url = type.getResource(resource);
+      if (url == null)
+         throw new IllegalArgumentException("Failed to find resource " + resource);
+      return type.cast(unmarshaller.unmarshal(url.toString(), schemaBindingResolver));
+   }
+}

Added: projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/schedule/ejb-jar.xml
===================================================================
--- projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/schedule/ejb-jar.xml	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/resources/org/jboss/metadata/ejb/test/schedule/ejb-jar.xml	2010-06-03 15:44:30 UTC (rev 105652)
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+      	  http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
+	version="3.1">
+
+	<enterprise-beans>
+		<session>
+			<ejb-name>SLSBInEjbJarXml</ejb-name>
+			<ejb-class>dummy</ejb-class>
+			<timer>
+				<schedule>
+					<day-of-month>*</day-of-month>
+					<day-of-week>Wed</day-of-week>
+				</schedule>
+				<timeout-method>
+					<method-name>dummySLSBMethod</method-name>
+					<method-params>
+						<method-param>javax.ejb.Timer</method-param>
+					</method-params>
+				</timeout-method>
+				<persistent>true</persistent>
+			</timer>
+		</session>
+
+		<session>
+			<ejb-name>SingletonInEjbJarXml</ejb-name>
+			<ejb-class>dummy</ejb-class>
+			<timer>
+				<schedule>
+					<year>2009</year>
+				</schedule>
+				<timeout-method>
+					<method-name>dummySingletonMethod</method-name>
+					<method-params>
+						<method-param>javax.ejb.Timer</method-param>
+					</method-params>
+				</timeout-method>
+
+			</timer>
+
+		</session>
+
+		<message-driven>
+			<ejb-name>MDBInEjbJarXml</ejb-name>
+			<ejb-class>dummy</ejb-class>
+			<timer>
+				<schedule>
+					<second>5</second>
+					<minute>4</minute>
+					<hour>3</hour>
+					<day-of-month>1</day-of-month>
+					<month>Jan</month>
+					<day-of-week>2</day-of-week>
+					<year>*</year>
+				</schedule>
+				<timeout-method>
+					<method-name>dummyMDBMethod</method-name>
+					<method-params>
+						<method-param>javax.ejb.Timer</method-param>
+					</method-params>
+				</timeout-method>
+				<persistent>false</persistent>
+				<info>SomeInfoInXml</info>
+
+			</timer>
+		</message-driven>
+	</enterprise-beans>
+</ejb-jar>      
\ No newline at end of file




More information about the jboss-cvs-commits mailing list