[jboss-svn-commits] JBL Code SVN: r19638 - in labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product: rosetta/src/org/jboss/soa/esb/listeners/config and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Apr 19 03:35:50 EDT 2008
Author: tfennelly
Date: 2008-04-19 03:35:49 -0400 (Sat, 19 Apr 2008)
New Revision: 19638
Added:
labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/schedule/config-02.1.xml
Modified:
labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/etc/schemas/xml/jbossesb-1.0.1.xsd
labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/config/ScheduleProviderFactory.java
labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/schedule/ScheduleProvider.java
labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/schedule/SchedulingUnitTest.java
Log:
http://jira.jboss.com/jira/browse/JBESB-1584
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/etc/schemas/xml/jbossesb-1.0.1.xsd
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/etc/schemas/xml/jbossesb-1.0.1.xsd 2008-04-19 04:57:55 UTC (rev 19637)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/etc/schemas/xml/jbossesb-1.0.1.xsd 2008-04-19 07:35:49 UTC (rev 19638)
@@ -188,29 +188,36 @@
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="jesb:schedule">
- <xsd:attribute default="10" name="frequency"
- type="xsd:long" use="optional">
+ <xsd:attribute name="frequency" use="optional" type="xsd:long" default="10">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">Schedule frequency.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="frequencyUnits" use="optional" type="jesb:frequency-unit" default="seconds">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">Schedule frequency time units.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute default="-1" name="execCount" type="xsd:int" use="optional">
<xsd:annotation>
<xsd:documentation xml:lang="en">
- Schedule frequency, in seconds.
+ Schedule execution count. -1 to execute indefinitely.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
- <xsd:attribute default="-1" name="execCount"
- type="xsd:int" use="optional">
- <xsd:annotation>
- <xsd:documentation xml:lang="en">
- Schedule execution count. -1 to execute
- indefinitely.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
- <xsd:element name="cron-schedule"
+ <xsd:simpleType name="frequency-unit">
+ <xsd:restriction base="xsd:NMTOKEN">
+ <xsd:enumeration value="seconds"/>
+ <xsd:enumeration value="milliseconds"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:element name="cron-schedule"
substitutionGroup="jesb:schedule">
<xsd:complexType>
<xsd:complexContent>
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/config/ScheduleProviderFactory.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/config/ScheduleProviderFactory.java 2008-04-19 04:57:55 UTC (rev 19637)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/listeners/config/ScheduleProviderFactory.java 2008-04-19 07:35:49 UTC (rev 19638)
@@ -26,6 +26,7 @@
import org.jboss.soa.esb.listeners.config.xbeanmodel.ScheduleProviderDocument;
import org.jboss.soa.esb.listeners.config.xbeanmodel.SimpleScheduleDocument;
import org.jboss.soa.esb.listeners.config.xbeanmodel.CronScheduleDocument;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.FrequencyUnit;
import java.util.List;
import java.util.Properties;
@@ -93,9 +94,14 @@
if(scheduleConfig instanceof SimpleScheduleDocument.SimpleSchedule) {
SimpleSchedule simpleSchedule;
+ FrequencyUnit.Enum frequencyUnit = ((SimpleScheduleDocument.SimpleSchedule)scheduleConfig).getFrequencyUnits();
schedule = simpleSchedule = new SimpleSchedule(scheduleId);
+ if(frequencyUnit == FrequencyUnit.SECONDS) {
+ simpleSchedule.setFrequency(((SimpleScheduleDocument.SimpleSchedule)scheduleConfig).getFrequency() * 1000);
+ } else {
simpleSchedule.setFrequency(((SimpleScheduleDocument.SimpleSchedule)scheduleConfig).getFrequency());
+ }
simpleSchedule.setExecCount(((SimpleScheduleDocument.SimpleSchedule)scheduleConfig).getExecCount());
} else {
CronSchedule cronSchedule;
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/schedule/ScheduleProvider.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/schedule/ScheduleProvider.java 2008-04-19 04:57:55 UTC (rev 19637)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/schedule/ScheduleProvider.java 2008-04-19 07:35:49 UTC (rev 19638)
@@ -19,16 +19,19 @@
*/
package org.jboss.soa.esb.schedule;
+import org.apache.log4j.Logger;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.util.ClassUtil;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
-import org.apache.log4j.Logger;
-import java.util.*;
-import java.text.ParseException;
import java.io.IOException;
import java.io.InputStream;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
/**
* Schedule Provider.
@@ -87,13 +90,17 @@
if(schedule instanceof SimpleSchedule) {
SimpleSchedule simpleSchedule = (SimpleSchedule) schedule;
if(simpleSchedule.getExecCount() == -1) {
- trigger = TriggerUtils.makeSecondlyTrigger((int) simpleSchedule.getFrequency());
+ trigger = new SimpleTrigger();
+ ((SimpleTrigger)trigger).setRepeatInterval(simpleSchedule.getFrequency());
+ ((SimpleTrigger)trigger).setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
} else if(simpleSchedule.getExecCount() == 0) {
logger.warn("<simple-schedule> '" + scheduleId + "' has an execCount of 0 configured. This schedule will not fire!");
return;
} else {
// So the repeatCount = execCount - 1 ....
- trigger = TriggerUtils.makeSecondlyTrigger((int) simpleSchedule.getFrequency(), (simpleSchedule.getExecCount() - 1));
+ trigger = new SimpleTrigger();
+ ((SimpleTrigger)trigger).setRepeatInterval(simpleSchedule.getFrequency());
+ ((SimpleTrigger)trigger).setRepeatCount(simpleSchedule.getExecCount() - 1);
}
trigger.setName(simpleSchedule.getScheduleid());
} else {
@@ -129,26 +136,28 @@
private static volatile int nameDelta = 1;
private void addListener(ScheduledEventListener listener, Trigger trigger) throws SchedulingException {
- JobDataMap jobDataMap = new JobDataMap();
- JobDetail jobDetail;
+ synchronized (ScheduleProvider.class) {
+ JobDataMap jobDataMap = new JobDataMap();
+ JobDetail jobDetail;
- String name = trigger.getName();
+ String name = trigger.getName();
- // this is just to make sure they're unique - i.e. so as 1+
- // "things" can listen to the same schedule...
- // This is not thread safe!
- name += ("-" + nameDelta++);
- trigger.setName(name);
+ // this is just to make sure they're unique - i.e. so as 1+
+ // "things" can listen to the same schedule...
+ // This is not thread safe!
+ name += ("-" + nameDelta++);
+ trigger.setName(name);
- jobDetail = new JobDetail(name, JBOSS_ESB, ESBScheduledJob.class);
- jobDataMap.put(ScheduledEventListener.class.getName(), listener);
- jobDataMap.put(ClassLoader.class.getName(), tcc);
- jobDetail.setJobDataMap(jobDataMap);
- try {
- scheduler.scheduleJob(jobDetail, trigger);
- scheduledJobs.add(name);
- } catch (SchedulerException e) {
- throw new SchedulingException("Failed to schedule job.", e);
+ jobDetail = new JobDetail(name, JBOSS_ESB, ScheduleProvider.ESBScheduledJob.class);
+ jobDataMap.put(ScheduledEventListener.class.getName(), listener);
+ jobDataMap.put(ClassLoader.class.getName(), tcc);
+ jobDetail.setJobDataMap(jobDataMap);
+ try {
+ scheduler.scheduleJob(jobDetail, trigger);
+ scheduledJobs.add(name);
+ } catch (SchedulerException e) {
+ throw new SchedulingException("Failed to schedule job.", e);
+ }
}
}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/schedule/SchedulingUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/schedule/SchedulingUnitTest.java 2008-04-19 04:57:55 UTC (rev 19637)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/schedule/SchedulingUnitTest.java 2008-04-19 07:35:49 UTC (rev 19638)
@@ -76,8 +76,19 @@
// Just check that the schedule was triggered more than once...
assertTrue(MockScheduledEventMessageComposer.composedMessages.size() > 1);
+ assertTrue(MockScheduledEventMessageComposer.composedMessages.size() < 10);
}
+ public void test_simple_schedule_02_1() throws UnsupportedEncodingException, ParamRepositoryException, ConfigurationException, ManagedLifecycleException, SAXException, InterruptedException {
+ // Test millisecond frequency schedules...
+
+ runTestConfig("config-02.1.xml", 5000);
+
+ // Just check that the schedule was triggered more than once...
+ assertTrue(MockScheduledEventMessageComposer.composedMessages.size() > 20);
+ assertTrue(MockScheduledEventMessageComposer.composedMessages.size() < 100);
+ }
+
public void test_simple_schedule_03() throws UnsupportedEncodingException, ParamRepositoryException, ConfigurationException, ManagedLifecycleException, SAXException, InterruptedException {
runTestConfig("config-03.xml", 5000);
Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/schedule/config-02.1.xml (from rev 19625, labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/schedule/config-02.xml)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/schedule/config-02.1.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/schedule/config-02.1.xml 2008-04-19 07:35:49 UTC (rev 19638)
@@ -0,0 +1,24 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
+
+ <providers>
+ <schedule-provider name="schedule">
+ <!-- Run indefinitely... -->
+ <simple-schedule scheduleid="1-sec-trigger" frequency="100" frequencyUnits="milliseconds"/>
+ </schedule-provider>
+ </providers>
+
+ <services>
+ <service category="ServiceCat" name="ServiceName" description="Test Service">
+
+ <listeners>
+ <scheduled-listener name="simple-schedule-listener" scheduleidref="1-sec-trigger" event-processor="org.jboss.soa.esb.schedule.MockScheduledEventMessageComposer" />
+ </listeners>
+
+ <actions>
+ <action name="action" class="org.jboss.soa.esb.mock.MockAction" />
+ </actions>
+ </service>
+ </services>
+
+</jbossesb>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list